|
Last change
on this file since badbc79 was badbc79, checked in by Luka Cheshlarov <luka.cheshlarov@…>, 20 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | import React from "react";
|
|---|
| 2 | import {Grid, Typography} from "@mui/material";
|
|---|
| 3 | import {Navigate, useLoaderData, useParams} from "react-router-dom";
|
|---|
| 4 | import OrderCard from "../../components/cards/order-card";
|
|---|
| 5 | import {useAuthContext} from "../../configurations/AuthContext";
|
|---|
| 6 |
|
|---|
| 7 | const UserOrders = () => {
|
|---|
| 8 | const {loggedUserRole} = useAuthContext();
|
|---|
| 9 | const {orders} = useLoaderData();
|
|---|
| 10 | const {userId} = useParams();
|
|---|
| 11 |
|
|---|
| 12 | return (loggedUserRole?.roleId != userId ? <Navigate to={"/"}/> :
|
|---|
| 13 | <Grid container direction={"column"} justify={"center"} alignItems={"center"}>
|
|---|
| 14 | <Typography className={"mt-3"} variant={"h3"}>
|
|---|
| 15 | My Orders
|
|---|
| 16 | </Typography>
|
|---|
| 17 |
|
|---|
| 18 | <hr className={"horizontal-fancy"}/>
|
|---|
| 19 |
|
|---|
| 20 | <Grid container rowGap={2} rowSpacing={2}>
|
|---|
| 21 | {orders &&
|
|---|
| 22 | orders.length > 0 &&
|
|---|
| 23 | orders.map((order) => (
|
|---|
| 24 | <Grid key={order.id} item md={12} className={"m-3"}>
|
|---|
| 25 | <OrderCard order={order}/>
|
|---|
| 26 | </Grid>
|
|---|
| 27 | ))}
|
|---|
| 28 | </Grid>
|
|---|
| 29 | </Grid>
|
|---|
| 30 | )
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | export default UserOrders; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.