From 39b5e05a5fcc7ca26342f37e85c6585d1dacb3a5 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 5 Mar 2024 14:37:44 +0700 Subject: add address & expedisi di page quotation - template stepper approval --- src/lib/quotation/components/Quotation.jsx | 116 ++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 4 deletions(-) (limited to 'src/lib/quotation') diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index baf1492c..fbb0627c 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -24,6 +24,8 @@ import { SectionExpedisi, SectionListService, SectionValidation, + calculateEstimatedArrival, + splitDuration, } from '../../checkout/components/CheckoutSection'; import addressesApi from '@/lib/address/api/addressesApi'; import { getItemAddress } from '@/core/utils/address'; @@ -64,6 +66,7 @@ const Quotation = () => { const [biayaKirim, setBiayaKirim] = useState(0); const [selectedExpedisiService, setselectedExpedisiService] = useState(null); const [etd, setEtd] = useState(null); + const [etdFix, setEtdFix] = useState(null); const expedisiValidation = useRef(null); @@ -170,6 +173,19 @@ const Quotation = () => { } }, [selectedExpedisi]); + useEffect(() => { + if (selectedServiceType) { + let serviceType = selectedServiceType.split(','); + setBiayaKirim(serviceType[0]); + setselectedExpedisiService(serviceType[1]); + setEtd(serviceType[2]); + } + }, [selectedServiceType]); + + useEffect(() => { + if (etd) setEtdFix(calculateEstimatedArrival(etd)); + }, [etd]); + // end set up address and carrier useEffect(() => { @@ -248,6 +264,10 @@ const Quotation = () => { partner_invoice_id: auth.partnerId, user_id: auth.id, order_line: JSON.stringify(productOrder), + delivery_amount: biayaKirim, + carrier_id: selectedCarrierId, + estimated_arrival_days: splitDuration(etd), + delivery_service_type: selectedExpedisiService, }; const isSuccess = await checkoutApi({ data }); setIsLoading(false); @@ -278,6 +298,68 @@ const Quotation = () => { + {selectedCarrierId == SELF_PICKUP_ID && ( +
+ +
+ )} + + {selectedCarrierId == SELF_PICKUP_ID && ( + + )} + {selectedCarrierId != SELF_PICKUP_ID && ( + + + + + + )} + + + + + +
{products && ( @@ -313,12 +395,25 @@ const Quotation = () => {
PPN 11%
{currencyFormat(cartCheckout?.tax)}
+
+
+ Biaya Kirim

{etdFix}

+
+
+ {currencyFormat( + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + )} +
+

Grand Total
- {currencyFormat(cartCheckout?.grandTotal)} + {currencyFormat( + cartCheckout?.grandTotal + + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + )}

@@ -428,6 +523,16 @@ const Quotation = () => {

PPN 11%
{currencyFormat(cartCheckout?.tax)}
+
+
+ Biaya Kirim

{etdFix}

+
+
+ {currencyFormat( + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + )} +
+

@@ -435,12 +540,15 @@ const Quotation = () => {
Grand Total
- {currencyFormat(cartCheckout?.grandTotal)} + {currencyFormat( + cartCheckout?.grandTotal + + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + )}
-

+ {/*

*) Belum termasuk biaya pengiriman -

+

*/}

Dengan melakukan pembelian melalui website Indoteknik, saya menyetujui{' '} -- cgit v1.2.3