From 66960ab7912c4668b20c2c78e7dee7656ca0dcc4 Mon Sep 17 00:00:00 2001 From: UG Date: Thu, 11 Jan 2024 03:25:39 +0800 Subject: [PATCH] [frontend] fix --- frontend/src/components/Cart.tsx | 2 +- .../src/pages/user/seller/allCoupons/[sellerCouponID].tsx | 6 +++++- frontend/src/pages/user/seller/allCoupons/newCoupon.tsx | 6 +++--- .../src/pages/user/seller/allProducts/[sellerGoodsID].tsx | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Cart.tsx b/frontend/src/components/Cart.tsx index e7f4470a..3fae8cd8 100644 --- a/frontend/src/components/Cart.tsx +++ b/frontend/src/components/Cart.tsx @@ -170,7 +170,7 @@ const Cart = ({ products, cartInfo, refresh }: Props) => { alert('please wait for the checkout data'); return; } - if (getValues('card_id') === null) { + if (!getValues('card_id')) { if (checkoutData.payments.length === 0) { alert('please add a card'); } else { diff --git a/frontend/src/pages/user/seller/allCoupons/[sellerCouponID].tsx b/frontend/src/pages/user/seller/allCoupons/[sellerCouponID].tsx index 9c2332eb..dee5b512 100644 --- a/frontend/src/pages/user/seller/allCoupons/[sellerCouponID].tsx +++ b/frontend/src/pages/user/seller/allCoupons/[sellerCouponID].tsx @@ -264,9 +264,13 @@ const EachSellerCoupon = () => { if (!resp.ok) { if (resp.status === 500) { alert("error on modifying coupon, please check your shop's status"); + navigate('/user/seller/manageCoupons'); + } else { + const response = await resp.json(); + alert(response.message); } + } else { navigate('/user/seller/manageCoupons'); - return; } }; diff --git a/frontend/src/pages/user/seller/allCoupons/newCoupon.tsx b/frontend/src/pages/user/seller/allCoupons/newCoupon.tsx index 0561c604..1b0b4a55 100644 --- a/frontend/src/pages/user/seller/allCoupons/newCoupon.tsx +++ b/frontend/src/pages/user/seller/allCoupons/newCoupon.tsx @@ -95,11 +95,10 @@ const NewSellerCoupon = () => { if (!resp.ok) { if (resp.status === 500) { alert("error on adding tag, please check your shop's status"); + navigate('/user/seller/manageCoupons'); } else { alert('error when creating new tag'); } - navigate('/user/seller/manageCoupons'); - return; } else { const response = await resp.json(); append({ name: newTagName, tag_id: response.id }); @@ -196,12 +195,13 @@ const NewSellerCoupon = () => { if (!resp.ok) { if (resp.status === 500) { alert("error on creating coupon, please check your shop's status"); + navigate('/user/seller/manageCoupons'); } else { const response = await resp.json(); alert(response.message); } + } else { navigate('/user/seller/manageCoupons'); - return; } }; diff --git a/frontend/src/pages/user/seller/allProducts/[sellerGoodsID].tsx b/frontend/src/pages/user/seller/allProducts/[sellerGoodsID].tsx index ab19f897..472c14a0 100644 --- a/frontend/src/pages/user/seller/allProducts/[sellerGoodsID].tsx +++ b/frontend/src/pages/user/seller/allProducts/[sellerGoodsID].tsx @@ -228,10 +228,13 @@ const EachSellerGoods = () => { navigate('/user/seller/manageProducts'); return; } + } else { + navigate('/user/seller/manageProducts'); } return await response.json(); }, onSuccess: (responseData: PatchResponseProps) => { + // set value is redundant setValue('name', responseData.name); setValue('description', responseData.description); setValue('price', responseData.price);