diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-11-01 15:45:02 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-11-01 15:45:02 +0700 |
| commit | 0c48c602edb0ffb33e6259a774a2aad0fff75713 (patch) | |
| tree | fc88e7c1bc34906f1893c6c32d88523362826462 | |
| parent | d1a5c71e886d2a4ac208eb49e12f269ef1b87c2a (diff) | |
<iman> update pengajuan tempo
| -rw-r--r-- | src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index 4d5207c2..04797c5f 100644 --- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx +++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx @@ -171,37 +171,6 @@ const PengajuanTempo = () => { setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1)); }; - const splitDataAndSend = async (data, partSize = 50000) => { - const totalDataSize = JSON.stringify(data).length; - - if (totalDataSize <= partSize) { - return await createPengajuanTempoApi(data); - } - const dataParts = []; - let currentIndex = 0; - - while (currentIndex < totalDataSize) { - const part = JSON.stringify(data).slice( - currentIndex, - currentIndex + partSize - ); - dataParts.push(part); - currentIndex += partSize; - } - - const responses = []; - for (let i = 0; i < dataParts.length; i++) { - const partData = { - data: dataParts[i], - part: i + 1, - totalParts: dataParts.length, - }; - responses.push(await createPengajuanTempoApi(partData)); - } - - return responses; - }; - const handleDaftarTempo = async () => { for (const error of stepDivsError) { if (error.length > 0) { @@ -224,22 +193,57 @@ const PengajuanTempo = () => { base64: doc.base64, }, })); + const data2 = { + user_id: auth.id, ...form, ...formKontakPerson, ...formPengiriman, formDocs: JSON.stringify(formattedDokumen), formSupplier: JSON.stringify(productOrder), - user_id: auth.id, }; const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...'); setIsLoading(true); try { - const address = await splitDataAndSend(data2); + let address5; + const address = await createPengajuanTempoApi({ + id: '0', + user_id: auth.id, + ...form, + }); + if (address.id) { + const address2 = await createPengajuanTempoApi({ + id: address.id, + user_id: address.userId, + ...formKontakPerson, + }); + if (address2.id) { + const address3 = await createPengajuanTempoApi({ + id: address2.id, + user_id: address2.userId, + ...formPengiriman, + }); + if (address3.id) { + const address4 = await createPengajuanTempoApi({ + id: address3.id, + user_id: address3.userId, + formDocs: JSON.stringify(formattedDokumen), + }); + if (address4.id) { + address5 = await createPengajuanTempoApi({ + id: address4.id, + user_id: address4.userId, + tempo_request: true, + formSupplier: JSON.stringify(productOrder), + }); + } + } + } + } toast.dismiss(toastId); setIsLoading(false); - if (address) { + if (address5.id) { toast.success('Pengajuan tempo berhasil dilakukan'); // removeFromLocalStorage(); router.push('/pengajuan-tempo/finish?tempo_id=SO-2023-06480'); |
