import { useQuery } from "@tanstack/react-query"; import { TransactionsByTeacherAPI } from "../../API/API"; import styles from "../../../styles"; import CircularProgress from "@mui/material/CircularProgress/CircularProgress"; import React, { useState } from "react"; import TransactionEntry from "../../TransactionEntry/TransactionEntry"; import TransactionFilterMenu from "../../TransactionFilterMenu/TransactionFilterMenu"; import Popup from "reactjs-popup"; import EditTransactionModal from "../../EditTransactionModal/EditTransactionModal"; export default function TeacherTransactionListView() { const [EditTransactionOpen, SetEditTransactionOpen] = useState(false); const [SelectedTransaction, SetSelectedTransaction] = useState(0); const transactions = useQuery({ queryKey: ["transactions_teacher"], queryFn: TransactionsByTeacherAPI, }); const [filter, setFilter] = useState(""); if (transactions.isLoading) { return (

Loading

); } return (
{transactions.data ? ( transactions.data .filter((transaction) => filter !== "" ? transaction.transaction_status == filter : true ) .map((transaction) => ( { if ( transaction.transaction_status == "Pending Approval" ) { SetSelectedTransaction(transaction.id); SetEditTransactionOpen(true); } }} transaction={transaction} /> )) ) : ( <> )}
SetEditTransactionOpen(false)} modal position={"top center"} contentStyle={styles.popup_center} >
); }