From 6608d0e62fd232cbc19f42f58d1f56cfe2ef6842 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 17 May 2023 08:54:35 +0700 Subject: feedback UAT --- src/lib/checkout/components/Checkout.jsx | 116 +++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 30 deletions(-) (limited to 'src/lib/checkout/components') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 03d3e2d9..b2f9a866 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -6,7 +6,7 @@ import { getItemAddress } from '@/core/utils/address' import addressesApi from '@/lib/address/api/addressesApi' import CartApi from '@/lib/cart/api/CartApi' import { ExclamationCircleIcon } from '@heroicons/react/24/outline' -import { useEffect, useRef, useState } from 'react' +import React, { useEffect, useRef, useState } from 'react' import _ from 'lodash' import { deleteItemCart, getCart, getItemCart } from '@/core/utils/cart' import currencyFormat from '@/core/utils/currencyFormat' @@ -22,6 +22,8 @@ import DesktopView from '@/core/components/views/DesktopView' import ExpedisiList from '../api/ExpedisiList' import whatsappUrl from '@/core/utils/whatsappUrl' import { createSlug } from '@/core/utils/slug' +import { Button, Modal } from 'flowbite-react' +import BottomPopup from '@/core/components/elements/Popup/BottomPopup' const Checkout = () => { const router = useRouter() @@ -75,6 +77,8 @@ const Checkout = () => { const [checkWeigth, setCheckWeight] = useState(false) const [selectedServiceType, setSelectedServiceType] = useState(null) const [selectedExpedisiService, setselectedExpedisiService] = useState(null) + const [etd, setEtd] = useState(null) + const [etdFix, setEtdFix] = useState(null) useEffect(() => { const loadExpedisi = async () => { @@ -155,6 +159,7 @@ const Checkout = () => { setselectedExpedisiService( dataService.data[0].costs[0]?.description + '-' + dataService.data[0].costs[0]?.service ) + setEtd(dataService.data[0].costs[0]?.cost[0].etd) toast.success('Silahkan Pilih Service Tipe') } else { toast.error('Tidak Ada Service, Silahkan Pilih Expedisi lain !') @@ -166,6 +171,7 @@ const Checkout = () => { setListServiceExpedisi() setBiayaKirim(0) setselectedExpedisiService() + setEtd() } }, [selectedCarrier, selectedAddress, totalWeight]) @@ -174,9 +180,38 @@ const Checkout = () => { let serviceType = selectedServiceType.split(',') setBiayaKirim(serviceType[0]) setselectedExpedisiService(serviceType[1]) + setEtd(serviceType[2]) } }, [selectedServiceType]) + useEffect(() => { + if (etd) { + let estimationDate = etd.split('-') + if (Array.isArray(estimationDate)) { + let from = new Date() + let to = new Date() + from.setDate(from.getDate() + parseInt(estimationDate[0])) + to.setDate(to.getDate() + parseInt(estimationDate[1])) + setEtdFix( + '(' + + from.getDate() + + ' ' + + from.toLocaleString('default', { month: 'short' }) + + ' - ' + + to.getDate() + + ' ' + + to.toLocaleString('default', { month: 'short' }) + + ')' + ) + } else { + let to = new Date() + to.setDate(to.getDate() + parseInt(10)) + setEtdFrom('>') + setEtdTo(to.getDate() + ' ' + to.toLocaleString('default', { month: 'short' })) + } + } + }, [etd]) + useEffect(() => { if (selectedExpedisi) { let serviceType = selectedExpedisi.split(',') @@ -308,15 +343,22 @@ const Checkout = () => {
{currencyFormat(taxTotal)}
-
Biaya Kirim
-
{currencyFormat(biayaKirim)}
+
+ Biaya Kirim

*Estimasi tiba {etdFix}

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

Grand Total
- {currencyFormat(totalAmount - totalDiscountAmount + taxTotal + parseInt(biayaKirim))} + {currencyFormat( + totalAmount - + totalDiscountAmount + + taxTotal + + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + )}
{/*

*) Belum termasuk biaya pengiriman

*/} @@ -524,8 +566,11 @@ const Checkout = () => {
{currencyFormat(taxTotal)}
-
Biaya Kirim
-
{currencyFormat(biayaKirim)}
+
+ Biaya Kirim +

*Estimasi tiba {etdFix}

+
+
{currencyFormat(Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000)}
@@ -535,7 +580,10 @@ const Checkout = () => {
Grand Total
{currencyFormat( - totalAmount - totalDiscountAmount + taxTotal + parseInt(biayaKirim) + totalAmount - + totalDiscountAmount + + taxTotal + + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 )}
@@ -630,18 +678,16 @@ const SectionAddress = ({ address, label, url }) => ( const SectionValidation = ({ address, checkWeigth }) => address?.rajaongkirCityId == 0 && ( -
-
-
-

- SIlahkan Update alamat kirim melalui{' '} - - Link ini ! - -

-
+ +
+ Silahkan Update Alamat Anda Melalui Tombol di bawah ini{' '}
-
+
+ + Update Alamat + +
+ ) const SectionExpedisi = ({ address, listExpedisi, setSelectedExpedisi, checkWeigth }) => @@ -653,16 +699,17 @@ const SectionExpedisi = ({ address, listExpedisi, setSelectedExpedisi, checkWeig
@@ -689,11 +736,20 @@ const SectionListService = ({ listserviceExpedisi, setSelectedServiceType }) => -- cgit v1.2.3