mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2025-04-05 09:31:35 +08:00
Separate transaction filter menu into separate component for use within all user types
This commit is contained in:
parent
1281d8023f
commit
669e1d6009
4 changed files with 164 additions and 128 deletions
|
@ -4,7 +4,7 @@ import styles from "../../../styles";
|
||||||
import CircularProgress from "@mui/material/CircularProgress/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress/CircularProgress";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import TransactionEntry from "../../TransactionEntry/TransactionEntry";
|
import TransactionEntry from "../../TransactionEntry/TransactionEntry";
|
||||||
import TransactionFilterMenu from "../TransactionFilterMenu";
|
import TransactionFilterMenu from "../../TransactionFilterMenu/TransactionFilterMenu";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export default function StudentTransactionListView() {
|
export default function StudentTransactionListView() {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import styles from "../../../styles";
|
||||||
import CircularProgress from "@mui/material/CircularProgress/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress/CircularProgress";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import TransactionEntry from "../../TransactionEntry/TransactionEntry";
|
import TransactionEntry from "../../TransactionEntry/TransactionEntry";
|
||||||
import TransactionFilterMenu from "../TransactionFilterMenu";
|
import TransactionFilterMenu from "../../TransactionFilterMenu/TransactionFilterMenu";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export default function TeacherTransactionListView() {
|
export default function TeacherTransactionListView() {
|
||||||
|
|
|
@ -185,7 +185,7 @@ export default function TransactionFilterMenu(props: props) {
|
||||||
...{ margin: 0, textAlign: "left" },
|
...{ margin: 0, textAlign: "left" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Denied by technician
|
Denied by teacher
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
|
@ -14,6 +14,7 @@ import { colors } from "../../styles";
|
||||||
import Popup from "reactjs-popup";
|
import Popup from "reactjs-popup";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import EditTransactionModal from "../../Components/EditTransactionModal/EditTransactionModal";
|
import EditTransactionModal from "../../Components/EditTransactionModal/EditTransactionModal";
|
||||||
|
import TransactionFilterMenu from "../../Components/TransactionFilterMenu/TransactionFilterMenu";
|
||||||
|
|
||||||
export default function TransactionsListPage() {
|
export default function TransactionsListPage() {
|
||||||
const [EditTransactionOpen, SetEditTransactionOpen] = useState(false);
|
const [EditTransactionOpen, SetEditTransactionOpen] = useState(false);
|
||||||
|
@ -23,6 +24,7 @@ export default function TransactionsListPage() {
|
||||||
queryKey: ["transactions"],
|
queryKey: ["transactions"],
|
||||||
queryFn: TransactionsAPI,
|
queryFn: TransactionsAPI,
|
||||||
});
|
});
|
||||||
|
const [filter, setFilter] = useState("");
|
||||||
if (transactions.isLoading) {
|
if (transactions.isLoading) {
|
||||||
return (
|
return (
|
||||||
<div style={styles.background}>
|
<div style={styles.background}>
|
||||||
|
@ -55,7 +57,7 @@ export default function TransactionsListPage() {
|
||||||
<Header label={"Transactions"} />
|
<Header label={"Transactions"} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
...styles.flex_column,
|
...{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
|
@ -64,13 +66,16 @@ export default function TransactionsListPage() {
|
||||||
minHeight: "100%",
|
minHeight: "100%",
|
||||||
minWidth: "100%",
|
minWidth: "100%",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
|
},
|
||||||
|
...styles.flex_column,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TableContainer
|
<TableContainer
|
||||||
style={{ width: "90%", overflowY: "scroll", marginTop: "2rem" }}
|
style={{ width: "90%", overflowY: "scroll", marginTop: "2rem" }}
|
||||||
component={Paper}
|
component={Paper}
|
||||||
>
|
>
|
||||||
<Table sx={{ minWidth: "32rem" }} size="medium">
|
<TransactionFilterMenu filter={filter} setFilter={setFilter} />
|
||||||
|
<Table sx={{ marginTop: "8px", minWidth: "32rem" }} size="medium">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow style={{ backgroundColor: colors.header_color }}>
|
<TableRow style={{ backgroundColor: colors.header_color }}>
|
||||||
<TableCell align="center" style={styles.text_light}>
|
<TableCell align="center" style={styles.text_light}>
|
||||||
|
@ -95,7 +100,13 @@ export default function TransactionsListPage() {
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{transactions.data ? (
|
{transactions.data ? (
|
||||||
transactions.data.map((transaction) => (
|
transactions.data
|
||||||
|
.filter((transaction) =>
|
||||||
|
filter !== ""
|
||||||
|
? transaction.transaction_status == filter
|
||||||
|
: true
|
||||||
|
)
|
||||||
|
.map((transaction) => (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={transaction.id}
|
key={transaction.id}
|
||||||
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
||||||
|
@ -105,8 +116,13 @@ export default function TransactionsListPage() {
|
||||||
component="th"
|
component="th"
|
||||||
scope="row"
|
scope="row"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
transaction.transaction_status != "Finalized" &&
|
||||||
|
transaction.transaction_status != "Rejected"
|
||||||
|
) {
|
||||||
SetSelectedTransaction(transaction.id);
|
SetSelectedTransaction(transaction.id);
|
||||||
SetEditTransactionOpen(true);
|
SetEditTransactionOpen(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{transaction.id}
|
{transaction.id}
|
||||||
|
@ -116,8 +132,13 @@ export default function TransactionsListPage() {
|
||||||
component="th"
|
component="th"
|
||||||
scope="row"
|
scope="row"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
transaction.transaction_status != "Finalized" &&
|
||||||
|
transaction.transaction_status != "Rejected"
|
||||||
|
) {
|
||||||
SetSelectedTransaction(transaction.id);
|
SetSelectedTransaction(transaction.id);
|
||||||
SetEditTransactionOpen(true);
|
SetEditTransactionOpen(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{transaction.borrower.name}
|
{transaction.borrower.name}
|
||||||
|
@ -127,8 +148,13 @@ export default function TransactionsListPage() {
|
||||||
component="th"
|
component="th"
|
||||||
scope="row"
|
scope="row"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
transaction.transaction_status != "Finalized" &&
|
||||||
|
transaction.transaction_status != "Rejected"
|
||||||
|
) {
|
||||||
SetSelectedTransaction(transaction.id);
|
SetSelectedTransaction(transaction.id);
|
||||||
SetEditTransactionOpen(true);
|
SetEditTransactionOpen(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{transaction.teacher.name}
|
{transaction.teacher.name}
|
||||||
|
@ -138,8 +164,13 @@ export default function TransactionsListPage() {
|
||||||
component="th"
|
component="th"
|
||||||
scope="row"
|
scope="row"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
transaction.transaction_status != "Finalized" &&
|
||||||
|
transaction.transaction_status != "Rejected"
|
||||||
|
) {
|
||||||
SetSelectedTransaction(transaction.id);
|
SetSelectedTransaction(transaction.id);
|
||||||
SetEditTransactionOpen(true);
|
SetEditTransactionOpen(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{transaction.transaction_status}
|
{transaction.transaction_status}
|
||||||
|
@ -155,8 +186,13 @@ export default function TransactionsListPage() {
|
||||||
wordWrap: "break-word",
|
wordWrap: "break-word",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
transaction.transaction_status != "Finalized" &&
|
||||||
|
transaction.transaction_status != "Rejected"
|
||||||
|
) {
|
||||||
SetSelectedTransaction(transaction.id);
|
SetSelectedTransaction(transaction.id);
|
||||||
SetEditTransactionOpen(true);
|
SetEditTransactionOpen(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{transaction.remarks}
|
{transaction.remarks}
|
||||||
|
|
Loading…
Add table
Reference in a new issue