From 7f92d22feb841e1405e56505c742f90cbd365ffc Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 30 Dec 2024 15:49:18 +0700 Subject: update pengajuan tempo --- .../pengajuan-tempo/component/PengajuanTempo.jsx | 40 ++++++++++++---------- .../component/informasiPerusahaan.jsx | 34 ++++++++++-------- 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index dbf2c606..be994171 100644 --- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx +++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { useMemo, useState, useEffect, useRef } from 'react'; +import Image from '~/components/ui/image'; import Stepper from './Stepper'; import InformasiPerusahaan from './informasiPerusahaan'; import KontakPerusahaan from './KontakPerusahaan'; @@ -40,6 +41,7 @@ const PengajuanTempo = () => { const { control, watch, setValue } = useForm(); const auth = useAuth(); const router = useRouter(); + const [BannerTempo, setBannerTempo] = useState(); const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } = usePengajuanTempoStoreDokumen(); const { @@ -521,21 +523,6 @@ const PengajuanTempo = () => { } }; - const goToPreviousStep = () => { - setCurrentStep((prev) => (prev <= 0 ? prev : prev - 1)); - }; - - const saveToLocalStorage = (key, form) => { - localStorage.setItem(key, JSON.stringify(form)); - }; - - const getFromLocalStorage = (key) => { - const itemStr = localStorage.getItem(key); - if (!itemStr) return null; - - const item = JSON.parse(itemStr); - return item; - }; const removeFromLocalStorage = () => { for (const key of stepLabels) { localStorage.removeItem(key); @@ -547,12 +534,29 @@ const PengajuanTempo = () => { const handleCheckChange = (checked) => { setIsCheckedTNC(checked); }; - // if (isLoading && !bigData) { - // return; - // } + + useEffect(() => { + const getBanner = async () => { + const get = await odooApi('GET', '/api/v1/banner?type=banner-form-tempo'); + // setBannerTempo(get[0].image); + setBannerTempo( + 'http://192.168.23.244:8069/api/image/x_banner.banner/x_banner_image/479' + ); + }; + getBanner(); + }, []); return ( <>
+ {BannerTempo && ( + FORM Tempo + )}

Form Pengajuan Tempo

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)); } @@ -462,6 +462,11 @@ const InformasiPerusahaan = ({ } } }, [form]); + useEffect(() => { + if (form.city) { + setValue('city', parseInt(form.city)); + } + }, [form.city]); useEffect(() => { const loadProfile = async () => { try { @@ -469,6 +474,9 @@ const InformasiPerusahaan = ({ 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 ( <>