diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-18 10:37:49 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-18 10:37:49 +0700 |
| commit | bd4cdf2125f717875ba90e03893b319dd962f753 (patch) | |
| tree | 3ba720e5bcd6d7350992bf8e6396724cdfc2a482 /src/lib/checkout | |
| parent | 5559770e0b0e94b68de1e31bf2be5c978362821d (diff) | |
bittesip
Diffstat (limited to 'src/lib/checkout')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 48 | ||||
| -rw-r--r-- | src/lib/checkout/components/SectionExpedition.jsx | 16 |
2 files changed, 47 insertions, 17 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 99c7b40a..6479881d 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -44,11 +44,11 @@ const { getProductsCheckout } = require('../api/checkoutApi'); function convertToInternational(number) { if (typeof number !== 'string') { - throw new Error("Input harus berupa string"); + throw new Error('Input harus berupa string'); } if (number.startsWith('08')) { - return '+62' + number.slice(2); + return '+62' + number.slice(2); } return number; @@ -151,7 +151,23 @@ const Checkout = () => { const [loadingRajaOngkir, setLoadingRajaOngkir] = useState(false); const [grandTotal, setGrandTotal] = useState(0); - const {checkWeigth, setCheckWeight, hasFlashSale, setHasFlashSale, checkoutValidation, setCheckoutValidation, biayaKirim, products, setProducts, etd, unit, selectedCourier, selectedService, listExpedisi, setExpedisi} = useCheckout(); + const { + checkWeigth, + setCheckWeight, + hasFlashSale, + setHasFlashSale, + checkoutValidation, + setCheckoutValidation, + biayaKirim, + products, + setProducts, + etd, + unit, + selectedCourier, + selectedService, + listExpedisi, + setExpedisi, + } = useCheckout(); const expedisiValidation = useRef(null); @@ -279,7 +295,7 @@ const Checkout = () => { value: expedisi.id, label: expedisi.name, carrierId: expedisi.deliveryCarrierId, - logo : expedisi.image, + logo: expedisi.image, })); setExpedisi(dataExpedisi); }; @@ -291,7 +307,6 @@ const Checkout = () => { window.onpopstate = handlePopState; - return () => { window.onpopstate = null; }; @@ -416,7 +431,7 @@ const Checkout = () => { } return; } - if(!selectedService){ + if (!selectedService) { toast.error('Harap pilih tipe layanan pengiriman'); return; } @@ -471,10 +486,12 @@ const Checkout = () => { gtag('set', 'user_data', { email: auth.email, - phone_number: convertToInternational(auth.mobile) ?? convertToInternational(auth.phone), + phone_number: + convertToInternational(auth.mobile) ?? + convertToInternational(auth.phone), }); - gtag('config', 'AW-954540379', { ' allow_enhanced_conversions':true } ) ; + gtag('config', 'AW-954540379', { ' allow_enhanced_conversions': true }); for (const product of products) deleteItemCart({ productId: product.id }); if (grandTotal > 0) { @@ -1152,7 +1169,10 @@ const Checkout = () => { </div> <div className='flex gap-x-2 justify-between'> <div className='text-gray_r-11'> - Biaya Kirim <p className='text-xs mt-1'>{formatShipmentRange(etd, unit)}</p> + Biaya Kirim{' '} + <p className='text-xs mt-1'> + {formatShipmentRange(etd, unit)} + </p> </div> <div> {currencyFormat( @@ -1458,7 +1478,9 @@ const Checkout = () => { <div className='flex gap-x-2 justify-between'> <div className='text-gray_r-11'> Biaya Kirim - <p className='text-xs mt-1'>{formatShipmentRange(etd, unit)}</p> + <p className='text-xs mt-1'> + {formatShipmentRange(etd, unit)} + </p> </div> <div> {currencyFormat( @@ -1629,7 +1651,7 @@ const SectionAddress = ({ address, label, url }) => ( <p className='mt-1 text-gray_r-11'> {address.street}, {address?.city?.name} </p> - <div className='flex gap-x-2 items-center mt-4'> + <div className='flex gap-x-2 items-center mt-4 cursor-pointer'> <MapPinIcon className={ address.addressMap @@ -1640,7 +1662,9 @@ const SectionAddress = ({ address, label, url }) => ( {address.addressMap ? ( <label>Sudah Pinpoint</label> ) : ( - <label className='text-red-500 '>Belum Pinpoint</label> + <Link href={'/my/address/' + address.id + '/edit'} target='_blank' className='cursor-pointer'> + <label className='text-red-500 cursor-pointer '>Belum Pinpoint</label> + </Link> )} </div> </div> diff --git a/src/lib/checkout/components/SectionExpedition.jsx b/src/lib/checkout/components/SectionExpedition.jsx index 8b59d210..5b4f6bfc 100644 --- a/src/lib/checkout/components/SectionExpedition.jsx +++ b/src/lib/checkout/components/SectionExpedition.jsx @@ -228,13 +228,10 @@ export default function SectionExpedition({ products }) { } ); - console.log('ini response', data); - useEffect(() => { if (data) { const couriers = reverseMappingCourier(listExpedisi, data?.data?.pricing); setCouriers(couriers); - console.log('ini scourier', couriers); } }, [data]); @@ -249,7 +246,15 @@ export default function SectionExpedition({ products }) { setSelectedCourier(courier.courier.courier_code); setServiceOptions(Object.values(courier.courier.service_type)); } else { - toast.error('Maaf, layanan tidak tersedia. Mohon pilih expedisi lain.'); + if ((courier.label === 'GRAB' || courier.label === 'GOJEK') && !addressMaps) { + toast.error( + 'Maaf, layanan kurir ' + courier.label + ' tidak tersedia. Karena Anda Belum Melakukan Pengaturan PinPoint Alamat Pegiriman.' + ) + } else { + toast.error( + 'Maaf, layanan tidak tersedia. Mohon pilih expedisi lain.' + ); + } } } else { setSelectedCourier(courier === 32 ? 'SELF PICKUP' : null); @@ -376,7 +381,8 @@ export default function SectionExpedition({ products }) { )} </div> - {serviceOptions.length > 0 && selectedCourier && + {serviceOptions.length > 0 && + selectedCourier && selectedCourier !== 32 && selectedCourier !== 0 && ( <div className='px-4 py-2'> |
