From c7c3e3fd6f221447a0c81459a45c090aa0714334 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Mon, 28 Oct 2024 17:03:34 +0700
Subject: maps component

---
 src/lib/address/components/CreateAddress.jsx | 323 +++++++++++++++------------
 1 file changed, 181 insertions(+), 142 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 9d70e8fc..70307401 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -1,7 +1,7 @@
 import HookFormSelect from '@/core/components/elements/Select/HookFormSelect';
 import useAuth from '@/core/hooks/useAuth';
 import { useRouter } from 'next/router';
-import { Controller, useForm } from 'react-hook-form';
+import { Controller, set, useForm } from 'react-hook-form';
 import * as Yup from 'yup';
 import cityApi from '../api/cityApi';
 import districtApi from '../api/districtApi';
@@ -14,6 +14,12 @@ import Menu from '@/lib/auth/components/Menu';
 import useAddresses from '../hooks/useAddresses';
 import stateApi from '../api/stateApi';
 
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
+import PinPointMap from '../../maps/components/PinPointMap';
+import { Button } from '@chakra-ui/react';
+import { MapPinIcon } from 'lucide-react';
+import { useMaps } from '../../maps/stores/useMaps';
+
 const CreateAddress = () => {
   const auth = useAuth();
   const router = useRouter();
@@ -34,6 +40,8 @@ const CreateAddress = () => {
   const [districts, setDistricts] = useState([]);
   const [subDistricts, setSubDistricts] = useState([]);
   const [filteredTypes, setFilteredTypes] = useState(types); // State to manage filtered types
+  const [pinedMaps, setPinedMaps] = useState(false);
+  const { addressMaps, setAddressMaps } = useMaps();
 
   useEffect(() => {
     const loadState = async () => {
@@ -52,7 +60,7 @@ const CreateAddress = () => {
     setValue('city', '');
     if (watchState) {
       const loadCities = async () => {
-        let dataCities = await cityApi({stateId: watchState});
+        let dataCities = await cityApi({ stateId: watchState });
         dataCities = dataCities.map((city) => ({
           value: city.id,
           label: city.name,
@@ -133,167 +141,198 @@ const CreateAddress = () => {
   };
 
   return (
-    <div className='max-w-none md:container mx-auto flex p-0 md:py-10'>
-      <div className='hidden md:block w-3/12 pr-4'>
-        <Menu />
-      </div>
-      <div className='w-full md:w-9/12 p-4 bg-white border border-gray_r-6 rounded'>
-        <form onSubmit={handleSubmit(onSubmitHandler)}>
-          <div className='grid grid-cols-1 md:grid-cols-2 gap-4'>
-            <div>
-              <label className='form-label mb-2'>Label Alamat</label>
-              <Controller
-                name='type'
-                control={control}
-                render={(props) => (
-                  <HookFormSelect
-                    {...props}
-                    isSearchable={false}
-                    options={filteredTypes}
-                  />
-                )}
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.type?.message}
-              </div>
+    <>
+      <BottomPopup
+        className=' !h-[75%]'
+        title='Pin Maps Address'
+        active={pinedMaps}
+        close={() => setPinedMaps(false)}
+      >
+        <div className='flex mt-4'>
+          <PinPointMap />
+        </div>
+      </BottomPopup>
+      <div className='max-w-none md:container mx-auto flex p-0 md:py-10'>
+        <div className='hidden md:block w-3/12 pr-4'>
+          <Menu />
+        </div>
+        <div className='w-full md:w-9/12 p-4 bg-white border border-gray_r-6 rounded'>
+          <form onSubmit={handleSubmit(onSubmitHandler)}>
+            <div className='mb-4 items-start'>
+              <label className='form-label mb-2'>PinPoint</label>
+              {addressMaps ? (
+                <div className='flex gap-x-2 items-center'>
+                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3' />{' '}
+                  <span> {addressMaps} </span>
+                </div>
+              ) : (
+                <Button variant='plain' onClick={() => setPinedMaps(true)}>
+                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3' />
+                  Pin Alamat
+                </Button>
+              )}
+             
             </div>
+            <div className='grid grid-cols-1 md:grid-cols-2 gap-4'>
+              <div>
+                <label className='form-label mb-2'>Label Alamat</label>
+                <Controller
+                  name='type'
+                  control={control}
+                  render={(props) => (
+                    <HookFormSelect
+                      {...props}
+                      isSearchable={false}
+                      options={filteredTypes}
+                    />
+                  )}
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.type?.message}
+                </div>
+              </div>
 
-            <div>
-              <label className='form-label mb-2'>Nama</label>
-              <input
-                {...register('name')}
-                placeholder='John Doe'
-                type='text'
-                className='form-input'
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.name?.message}
+              <div>
+                <label className='form-label mb-2'>Nama</label>
+                <input
+                  {...register('name')}
+                  placeholder='John Doe'
+                  type='text'
+                  className='form-input'
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.name?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Email</label>
-              <input
-                {...register('email')}
-                placeholder='contoh@email.com'
-                type='email'
-                className='form-input'
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.email?.message}
+              <div>
+                <label className='form-label mb-2'>Email</label>
+                <input
+                  {...register('email')}
+                  placeholder='contoh@email.com'
+                  type='email'
+                  className='form-input'
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.email?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Mobile</label>
-              <input
-                {...register('mobile')}
-                placeholder='08xxxxxxxx'
-                type='tel'
-                className='form-input'
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.mobile?.message}
+              <div>
+                <label className='form-label mb-2'>Mobile</label>
+                <input
+                  {...register('mobile')}
+                  placeholder='08xxxxxxxx'
+                  type='tel'
+                  className='form-input'
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.mobile?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Alamat</label>
-              <input
-                {...register('street')}
-                placeholder='Jl. Bandengan Utara 85A'
-                type='text'
-                className='form-input'
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.street?.message}
+              <div>
+                <label className='form-label mb-2'>Alamat</label>
+                <input
+                  {...register('street')}
+                  placeholder='Jl. Bandengan Utara 85A'
+                  type='text'
+                  className='form-input'
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.street?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Kode Pos</label>
-              <input
-                {...register('zip')}
-                placeholder='10100'
-                type='number'
-                className='form-input'
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.zip?.message}
+              <div>
+                <label className='form-label mb-2'>Kode Pos</label>
+                <input
+                  {...register('zip')}
+                  placeholder='10100'
+                  type='number'
+                  className='form-input'
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.zip?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Provinsi</label>
-              <Controller
-                name='state'
-                control={control}
-                render={(props) => (
-                  <HookFormSelect {...props} options={states} />
-                )}
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.state?.message}
+              <div>
+                <label className='form-label mb-2'>Provinsi</label>
+                <Controller
+                  name='state'
+                  control={control}
+                  render={(props) => (
+                    <HookFormSelect {...props} options={states} />
+                  )}
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.state?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Kota</label>
-              <Controller
-                name='city'
-                control={control}
-                render={(props) => (
-                  <HookFormSelect {...props} options={cities}  disabled={!watchState}/>
-                )}
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.city?.message}
+              <div>
+                <label className='form-label mb-2'>Kota</label>
+                <Controller
+                  name='city'
+                  control={control}
+                  render={(props) => (
+                    <HookFormSelect
+                      {...props}
+                      options={cities}
+                      disabled={!watchState}
+                    />
+                  )}
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.city?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Kecamatan</label>
-              <Controller
-                name='district'
-                control={control}
-                render={(props) => (
-                  <HookFormSelect
-                    {...props}
-                    options={districts}
-                    disabled={!watchCity}
-                  />
-                )}
-              />
-              <div className='text-caption-2 text-danger-500 mt-1'>
-                {errors.district?.message}
+              <div>
+                <label className='form-label mb-2'>Kecamatan</label>
+                <Controller
+                  name='district'
+                  control={control}
+                  render={(props) => (
+                    <HookFormSelect
+                      {...props}
+                      options={districts}
+                      disabled={!watchCity}
+                    />
+                  )}
+                />
+                <div className='text-caption-2 text-danger-500 mt-1'>
+                  {errors.district?.message}
+                </div>
               </div>
-            </div>
 
-            <div>
-              <label className='form-label mb-2'>Kelurahan</label>
-              <Controller
-                name='subDistrict'
-                control={control}
-                render={(props) => (
-                  <HookFormSelect
-                    {...props}
-                    options={subDistricts}
-                    disabled={!watchDistrict}
-                  />
-                )}
-              />
+              <div>
+                <label className='form-label mb-2'>Kelurahan</label>
+                <Controller
+                  name='subDistrict'
+                  control={control}
+                  render={(props) => (
+                    <HookFormSelect
+                      {...props}
+                      options={subDistricts}
+                      disabled={!watchDistrict}
+                    />
+                  )}
+                />
+              </div>
             </div>
-          </div>
 
-          <button
-            type='submit'
-            className='btn-yellow w-full md:w-fit mt-6 ml-0 md:ml-auto'
-          >
-            Simpan
-          </button>
-        </form>
+            <button
+              type='submit'
+              className='btn-yellow w-full md:w-fit mt-6 ml-0 md:ml-auto'
+            >
+              Simpan
+            </button>
+          </form>
+        </div>
       </div>
-    </div>
+    </>
   );
 };
 
-- 
cgit v1.2.3


From bc4fe87e012cc1b06572ca12f1a3b92f6d1757e0 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 31 Oct 2024 09:09:05 +0700
Subject: detail adress

---
 src/lib/address/components/CreateAddress.jsx | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 70307401..a53be0fa 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -41,7 +41,7 @@ const CreateAddress = () => {
   const [subDistricts, setSubDistricts] = useState([]);
   const [filteredTypes, setFilteredTypes] = useState(types); // State to manage filtered types
   const [pinedMaps, setPinedMaps] = useState(false);
-  const { addressMaps, setAddressMaps } = useMaps();
+  const { addressMaps, setAddressMaps, selectedPosition, setSelectedPosition } = useMaps();
 
   useEffect(() => {
     const loadState = async () => {
@@ -131,9 +131,12 @@ const CreateAddress = () => {
       district_id: values.district,
       sub_district_id: values.subDistrict,
       parent_id: auth.partnerId,
+      latitude: selectedPosition?.lat,
+      longtitude: selectedPosition?.lng,
+      address_maps: JSON.stringify(addressMaps),
     };
-
-    const address = await createAddressApi({ data });
+console.log('ini data',data);
+    // const address = await createAddressApi({ data });
     if (address?.id) {
       toast.success('Berhasil menambahkan alamat');
       router.back();
-- 
cgit v1.2.3


From 053c801a8c43688c2c4eec6800368898a81bfc39 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 31 Oct 2024 16:55:07 +0700
Subject: integrasi google maps service

---
 src/lib/address/components/CreateAddress.jsx | 88 ++++++++++++++++++++++++----
 1 file changed, 75 insertions(+), 13 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index a53be0fa..404143f9 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -1,23 +1,23 @@
 import HookFormSelect from '@/core/components/elements/Select/HookFormSelect';
 import useAuth from '@/core/hooks/useAuth';
+import Menu from '@/lib/auth/components/Menu';
+import { yupResolver } from '@hookform/resolvers/yup';
 import { useRouter } from 'next/router';
-import { Controller, set, useForm } from 'react-hook-form';
+import { useEffect, useState } from 'react';
+import { Controller, useForm } from 'react-hook-form';
+import { toast } from 'react-hot-toast';
 import * as Yup from 'yup';
 import cityApi from '../api/cityApi';
+import createAddressApi from '../api/createAddressApi';
 import districtApi from '../api/districtApi';
+import stateApi from '../api/stateApi';
 import subDistrictApi from '../api/subDistrictApi';
-import { useEffect, useState } from 'react';
-import createAddressApi from '../api/createAddressApi';
-import { toast } from 'react-hot-toast';
-import { yupResolver } from '@hookform/resolvers/yup';
-import Menu from '@/lib/auth/components/Menu';
 import useAddresses from '../hooks/useAddresses';
-import stateApi from '../api/stateApi';
 
 import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
-import PinPointMap from '../../maps/components/PinPointMap';
 import { Button } from '@chakra-ui/react';
 import { MapPinIcon } from 'lucide-react';
+import PinPointMap from '../../maps/components/PinPointMap';
 import { useMaps } from '../../maps/stores/useMaps';
 
 const CreateAddress = () => {
@@ -41,7 +41,24 @@ const CreateAddress = () => {
   const [subDistricts, setSubDistricts] = useState([]);
   const [filteredTypes, setFilteredTypes] = useState(types); // State to manage filtered types
   const [pinedMaps, setPinedMaps] = useState(false);
-  const { addressMaps, setAddressMaps, selectedPosition, setSelectedPosition } = useMaps();
+  const {
+    addressMaps,
+    selectedPosition,
+    detailAddress,
+  } = useMaps();
+
+  useEffect(() => {
+    if (detailAddress) {
+      setValue('zip', detailAddress.postalCode);
+      const selectedState = states.find(
+        (state) =>
+          detailAddress?.province.includes(state.label) ||
+          state.label.includes(detailAddress?.province)
+      );
+      setValue('state', selectedState?.value);
+    
+    }
+  }, [detailAddress, setValue]);
 
   useEffect(() => {
     const loadState = async () => {
@@ -56,6 +73,7 @@ const CreateAddress = () => {
   }, []);
 
   const watchState = watch('state');
+  console.log(watchState);
   useEffect(() => {
     setValue('city', '');
     if (watchState) {
@@ -71,6 +89,21 @@ const CreateAddress = () => {
     }
   }, [watchState, setValue]);
 
+  useEffect(() => {
+    if (detailAddress) {
+      const selectedCities = cities.find(
+        (city) =>
+          detailAddress.district
+            .toLowerCase()
+            .includes(city.label.toLowerCase()) ||
+          city.label
+            .toLowerCase()
+            .includes(detailAddress.district.toLowerCase())
+      );
+      setValue('city', selectedCities?.value);
+    }
+  }, [cities, detailAddress, setValue]);
+
   useEffect(() => {
     if (addresses) {
       let hasContactAddress = false;
@@ -105,6 +138,21 @@ const CreateAddress = () => {
     }
   }, [watchCity, setValue]);
 
+  useEffect(() => {
+    if (detailAddress) {
+      const selectedDistrict = districts.find(
+        (district) =>
+          detailAddress.subDistrict
+            .toLowerCase()
+            .includes(district.label.toLowerCase()) ||
+          district.label
+            .toLowerCase()
+            .includes(detailAddress.subDistrict.toLowerCase())
+      );
+      setValue('district', selectedDistrict?.value);
+    }
+  }, [districts, detailAddress, setValue]);
+
   const watchDistrict = watch('district');
   useEffect(() => {
     setValue('subDistrict', '');
@@ -123,6 +171,22 @@ const CreateAddress = () => {
     }
   }, [watchDistrict, setValue]);
 
+  useEffect(() => {
+    if (detailAddress) {
+      const selectedSubDistrict = subDistricts.find(
+        (district) =>
+          detailAddress.village
+            .toLowerCase()
+            .includes(district.label.toLowerCase()) ||
+          district.label
+            .toLowerCase()
+            .includes(detailAddress.village.toLowerCase())
+      );
+
+      setValue('subDistrict', selectedSubDistrict?.value);
+    }
+  }, [subDistricts, detailAddress, setValue]);
+
   const onSubmitHandler = async (values) => {
     const data = {
       ...values,
@@ -133,10 +197,9 @@ const CreateAddress = () => {
       parent_id: auth.partnerId,
       latitude: selectedPosition?.lat,
       longtitude: selectedPosition?.lng,
-      address_maps: JSON.stringify(addressMaps),
+      address_map: addressMaps,
     };
-console.log('ini data',data);
-    // const address = await createAddressApi({ data });
+    const address = await createAddressApi({ data });
     if (address?.id) {
       toast.success('Berhasil menambahkan alamat');
       router.back();
@@ -174,7 +237,6 @@ console.log('ini data',data);
                   Pin Alamat
                 </Button>
               )}
-             
             </div>
             <div className='grid grid-cols-1 md:grid-cols-2 gap-4'>
               <div>
-- 
cgit v1.2.3


From d1592286eef165533c21d52aec70dbb703cdcfd3 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Wed, 18 Dec 2024 15:03:52 +0700
Subject: feedback uat

---
 src/lib/address/components/CreateAddress.jsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 404143f9..5f041eb2 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -45,6 +45,7 @@ const CreateAddress = () => {
     addressMaps,
     selectedPosition,
     detailAddress,
+    setAddressMaps,
   } = useMaps();
 
   useEffect(() => {
@@ -56,6 +57,7 @@ const CreateAddress = () => {
           state.label.includes(detailAddress?.province)
       );
       setValue('state', selectedState?.value);
+      setValue('street', detailAddress?.street);
     
     }
   }, [detailAddress, setValue]);
@@ -70,10 +72,10 @@ const CreateAddress = () => {
       setState(dataState);
     };
     loadState();
+    setAddressMaps('');
   }, []);
 
   const watchState = watch('state');
-  console.log(watchState);
   useEffect(() => {
     setValue('city', '');
     if (watchState) {
@@ -228,7 +230,7 @@ const CreateAddress = () => {
               <label className='form-label mb-2'>PinPoint</label>
               {addressMaps ? (
                 <div className='flex gap-x-2 items-center'>
-                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3' />{' '}
+                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3 cursor-pointer' onClick={() => setPinedMaps(true)} />{' '}
                   <span> {addressMaps} </span>
                 </div>
               ) : (
-- 
cgit v1.2.3


From 1028a583b1b685ed3a2ad4705ac9e2b5e23f0782 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Wed, 16 Apr 2025 15:03:12 +0700
Subject: fixing

---
 src/lib/address/components/CreateAddress.jsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 8c51dd89..cb5b364f 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -47,7 +47,6 @@ const CreateAddress = () => {
     detailAddress,
     setAddressMaps,
   } = useMaps();
-
   useEffect(() => {
     if (detailAddress) {
       setValue('zip', detailAddress.postalCode);
@@ -92,15 +91,15 @@ const CreateAddress = () => {
   }, [watchState, setValue]);
 
   useEffect(() => {
-    if (detailAddress) {
+    if (detailAddress && Object.keys(detailAddress).length > 0) {
       const selectedCities = cities.find(
         (city) =>
-          detailAddress.district
+          detailAddress?.district
             .toLowerCase()
             .includes(city.label.toLowerCase()) ||
           city.label
             .toLowerCase()
-            .includes(detailAddress.district.toLowerCase())
+            .includes(detailAddress?.district.toLowerCase())
       );
       setValue('city', selectedCities?.value);
     }
@@ -141,7 +140,7 @@ const CreateAddress = () => {
   }, [watchCity, setValue]);
 
   useEffect(() => {
-    if (detailAddress) {
+    if (detailAddress && Object.keys(detailAddress).length > 0) {
       const selectedDistrict = districts.find(
         (district) =>
           detailAddress.subDistrict
@@ -174,7 +173,7 @@ const CreateAddress = () => {
   }, [watchDistrict, setValue]);
 
   useEffect(() => {
-    if (detailAddress) {
+    if (detailAddress && Object.keys(detailAddress).length > 0) {
       const selectedSubDistrict = subDistricts.find(
         (district) =>
           detailAddress.village
-- 
cgit v1.2.3


From 0aa0d458e668520ef96ccf7ecb35bf84a585b279 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Mon, 21 Apr 2025 13:05:57 +0700
Subject: fedback renca

---
 src/lib/address/components/CreateAddress.jsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index cb5b364f..fbb01fcc 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -40,12 +40,13 @@ const CreateAddress = () => {
   const [districts, setDistricts] = useState([]);
   const [subDistricts, setSubDistricts] = useState([]);
   const [filteredTypes, setFilteredTypes] = useState(types); // State to manage filtered types
-  const [pinedMaps, setPinedMaps] = useState(false);
   const {
     addressMaps,
     selectedPosition,
     detailAddress,
     setAddressMaps,
+    pinedMaps,
+    setPinedMaps
   } = useMaps();
   useEffect(() => {
     if (detailAddress) {
-- 
cgit v1.2.3


From e0e0729ee57d2f9b1188a0604e3cc4a51317b0ed Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 12 Jun 2025 11:00:00 +0700
Subject: <hafid> fix pinpoint

---
 src/lib/address/components/CreateAddress.jsx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index fbb01fcc..35c966c7 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -212,7 +212,7 @@ const CreateAddress = () => {
     <>
       <BottomPopup
         className=' !h-[75%]'
-        title='Pin Maps Address'
+        title='Pin Koordinat Address'
         active={pinedMaps}
         close={() => setPinedMaps(false)}
       >
@@ -227,16 +227,20 @@ const CreateAddress = () => {
         <div className='w-full md:w-9/12 p-4 bg-white border border-gray_r-6 rounded'>
           <form onSubmit={handleSubmit(onSubmitHandler)}>
             <div className='mb-4 items-start'>
-              <label className='form-label mb-2'>PinPoint</label>
+              <label className='form-label mb-2'>Koordinat Alamat</label>
               {addressMaps ? (
-                <div className='flex gap-x-2 items-center'>
-                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3 cursor-pointer' onClick={() => setPinedMaps(true)} />{' '}
+                <div className='flex items-center'>
+                  <button type='button' className="flex items-center justify-center me-3 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition">
+                  <MapPinIcon class='h-6 w-6' onClick={() => setPinedMaps(true)} />{' '}
+                    </button>
                   <span> {addressMaps} </span>
                 </div>
               ) : (
-                <Button variant='plain' onClick={() => setPinedMaps(true)}>
-                  <MapPinIcon class='h-6 w-6 text-gray-500 mr-3' />
-                  Pin Alamat
+                <Button variant='plain' style={{ padding: 0 }} onClick={() => setPinedMaps(true)}>
+                 <button type='button' className="flex items-center justify-center me-3 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition">
+                    <MapPinIcon className="h-6 w-6" />
+                  </button>
+                    Pin Koordinat Alamat
                 </Button>
               )}
             </div>
-- 
cgit v1.2.3


From 6720e02766441036d872203216a1d9a45025f5a9 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 28 Jun 2025 10:35:02 +0700
Subject: <hafid> fix cities address

---
 src/lib/address/components/CreateAddress.jsx | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

(limited to 'src/lib/address/components/CreateAddress.jsx')

diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 35c966c7..963a19aa 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -94,14 +94,13 @@ const CreateAddress = () => {
   useEffect(() => {
     if (detailAddress && Object.keys(detailAddress).length > 0) {
       const selectedCities = cities.find(
-        (city) =>
-          detailAddress?.district
-            .toLowerCase()
-            .includes(city.label.toLowerCase()) ||
-          city.label
-            .toLowerCase()
-            .includes(detailAddress?.district.toLowerCase())
-      );
+          (city) => 
+            city.label.toLowerCase() === detailAddress?.district.toLowerCase()
+        ) || cities.find(
+          (city) =>
+            detailAddress?.district.toLowerCase().includes(city.label.toLowerCase()) ||
+            city.label.toLowerCase().includes(detailAddress?.district.toLowerCase())
+        );
       setValue('city', selectedCities?.value);
     }
   }, [cities, detailAddress, setValue]);
-- 
cgit v1.2.3

