summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-migrate/modules/register/stores/usePengajuanTempoStore.ts2
-rw-r--r--src-migrate/validations/tempo.ts1
-rw-r--r--src/core/components/elements/Navbar/NavbarDesktop.jsx12
-rw-r--r--src/lib/address/api/stateApi.js12
-rw-r--r--src/lib/address/components/CreateAddress.jsx10
-rw-r--r--src/lib/address/components/EditAddress.jsx40
-rw-r--r--src/lib/pengajuan-tempo/component/Dokumen.jsx36
-rw-r--r--src/lib/pengajuan-tempo/component/PengajuanTempo.jsx25
-rw-r--r--src/lib/pengajuan-tempo/component/Pengiriman.jsx104
-rw-r--r--src/lib/pengajuan-tempo/component/Referensi.jsx81
-rw-r--r--src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx10
-rw-r--r--src/lib/tempo/components/Tempo.jsx3
-rw-r--r--src/pages/pengajuan-tempo/[status].jsx20
-rw-r--r--src/pages/pengajuan-tempo/index.jsx15
14 files changed, 240 insertions, 131 deletions
diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
index 0551b275..48d789cd 100644
--- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
+++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
@@ -50,6 +50,7 @@ export const usePengajuanTempoStore = create<State & Action>((set, get) => ({
estimasi: '',
tempoDuration: '',
bersedia: '',
+ website: '',
categoryProduk: '',
tempoLimit: '',
},
@@ -95,6 +96,7 @@ export const usePengajuanTempoStore = create<State & Action>((set, get) => ({
bankName: '',
accountName: '',
accountNumber: '',
+ website: '',
estimasi: '',
tempoDuration: '',
bersedia: '',
diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts
index 0154c1c9..646e9b4d 100644
--- a/src-migrate/validations/tempo.ts
+++ b/src-migrate/validations/tempo.ts
@@ -22,6 +22,7 @@ export const TempoSchema = z.object({
message: 'Nomor rekening hanya boleh mengandung angka',
}),
estimasi: z.string().optional(),
+ website: z.string().optional(),
tempoDuration: z.string().min(1, { message: 'Durasi tempo harus dipilih' }),
bersedia: z.string().min(1, { message: 'Harus dipilih' }),
categoryProduk: z
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 253a2b03..d6b1bdea 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -117,7 +117,7 @@ const NavbarDesktop = () => {
// };
// handleCartChange();
- setCartCount(cart?.products?.length)
+ setCartCount(cart?.products?.length);
// window.addEventListener('localStorageChange', handleCartChange);
@@ -172,8 +172,8 @@ const NavbarDesktop = () => {
<MenuItem as='a' href='/tentang-kami'>
Tentang Indoteknik
</MenuItem>
- <MenuItem as='a' href='/my/pembayaran-tempo'>
- Pembayaran Tempo
+ <MenuItem as='a' href='/pengajuan-tempo'>
+ Pengajuan Tempo
</MenuItem>
</MenuList>
</Menu>
@@ -370,7 +370,11 @@ const NavbarDesktop = () => {
)}
{auth && (
<>
- <div href='/' className='navbar-user-dropdown-button' aria-label='User'>
+ <div
+ href='/'
+ className='navbar-user-dropdown-button'
+ aria-label='User'
+ >
<span>Halo, {auth?.name}</span>
<div className='ml-auto'>
<ChevronDownIcon className='w-6' />
diff --git a/src/lib/address/api/stateApi.js b/src/lib/address/api/stateApi.js
index cea49e7e..6bfd36d2 100644
--- a/src/lib/address/api/stateApi.js
+++ b/src/lib/address/api/stateApi.js
@@ -1,8 +1,8 @@
-import odooApi from '@/core/api/odooApi'
+import odooApi from '@/core/api/odooApi';
-const stateApi = async () => {
- const dataState = await odooApi('GET', '/api/v1/state')
- return dataState
-}
+const stateApi = async ({ tempo = false }) => {
+ const dataState = await odooApi('GET', `/api/v1/state?tempo=${tempo}`);
+ return dataState;
+};
-export default stateApi \ No newline at end of file
+export default stateApi;
diff --git a/src/lib/address/components/CreateAddress.jsx b/src/lib/address/components/CreateAddress.jsx
index 9d70e8fc..97db7ed8 100644
--- a/src/lib/address/components/CreateAddress.jsx
+++ b/src/lib/address/components/CreateAddress.jsx
@@ -37,7 +37,7 @@ const CreateAddress = () => {
useEffect(() => {
const loadState = async () => {
- let dataState = await stateApi();
+ let dataState = await stateApi({ tempo: false });
dataState = dataState.map((state) => ({
value: state.id,
label: state.name,
@@ -52,7 +52,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,
@@ -243,7 +243,11 @@ const CreateAddress = () => {
name='city'
control={control}
render={(props) => (
- <HookFormSelect {...props} options={cities} disabled={!watchState}/>
+ <HookFormSelect
+ {...props}
+ options={cities}
+ disabled={!watchState}
+ />
)}
/>
<div className='text-caption-2 text-danger-500 mt-1'>
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,
diff --git a/src/lib/pengajuan-tempo/component/Dokumen.jsx b/src/lib/pengajuan-tempo/component/Dokumen.jsx
index 264732dc..d74e85be 100644
--- a/src/lib/pengajuan-tempo/component/Dokumen.jsx
+++ b/src/lib/pengajuan-tempo/component/Dokumen.jsx
@@ -176,8 +176,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
NIB (SIUP/TDP/SKDP){' '}
<span className='text-danger-500 text-xl'>*</span>
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -220,8 +220,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
<label className='form-label text-nowrap'>
NPWP Perusahaan
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -262,8 +262,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
>
<div>
<label className='form-label text-nowrap'>SPPKP</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -307,8 +307,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
Akta Perubahan{' '}
<span className=' opacity-60'>(Opsional)</span>{' '}
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -352,8 +352,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
<span className=' opacity-60'>(Opsional)</span>{' '}
<span className='text-danger-500 text-xl'>*</span>
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -401,8 +401,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
<span className=' opacity-60'>(Opsional)</span>{' '}
<span className='text-danger-500 text-xl'>*</span>
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -446,8 +446,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
Laporan Keuangan
<span className=' opacity-60'>(Opsional)</span>
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -490,8 +490,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
<label className='form-label text-nowrap'>
Foto Kantor (Tampak Depan)
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
@@ -534,8 +534,8 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
<label className='form-label text-nowrap'>
Foto tempat kerja
</label>
- <span className='text-xs opacity-60'>
- Pastikan dokumen yang anda upload sudah benar
+ <span className='text-xs opacity-60 text-red-500'>
+ Format: pdf, jpeg, jpg, png. max file size 2MB
</span>
</div>
<div className=''>
diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
index 58794b31..aff49373 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -178,6 +178,7 @@ const PengajuanTempo = () => {
`/api/v1/partner/detail-tempo/${auth.parentId}`
);
const transformedData = transformKeysToCamelCase(dataPaymentTerm);
+
setBigData(transformedData);
} catch (error) {
console.error('Error loading dataPaymentTerm:', error);
@@ -454,16 +455,28 @@ const PengajuanTempo = () => {
}
}
+ toast.dismiss(toastId);
+ setIsLoading(false);
+ toast.success('Pengajuan tempo berhasil dilakukan');
if (address4?.id) {
+ const toastId = toast.loading('Mengubah status akun...');
+ setIsLoading(true);
const isUpdated = await editAuthTempo();
if (isUpdated?.user) {
- setAuth(isUpdated.user);
- toast.dismiss(toastId);
- setIsLoading(false);
- toast.success('Pengajuan tempo berhasil dilakukan');
- toast.success('Berhasil mengubah status akun', { duration: 1000 });
+ const update = await setAuth(isUpdated.user);
+ if (update) {
+ toast.dismiss(toastId);
+ setIsLoading(false);
+ toast.success('Berhasil mengubah status akun', { duration: 1000 });
+ router.push('/pengajuan-tempo/finish');
+ } else {
+ toast.dismiss(toastId);
+ setIsLoading(false);
+ toast.success('Pengajuan tempo berhasil dilakukan');
+ toast.error('Gagal mengubah status akun', { duration: 1000 });
+ router.push('/pengajuan-tempo');
+ }
removeFromLocalStorage();
- router.push('/pengajuan-tempo/finish');
return;
}
}
diff --git a/src/lib/pengajuan-tempo/component/Pengiriman.jsx b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
index d32fa226..000f209c 100644
--- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx
+++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
@@ -23,6 +23,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
const { form, errors, validate, updateForm } = usePengajuanTempoStore();
const [states, setState] = useState([]);
const [cities, setCities] = useState([]);
+ const [citiesInvoice, setCitiesInvoice] = useState([]);
const [sameAddress, setSameAddress] = useState(false);
const [sameAddressStreet, setSameAddressStreet] = useState(false);
const [everyWeekday, setEveryWeekday] = useState(false);
@@ -90,7 +91,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
useEffect(() => {
const loadState = async () => {
- let dataState = await stateApi();
+ let dataState = await stateApi({ tempo: true });
dataState = dataState.map((state) => ({
value: state.id,
label: state.name,
@@ -125,6 +126,33 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
validatePengiriman();
}
}, [watchCity]);
+
+ const watchStateInvoice = watch('stateInvoice');
+ useEffect(() => {
+ // updateFormPengiriman('cityPengiriman', '');
+ if (watchStateInvoice) {
+ updateFormPengiriman('stateInvoice', `${watchStateInvoice}`);
+ validatePengiriman();
+ const loadCities = async () => {
+ let dataCities = await cityApi({ stateId: watchStateInvoice });
+ dataCities = dataCities.map((city) => ({
+ value: city.id,
+ label: city.name,
+ }));
+ setCitiesInvoice(dataCities);
+ };
+ loadCities();
+ }
+ }, [watchStateInvoice]);
+
+ const watchCityInvoice = watch('cityInvoice');
+ useEffect(() => {
+ if (watchCityInvoice) {
+ updateFormPengiriman('cityInvoice', `${watchCityInvoice}`);
+ validatePengiriman();
+ }
+ }, [watchCityInvoice]);
+
const handleInputChange = (event) => {
const { name, value } = event.target;
updateFormPengiriman(name, value);
@@ -171,23 +199,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
setTukarInvoicePembayaran(!tukarInvoicePembayaran);
};
- // useEffect(() => {
- // updateFormPengiriman('everyWeekday', everyWeekday);
- // updateFormPengiriman('everyWeek', everyWeek);
- // updateFormPengiriman('tukarInvoice', tukarInvoice);
- // updateFormPengiriman('everyWeekdayPembayaran', everyWeekdayPembayaran);
- // updateFormPengiriman('everyWeekPembayaran', everyWeekPembayaran);
- // updateFormPengiriman('tukarInvoicePembayaran', tukarInvoicePembayaran);
- // validatePengiriman();
- // }, [
- // everyWeekday,
- // everyWeek,
- // tukarInvoice,
- // everyWeekdayPembayaran,
- // everyWeekPembayaran,
- // tukarInvoicePembayaran,
- // ]);
-
const isFormValid = useMemo(
() => Object.keys(errorsPengiriman).length === 0,
[errorsPengiriman]
@@ -306,6 +317,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
useEffect(() => {
if (formPengiriman.isSameAddrees == 'true') {
setSameAddress(true);
+ } else {
+ setSameAddress(false);
}
}, [formPengiriman.isSameAddrees]);
@@ -371,6 +384,29 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
formPengiriman.statePengiriman,
formPengiriman.cityPengiriman,
]);
+
+ useEffect(() => {
+ if (sameAddress) {
+ updateFormPengiriman('streetInvoice', formPengiriman.streetPengiriman);
+ updateFormPengiriman('stateInvoice', formPengiriman.statePengiriman);
+ setValue('stateInvoice', parseInt(formPengiriman.statePengiriman));
+ updateFormPengiriman('cityInvoice', formPengiriman.cityPengiriman);
+ setValue('cityInvoice', parseInt(formPengiriman.cityPengiriman));
+ updateFormPengiriman('isSameAddrees', `${sameAddress}`);
+ } else {
+ // updateFormPengiriman('stateInvoice', formPengiriman.stateInvoice);
+ // setValue('stateInvoice', parseInt(formPengiriman.stateInvoice));
+ // updateFormPengiriman('cityInvoice', formPengiriman.cityInvoice);
+ // setValue('cityInvoice', parseInt(formPengiriman.cityInvoice));
+ }
+ validatePengiriman();
+ }, [
+ sameAddress,
+ formPengiriman.streetPengiriman,
+ formPengiriman.statePengiriman,
+ formPengiriman.cityPengiriman,
+ ]);
+
useEffect(() => {
if (formPengiriman.sameAddressStreet?.toLowerCase().includes('true')) {
setSameAddressStreet(true);
@@ -388,6 +424,16 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
setValue('cityPengiriman', parseInt(formPengiriman.cityPengiriman));
}
}, [formPengiriman.cityPengiriman]);
+ useEffect(() => {
+ if (formPengiriman.stateInvoice) {
+ setValue('stateInvoice', parseInt(formPengiriman.stateInvoice));
+ }
+ }, [formPengiriman.stateInvoice]);
+ useEffect(() => {
+ if (formPengiriman.cityInvoice) {
+ setValue('cityInvoice', parseInt(formPengiriman.cityInvoice));
+ }
+ }, [formPengiriman.cityInvoice]);
useEffect(() => {
if (sameAddressStreet) {
@@ -483,11 +529,19 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
// cachedData?.tukarInvoicePembayaran,
// ]);
const handleChangeSameAddress = () => {
- setSameAddress(!sameAddress);
+ // setSameAddress(!sameAddress);
+ // if (sameAddress) {
+ // console.log('sameAddress adalah', sameAddress);
+ // updateFormPengiriman('sameAddress', `true`);
+ // } else {
+ // console.log('sameAddress merupakan', sameAddress);
+ // }
+ updateFormPengiriman('isSameAddrees', `${!sameAddress}`);
+ validate();
};
const handleChangeSameAddressStreet = () => {
// updateFormPengiriman('sameAddressStreet', `${!sameAddressStreet}`);
- setSameAddressStreet(!sameAddressStreet);
+ // setSameAddressStreet(!sameAddressStreet);
if (sameAddressStreet == false) {
updateFormPengiriman('streetPengiriman', '');
updateFormPengiriman('statePengiriman', '');
@@ -496,9 +550,9 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
setValue('streetPengiriman', '');
setValue('statePengiriman', '');
setValue('cityPengiriman', '');
- updateFormPengiriman('isSameAddreesStreet', `${sameAddressStreet}`);
- validate();
}
+ updateFormPengiriman('isSameAddreesStreet', `${!sameAddressStreet}`);
+ validate();
};
useEffect(() => {
@@ -546,8 +600,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
loadIndustries();
}, [formPengiriman.zipPengiriman]);
-
-
return (
<>
{isDesktop && (
@@ -829,8 +881,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
render={(props) => (
<HookFormSelect
{...props}
- options={cities}
- disabled={!watchState || sameAddress}
+ options={citiesInvoice}
+ disabled={!watchStateInvoice || sameAddress}
placeholder='Kota'
/>
)}
diff --git a/src/lib/pengajuan-tempo/component/Referensi.jsx b/src/lib/pengajuan-tempo/component/Referensi.jsx
index 6d9d0bd6..1b7b0f4c 100644
--- a/src/lib/pengajuan-tempo/component/Referensi.jsx
+++ b/src/lib/pengajuan-tempo/component/Referensi.jsx
@@ -10,8 +10,12 @@ import { PlusCircleIcon } from '@heroicons/react/24/outline';
import useDevice from '@/core/hooks/useDevice';
import { Trash2Icon } from 'lucide-react';
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
const initialData = [];
const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
+ const [changeConfirmation, setChangeConfirmation] = useState(false);
+ const [selectedIndex, setSelectedIndex] = useState(null);
+
const { isDesktop, isMobile } = useDevice();
const [openIndexes, setOpenIndexes] = useState([]);
@@ -26,7 +30,7 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
resolver: yupResolver(validationSchema),
defaultValues,
});
- const { formSupplier, updateFormSupplier, updateHasSave } =
+ const { formSupplier, updateFormSupplier, updateHasSave, hasSavedata } =
usePengajuanTempoStoreSupplier();
const { form } = usePengajuanTempoStore();
const [formData, setFormData] = useState([
@@ -63,9 +67,8 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
const editData = supplierData.map((item, i) =>
i === index ? { ...item, [name]: formattedValue } : item
);
-
setSupplierData(editData);
- if (value == '') {
+ if (value == '' && supplierData.supplier) {
updateHasSave(true);
}
};
@@ -89,12 +92,26 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
}
};
- const handleDeleteSupplier = (index) => {
- // updateHasSave(false); // Indikasi bahwa data telah berubah
-
- const updatedData = supplierData.filter((_, i) => i !== index);
- setSupplierData(updatedData);
- updateFormSupplier(updatedData); // Update store atau state terkait
+ useEffect(() => {
+ const isAllFieldsEmpty = Object.values(newSupplier).every(
+ (value) => value === ''
+ );
+ if (isAllFieldsEmpty) {
+ updateHasSave(true);
+ } else {
+ updateHasSave(false);
+ }
+ }, [newSupplier]);
+
+ const handleDeleteSupplier = () => {
+ if (selectedIndex !== null) {
+ // Logika untuk menghapus supplier
+ const updatedSuppliers = supplierData.filter(
+ (_, idx) => idx !== selectedIndex
+ );
+ setSupplierData(updatedSuppliers);
+ setChangeConfirmation(false);
+ }
};
const handleAddNewSupplier = () => {
@@ -181,8 +198,37 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
);
};
+ const handleOpenConfirmation = (index) => {
+ setSelectedIndex(index);
+ setChangeConfirmation(true);
+ };
return (
<>
+ <BottomPopup
+ active={changeConfirmation}
+ close={() => setChangeConfirmation(false)}
+ title='Ubah profil Bisnis'
+ >
+ <div className='leading-7 text-gray_r-12/80'>
+ Apakah anda yakin menghapus data?
+ </div>
+ <div className='flex mt-6 gap-x-4 md:justify-end'>
+ <button
+ className='btn-solid-red flex-1 md:flex-none'
+ type='button'
+ onClick={handleDeleteSupplier}
+ >
+ Ya, Hapus
+ </button>
+ <button
+ className='btn-light flex-1 md:flex-none'
+ type='button'
+ onClick={() => setChangeConfirmation(false)}
+ >
+ Batal
+ </button>
+ </div>
+ </BottomPopup>
{isDesktop && (
<div className='py-4'>
<div className='flex flex-col justify-start'>
@@ -262,7 +308,8 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
/>
<Trash2Icon
size={18}
- onClick={() => handleDeleteSupplier(index)}
+ onClick={() => handleOpenConfirmation(index)}
+ className='cursor-pointer'
/>
</td>
</tr>
@@ -332,13 +379,15 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
className='bg-gray-200 border border-gray-500 rounded-md text-sm text-gray-500 p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
>
{<PlusCircleIcon className='w-5 mr-2' />}
- {''} Tambah data baru
+ {''} Tambah Data Baru
</button>
<button
onClick={simpanData}
- className='bg-red-500 border border-red-500 opacity-70 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
+ className={`bg-red-500 border border-red-500 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center ${
+ hasSavedata ? 'hidden' : ''
+ }`}
>
- simpan data
+ Simpan Data
</button>
<span className='text-sm opacity-60 text-red-500'>
*Klik simpan sebelum lanjut ke tahap selanjutnya
@@ -546,9 +595,11 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
</span>
<button
onClick={simpanData}
- className='bg-gray-200 border border-gray-500 rounded-md w-full text-sm text-gray-500 p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
+ className={`bg-gray-200 border border-gray-500 rounded-md w-full text-sm text-gray-500 p-2 h-11 mb-1 content-center flex flex-row justify-center items-center ${
+ hasSavedata ? 'hidden' : ''
+ }`}
>
- simpan data
+ Simpan Data
</button>
</div>
</div>
diff --git a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
index 19f46dec..6a7eb3cb 100644
--- a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
+++ b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
@@ -52,7 +52,7 @@ const InformasiPerusahaan = ({
useEffect(() => {
const loadState = async () => {
- let dataState = await stateApi();
+ let dataState = await stateApi({ tempo: true });
dataState = dataState.map((state) => ({
value: state.id,
label: state.name,
@@ -115,10 +115,10 @@ const InformasiPerusahaan = ({
useEffect(() => {
const loadPaymentTerm = async () => {
const dataPaymentTerm = [
- { id: 29, name: 'Tempo 7 Hari' },
{ id: 24, name: 'Tempo 14 Hari' },
- { id: 32, name: 'Tempo 21 Hari' },
{ id: 25, name: 'Tempo 30 Hari' },
+ { id: 29, name: 'Tempo 7 Hari' },
+ { id: 32, name: 'Tempo 21 Hari' },
];
setPaymentTerm(
dataPaymentTerm?.map((o) => ({
@@ -585,7 +585,7 @@ const InformasiPerusahaan = ({
</div>
<div className='flex flex-row justify-between items-start'>
<div className='w-2/5 text-nowrap'>
- <label className='form-label '>No. Telfon Perusahaan</label>
+ <label className='form-label '>No. HP Perusahaan</label>
{!isKonfirmasi && (
<span className='text-xs opacity-60'>
isi no telfon perusahaan yang sesuai
@@ -1059,7 +1059,7 @@ const InformasiPerusahaan = ({
</div>
<div className='flex flex-col gap-2 justify-between items-start'>
- <label className='form-label '>No. Telfon Perusahaan</label>
+ <label className='form-label '>No. HP Perusahaan</label>
<input
id='mobile'
name='mobile'
diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx
index 33c5bae6..dc8307c8 100644
--- a/src/lib/tempo/components/Tempo.jsx
+++ b/src/lib/tempo/components/Tempo.jsx
@@ -175,8 +175,7 @@ const Tempo = () => {
{getLabel()}
</span>
</div>
- {!invoices?.data?.invoices ||
- invoices?.data?.invoices?.length == 0 ? (
+ {tempo.length > 0 && !tempo.paymentTerm ? (
<div className='flex justify-center'>
<Image
src='/images/ICON-DOKUMEN-VERIFIKASI.png'
diff --git a/src/pages/pengajuan-tempo/[status].jsx b/src/pages/pengajuan-tempo/[status].jsx
index 1ebf167b..c97b5897 100644
--- a/src/pages/pengajuan-tempo/[status].jsx
+++ b/src/pages/pengajuan-tempo/[status].jsx
@@ -3,7 +3,9 @@ import IsAuth from '@/lib/auth/components/IsAuth';
import FinishTempoComponent from '@/lib/pengajuan-tempo/component/FinishTempo';
import { useRouter } from 'next/router';
import axios from 'axios';
+import { useState, useEffect } from 'react';
import Seo from '@/core/components/Seo';
+import { getAuth } from '~/libs/auth';
export async function getServerSideProps(context) {
const { tempo_id } = context.query;
@@ -16,8 +18,26 @@ export async function getServerSideProps(context) {
}
export default function Finish() {
+ const [isLoading, setIsLoading] = useState(true);
const router = useRouter();
+ const auth = getAuth();
+ useEffect(() => {
+ if (!auth) {
+ const nextUrl = encodeURIComponent(router.asPath);
+ router.push(`/login?next=${nextUrl}`);
+ } else if (
+ (router.query.status == 'approve' || router.query.status == 'review') &&
+ auth.tempoProgres === ''
+ ) {
+ router.push('/pengajuan-tempo');
+ } else {
+ setIsLoading(false);
+ }
+ }, [auth]);
+ if (isLoading || !auth) {
+ return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
+ }
return (
<>
<Seo title='Pengajuan Tempo Indoteknik.com' />
diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx
index f0681663..d485c721 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -41,25 +41,26 @@ export default function TrackingOrder() {
} else {
setIsLoading(false);
}
- }, [auth]);
-
+ }, []);
useEffect(() => {
if (!auth) {
const nextUrl = encodeURIComponent(router.asPath);
router.push(`/login?next=${nextUrl}`);
- } else if (!auth.parentId) {
- router.push('/pengajuan-tempo/switch-account');
- } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) {
- router.push('/pengajuan-tempo/review');
} else if (
auth.tempoProgres === 'approve' &&
tempo?.paymentTerm?.toLowerCase().includes('tempo')
) {
router.push('/pengajuan-tempo/approve');
+ } else if (!auth.parentId) {
+ router.push('/pengajuan-tempo/switch-account');
+ } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) {
+ router.push('/pengajuan-tempo/review');
} else if (auth.tempoProgres === 'rejected') {
router.push('/pengajuan-tempo/rejected');
+ } else {
+ setIsLoading(false);
}
- }, [auth, router, tempo]);
+ }, [tempo]);
if (isLoading || !auth || !tempo) {
return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia