Added update transaction modal for teacher

This commit is contained in:
Keannu Bernasol 2024-01-03 17:01:34 +08:00
parent 669e1d6009
commit 2d59a775c1
5 changed files with 33 additions and 16 deletions

View file

@ -57,12 +57,12 @@ export default function StudentTransactionListView() {
.map((transaction) => ( .map((transaction) => (
<React.Fragment key={transaction.id}> <React.Fragment key={transaction.id}>
<TransactionEntry <TransactionEntry
onClick={() => onClick={() => {
navigate(`/view/transaction/${transaction.id}`, { navigate(`/view/transaction/${transaction.id}`, {
replace: true, replace: true,
state: { id: transaction.id }, state: { id: transaction.id },
}) });
} }}
transaction={transaction} transaction={transaction}
/> />
</React.Fragment> </React.Fragment>

View file

@ -5,10 +5,12 @@ 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/TransactionFilterMenu"; import TransactionFilterMenu from "../../TransactionFilterMenu/TransactionFilterMenu";
import { useNavigate } from "react-router-dom"; import Popup from "reactjs-popup";
import EditTransactionModal from "../../EditTransactionModal/EditTransactionModal";
export default function TeacherTransactionListView() { export default function TeacherTransactionListView() {
const navigate = useNavigate(); const [EditTransactionOpen, SetEditTransactionOpen] = useState(false);
const [SelectedTransaction, SetSelectedTransaction] = useState(0);
const transactions = useQuery({ const transactions = useQuery({
queryKey: ["transactions_teacher"], queryKey: ["transactions_teacher"],
queryFn: TransactionsByTeacherAPI, queryFn: TransactionsByTeacherAPI,
@ -57,12 +59,14 @@ export default function TeacherTransactionListView() {
.map((transaction) => ( .map((transaction) => (
<React.Fragment key={transaction.id}> <React.Fragment key={transaction.id}>
<TransactionEntry <TransactionEntry
onClick={() => onClick={() => {
navigate(`/view/transaction/${transaction.id}`, { if (
replace: true, transaction.transaction_status == "Pending Approval"
state: { id: transaction.id }, ) {
}) SetSelectedTransaction(transaction.id);
SetEditTransactionOpen(true);
} }
}}
transaction={transaction} transaction={transaction}
/> />
</React.Fragment> </React.Fragment>
@ -72,6 +76,18 @@ export default function TeacherTransactionListView() {
)} )}
</div> </div>
</div> </div>
<Popup
open={EditTransactionOpen}
onClose={() => SetEditTransactionOpen(false)}
modal
position={"top center"}
contentStyle={styles.popup_center}
>
<EditTransactionModal
id={SelectedTransaction}
setOpen={SetEditTransactionOpen}
/>
</Popup>
</div> </div>
); );
} }

View file

@ -204,7 +204,8 @@ export default function EditTransactionModal(props: {
/> />
</> </>
) : null} ) : null}
{transaction.data?.transaction_status == "Borrowed" ? ( {transaction.data?.transaction_status ==
"Returned: Pending Checking" ? (
<> <>
<FormControlLabel <FormControlLabel
value="With Breakages: Pending Resolution" value="With Breakages: Pending Resolution"

View file

@ -9,7 +9,7 @@ export interface props {
export default function TransactionEntry(props: props) { export default function TransactionEntry(props: props) {
return ( return (
<div <button
style={{ style={{
alignSelf: "center", alignSelf: "center",
justifySelf: "center", justifySelf: "center",
@ -19,7 +19,7 @@ export default function TransactionEntry(props: props) {
margin: "8px", margin: "8px",
padding: "8px", padding: "8px",
}} }}
onClick={() => props.onClick} onClick={props.onClick}
> >
<div style={styles.flex_row}> <div style={styles.flex_row}>
<p <p
@ -147,6 +147,6 @@ export default function TransactionEntry(props: props) {
> >
{`${props.transaction.transaction_status}`} {`${props.transaction.transaction_status}`}
</p> </p>
</div> </button>
); );
} }

View file

@ -109,7 +109,7 @@ export default function TransactionFilterMenu(props: props) {
...{ margin: 0, textAlign: "left" }, ...{ margin: 0, textAlign: "left" },
}} }}
> >
Awaiting techncian approval Awaiting teacher approval
</p> </p>
</div> </div>
</Button> </Button>