diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-04 10:59:21 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-04 10:59:21 +0700 |
| commit | 9a49b8d84761781531cb417731cb9ef802f63541 (patch) | |
| tree | 140f9ca02190789d0d20f8ca13d00f20e81b6adc | |
| parent | 77f9843ad5072583cb1797d7ecf5ac80394bad3f (diff) | |
<iman> update pengajuan tempo
| -rw-r--r-- | public/images/ICON-DOKUMEN-VERIFIKASI.png | bin | 0 -> 100281 bytes | |||
| -rw-r--r-- | public/images/ICON-TEMPO.png | bin | 0 -> 148062 bytes | |||
| -rw-r--r-- | src-migrate/modules/register/index.tsx | 5 | ||||
| -rw-r--r-- | src-migrate/validations/tempo.ts | 20 | ||||
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarUserDropdown.jsx | 11 | ||||
| -rw-r--r-- | src/lib/auth/components/Menu.jsx | 27 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/Dokumen.jsx | 70 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/FinishTempo.jsx | 45 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx | 110 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 90 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/Pengiriman.jsx | 309 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/Referensi.jsx | 4 | ||||
| -rw-r--r-- | src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx | 3 | ||||
| -rw-r--r-- | src/lib/product/components/ProductCard.jsx | 1 | ||||
| -rw-r--r-- | src/lib/tempo/components/Tempo.jsx | 3 | ||||
| -rw-r--r-- | src/pages/pengajuan-tempo/index.jsx | 21 |
16 files changed, 402 insertions, 317 deletions
diff --git a/public/images/ICON-DOKUMEN-VERIFIKASI.png b/public/images/ICON-DOKUMEN-VERIFIKASI.png Binary files differnew file mode 100644 index 00000000..c1fda877 --- /dev/null +++ b/public/images/ICON-DOKUMEN-VERIFIKASI.png diff --git a/public/images/ICON-TEMPO.png b/public/images/ICON-TEMPO.png Binary files differnew file mode 100644 index 00000000..dee76189 --- /dev/null +++ b/public/images/ICON-TEMPO.png diff --git a/src-migrate/modules/register/index.tsx b/src-migrate/modules/register/index.tsx index da41fd8b..2cc8a28b 100644 --- a/src-migrate/modules/register/index.tsx +++ b/src-migrate/modules/register/index.tsx @@ -161,7 +161,7 @@ const Register = () => { )} </div> <section className='mt-2'> - <FormCaptcha /> + {/* <FormCaptcha /> */} <TermCondition /> <Button type='submit' @@ -170,7 +170,8 @@ const Register = () => { size='lg' onClick={handleSubmit} isDisabled={ - !isCheckedTNC || mutation.isLoading || !isValidCaptcha + // !isCheckedTNC || mutation.isLoading || !isValidCaptcha + !isCheckedTNC || mutation.isLoading } > {mutation.isLoading ? 'Loading...' : 'Daftar'} diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index cb2b279d..4db5b099 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -112,18 +112,18 @@ export const TempoSchemaSupplier = z.object({ export const TempoSchemaDokumen = z.object({ dokumenNib: z.object({ name: z.string().min(1, { message: 'Nama file harus diisi' }), - format: z.string().min(1, { message: 'Format file harus diisi' }), - base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + format: z.string().optional(), + base64: z.string().optional(), }), dokumenNpwp: z.object({ name: z.string().min(1, { message: 'Nama file harus diisi' }), - format: z.string().min(1, { message: 'Format file harus diisi' }), - base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + format: z.string().optional(), + base64: z.string().optional(), }), dokumenSppkp: z.object({ name: z.string().min(1, { message: 'Nama file harus diisi' }), - format: z.string().min(1, { message: 'Format file harus diisi' }), - base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + format: z.string().optional(), + base64: z.string().optional(), }), dokumenAktaPerubahan: z.object({ name: z.string().optional(), @@ -147,12 +147,12 @@ export const TempoSchemaDokumen = z.object({ }), dokumenFotoKantor: z.object({ name: z.string().min(1, { message: 'Nama file harus diisi' }), - format: z.string().min(1, { message: 'Format file harus diisi' }), - base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + format: z.string().optional(), + base64: z.string().optional(), }), dokumenTempatBekerja: z.object({ name: z.string().min(1, { message: 'Nama file harus diisi' }), - format: z.string().min(1, { message: 'Format file harus diisi' }), - base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + format: z.string().optional(), + base64: z.string().optional(), }), }); diff --git a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx index b2abe80f..d19cf11d 100644 --- a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx +++ b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx @@ -13,7 +13,6 @@ const NavbarUserDropdown = () => { router.push('/login'); }); }; - console.log('atuh', atuh); return ( <div className='navbar-user-dropdown-wrapper'> <div className='navbar-user-dropdown'> @@ -22,10 +21,12 @@ const NavbarUserDropdown = () => { <Link href='/my/transactions'>Daftar Transaksi</Link> <Link href='/my/shipments'>Daftar Pengiriman</Link> <Link href='/my/invoices'>Invoice & Faktur Pajak</Link> - {(atuh?.partnerTempo.toLowerCase().includes('tempo') || - atuh.tempoProgres == 'review') && ( - <Link href='/my/tempo'>Pembayaran Tempo</Link> - )} + {atuh && + (atuh.partnerTempo?.toLowerCase().includes('tempo') || + atuh.tempoProgres === 'review') && ( + <Link href='/my/tempo'>Pembayaran Tempo</Link> + )} + <Link href='/my/wishlist'>Wishlist</Link> <Link href='/my/address'>Daftar Alamat</Link> {!atuh?.external && ( diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index 466b793e..82a4de81 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -62,19 +62,20 @@ const Menu = () => { <p>Invoice & Faktur Pajak</p> </div> </LinkItem> - {(atuh?.partnerTempo.toLowerCase().includes('tempo') || - atuh.tempoProgres == 'review') && ( - <LinkItem href='/my/tempo' active={routeStartWith('/my/tempo')}> - <div className='flex gap-x-3 items-center'> - <ImageNext - src='/images/icon/icon_tempo.svg' - width={18} - height={20} - /> - <p>Pembayaran Tempo</p> - </div> - </LinkItem> - )} + {auth && + (auth?.partnerTempo.toLowerCase().includes('tempo') || + auth.tempoProgres == 'review') && ( + <LinkItem href='/my/tempo' active={routeStartWith('/my/tempo')}> + <div className='flex gap-x-3 items-center'> + <ImageNext + src='/images/icon/icon_tempo.svg' + width={18} + height={20} + /> + <p>Pembayaran Tempo</p> + </div> + </LinkItem> + )} <LinkItem href='/my/wishlist' active={routeStartWith('/my/wishlist')}> <div className='flex gap-x-3 items-center'> <ImageNext diff --git a/src/lib/pengajuan-tempo/component/Dokumen.jsx b/src/lib/pengajuan-tempo/component/Dokumen.jsx index 8391de4a..f05dc9ce 100644 --- a/src/lib/pengajuan-tempo/component/Dokumen.jsx +++ b/src/lib/pengajuan-tempo/component/Dokumen.jsx @@ -72,6 +72,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { const dokumenTempatBekerjaRef = useRef(null); useEffect(() => { + validateDokumen(); // window.scrollTo({ // top: 0, // behavior: 'smooth', @@ -83,7 +84,6 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { block: 'center', }; if (errorsDokumen.dokumenNib && dokumenNibRef.current) { - console.log('errorsDokumen', errorsDokumen); dokumenNibRef.current.scrollIntoView(options); return; } @@ -165,9 +165,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenNib' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded min-w-40 text-center' > - Upload Dokumen + {formDokumen?.dokumenNib?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen?.dokumenNib?.name} @@ -207,9 +209,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenNpwp' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenNpwp?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenNpwp} @@ -247,9 +251,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenSppkp' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenSppkp?.name.length > 0 + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenSppkp} @@ -290,9 +296,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenAktaPerubahan' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenAktaPerubahan?.name.length > 0 + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenAktaPerubahan} @@ -332,9 +340,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenKtpDirut' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenKtpDirut?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenKtpDirut} @@ -378,9 +388,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenAktaPendirian' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenAktaPendirian?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenAktaPendirian} @@ -421,9 +433,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenLaporanKeuangan' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenLaporanKeuangan?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenLaporanKeuangan} @@ -463,9 +477,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenFotoKantor' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenFotoKantor?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenFotoKantor} @@ -505,9 +521,11 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-col items-start'> <label htmlFor='dokumenTempatBekerja' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' + className='cursor-pointer min-w-40 text-center bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded' > - Upload Dokumen + {formDokumen?.dokumenTempatBekerja?.name + ? 'Ubah Dokumen' + : 'Upload Dokumen'} </label> <input // value={formDokumen.dokumenTempatBekerja} @@ -588,7 +606,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenNib' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenNib?.name ? 'Sudah Upload' @@ -626,7 +644,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenNpwp' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenNpwp?.name ? 'Sudah Upload' @@ -662,7 +680,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenSppkp' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenSppkp?.name ? 'Sudah Upload' @@ -703,7 +721,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenAktaPerubahan' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenAktaPerubahan?.name ? 'Sudah Upload' @@ -745,7 +763,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenKtpDirut' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenKtpDirut?.name ? 'Sudah Upload' @@ -828,7 +846,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenLaporanKeuangan' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenLaporanKeuangan?.name ? 'Sudah Upload' @@ -910,7 +928,7 @@ const Dokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='flex flex-row gap-2'> <label htmlFor='dokumenTempatBekerja' - className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' + className='cursor-pointer bg-gray-200 hover:bg-gray-300 text-gray-700 py-2 px-4 rounded w-fit min-w-40 text-nowrap text-center flex items-center justify-center' > {formDokumen?.dokumenTempatBekerja?.name ? 'Sudah Upload' diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index 612b502a..ba28ab2a 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -52,28 +52,40 @@ const FinishTempo = ({ query }) => { } justify-center items-center`} > <h1 - className={`text-red-500 text-center font-semibold ${ + className={`text-red-500 text-center py-4 font-semibold ${ isMobile ? 'text-lg' : 'text-3xl' }`} > - {query?.status == 'switch-account' - ? 'Form Pengajuan Tempo kamu gagal dilakukan' - : 'Form Pengajuan Tempo kamu Telah Berhasil Didaftarkan Mohon menunggu hingga Proses Selesai'} + {query?.status == 'finish' && + 'Form Pengajuan Tempo kamu Telah Berhasil Didaftarkan Mohon menunggu hingga Proses Verifikasi Selesai Dilakukan'} + {query?.status == 'switch-account' && + 'Form Pengajuan Tempo Kamu Gagal Dilakukan'} + {query?.status == 'review' && + 'Pengajuan Tempo dalam Proses Verifikasi'} </h1> </div> - {query?.status != 'switch-account' ? ( + {query?.status == 'finish' && ( + <Image + src='/images/ICON-TEMPO.png' + alt='Registrasi Tempo' + width={isMobile ? 300 : 550} + height={isMobile ? 300 : 550} + /> + )} + {query?.status == 'switch-account' && ( <Image src='/images/REGISTRASI-TEMPO.svg' alt='Registrasi Tempo' - width={isMobile ? 300 : 450} - height={isMobile ? 300 : 450} + width={isMobile ? 300 : 550} + height={isMobile ? 300 : 550} /> - ) : ( + )} + {query?.status == 'review' && ( <Image - src='/images/ICON TEMPO-02.svg' + src='/images/ICON-DOKUMEN-VERIFIKASI.png' alt='Registrasi Tempo' - width={isMobile ? 300 : 450} - height={isMobile ? 300 : 450} + width={isMobile ? 300 : 550} + height={isMobile ? 300 : 550} /> )} @@ -82,12 +94,15 @@ const FinishTempo = ({ query }) => { isMobile ? 'w-full text-sm' : 'w-4/5 text-base' }`} > - {query?.status == 'switch-account' - ? 'Terima kasih atas minat anda untuk mendaftar Tempo, namun sayangnya akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi Bisnis untuk menggunakan fitur ini' - : 'Mohon menunggu untuk verifikasi dokumen dan kelengkapan data yang telah anda berikan. Proses approval pembayaran tempo kamu berhasil atau tidak akan diinfokan melalui email perusahaan / email yang mendaftar'} + {query?.status == 'switch-account' && + 'Terima kasih atas minat anda untuk mendaftar Tempo, namun sayangnya akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi Bisnis untuk menggunakan fitur ini'} + {query?.status == 'finish' && + 'Mohon menunggu untuk verifikasi dokumen dan kelengkapan data yang telah anda berikan. Proses approval pembayaran tempo kamu berhasil atau tidak akan diinfokan melalui email perusahaan / email yang mendaftar'} + {query?.status == 'review' && + 'Proses pengajuan tempo anda saat ini sedang dalam tahapan proses verifikasi oleh tim indoteknik, mohon menunggu'} </div> <Link - href={query?.status == 'switch-account' ? `/profil` : `/my/tempo/`} + href={query?.status == 'switch-account' ? `/my/profile` : `/my/tempo/`} className='btn-solid-red rounded-md text-base flex flex-row' > {query?.status == 'switch-account' diff --git a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx index 9b0f1d8f..c1f2d07c 100644 --- a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx +++ b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx @@ -145,7 +145,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { validateDokumen(); }, [buttonSubmitClick]); - return ( <> {isDesktop && ( @@ -168,7 +167,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenNib' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -219,7 +218,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenNpwp' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -268,7 +267,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenSppkp' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -321,9 +320,11 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenAktaPerubahan' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > - Ubah + {formDokumen.dokumenAktaPerubahan.name + ? 'ubah' + : 'upload'} </label> <input // value={formDokumen?.dokumenNib?.name} @@ -374,7 +375,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenKtpDirut' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -426,7 +427,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenAktaPendirian' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -479,7 +480,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenLaporanKeuangan' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -531,7 +532,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenFotoKantor' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -583,7 +584,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenTempatBekerja' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -651,7 +652,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenNib' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -700,7 +701,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenNpwp' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -749,7 +750,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenSppkp' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -802,7 +803,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenAktaPerubahan' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -855,7 +856,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenKtpDirut' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -907,7 +908,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenAktaPendirian' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -960,7 +961,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenLaporanKeuangan' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -1012,7 +1013,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenFotoKantor' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20 text-center' > Ubah </label> @@ -1062,7 +1063,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-2/5 flex flex-row gap-2'> <label htmlFor='dokumenTempatBekerja' - className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded' + className='cursor-pointer bg-red-500 hover:bg-red-600 text-white py-1 px-3 text-sm rounded min-w-20' > Ubah </label> @@ -1118,12 +1119,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { close={() => setIsExample(false)} > <div className='flex justify-center items-center p-2'> - {/* <embed - src={`data:${format};base64,${base64}`} - type={format} - width='100%' - height='600px' - /> */} <iframe src={`data:${format};base64,${base64}`} width='100%' @@ -1141,35 +1136,46 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { close={() => setIsExample(false)} > <div className='flex justify-center items-center p-2'> + {!format.includes('undifined') ? ( + <object + data={`data:${format};base64,${base64}`} + type={format} + width='100%' + height='100%' + onError={(e) => { + // Jika <object> gagal menampilkan PDF, unduh otomatis + const link = document.createElement('a'); + link.href = `data:${format};base64,${base64}`; + link.download = 'document.pdf'; + link.click(); + }} + > + PDF tidak dapat ditampilkan. + <a + href={`data:${format};base64,${base64}`} + download='document.pdf' + > + {' '} + Klik <span className='text-red-500'>di sini</span> untuk + mengunduh PDF + </a> + </object> + ) : ( + <embed + src={ + '/web/image/2540181?unique=7050288dd34d7318bf059e7f362540f6ad5533f9' + } + width='100%' + height='600px' + /> + )} {/* <embed - src={`data:${format};base64,${base64}`} - type={format} + src={ + '/web/image/2540181?unique=7050288dd34d7318bf059e7f362540f6ad5533f9' + } width='100%' - height='100%' + height='600px' /> */} - <object - data={`data:${format};base64,${base64}`} - type={format} - width='100%' - height='100%' - onError={(e) => { - // Jika <object> gagal menampilkan PDF, unduh otomatis - const link = document.createElement('a'); - link.href = `data:${format};base64,${base64}`; - link.download = 'document.pdf'; - link.click(); - }} - > - PDF tidak dapat ditampilkan. - <a - href={`data:${format};base64,${base64}`} - download='document.pdf' - > - {' '} - Klik <span className='text-red-500'>di sini</span> untuk - mengunduh PDF - </a> - </object> </div> </BottomPopup> )} diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index 97e64030..1704556e 100644 --- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx +++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx @@ -176,12 +176,6 @@ const PengajuanTempo = () => { `/api/v1/partner/detail-tempo/${auth.parentId}` ); - console.log('Original dataPaymentTerm', dataPaymentTerm); - - const transformedData = transformKeysToCamelCase(dataPaymentTerm); - - console.log('Transformed dataPaymentTerm', transformedData); - setBigData(transformedData); } catch (error) { console.error('Error loading dataPaymentTerm:', error); @@ -189,54 +183,50 @@ const PengajuanTempo = () => { }; loadBigData(); - }, []); - - console.log('bigData', bigData); + }, [auth]); useEffect(() => { const cachedData = bigData; - console.log('data_lama', getFromLocalStorage(stepLabels[currentStep])); - - if (cachedData) { - // Ambil kunci-kunci yang relevan berdasarkan currentStep dari stepDivsForm - const formKeys = stepDivsForm[currentStep] - ? Object.keys(stepDivsForm[currentStep]) - : []; - console.log('formKeys', formKeys); - if (currentStep === 3) { - console.log('cachedData', cachedData.supplierIds[0]); - stepDivsUpdateForm[currentStep](cachedData.supplierIds); - } else if (currentStep === 4) { - formKeys.forEach((key) => { - if (cachedData[key]) { - // Proses hanya kunci yang ada di cachedData - const { name, format, base64 } = cachedData[key]; - stepDivsUpdateForm[currentStep](key, name, format, base64); - } - }); - } else { - formKeys.forEach((key) => { - if (cachedData[key]) { - // Ubah data menjadi string - const stringData = - typeof cachedData[key] === 'object' - ? JSON.stringify(cachedData[key]) // Untuk objek atau array - : String(cachedData[key]); // Untuk tipe primitif - // Kirim data yang sudah diubah ke string ke stepDivsUpdateForm - stepDivsUpdateForm[currentStep](key, stringData); - } - }); + const loadBigData = async () => { + if (cachedData) { + // Ambil kunci-kunci yang relevan berdasarkan currentStep dari stepDivsForm + const formKeys = stepDivsForm[currentStep] + ? Object.keys(stepDivsForm[currentStep]) + : []; + if (currentStep === 3) { + stepDivsUpdateForm[currentStep](cachedData.supplierIds); + } else if (currentStep === 4) { + formKeys.forEach((key) => { + if (cachedData[key]) { + // Proses hanya kunci yang ada di cachedData + const { name, format, base64 } = cachedData[key]; + stepDivsUpdateForm[currentStep](key, name, format, base64); + } + }); + } else { + formKeys.forEach((key) => { + if (bigData[key]) { + // Ubah data menjadi string + const stringData = + typeof bigData[key] === 'object' + ? JSON.stringify(bigData[key]) // Untuk objek atau array + : String(bigData[key]); // Untuk tipe primitif + // Kirim data yang sudah diubah ke string ke stepDivsUpdateForm + stepDivsUpdateForm[currentStep](key, stringData); + } + }); + } } - } - + }; + loadBigData(); validate(); validateKontakPerson(); validatePengiriman(); validateDokumen(); validateSupplier(); updateHasSave(false); - }, [currentStep, bigData]); + }, [currentStep, bigData, auth]); const goToNextStep = () => { if (!isFormValid) { @@ -277,6 +267,7 @@ const PengajuanTempo = () => { const address = await createPengajuanTempoApi({ id: idTempo, user_id: auth.parentId, + partner_id: auth.partnerId, section: label, tempo_request: tempoRequest, ...formData, @@ -297,7 +288,6 @@ const PengajuanTempo = () => { const handleDaftarTempoDokumen = async () => { for (const error of stepDivsError) { if (error.length > 0) { - console.log('iman_erro', error); return; } } @@ -315,6 +305,7 @@ const PengajuanTempo = () => { const address = await createPengajuanTempoApi({ id: idTempo, user_id: auth.parentId, + partner_id: auth.partnerId, formDocs: JSON.stringify(formattedDokumen), }); if (address.id) { @@ -343,15 +334,14 @@ const PengajuanTempo = () => { durasiTempo: product.durasiTempo, creditLimit: product.creditLimit, })); - console.log('productOrder', productOrder); const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...'); setIsLoading(true); try { const address = await createPengajuanTempoApi({ id: idTempo, user_id: auth.parentId, + partner_id: auth.partnerId, formSupplier: JSON.stringify(productOrder), - section, }); if (address.id) { setIdTempo(address.id); @@ -402,7 +392,6 @@ const PengajuanTempo = () => { setIsLoading(true); try { let address5; - console.log('MASUK SINI'); const address = await createPengajuanTempoApi({ id: 0, partner_id: auth.partnerId, @@ -410,7 +399,6 @@ const PengajuanTempo = () => { tempo_request: false, ...form, }); - console.log('address', address); if (address.id) { const address2 = await createPengajuanTempoApi({ id: address.id, @@ -447,12 +435,12 @@ const PengajuanTempo = () => { } } } - toast.dismiss(toastId); - setIsLoading(false); if (address5.id) { - toast.success('Pengajuan tempo berhasil dilakukan'); const isUpdated = await editAuthTempo(); + toast.dismiss(toastId); + setIsLoading(false); + toast.success('Pengajuan tempo berhasil dilakukan'); if (isUpdated?.user) { setAuth(isUpdated.user); toast.success('Berhasil mengubah status akun', { duration: 1000 }); diff --git a/src/lib/pengajuan-tempo/component/Pengiriman.jsx b/src/lib/pengajuan-tempo/component/Pengiriman.jsx index 7b0a9455..8b8961c5 100644 --- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx +++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx @@ -39,7 +39,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { ? formPengiriman.dokumenPengiriman.split(',').map(Number) : [] ); - console.log('selectedIds', selectedIds); const [selectedIdsDokumenInvoice, setSelectedIdsselectedIdsDokumenInvoice] = useState( formPengiriman.dokumenPengirimanInvoice @@ -132,7 +131,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { validatePengiriman(); }; const handleRadioChange = (value) => { - console.log('value', value); setSelectedRadio(value); if (value == 'everyWeekday') { setEveryWeekday(!everyWeekday); @@ -173,22 +171,22 @@ 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, - ]); + // 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, @@ -301,44 +299,55 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { }, [buttonSubmitClick, chekValid]); useEffect(() => { - validatePengiriman(); - if (formPengiriman.isSameAddrees) { - const isSame = formPengiriman.isSameAddrees; - if (isSame == 'true') { - setSameAddress(true); - } else { - setSameAddress(false); - } + if (formPengiriman.isSameAddreesStreet == 'true') { + setSameAddressStreet(true); } - if (formPengiriman.isSameAddreesStreet) { - const isSame = formPengiriman.isSameAddreesStreet; - if (isSame == 'true') { - setSameAddressStreet(true); - } else { - setSameAddressStreet(false); - } - } - validatePengiriman(); - }, [buttonSubmitClick]); + }, [formPengiriman.isSameAddreesStreet]); useEffect(() => { - if (formPengiriman.isSameAddrees) { - const isSame = formPengiriman.isSameAddrees; - if (isSame == 'true') { - setSameAddress(true); - } else { - setSameAddress(false); - } + if (formPengiriman.isSameAddrees == 'true') { + setSameAddress(true); } - if (formPengiriman.isSameAddreesStreet) { - const isSame = formPengiriman.isSameAddreesStreet; - if (isSame == 'true') { - setSameAddressStreet(true); - } else { - setSameAddressStreet(false); - } - } - validatePengiriman(); - }, [formPengiriman.isSameAddrees, formPengiriman.isSameAddreesStreet]); + }, [formPengiriman.isSameAddrees]); + + // useEffect(() => { + // validatePengiriman(); + // if (formPengiriman.isSameAddrees) { + // const isSame = formPengiriman.isSameAddrees; + // if (isSame == 'true') { + // setSameAddress(true); + // } else { + // setSameAddress(false); + // } + // } + // if (formPengiriman.isSameAddreesStreet) { + // const isSame = formPengiriman.isSameAddreesStreet; + // if (isSame == 'true') { + // setSameAddressStreet(true); + // } else { + // setSameAddressStreet(false); + // } + // } + // validatePengiriman(); + // }, [buttonSubmitClick]); + // useEffect(() => { + // if (formPengiriman.isSameAddrees) { + // const isSame = formPengiriman.isSameAddrees; + // if (isSame == 'true') { + // setSameAddress(true); + // } else { + // setSameAddress(false); + // } + // } + // if (formPengiriman.isSameAddreesStreet) { + // const isSame = formPengiriman.isSameAddreesStreet; + // if (isSame == 'true') { + // setSameAddressStreet(true); + // } else { + // setSameAddressStreet(false); + // } + // } + // validatePengiriman(); + // }, [formPengiriman.isSameAddrees, formPengiriman.isSameAddreesStreet]); useEffect(() => { if (sameAddress) { updateFormPengiriman('streetInvoice', formPengiriman.streetPengiriman); @@ -383,77 +392,75 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { return item; }; - const cachedData = getFromLocalStorage('Pengiriman'); - useEffect(() => { - if (cachedData) { - setValue('cityPengiriman', parseInt(cachedData?.cityPengiriman)); - updateFormPengiriman('cityPengiriman', `${cachedData?.cityPengiriman}`); - } - if (cachedData?.statePengiriman) { - setValue('statePengiriman', parseInt(cachedData?.statePengiriman)); - } - if (cachedData?.stateInvoice) { - setValue('stateInvoice', parseInt(cachedData?.stateInvoice)); - } - if (cachedData?.cityInvoice) { - setValue('cityInvoice', parseInt(cachedData?.cityInvoice)); - } - if (cachedData?.isSameAddrees) { - updateFormPengiriman('isSameAddrees', `${cachedData?.isSameAddrees}`); - } - validatePengiriman(); - }, [cachedData?.cityPengiriman]); - useEffect(() => { - if (cachedData?.everyWeek) { - updateFormPengiriman('everyWeek', cachedData?.everyWeek); - setEveryWeek(cachedData?.everyWeek); - } - if (cachedData?.everyWeekday) { - updateFormPengiriman('everyWeekday', cachedData?.everyWeekday); - setEveryWeekday(cachedData?.everyWeekday); - } - if (cachedData?.tukarInvoice) { - updateFormPengiriman('tukarInvoice', cachedData?.tukarInvoice); - setTukarInvoice(cachedData?.tukarInvoice); - } - if (cachedData?.everyWeekPembayaran) { - updateFormPengiriman( - 'everyWeekPembayaran', - cachedData?.everyWeekPembayaran - ); - setEveryWeekPembayaran(cachedData?.everyWeekPembayaran); - } - if (cachedData?.everyWeekdayPembayaran) { - updateFormPengiriman( - 'everyWeekdayPembayaran', - cachedData?.everyWeekdayPembayaran - ); - setEveryWeekdayPembayaran(cachedData?.everyWeekdayPembayaran); - } - if (cachedData?.tukarInvoicePembayaran) { - updateFormPengiriman( - 'tukarInvoicePembayaran', - cachedData?.tukarInvoicePembayaran - ); - setTukarInvoicePembayaran(cachedData?.tukarInvoicePembayaran); - } - validatePengiriman(); - }, [ - cachedData?.everyWeek, - cachedData?.everyWeekday, - cachedData?.tukarInvoice, - cachedData?.everyWeekdayPembayaran, - cachedData?.everyWeekPembayaran, - cachedData?.tukarInvoicePembayaran, - ]); + // const cachedData = getFromLocalStorage('Pengiriman'); + // useEffect(() => { + // if (cachedData) { + // setValue('cityPengiriman', parseInt(cachedData?.cityPengiriman)); + // updateFormPengiriman('cityPengiriman', `${cachedData?.cityPengiriman}`); + // } + // if (cachedData?.statePengiriman) { + // setValue('statePengiriman', parseInt(cachedData?.statePengiriman)); + // } + // if (cachedData?.stateInvoice) { + // setValue('stateInvoice', parseInt(cachedData?.stateInvoice)); + // } + // if (cachedData?.cityInvoice) { + // setValue('cityInvoice', parseInt(cachedData?.cityInvoice)); + // } + // if (cachedData?.isSameAddrees) { + // updateFormPengiriman('isSameAddrees', `${cachedData?.isSameAddrees}`); + // } + // validatePengiriman(); + // }, [cachedData?.cityPengiriman]); + // useEffect(() => { + // if (cachedData?.everyWeek) { + // updateFormPengiriman('everyWeek', cachedData?.everyWeek); + // setEveryWeek(cachedData?.everyWeek); + // } + // if (cachedData?.everyWeekday) { + // updateFormPengiriman('everyWeekday', cachedData?.everyWeekday); + // setEveryWeekday(cachedData?.everyWeekday); + // } + // if (cachedData?.tukarInvoice) { + // updateFormPengiriman('tukarInvoice', cachedData?.tukarInvoice); + // setTukarInvoice(cachedData?.tukarInvoice); + // } + // if (cachedData?.everyWeekPembayaran) { + // updateFormPengiriman( + // 'everyWeekPembayaran', + // cachedData?.everyWeekPembayaran + // ); + // setEveryWeekPembayaran(cachedData?.everyWeekPembayaran); + // } + // if (cachedData?.everyWeekdayPembayaran) { + // updateFormPengiriman( + // 'everyWeekdayPembayaran', + // cachedData?.everyWeekdayPembayaran + // ); + // setEveryWeekdayPembayaran(cachedData?.everyWeekdayPembayaran); + // } + // if (cachedData?.tukarInvoicePembayaran) { + // updateFormPengiriman( + // 'tukarInvoicePembayaran', + // cachedData?.tukarInvoicePembayaran + // ); + // setTukarInvoicePembayaran(cachedData?.tukarInvoicePembayaran); + // } + // validatePengiriman(); + // }, [ + // cachedData?.everyWeek, + // cachedData?.everyWeekday, + // cachedData?.tukarInvoice, + // cachedData?.everyWeekdayPembayaran, + // cachedData?.everyWeekPembayaran, + // cachedData?.tukarInvoicePembayaran, + // ]); const handleChangeSameAddress = () => { setSameAddress(!sameAddress); }; const handleChangeSameAddressStreet = () => { setSameAddressStreet(!sameAddressStreet); }; - console.log('formPengiriman', formPengiriman); - console.log('errorsPengiriman', errorsPengiriman); return ( <> {isDesktop && ( @@ -479,6 +486,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { className='form-input' aria-invalid={errorsPengiriman.PICName} ref={PICNameRef} + aria-label='PICName' onChange={handleInputChange} /> {chekValid && ( @@ -516,6 +524,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { id='streetPengiriman' name='streetPengiriman' ref={streetPengirimanRef} + aria-label='streetPengiriman' placeholder='Masukkan alamat lengkap pengiriman barang' type='text' value={formPengiriman.streetPengiriman} @@ -529,7 +538,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { )} </div> <div className='sub-alamat flex flex-row w-full gap-3'> - <div className='w-2/5' ref={statePengirimanRef}> + <div + className='w-2/5' + ref={statePengirimanRef} + aria-label='statePengiriman' + > <Controller name='statePengiriman' control={control} @@ -550,6 +563,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-1/3' ref={cityPengirimanRef}> <Controller name='cityPengiriman' + aria-label='cityPengiriman' control={control} render={(props) => ( <HookFormSelect @@ -569,6 +583,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-1/3'> <input id='zipPengiriman' + aria-label='zipPengiriman' name='zipPengiriman' ref={zipRef} placeholder='Kode Pos' @@ -600,6 +615,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { value={formPengiriman.invoicePic} id='invoicePic' name='invoicePic' + aria-label='invoicePic' placeholder='Masukkan nama pic invoice disini' type='text' className='form-input' @@ -643,6 +659,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <input id='streetInvoice' name='streetInvoice' + aria-label='streetInvoice' ref={streetInvoiceRef} placeholder='Masukkan alamat lengkap pengiriman invoice' type='text' @@ -657,7 +674,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { )} </div> <div className='sub-alamat flex flex-row w-full gap-3'> - <div className='w-3/5' ref={stateInvoiceRef}> + <div + className='w-3/5' + ref={stateInvoiceRef} + aria-label='stateInvoice' + > <Controller name='stateInvoice' control={control} @@ -675,7 +696,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </div> )} </div> - <div className='w-2/5' ref={cityInvoiceRef}> + <div + className='w-2/5' + ref={cityInvoiceRef} + aria-label='cityInvoice' + > <Controller name='cityInvoice' control={control} @@ -723,6 +748,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Radio> <input id='everyWeekdayInput' + aria-label='everyWeekdayInput' name='everyWeekdayInput' ref={everyWeekdayInputRef} placeholder='Format: Senin, Selasa, Rabu, Kamis, Jumat, Sabtu, Minggu' @@ -738,6 +764,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Radio> <input id='everyWeekInput' + aria-label='everyWeekInput' name='everyWeekInput' ref={everyWeekInputRef} placeholder='Format: Minggu 1 & Minggu 2' @@ -754,6 +781,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <textarea id='tukarInvoiceInput' name='tukarInvoiceInput' + aria-label='tukarInvoiceInput' placeholder='Isi manual dokumen yang anda mau' value={formPengiriman.tukarInvoiceInput} className='form-input' @@ -844,6 +872,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-3/5 flex gap-3 flex-col' ref={dokumenPengirimanRef} + aria-label='dokumenPengirimanInput' > <Checkbox colorScheme='red' @@ -890,6 +919,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <textarea id='dokumenPengirimanInput' name='dokumenPengirimanInput' + aria-label='dokumenPengirimanInput' placeholder='isi manual dokumen yang anda mau' type='textarea' ref={dokumenPengirimanInputRef} @@ -920,6 +950,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-3/5 flex gap-3 flex-col' ref={dokumenPengirimanInvoiceRef} + name='dokumenPengirimanInvoiceInput' > <Checkbox colorScheme='red' @@ -985,6 +1016,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Checkbox> <textarea id='dokumenPengirimanInvoiceInput' + aria-label='dokumenPengirimanInvoiceInput' name='dokumenPengirimanInvoiceInput' placeholder='isi manual dokumen yang anda mau' type='textarea' @@ -1026,6 +1058,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { value={formPengiriman.PICName} id='PICName' name='PICName' + aria-label='PICName' placeholder='Masukkan nama pic pengiriman disini' type='text' className='form-input' @@ -1048,6 +1081,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <input id='streetPengiriman' name='streetPengiriman' + aria-label='streetPengiriman' ref={streetPengirimanRef} placeholder='Masukkan alamat lengkap pengiriman barang' type='text' @@ -1062,7 +1096,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { )} </div> <div className='sub-alamat flex flex-row w-full gap-2'> - <div className='w-2/5' ref={statePengirimanRef}> + <div + className='w-2/5' + ref={statePengirimanRef} + aria-label='statePengiriman' + > <Controller name='statePengiriman' control={control} @@ -1075,7 +1113,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { )} /> </div> - <div className='w-1/3' ref={cityPengirimanRef}> + <div + className='w-1/3' + ref={cityPengirimanRef} + aria-label='cityPengiriman' + > <Controller name='cityPengiriman' control={control} @@ -1092,6 +1134,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-1/3'> <input id='zipPengiriman' + aria-label='zipPengiriman' name='zipPengiriman' ref={zipRef} placeholder='Kode Pos' @@ -1126,6 +1169,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <input value={formPengiriman.invoicePic} id='invoicePic' + aria-label='invoicePic' name='invoicePic' placeholder='Masukkan nama pic invoice disini' type='text' @@ -1160,6 +1204,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-full'> <input id='streetInvoice' + aria-label='streetInvoice' name='streetInvoice' ref={streetInvoiceRef} placeholder='Masukkan alamat lengkap pengiriman invoice' @@ -1175,7 +1220,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { )} </div> <div className='sub-alamat flex flex-row w-full gap-3'> - <div className='w-3/5' ref={stateInvoiceRef}> + <div + className='w-3/5' + ref={stateInvoiceRef} + aria-label='stateInvoice' + > <Controller name='stateInvoice' control={control} @@ -1193,7 +1242,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </div> )} </div> - <div className='w-2/5' ref={cityInvoiceRef}> + <div + className='w-2/5' + ref={cityInvoiceRef} + aria-label='cityInvoice' + > <Controller name='cityInvoice' control={control} @@ -1239,6 +1292,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Checkbox> <input id='everyWeekdayInput' + aria-label='everyWeekdayInput' name='everyWeekdayInput' ref={everyWeekdayInputRef} placeholder='Format: Senin, Selasa, Rabu, Kamis, Jumat, Sabtu, Minggu' @@ -1259,6 +1313,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Checkbox> <input id='everyWeekInput' + aria-label='everyWeekInput' name='everyWeekInput' ref={everyWeekInputRef} placeholder='Format: Minggu 1 & Minggu 2' @@ -1378,6 +1433,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-full flex gap-2 flex-col' ref={dokumenPengirimanRef} + aria-label='dokumenPengirimanInput' > <Checkbox size='sm' @@ -1428,6 +1484,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Checkbox> <textarea id='dokumenPengirimanInput' + aria-label='dokumenPengirimanInput' name='dokumenPengirimanInput' placeholder='isi manual dokumen yang anda mau' type='textarea' @@ -1457,6 +1514,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { <div className='w-full flex gap-2 flex-col' ref={dokumenPengirimanInvoiceRef} + aria-label='dokumenPengirimanInvoiceInput' > <Checkbox size='sm' @@ -1528,6 +1586,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { </Checkbox> <textarea id='dokumenPengirimanInvoiceInput' + aria-label='dokumenPengirimanInvoiceInput' name='dokumenPengirimanInvoiceInput' placeholder='isi manual dokumen yang anda mau' type='textarea' diff --git a/src/lib/pengajuan-tempo/component/Referensi.jsx b/src/lib/pengajuan-tempo/component/Referensi.jsx index 24f44728..e285c2b9 100644 --- a/src/lib/pengajuan-tempo/component/Referensi.jsx +++ b/src/lib/pengajuan-tempo/component/Referensi.jsx @@ -84,7 +84,6 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => { }; const handleDeleteSupplier = (index) => { - console.log('index', index); const updatedData = supplierData.filter((_, i) => i !== index); setSupplierData(updatedData); @@ -159,9 +158,6 @@ const Referensi = ({ chekValid, buttonSubmitClick, data }) => { return item; }; useEffect(() => { - console.log('supplierData', supplierData); - console.log('form supplier', formSupplier); - console.log('data', data); // const cachedData = getFromLocalStorage('Referensi'); if (data) { setSupplierData(data); diff --git a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx index 6a50b0c7..f641d8fa 100644 --- a/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx +++ b/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx @@ -117,7 +117,6 @@ const InformasiPerusahaan = ({ 'GET', '/api/v1/partner/payment_term' ); - console.log('dataPaymentTerm', dataPaymentTerm); setPaymentTerm( dataPaymentTerm?.map((o) => ({ value: o.id, @@ -331,7 +330,6 @@ const InformasiPerusahaan = ({ const loadProfile = async () => { try { const dataProfile = await addressApi({ id: auth.parentId }); - console.log('dataProfile', dataProfile); if (dataProfile.name) { updateForm('name', dataProfile.name); } @@ -372,7 +370,6 @@ const InformasiPerusahaan = ({ loadProfile(); } }, [auth?.parentId, setValue]); - console.log('form', form); return ( <> {isDesktop && ( diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 16e20703..174e5cb1 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -21,7 +21,6 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { voucherPastiHemat = product?.newVoucherPastiHemat[0] ? product?.newVoucherPastiHemat[0] : product?.newVoucherPastiHemat; - console.log('voucherPastiHemat', voucherPastiHemat); const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx index 80d593e6..e6c3959d 100644 --- a/src/lib/tempo/components/Tempo.jsx +++ b/src/lib/tempo/components/Tempo.jsx @@ -301,8 +301,7 @@ const Tempo = () => { w={24} className='badge-solid-green px-1 text-xs flex items-center justify-center font-thin' > - {' '} - {tempo.paymentTerm} + {tempo.paymentTerm ? tempo.paymentTerm : 'Review'} </Skeleton> </p> </div> diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx index 9f772ddd..25db0c4b 100644 --- a/src/pages/pengajuan-tempo/index.jsx +++ b/src/pages/pengajuan-tempo/index.jsx @@ -6,7 +6,7 @@ import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import { getAuth } from '~/libs/auth'; import { useRouter } from 'next/router'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; const PagePengajuanTempo = dynamic(() => import('@/lib/pengajuan-tempo/component/PengajuanTempo') @@ -15,30 +15,35 @@ const PagePengajuanTempo = dynamic(() => export default function TrackingOrder() { const auth = getAuth(); const router = useRouter(); + const [isLoading, setIsLoading] = useState(true); // Set default isLoading to true useEffect(() => { - if (!auth) { + if (!auth) return; // Prevent unnecessary processing if auth is not ready + + if (auth.tempoProgres === 'review') { + router.push('/pengajuan-tempo/review'); + } else if (!auth.parentId) { + router.push('/pengajuan-tempo/switch-account'); + } else if (!auth) { const nextUrl = encodeURIComponent(router.asPath); router.push(`/login?next=${nextUrl}`); - } else if (!auth?.parentId) { - router.push('/pengajuan-tempo/switch-account'); + } else { + setIsLoading(false); // Set isLoading to false only when routing is not required } }, [auth, router]); - if (!auth?.parentId) { - return null; + if (isLoading || !auth) { + return null; // Show nothing while loading or if auth is not ready } return ( <> <Seo title='Pengajuan Tempo - Indoteknik.com' /> - <DesktopView> <BasicLayout> <PagePengajuanTempo /> </BasicLayout> </DesktopView> - <MobileView> <BasicLayout> <PagePengajuanTempo /> |
