mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2024-11-17 06:19:27 +08:00
Merge pull request 'Refactor filter menu to be usable by all user types and added initial content for teacher dashboard' (#2) from feature/teacher_pages into master
Reviewed-on: https://git.keannu1.duckdns.org/keannu125/Borrowing-TrackerFrontend/pulls/2
This commit is contained in:
commit
564a7d41d8
5 changed files with 77 additions and 7 deletions
|
@ -4,7 +4,7 @@ import styles from "../../../styles";
|
||||||
import CircularProgress from "@mui/material/CircularProgress/CircularProgress";
|
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 StudentTransactionFilterMenu from "./StudentTransactionFilterMenu";
|
import TransactionFilterMenu from "../TransactionFilterMenu";
|
||||||
|
|
||||||
export default function StudentTransactionListView() {
|
export default function StudentTransactionListView() {
|
||||||
const transactions = useQuery({
|
const transactions = useQuery({
|
||||||
|
@ -39,7 +39,7 @@ export default function StudentTransactionListView() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={styles.flex_column}>
|
<div style={styles.flex_column}>
|
||||||
<StudentTransactionFilterMenu filter={filter} setFilter={setFilter} />
|
<TransactionFilterMenu filter={filter} setFilter={setFilter} />
|
||||||
<div style={{ marginTop: "16px" }} />
|
<div style={{ marginTop: "16px" }} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
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";
|
||||||
|
|
||||||
|
export default function TeacherTransactionListView() {
|
||||||
|
const transactions = useQuery({
|
||||||
|
queryKey: ["transactions_teacher"],
|
||||||
|
queryFn: TransactionsByTeacherAPI,
|
||||||
|
});
|
||||||
|
const [filter, setFilter] = useState("");
|
||||||
|
if (transactions.isLoading) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
...styles.flex_column,
|
||||||
|
...{
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
paddingTop: "64px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress style={{ height: "128px", width: "128px" }} />
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
...styles.text_dark,
|
||||||
|
...styles.text_L,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Loading
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div style={styles.flex_column}>
|
||||||
|
<TransactionFilterMenu filter={filter} setFilter={setFilter} />
|
||||||
|
<div style={{ marginTop: "16px" }} />
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
...styles.flex_column,
|
||||||
|
...{ height: "50vh", overflowY: "scroll" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{transactions.data ? (
|
||||||
|
transactions.data
|
||||||
|
.filter((transaction) =>
|
||||||
|
filter !== "" ? transaction.transaction_status == filter : true
|
||||||
|
)
|
||||||
|
.map((transaction) => (
|
||||||
|
<React.Fragment key={transaction.id}>
|
||||||
|
<TransactionEntry transaction={transaction} />
|
||||||
|
</React.Fragment>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import styles from "../../../styles";
|
import styles from "../../styles";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
@ -22,7 +22,7 @@ type props = {
|
||||||
setFilter: React.Dispatch<React.SetStateAction<string>>;
|
setFilter: React.Dispatch<React.SetStateAction<string>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function StudentTransactionFilterMenu(props: props) {
|
export default function TransactionFilterMenu(props: props) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p
|
<p
|
||||||
|
@ -31,7 +31,7 @@ export default function StudentTransactionFilterMenu(props: props) {
|
||||||
...styles.text_L,
|
...styles.text_L,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Personal Transactions
|
Transactions
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div
|
<div
|
|
@ -2,7 +2,7 @@ import styles, { colors } from "../../styles";
|
||||||
import AccountCircleIcon from "@mui/icons-material/AccountCircle";
|
import AccountCircleIcon from "@mui/icons-material/AccountCircle";
|
||||||
import HomeIcon from "@mui/icons-material/Home";
|
import HomeIcon from "@mui/icons-material/Home";
|
||||||
import LogoutIcon from "@mui/icons-material/Logout";
|
import LogoutIcon from "@mui/icons-material/Logout";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import {
|
import {
|
||||||
ClearanceAPI,
|
ClearanceAPI,
|
||||||
UserAPI,
|
UserAPI,
|
||||||
|
@ -15,6 +15,7 @@ import { auth_toggle } from "../Plugins/Redux/Slices/AuthSlice/AuthSlice";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
export default function Drawer() {
|
export default function Drawer() {
|
||||||
|
const queryclient = useQueryClient();
|
||||||
const user = useQuery({ queryKey: ["user"], queryFn: UserAPI });
|
const user = useQuery({ queryKey: ["user"], queryFn: UserAPI });
|
||||||
const clearance = useQuery({
|
const clearance = useQuery({
|
||||||
enabled:
|
enabled:
|
||||||
|
@ -173,6 +174,7 @@ export default function Drawer() {
|
||||||
await dispatch(auth_toggle());
|
await dispatch(auth_toggle());
|
||||||
await setAccessToken("");
|
await setAccessToken("");
|
||||||
await setRefreshToken("");
|
await setRefreshToken("");
|
||||||
|
queryclient.clear();
|
||||||
toast("Logged out", {
|
toast("Logged out", {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
autoClose: 2000,
|
autoClose: 2000,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import TechnicianEquipmentButtons from "../../Components/DashboardPage/Technicia
|
||||||
import TechnicianLogButtons from "../../Components/DashboardPage/Technician/TechnicianLogButtons";
|
import TechnicianLogButtons from "../../Components/DashboardPage/Technician/TechnicianLogButtons";
|
||||||
import StudentTransactionListView from "../../Components/DashboardPage/Student/StudentTransactionListView";
|
import StudentTransactionListView from "../../Components/DashboardPage/Student/StudentTransactionListView";
|
||||||
import StudentDashboard from "../../Components/DashboardPage/Student/StudentDashboard";
|
import StudentDashboard from "../../Components/DashboardPage/Student/StudentDashboard";
|
||||||
|
import TeacherTransactionListView from "../../Components/DashboardPage/Teacher/TeacherTransactionListView";
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
return (
|
return (
|
||||||
<div style={styles.background}>
|
<div style={styles.background}>
|
||||||
|
@ -32,7 +33,7 @@ export default function Dashboard() {
|
||||||
</div>
|
</div>
|
||||||
</RestrictedComponent>
|
</RestrictedComponent>
|
||||||
<RestrictedComponent allow_only={"Teacher"}>
|
<RestrictedComponent allow_only={"Teacher"}>
|
||||||
<p style={styles.text_dark}>Welcome teacher!</p>
|
<TeacherTransactionListView />
|
||||||
</RestrictedComponent>
|
</RestrictedComponent>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue