summaryrefslogtreecommitdiff
path: root/src/lib/checkout/components/Checkout.jsx
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2024-11-13 14:46:59 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2024-11-13 14:46:59 +0700
commit7966f67569d01c25f7a337962d7d0bb1a0c57808 (patch)
tree7069dae9adba31fd8dba56bbdaecaaa391e86654 /src/lib/checkout/components/Checkout.jsx
parentebba81f144b860eaf3bd7a9ef2b1c63a2ff021e0 (diff)
get couries, mapping couries and service
Diffstat (limited to 'src/lib/checkout/components/Checkout.jsx')
-rw-r--r--src/lib/checkout/components/Checkout.jsx53
1 files changed, 39 insertions, 14 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 6da27745..b4c311a9 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -1,4 +1,4 @@
-import { Button, Skeleton, Spinner } from '@chakra-ui/react';
+import { Skeleton, Spinner } from '@chakra-ui/react';
import {
BanknotesIcon,
ChevronLeftIcon,
@@ -28,10 +28,12 @@ import getFileBase64 from '@/core/utils/getFileBase64';
import { gtagPurchase } from '@/core/utils/googleTag';
import whatsappUrl from '@/core/utils/whatsappUrl';
import addressesApi from '@/lib/address/api/addressesApi';
+import { MapPinIcon } from 'lucide-react';
import CartItem from '~/modules/cart/components/Item.tsx';
import ExpedisiList from '../api/ExpedisiList';
-import { findVoucher, getVoucher, getVoucherNew } from '../api/getVoucher';
-import { MapPinIcon } from 'lucide-react';
+import { getVoucher } from '../api/getVoucher';
+import { useAddress } from '../stores/useAdress';
+import SectionExpedition from './SectionExpedition';
const SELF_PICKUP_ID = 32;
@@ -57,11 +59,15 @@ const Checkout = () => {
})
);
- const [selectedAddress, setSelectedAddress] = useState({
- shipping: null,
- invoicing: null,
- });
- const [addresses, setAddresses] = useState(null);
+ const {
+ selectedAddress,
+ setSelectedAddress,
+ addresses,
+ setAddresses,
+ setAddressMaps,
+ setCoordinate,
+ setPostalCode,
+ } = useAddress();
useEffect(() => {
if (!auth) return;
@@ -91,10 +97,20 @@ const Checkout = () => {
return addresses[0];
};
+ let ship = matchAddress('shipping');
+
setSelectedAddress({
shipping: matchAddress('shipping'),
invoicing: matchAddress('invoicing'),
});
+ setPostalCode(ship?.zip);
+ if (ship?.addressMap) {
+ setAddressMaps(ship?.addressMap);
+ setCoordinate({
+ destination_latitude: ship?.latitude,
+ destination_longitude: ship?.longtitude,
+ });
+ }
}, [addresses]);
const [products, setProducts] = useState(null);
@@ -1340,6 +1356,7 @@ const Checkout = () => {
/>
</Skeleton>
)}
+ {products && <SectionExpedition products={products} />}
<Divider />
<SectionValidation address={selectedAddress.invoicing} />
<SectionExpedisi
@@ -1621,12 +1638,22 @@ const SectionAddress = ({ address, label, url }) => (
{address.street}, {address?.city?.name}
</p>
<div className='flex gap-x-2 items-center mt-4'>
- <MapPinIcon className={address.addressMap ? `h-6 w-6 text-gray-500` : `h-6 w-6 text-red-500`} />
- {address.addressMap ? <label>Sudah Pinpoint</label> : <label className='text-red-500 '>Belum Pinpoint</label>}
+ <MapPinIcon
+ className={
+ address.addressMap
+ ? `h-6 w-6 text-gray-500`
+ : `h-6 w-6 text-red-500`
+ }
+ />
+ {address.addressMap ? (
+ <label>Sudah Pinpoint</label>
+ ) : (
+ <label className='text-red-500 '>Belum Pinpoint</label>
+ )}
</div>
</div>
)}
- </div>
+ </div>
);
const SectionValidation = ({ address }) =>
@@ -1647,11 +1674,9 @@ const SectionValidation = ({ address }) =>
);
const SectionExpedisiBiteship = ({ listExpedisi, setSelectedExpedisi }) => (
- <>
- </>
+ <></>
);
-
const SectionExpedisi = ({
address,
listExpedisi,