import { useQuery } from "@tanstack/react-query"; import { TransactionsByStudentAPI } 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 { useNavigate } from "react-router-dom"; export default function StudentTransactionListView() { const navigate = useNavigate(); const transactions = useQuery({ queryKey: ["transactions_student"], queryFn: TransactionsByStudentAPI, }); const [filter, setFilter] = useState(""); if (transactions.isLoading) { return (

Loading

); } return (
{transactions.data ? ( transactions.data .filter((transaction) => filter !== "" ? transaction.transaction_status == filter : true ) .map((transaction) => ( navigate(`/view/transaction/${transaction.id}`, { replace: true, state: { id: transaction.id }, }) } transaction={transaction} /> )) ) : ( <> )}
); }