Commit 72966fce authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

update order when order in cart

parent 69826254
...@@ -14,11 +14,12 @@ import { ...@@ -14,11 +14,12 @@ import {
Snackbar, Snackbar,
} from "@mui/material"; } from "@mui/material";
import axios from "axios"; import axios from "axios";
import { CartContext, UserContext } from "@/pages/_app"; import { CartContext, OrderContext, UserContext } from "@/pages/_app";
export default function ConfirmOrder({ open, handleClose }) { export default function ConfirmOrder({ open, handleClose }) {
const user = useContext(UserContext); const user = useContext(UserContext);
const cart = useContext(CartContext); const cart = useContext(CartContext);
const order = useContext(OrderContext)
const [message, setMessage] = useState({ message: "", error: false }); const [message, setMessage] = useState({ message: "", error: false });
const [address, setAddress] = useState(user.value?.address ?? ""); const [address, setAddress] = useState(user.value?.address ?? "");
...@@ -43,6 +44,7 @@ export default function ConfirmOrder({ open, handleClose }) { ...@@ -43,6 +44,7 @@ export default function ConfirmOrder({ open, handleClose }) {
}, 2000); }, 2000);
cart.fetch(); cart.fetch();
order.fetch();
handleClose(); handleClose();
} catch (err) { } catch (err) {
setMessage({ message: "พบข้อผิดพลาด กรุณาลองใหม่อีกครั้ง", error: true }); setMessage({ message: "พบข้อผิดพลาด กรุณาลองใหม่อีกครั้ง", error: true });
......
...@@ -13,7 +13,6 @@ import { CartContext, UserContext, WishlistContext } from "./_app"; ...@@ -13,7 +13,6 @@ import { CartContext, UserContext, WishlistContext } from "./_app";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import axios from "axios"; import axios from "axios";
import { Delete } from "@mui/icons-material"; import { Delete } from "@mui/icons-material";
import { ShoppingCart } from "@mui/icons-material";
import PopupAlert from "@/components/PopupAlert"; import PopupAlert from "@/components/PopupAlert";
import Head from "next/head"; import Head from "next/head";
import { ShoppingBag } from "@mui/icons-material"; import { ShoppingBag } from "@mui/icons-material";
......
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