Commit 44bf1622 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

search order by id

parent 735c3fd7
...@@ -18,6 +18,7 @@ import PopupAlert from "@/components/PopupAlert"; ...@@ -18,6 +18,7 @@ import PopupAlert from "@/components/PopupAlert";
import Head from "next/head"; import Head from "next/head";
import Link from "next/link"; import Link from "next/link";
import ConfirmPayment from "@/components/order/ConfirmPayment"; import ConfirmPayment from "@/components/order/ConfirmPayment";
import { useRouter } from "next/router";
export default function Order() { export default function Order() {
const user = useContext(UserContext); const user = useContext(UserContext);
...@@ -27,6 +28,7 @@ export default function Order() { ...@@ -27,6 +28,7 @@ export default function Order() {
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 [payFilter, setPayFilter] = useState(false);
const router = useRouter()
const fetchProduct = async () => { const fetchProduct = async () => {
try { try {
...@@ -102,6 +104,7 @@ export default function Order() { ...@@ -102,6 +104,7 @@ export default function Order() {
{order.value.map( {order.value.map(
(order, idx) => (order, idx) =>
order && order &&
(!router.query?.q || Number(router.query.q) === order.id ) &&
(!payFilter || order.pay_status === 0) && ( (!payFilter || order.pay_status === 0) && (
<TableRow key={idx}> <TableRow key={idx}>
<TableCell>{order.id}</TableCell> <TableCell>{order.id}</TableCell>
......
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