diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-11 11:51:45 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-11 11:51:45 +0700 |
| commit | 0f84963214ee6dc5b5a44d945540826a66bec9e0 (patch) | |
| tree | 4011423ed5147059f40afa873f87e167202f5f79 /src/lib/address/components/EditAddress.jsx | |
| parent | cecccfaf318e0e7c52132cf1d04c90c0df745d14 (diff) | |
<iman> update pengajuan tempo
Diffstat (limited to 'src/lib/address/components/EditAddress.jsx')
| -rw-r--r-- | src/lib/address/components/EditAddress.jsx | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/src/lib/address/components/EditAddress.jsx b/src/lib/address/components/EditAddress.jsx index dd5c27fd..b98ab7b4 100644 --- a/src/lib/address/components/EditAddress.jsx +++ b/src/lib/address/components/EditAddress.jsx @@ -35,7 +35,6 @@ const EditAddress = ({ id, defaultValues }) => { const [cities, setCities] = useState([]); const [districts, setDistricts] = useState([]); const [subDistricts, setSubDistricts] = useState([]); - const [isZipTrue, setIsZipTrue] = useState(false); useEffect(() => { const loadProfile = async () => { @@ -53,7 +52,7 @@ const EditAddress = ({ id, defaultValues }) => { useEffect(() => { const loadStates = async () => { - let dataStates = await stateApi(); + let dataStates = await stateApi({ tempo: false }); dataStates = dataStates.map((state) => ({ value: state.id, label: state.name, @@ -128,44 +127,7 @@ const EditAddress = ({ id, defaultValues }) => { loadSubDistricts(); } }, [watchDistrict, setValue, getValues]); - - const watchZip = watch('zip'); const onSubmitHandler = async (values) => { - if (watchZip) { - const loadZip = async () => { - try { - const response = await fetch( - `https://alamat.thecloudalert.com/api/cari/index/?keyword=${watchZip}` - ); - - if (!response.ok) { - toast.error('Gagal memuat data alamat pos.'); - setValue('zip', ''); - return false; - } - - const result = await response.json(); - console.log('result', result); - - if (result.length === 0) { - toast.error('Alamat pos salah'); - setValue('zip', ''); - return false; - } - - return true; // Jika valid - } catch (error) { - toast.error('Terjadi kesalahan saat memeriksa alamat pos.'); - console.error('Error:', error); - return false; - } - }; - - const isValidZip = await loadZip(); - if (!isValidZip) { - return; // Menghentikan eksekusi jika alamat salah - } - } const data = { ...values, phone: values.mobile, |
