Commit 735c3fd7 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

in order page can view only not make payment yet

parent 4065c60f
...@@ -2,11 +2,14 @@ import { ...@@ -2,11 +2,14 @@ import {
Box, Box,
Button, Button,
Paper, Paper,
Stack,
Switch,
Table, Table,
TableBody, TableBody,
TableCell, TableCell,
TableHead, TableHead,
TableRow, TableRow,
Typography,
} from "@mui/material"; } from "@mui/material";
import React, { useContext, useEffect, useState } from "react"; import React, { useContext, useEffect, useState } from "react";
import { CartContext, OrderContext, UserContext } from "./_app"; import { CartContext, OrderContext, UserContext } from "./_app";
...@@ -23,6 +26,7 @@ export default function Order() { ...@@ -23,6 +26,7 @@ export default function Order() {
const [message, setMessage] = useState({ error: false, message: "" }); const [message, setMessage] = useState({ error: false, message: "" });
const order = useContext(OrderContext); const order = useContext(OrderContext);
const [payment, setPayment] = useState({ open: false, id: -1, price: -1 }); const [payment, setPayment] = useState({ open: false, id: -1, price: -1 });
const [payFilter, setPayFilter] = useState(false);
const fetchProduct = async () => { const fetchProduct = async () => {
try { try {
...@@ -57,6 +61,24 @@ export default function Order() { ...@@ -57,6 +61,24 @@ export default function Order() {
isError={message.error} isError={message.error}
message={message.message} message={message.message}
/> />
<Box sx={{ maxWidth: 1200, mx: "auto" }}>
<Box>
<Stack
direction={"row"}
alignItems={"center"}
justifyContent={"end"}
>
<Typography>ทั้งหมด</Typography>
<Switch
checked={payFilter}
onChange={(e) => {
console.log(e.target.checked);
setPayFilter(e.target.checked);
}}
/>
<Typography>ยังไม่ชำระเงิน</Typography>
</Stack>
</Box>
<Paper sx={{ p: 1, overflowX: "scroll" }}> <Paper sx={{ p: 1, overflowX: "scroll" }}>
{order.value?.length > 0 ? ( {order.value?.length > 0 ? (
<Box> <Box>
...@@ -79,7 +101,8 @@ export default function Order() { ...@@ -79,7 +101,8 @@ export default function Order() {
<TableBody> <TableBody>
{order.value.map( {order.value.map(
(order, idx) => (order, idx) =>
order && ( order &&
(!payFilter || order.pay_status === 0) && (
<TableRow key={idx}> <TableRow key={idx}>
<TableCell>{order.id}</TableCell> <TableCell>{order.id}</TableCell>
<TableCell> <TableCell>
...@@ -116,7 +139,9 @@ export default function Order() { ...@@ -116,7 +139,9 @@ export default function Order() {
<TableCell> <TableCell>
{order.send_status == 0 ? ( {order.send_status == 0 ? (
<Box color="gray"> <Box color="gray">
{order.send_status ? "ส่งแล้ว" : "ยังไม่จัดส่ง"} {order.send_status
? "ส่งแล้ว"
: "ยังไม่จัดส่ง"}
</Box> </Box>
) : ( ) : (
<> <>
...@@ -143,6 +168,7 @@ export default function Order() { ...@@ -143,6 +168,7 @@ export default function Order() {
)} )}
</Paper> </Paper>
</Box> </Box>
</Box>
</> </>
); );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment