From 7966f67569d01c25f7a337962d7d0bb1a0c57808 Mon Sep 17 00:00:00 2001
From: trisusilo48
Date: Wed, 13 Nov 2024 14:46:59 +0700
Subject: get couries, mapping couries and service
---
src/lib/checkout/components/Checkout.jsx | 53 +++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 14 deletions(-)
(limited to 'src/lib/checkout/components/Checkout.jsx')
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 = () => {
/>
)}
+ {products && }
(
{address.street}, {address?.city?.name}
-
- {address.addressMap ? : }
+
+ {address.addressMap ? (
+
+ ) : (
+
+ )}
)}
-
+
);
const SectionValidation = ({ address }) =>
@@ -1647,11 +1674,9 @@ const SectionValidation = ({ address }) =>
);
const SectionExpedisiBiteship = ({ listExpedisi, setSelectedExpedisi }) => (
- <>
- >
+ <>>
);
-
const SectionExpedisi = ({
address,
listExpedisi,
--
cgit v1.2.3