Improved all rendered tables by removing redundant div

This commit is contained in:
Keannu Christian Bernasol 2023-12-14 20:32:12 +08:00
parent d2521a628d
commit 9bb312808e
5 changed files with 402 additions and 397 deletions

View file

@ -66,143 +66,144 @@ export default function TransactionsListPage() {
flexWrap: "wrap",
}}
>
<div style={{ width: "90%", overflowY: "scroll", marginTop: "2rem" }}>
<TableContainer component={Paper}>
<Table sx={{ minWidth: "32rem" }} size="medium">
<TableHead>
<TableRow style={{ backgroundColor: colors.header_color }}>
<TableCell align="center" style={styles.text_light}>
ID
</TableCell>
<TableCell align="center" style={styles.text_light}>
Borrower
</TableCell>
<TableCell align="center" style={styles.text_light}>
Teacher
</TableCell>
<TableCell align="center" style={styles.text_light}>
Status
</TableCell>
<TableCell align="center" style={styles.text_light}>
Equipments
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{transactions.data ? (
transactions.data.map((transaction) => (
<TableRow
key={transaction.id}
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
<TableContainer
style={{ width: "90%", overflowY: "scroll", marginTop: "2rem" }}
component={Paper}
>
<Table sx={{ minWidth: "32rem" }} size="medium">
<TableHead>
<TableRow style={{ backgroundColor: colors.header_color }}>
<TableCell align="center" style={styles.text_light}>
ID
</TableCell>
<TableCell align="center" style={styles.text_light}>
Borrower
</TableCell>
<TableCell align="center" style={styles.text_light}>
Teacher
</TableCell>
<TableCell align="center" style={styles.text_light}>
Status
</TableCell>
<TableCell align="center" style={styles.text_light}>
Equipments
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{transactions.data ? (
transactions.data.map((transaction) => (
<TableRow
key={transaction.id}
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.id}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.borrower.name}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.teacher.name}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.transaction_status}
</TableCell>
<TableCell align="center">
<TableContainer component={Paper}>
<Table sx={{ minWidth: "4rem" }} size="medium">
<TableHead>
{transaction.id}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.borrower.name}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.teacher.name}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
onClick={() => {
SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
}}
>
{transaction.transaction_status}
</TableCell>
<TableCell style={{ overflowY: "scroll" }} align="center">
<TableContainer component={Paper}>
<Table sx={{ minWidth: "4rem" }} size="medium">
<TableHead>
<TableRow
style={{ backgroundColor: colors.header_color }}
>
<TableCell
align="center"
style={styles.text_light}
>
ID
</TableCell>
<TableCell
align="center"
style={styles.text_light}
>
Name
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{transaction.equipments.map((equipment) => (
<TableRow
style={{ backgroundColor: colors.header_color }}
key={equipment.id}
sx={{
"&:last-child td, &:last-child th": {
border: 0,
},
}}
onClick={() => {
SetEditTransactionOpen(false);
SetEditEquipmentsOpen(true);
}}
>
<TableCell
align="center"
style={styles.text_light}
component="th"
scope="row"
>
ID
{equipment.id}
</TableCell>
<TableCell
align="center"
style={styles.text_light}
component="th"
scope="row"
>
Name
{equipment.name}
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{transaction.equipments.map((equipment) => (
<TableRow
key={equipment.id}
sx={{
"&:last-child td, &:last-child th": {
border: 0,
},
}}
onClick={() => {
SetEditTransactionOpen(false);
SetEditEquipmentsOpen(true);
}}
>
<TableCell
align="center"
component="th"
scope="row"
>
{equipment.id}
</TableCell>
<TableCell
align="center"
component="th"
scope="row"
>
{equipment.name}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</TableCell>
</TableRow>
))
) : (
<></>
)}
</TableBody>
</Table>
</TableContainer>
</div>
))}
</TableBody>
</Table>
</TableContainer>
</TableCell>
</TableRow>
))
) : (
<></>
)}
</TableBody>
</Table>
</TableContainer>
</div>
<Popup
open={EditTransactionOpen}