summaryrefslogtreecommitdiff
path: root/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-29 16:22:33 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-29 16:22:33 +0700
commitdaaf32f9dd3af860013b70d04c89f4cca84724b1 (patch)
treefb37b9089eebfa1dc3949117ea00211c6cfe5a50 /src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
parent9054afb2c842a1177dbcf0842aadf2ad14403cde (diff)
<iman> updarte pengajuan tempo
Diffstat (limited to 'src/lib/pengajuan-tempo/component/PengajuanTempo.jsx')
-rw-r--r--src/lib/pengajuan-tempo/component/PengajuanTempo.jsx50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
index d44d44e6..0efea807 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -18,6 +18,7 @@ import {
usePengajuanTempoStoreDokumen,
} from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline';
+import createPengajuanTempoApi from '../api/createPengajuanTempoApi';
const PengajuanTempo = () => {
const [currentStep, setCurrentStep] = React.useState(0);
const NUMBER_OF_STEPS = 6;
@@ -71,7 +72,7 @@ const PengajuanTempo = () => {
formPengiriman,
formSupplier,
formDokumen,
- <div>Konfirmasi</div>,
+ '',
];
const stepDivsUpdateForm = [
updateForm,
@@ -89,6 +90,21 @@ const PengajuanTempo = () => {
'Dokumen',
'Konfirmasi',
];
+ const combineForms = () => {
+ return stepDivsForm.reduce((accumulator, currentForm, index) => {
+ if (currentForm && typeof currentForm === 'object') {
+ if (index === 3) {
+ if (!accumulator.formSupplier) {
+ accumulator.formSupplier = [];
+ }
+ accumulator.formSupplier.push(...currentForm);
+ } else {
+ return { ...accumulator, ...currentForm };
+ }
+ }
+ return accumulator;
+ }, {});
+ };
// const stepLabels = [
// `${auth.partnerId}_informasi_perusahaan`,
@@ -148,8 +164,36 @@ const PengajuanTempo = () => {
}
setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1));
};
- const handleDaftarTempo = () => {
- router.push('/pengajuan-tempo/finish?tempo_id=SO-2023-06480');
+ const handleDaftarTempo = async () => {
+ for (const error of stepDivsError) {
+ if (error.length > 0) {
+ console.log('ada yang salah');
+ return; // Keluar dari fungsi jika ada error
+ }
+ }
+ const combinedData = combineForms();
+ console.log('combinedData', combinedData);
+ const data = {
+ ...combinedData,
+ parent_id: auth.partnerId,
+ };
+
+ const productOrder = formSupplier.map((product) => ({
+ supplier: product.supplier,
+ pic: product.pic,
+ telepon: product.telepon,
+ quantitydurasiTempo: product.durasiTempo,
+ creditLimit: product.creditLimit,
+ }));
+ const data2 = {
+ form: JSON.stringify(productOrder),
+ parent_id: auth.partnerId,
+ };
+ const address = await createPengajuanTempoApi({ combinedData });
+
+ console.log('Sukses Daftar');
+ // router.push('/pengajuan-tempo/finish?tempo_id=SO-2023-06480');
+
// if (!isFormValid) {
// setNotValid(true);
// setButtonSubmitClick(!buttonSubmitClick);