source: frontend/src/routes/orders/order-list.jsx

Last change on this file was badbc79, checked in by Luka Cheshlarov <luka.cheshlarov@…>, 20 months ago

Initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import React from "react";
2import {Grid, Typography} from "@mui/material";
3import {useLoaderData, useSearchParams} from "react-router-dom";
4import OrderCard from "../../components/cards/order-card";
5import {useAuthContext} from "../../configurations/AuthContext";
6import {UserRole} from "../../services/user-service";
7
8const OrderList = () => {
9 const {orders} = useLoaderData();
10 const {loggedUserRole} = useAuthContext();
11 const [searchParams, setSearchParams] = useSearchParams();
12
13 [UserRole.Vozac, UserRole.Admin].includes(loggedUserRole?.role)
14 return (orders &&
15 <Grid container direction={"column"} justify={"center"} alignItems={"center"}>
16 <Typography className={"mt-3"} variant={"h3"}>
17 {!searchParams.get("active") ? "All" : searchParams.get("active") === "true" ? "Active" : "Finished"} Orders
18 </Typography>
19
20 <hr className={"horizontal-fancy"}/>
21
22 <Grid container rowGap={2} rowSpacing={2}>
23 {orders &&
24 orders.length > 0 &&
25 orders.map((order) => (
26 <Grid key={order.id} item md={12} className={"m-3"}>
27 <OrderCard order={order}/>
28 </Grid>
29 ))}
30 </Grid>
31 </Grid>
32 )
33}
34
35export default OrderList;
Note: See TracBrowser for help on using the repository browser.