diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-26 11:16:32 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-26 11:16:32 +0700 |
| commit | 9dc7af1641f06f3c7cffda102febe90c806ffee1 (patch) | |
| tree | e82bd0209247d5b85e7434e81bde8f2d9b525289 /src/lib/quotation/components/Quotation.jsx | |
| parent | 461d2786935c5c9b3cf627c44fc06fcd1c3e8075 (diff) | |
| parent | 1c56a76f979a6e433d70634b92b1887fb1f19509 (diff) | |
Merge branch 'new-release' into Feature/switch-account
Diffstat (limited to 'src/lib/quotation/components/Quotation.jsx')
| -rw-r--r-- | src/lib/quotation/components/Quotation.jsx | 107 |
1 files changed, 57 insertions, 50 deletions
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(); </Link>{' '} yang berlaku </p> - <hr className='my-4 border-gray_r-6' /> - - <div className='flex gap-x-2 justify-start mb-4'> - <div className=''>Note</div> - {isApproval && ( - <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div> - )} - </div> - <div className='text-caption-2 text-gray_r-11'> - <textarea - rows="4" - cols="50" - className={`w-full p-1 rounded border border-gray_r-6`} - onChange={(e) => setselectedNote_websiteText(e.target.value)} - /> - </div> + <hr className='my-4 border-gray_r-6' /> + + <div className='flex gap-x-2 justify-start mb-4'> + <div className=''>Note</div> + {isApproval && ( + <div className='text-caption-1 text-red-500 items-center flex'> + *harus diisi + </div> + )} + </div> + <div className='text-caption-2 text-gray_r-11'> + <textarea + rows='4' + cols='50' + className={`w-full p-1 rounded border border-gray_r-6`} + onChange={(e) => setselectedNote_websiteText(e.target.value)} + /> + </div> </div> - - + <Divider /> <div className='flex gap-x-3 p-4'> @@ -606,27 +609,31 @@ const { setRefreshCart } = useProductCartContext(); yang berlaku </p> - <div> - <hr className='my-4 border-gray_r-6' /> - - <div className='flex gap-x-1 flex-col mb-4'> - <div className='flex flex-row gap-x-1'> - <div className=''>Note</div> - {isApproval && ( - <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div> - )} - </div> - <div className='text-caption-2 text-gray_r-11'> - <textarea - rows="4" - cols="50" - className={`w-full p-1 rounded border border-gray_r-6`} - onChange={(e) => setselectedNote_websiteText(e.target.value)} - /> - </div> + <div> + <hr className='my-4 border-gray_r-6' /> + + <div className='flex gap-x-1 flex-col mb-4'> + <div className='flex flex-row gap-x-1'> + <div className=''>Note</div> + {isApproval && ( + <div className='text-caption-1 text-red-500 items-center flex'> + *harus diisi + </div> + )} + </div> + <div className='text-caption-2 text-gray_r-11'> + <textarea + rows='4' + cols='50' + className={`w-full p-1 rounded border border-gray_r-6`} + onChange={(e) => + setselectedNote_websiteText(e.target.value) + } + /> </div> </div> - + </div> + <hr className='my-4 border-gray_r-6' /> <button |
