Commit b9dbcf28 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

fix: show order detail on admin

parent 72966fce
...@@ -35,6 +35,22 @@ const AdminOrderController = { ...@@ -35,6 +35,22 @@ const AdminOrderController = {
res.json({ status: 300, message: "Error with server" }); res.json({ status: 300, message: "Error with server" });
} }
}, },
/**
*
* @param {Request} req
* @param {Response} res
*/
async detail(req, res) {
try {
const { id } = req.query;
let orderdetail = await db.order_detail.findMany({
where: { order_id: Number(id) },
});
res.json(orderdetail);
} catch (err) {
res.status(403).json({ status: 100, message: "found error on server" });
}
},
}; };
export default AdminOrderController; export default AdminOrderController;
...@@ -19,5 +19,6 @@ adminRouter.delete("/category", CategoryController.delete); ...@@ -19,5 +19,6 @@ adminRouter.delete("/category", CategoryController.delete);
adminRouter.get("/order", AdminOrderController.index); adminRouter.get("/order", AdminOrderController.index);
adminRouter.put("/order/sending", AdminOrderController.sending); adminRouter.put("/order/sending", AdminOrderController.sending);
adminRouter.get("/order/detail", AdminOrderController.detail);
export default adminRouter; export default adminRouter;
...@@ -31,9 +31,13 @@ export default function AdminOrderDetail() { ...@@ -31,9 +31,13 @@ export default function AdminOrderDetail() {
const fetchOrderDetail = async () => { const fetchOrderDetail = async () => {
if (!user.value?.token) return; if (!user.value?.token) return;
try { try {
let response = await axios.get("/api/u/order/detail?id=" + router.query.id, { let response = await axios.get(
"/api/admin/order/detail?id=" + router.query.id,
{
headers: { token: user.value.token }, headers: { token: user.value.token },
}); }
);
console.log(response.data);
setOrderDetailList(response.data); setOrderDetailList(response.data);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
......
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