diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-09 15:00:45 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-09 15:00:45 +0700 |
| commit | f2451beed670dc697aa2026b2df6ad1ad1e90da2 (patch) | |
| tree | e25ff3230b6878ff037216b6cd1dad527440dfb8 | |
| parent | e9cd13307f0095dc4edc5048752675d80c551564 (diff) | |
<iman> update pengajuan tempo
| -rw-r--r-- | src/lib/pengajuan-tempo/component/Dokumen.jsx | 1 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/FinishTempo.jsx | 25 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx | 2 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/KontakPerusahaan.jsx | 2 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 13 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/Pengiriman.jsx | 3 | ||||
| -rw-r--r-- | src/lib/tempo/components/Tempo.jsx | 12 | ||||
| -rw-r--r-- | src/pages/pengajuan-tempo/index.jsx | 44 |
8 files changed, 50 insertions, 52 deletions
diff --git a/src/lib/pengajuan-tempo/component/Dokumen.jsx b/src/lib/pengajuan-tempo/component/Dokumen.jsx index 52217e56..264732dc 100644 --- a/src/lib/pengajuan-tempo/component/Dokumen.jsx +++ b/src/lib/pengajuan-tempo/component/Dokumen.jsx @@ -157,7 +157,6 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { validateDokumen(); }, [buttonSubmitClick]); - console.log('formDokumen', formDokumen); return ( <> {isDesktop && ( diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index 933ede62..bfcd0909 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -14,7 +14,6 @@ const FinishTempo = ({ query }) => { const [transactionData, setTransactionData] = useState(); const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); - console.log('auth', auth); const so_order = query?.order_id?.replaceAll('-', '/'); useEffect(() => { const fetchData = async () => { @@ -27,24 +26,6 @@ const FinishTempo = ({ query }) => { fetchData(); }, [query]); - // Kirim email ketika komponen ini dimount atau sesuai kondisi - const sendEmail = async () => { - try { - const send = await axios.post( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query?.order_id}`, - {} - ); - if (send.status === 200) { - toast.success('Berhasil mengirim rincian pesanan'); - } else { - toast.error('Gagal mengirimkan rincian pesanan'); - } - } catch (error) { - console.error(error); - toast.error('Gagal mengirimkan rincian pesanan'); - } - }; - return ( <div className='container flex flex-col items-center gap-4'> <div @@ -68,7 +49,7 @@ const FinishTempo = ({ query }) => { </div> {query?.status == 'finish' && ( <Image - src='/images/ICON-TEMPO.png' + src='/images/REGISTRASI-TEMPO.svg' alt='Registrasi Tempo' width={isMobile ? 300 : 550} height={isMobile ? 300 : 550} @@ -76,7 +57,7 @@ const FinishTempo = ({ query }) => { )} {query?.status == 'switch-account' && ( <Image - src='/images/REGISTRASI-TEMPO.svg' + src='/images/ICON-TEMPO.png' alt='Registrasi Tempo' width={isMobile ? 300 : 550} height={isMobile ? 300 : 550} @@ -115,7 +96,7 @@ const FinishTempo = ({ query }) => { </div> <Link href={query?.status == 'switch-account' ? `/my/profile` : `/my/tempo/`} - className='btn-solid-red rounded-md text-base flex flex-row' + className='btn-solid-red rounded-md text-base flex flex-row items-center justify-center' > {query?.status == 'switch-account' ? 'Ubah Akun' diff --git a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx index e9ec01e1..19b7fed2 100644 --- a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx +++ b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx @@ -28,7 +28,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { } = usePengajuanTempoStoreDokumen(); const handleConfirmSubmit = (format, base64) => { - console.log('format iman', format); if (format == 'pdf') { setFormat(`application/${format}`); } else if (format == undefined) { @@ -172,7 +171,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { validateDokumen(); }, [buttonSubmitClick]); - console.log('format', format); return ( <> {isDesktop && ( diff --git a/src/lib/pengajuan-tempo/component/KontakPerusahaan.jsx b/src/lib/pengajuan-tempo/component/KontakPerusahaan.jsx index d5bb69fb..77bf4316 100644 --- a/src/lib/pengajuan-tempo/component/KontakPerusahaan.jsx +++ b/src/lib/pengajuan-tempo/component/KontakPerusahaan.jsx @@ -11,7 +11,6 @@ const KontakPerusahaan = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { const { isDesktop, isMobile } = useDevice(); const handleInputChange = (event) => { const { name, value } = event.target; - console.log('name', name, value); updateFormKontakPerson(name, value); validateKontakPerson(); }; @@ -85,7 +84,6 @@ const KontakPerusahaan = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { validateKontakPerson(); }, [buttonSubmitClick]); - console.log('formKontakPerson', formKontakPerson); return ( <> {isDesktop && ( diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index 82b64df7..58794b31 100644 --- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx +++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx @@ -177,7 +177,6 @@ const PengajuanTempo = () => { 'GET', `/api/v1/partner/detail-tempo/${auth.parentId}` ); - console.log('original data', dataPaymentTerm); const transformedData = transformKeysToCamelCase(dataPaymentTerm); setBigData(transformedData); } catch (error) { @@ -216,7 +215,6 @@ const PengajuanTempo = () => { ? JSON.stringify(bigData[key]) // Untuk objek atau array : String(bigData[key]); // Untuk tipe primitif // Kirim data yang sudah diubah ke string ke stepDivsUpdateForm - console.log('key', key, stringData); stepDivsUpdateForm[currentStep](key, stringData); } }); @@ -369,8 +367,10 @@ const PengajuanTempo = () => { // Periksa perubahan const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...'); - if (!isSupplierDataChanged(productOrder, bigData.supplierIds)) { - return; + if (bigData.supplierIds) { + if (!isSupplierDataChanged(productOrder, bigData.supplierIds)) { + return; + } } setIsLoading(true); @@ -456,9 +456,9 @@ const PengajuanTempo = () => { if (address4?.id) { const isUpdated = await editAuthTempo(); - toast.dismiss(toastId); 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 }); @@ -502,9 +502,6 @@ const PengajuanTempo = () => { const handleCheckChange = (checked) => { setIsCheckedTNC(checked); }; - console.log('formSupplier', formSupplier); - console.log('!hassavedata', hasSavedata); - console.log('isCheckedTNC', isCheckedTNC); return ( <> <div className='container flex flex-col items-center '> diff --git a/src/lib/pengajuan-tempo/component/Pengiriman.jsx b/src/lib/pengajuan-tempo/component/Pengiriman.jsx index 0352b54f..d32fa226 100644 --- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx +++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx @@ -391,7 +391,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { if (sameAddressStreet) { - console.log('form.state', form); updateFormPengiriman('streetPengiriman', form.street); updateFormPengiriman('statePengiriman', form.state); setValue('statePengiriman', parseInt(form.state)); @@ -548,8 +547,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { loadIndustries(); }, [formPengiriman.zipPengiriman]); - console.log('formPengiriman', formPengiriman); - console.log('errorsPengiriman', errorsPengiriman); return ( <> diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx index 95eb461f..33c5bae6 100644 --- a/src/lib/tempo/components/Tempo.jsx +++ b/src/lib/tempo/components/Tempo.jsx @@ -61,7 +61,7 @@ const Tempo = () => { setIsLoading(true); const dataTempo = await odooApi( 'GET', - `/api/v1/check/${auth.parentId}/tempo` + `/api/v1/check/${auth.partnerId}/tempo` ); setTempo(dataTempo); setIsLoading(false); @@ -329,7 +329,7 @@ const Tempo = () => { // w={16} className='font-semibold text-base' > - {currencyFormat(amountDue)} + {amountDue ? currencyFormat(amountDue) : '-'} </Skeleton> </div> <div className='w-[30%] flex flex-col gap-2'> @@ -340,7 +340,11 @@ const Tempo = () => { // w={16} className='font-semibold text-base' > - {currencyFormat(Math.round(parseInt(limitTempo - amountDue)))} + {limitTempo && amountDue + ? currencyFormat( + Math.round(parseInt(limitTempo - amountDue)) + ) + : '-'} </Skeleton> </div> <div className=' w-[30%] flex flex-col gap-2'> @@ -351,7 +355,7 @@ const Tempo = () => { // w={16} className=' font-semibold text-base' > - {currencyFormat(limitTempo)} + {limitTempo ? currencyFormat(limitTempo) : '-'} </Skeleton> </div> </div> diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx index 271914c3..f0681663 100644 --- a/src/pages/pengajuan-tempo/index.jsx +++ b/src/pages/pengajuan-tempo/index.jsx @@ -7,38 +7,62 @@ import MobileView from '@/core/components/views/MobileView'; import { getAuth } from '~/libs/auth'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; +import odooApi from '@/core/api/odooApi'; const PagePengajuanTempo = dynamic(() => import('@/lib/pengajuan-tempo/component/PengajuanTempo') ); export default function TrackingOrder() { + const [tempo, setTempo] = useState(null); + const [isLoading, setIsLoading] = useState(true); const auth = getAuth(); - console.log('auth', auth); const router = useRouter(); - const [isLoading, setIsLoading] = useState(true); // Set default isLoading to true useEffect(() => { - // if (!auth) return; // Prevent unnecessary processing if auth is not ready + const loadTempo = async () => { + try { + if (auth?.partnerId) { + const dataTempo = await odooApi( + 'GET', + `/api/v1/check/${auth.partnerId}/tempo` + ); + setTempo(dataTempo); + } + } catch (error) { + console.error('Error fetching tempo data:', error); + } finally { + setIsLoading(false); + } + }; + if (auth) { + loadTempo(); + } 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') { + } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) { router.push('/pengajuan-tempo/review'); - } else if (auth.tempoProgres === 'approve') { + } else if ( + auth.tempoProgres === 'approve' && + tempo?.paymentTerm?.toLowerCase().includes('tempo') + ) { router.push('/pengajuan-tempo/approve'); } else if (auth.tempoProgres === 'rejected') { router.push('/pengajuan-tempo/rejected'); - } else { - setIsLoading(false); // Set isLoading to false only when routing is not required } - }, [auth, router]); + }, [auth, router, tempo]); - if (isLoading || !auth) { - return null; // Show nothing while loading or if auth is not ready + if (isLoading || !auth || !tempo) { + return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia } return ( |
