Added breakage handling for technician transaction view

This commit is contained in:
Keannu Bernasol 2024-01-03 17:28:43 +08:00
parent 8ef4efb1d9
commit fee55c95c8
3 changed files with 26 additions and 2 deletions

View file

@ -61,6 +61,9 @@ export default function EditItemInstanceModal(props: {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["equipment_instance", props.id], queryKey: ["equipment_instance", props.id],
}); });
queryClient.invalidateQueries({
queryKey: ["transactions"],
});
setError("Updated successfully"); setError("Updated successfully");
toast( toast(
`Item updated successfuly, ${ `Item updated successfuly, ${
@ -84,6 +87,7 @@ export default function EditItemInstanceModal(props: {
status: data[1].status, status: data[1].status,
}); });
} }
props.setOpen(false);
}, },
}); });

View file

@ -123,6 +123,7 @@ export type TransactionType = {
equipments: Array<{ equipments: Array<{
id: number; id: number;
name: string; name: string;
status: string;
}>; }>;
transaction_status: string; transaction_status: string;
timestamp: string; timestamp: string;

View file

@ -15,11 +15,13 @@ 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"; import TransactionFilterMenu from "../../Components/TransactionFilterMenu/TransactionFilterMenu";
import EditItemInstanceModal from "../../Components/EditItemInstanceModal/EditItemInstanceModal";
export default function TransactionsListPage() { export default function TransactionsListPage() {
const [EditTransactionOpen, SetEditTransactionOpen] = useState(false); const [EditTransactionOpen, SetEditTransactionOpen] = useState(false);
const [SelectedTransaction, SetSelectedTransaction] = useState(0); const [SelectedTransaction, SetSelectedTransaction] = useState(0);
const [EditEquipmentsOpen, SetEditEquipmentsOpen] = useState(false); const [EditEquipmentsOpen, SetEditEquipmentsOpen] = useState(false);
const [SelectedEquipment, SetSelectedEquipment] = useState(0);
const transactions = useQuery({ const transactions = useQuery({
queryKey: ["transactions"], queryKey: ["transactions"],
queryFn: TransactionsAPI, queryFn: TransactionsAPI,
@ -197,7 +199,7 @@ export default function TransactionsListPage() {
> >
{transaction.remarks} {transaction.remarks}
</TableCell> </TableCell>
<TableCell style={{}} align="center"> <TableCell align="center">
<TableContainer <TableContainer
style={{ style={{
maxHeight: "192px", maxHeight: "192px",
@ -228,6 +230,12 @@ export default function TransactionsListPage() {
> >
Name Name
</TableCell> </TableCell>
<TableCell
align="center"
style={styles.text_light}
>
Status
</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody <TableBody
@ -246,6 +254,7 @@ export default function TransactionsListPage() {
transaction.transaction_status == transaction.transaction_status ==
"With Breakages: Pending Resolution" "With Breakages: Pending Resolution"
) { ) {
SetSelectedEquipment(equipment.id);
SetEditTransactionOpen(false); SetEditTransactionOpen(false);
SetEditEquipmentsOpen(true); SetEditEquipmentsOpen(true);
} }
@ -265,6 +274,13 @@ export default function TransactionsListPage() {
> >
{equipment.name} {equipment.name}
</TableCell> </TableCell>
<TableCell
align="center"
component="th"
scope="row"
>
{equipment.status}
</TableCell>
</TableRow> </TableRow>
))} ))}
</TableBody> </TableBody>
@ -299,7 +315,10 @@ export default function TransactionsListPage() {
position={"top center"} position={"top center"}
contentStyle={styles.popup_center} contentStyle={styles.popup_center}
> >
<p style={styles.text_dark}>Edit Transaction Equipment Modal</p> <EditItemInstanceModal
id={SelectedEquipment}
setOpen={SetEditEquipmentsOpen}
/>
</Popup> </Popup>
</div> </div>
); );