mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2024-11-17 06:19:27 +08:00
Added update transaction modal for teacher
This commit is contained in:
parent
669e1d6009
commit
2d59a775c1
5 changed files with 33 additions and 16 deletions
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue