From 0cf4e527dd7565261349d9485a82695379427892 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 26 Sep 2024 10:06:58 +0700 Subject: bug ga bisa pilih alamat di quotation --- src/lib/quotation/components/Quotation.jsx | 107 +++++++++++++++-------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'src/lib') diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 0ad042de..cf0ad41f 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -39,12 +39,12 @@ const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi'); const Quotation = () => { const router = useRouter(); const auth = useAuth(); - + const { data: cartCheckout } = useQuery('cartCheckout', () => getProductsCheckout() -); + ); -const { setRefreshCart } = useProductCartContext(); + const { setRefreshCart } = useProductCartContext(); const SELF_PICKUP_ID = 32; const [products, setProducts] = useState(null); @@ -69,18 +69,18 @@ const { setRefreshCart } = useProductCartContext(); const [selectedExpedisiService, setselectedExpedisiService] = useState(null); const [etd, setEtd] = useState(null); const [etdFix, setEtdFix] = useState(null); - + const [isApproval, setIsApproval] = useState(false); - + const expedisiValidation = useRef(null); - + const [selectedAddress, setSelectedAddress] = useState({ shipping: null, invoicing: null, }); - + const [addresses, setAddresses] = useState(null); - + const [note_websiteText, setselectedNote_websiteText] = useState(''); useEffect(() => { @@ -99,6 +99,9 @@ const { setRefreshCart } = useProductCartContext(); if (!addresses) return; const matchAddress = (key) => { + if (key === 'invoicing') { + key = 'invoice'; + } const addressToMatch = getItemAddress(key); const foundAddress = addresses.filter( (address) => address.id == addressToMatch @@ -271,7 +274,7 @@ const { setRefreshCart } = useProductCartContext(); toast.error('Maaf, Note wajib dimasukkan.'); return; } - + setIsLoading(true); const productOrder = products.map((product) => ({ product_id: product.id, @@ -286,11 +289,10 @@ const { setRefreshCart } = useProductCartContext(); carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, - note_website : note_websiteText, + note_website: note_websiteText, }; - + const isSuccess = await checkoutApi({ data }); - ; setIsLoading(false); if (isSuccess?.id) { for (const product of products) deleteItemCart({ productId: product.id }); @@ -298,7 +300,7 @@ const { setRefreshCart } = useProductCartContext(); setRefreshCart(true); return; } - + toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); }; @@ -455,25 +457,26 @@ const { setRefreshCart } = useProductCartContext(); {' '} yang berlaku

-
- -
-
Note
- {isApproval && ( -
*harus diisi
- )} -
-
-