summaryrefslogtreecommitdiff
path: root/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-12-30 15:49:18 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-12-30 15:49:18 +0700
commit7f92d22feb841e1405e56505c742f90cbd365ffc (patch)
tree10f11ceff97188e3f6d4e73ad850f9d60d487358 /src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
parentdaa0b872601789815513508d48a14cbd8e1f6518 (diff)
<iman> update pengajuan tempo
Diffstat (limited to 'src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx')
-rw-r--r--src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
index fc0f1c28..d385bc3b 100644
--- a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
+++ b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
@@ -73,9 +73,6 @@ const InformasiPerusahaan = ({
const watchState = watch('state');
useEffect(() => {
- // setValue('city', '');
- // setValue('district', '');
- // setValue('subDistrict', '');
if (watchState) {
updateForm('state', `${watchState}`);
validate();
@@ -93,6 +90,15 @@ const InformasiPerusahaan = ({
const watchCity = watch('city');
+ // Untuk memperbarui form.city
+ useEffect(() => {
+ if (watchCity && form.city !== `${watchCity}`) {
+ updateForm('city', `${watchCity}`);
+ validate();
+ }
+ }, [watchCity]);
+
+ // Untuk memuat distrik
useEffect(() => {
if (watchCity) {
const loadDistricts = async () => {
@@ -103,10 +109,6 @@ const InformasiPerusahaan = ({
}));
setDistricts(dataDistricts);
};
- if (form.city !== `${watchCity}`) {
- updateForm('city', `${watchCity}`);
- }
- validate();
loadDistricts();
}
}, [watchCity]);
@@ -429,9 +431,7 @@ const InformasiPerusahaan = ({
if (form.state) {
setValue('state', parseInt(form.state));
}
- if (form.city) {
- setValue('city', parseInt(form.city));
- }
+
if (form.district) {
setValue('district', parseInt(form.district));
}
@@ -463,12 +463,20 @@ const InformasiPerusahaan = ({
}
}, [form]);
useEffect(() => {
+ if (form.city) {
+ setValue('city', parseInt(form.city));
+ }
+ }, [form.city]);
+ useEffect(() => {
const loadProfile = async () => {
try {
const dataProfile = await addressApi({ id: auth.parentId });
if (dataProfile.name) {
updateForm('name', dataProfile.name);
}
+ if (dataProfile.street) {
+ updateForm('street', dataProfile.street);
+ }
if (dataProfile.stateId.id) {
updateForm('state', `${dataProfile.stateId.id}`);
}
@@ -481,9 +489,6 @@ const InformasiPerusahaan = ({
if (dataProfile.subDistrict.id) {
updateForm('subDistrict', `${dataProfile.subDistrict.id}`);
}
- if (dataProfile.alamatBisnis) {
- updateForm('street', dataProfile.alamatBisnis);
- }
if (dataProfile.zip) {
updateForm('zip', dataProfile.zip);
}
@@ -509,7 +514,7 @@ const InformasiPerusahaan = ({
useEffect(() => {
const loadProfile = async () => {
try {
- const dataProfile = await addressApi({ id: auth.partnerId });
+ const dataProfile = await addressApi({ id: auth.parentId });
setValue('industryId', parseInt(dataProfile.industryId));
setValue('state', parseInt(dataProfile.stateId.id));
setValue('city', parseInt(dataProfile.city.id));
@@ -528,7 +533,6 @@ const InformasiPerusahaan = ({
const handleLengkapiData = () => {
router.push('/my/profile');
};
-
return (
<>
<BottomPopup