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

