diff options
| author | Indoteknik . <andrifebriyadiputra@gmail.com> | 2025-08-13 10:57:36 +0700 |
|---|---|---|
| committer | Indoteknik . <andrifebriyadiputra@gmail.com> | 2025-08-13 10:57:36 +0700 |
| commit | 1085602ad84e73692e3ab8b9141c5f61381a8cea (patch) | |
| tree | f67fbb3bd2117faac875bd2a0005f39b05f25f99 /src | |
| parent | c527fa8fe9772b456a11a52f52c7ee091504d734 (diff) | |
(andri) layout pengajuan tempo jika status akun pending
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/pengajuan-tempo/component/FinishTempo.jsx | 77 |
1 files changed, 57 insertions, 20 deletions
diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index ad8a7e67..abf218d9 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -9,9 +9,12 @@ import axios from 'axios'; import { toast } from 'react-hot-toast'; import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; import { useRouter } from 'next/router'; +import switchAccountProgresApi from '@/lib/auth/api/switchAccountProgresApi.js'; const FinishTempo = ({ query }) => { const [data, setData] = useState(); + const [switchStatus, setSwitchStatus] = useState(null); + const [loadingStatus, setLoadingStatus] = useState(true); const [transactionData, setTransactionData] = useState(); const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); @@ -29,16 +32,46 @@ const FinishTempo = ({ query }) => { fetchData(); }, [query]); + useEffect(() => { + const fetchSwitchStatus = async () => { + try { + const progres = await switchAccountProgresApi(); + setSwitchStatus(progres?.status); + } catch (err) { + console.error('Gagal cek progres switch account:', err); + } finally { + setLoadingStatus(false); + } + }; + fetchSwitchStatus(); + }, []); + // Handler khusus untuk tombol Ubah Akun const handleSwitchAccountClick = () => { - // Set flag di localStorage + if (switchStatus === 'pending') { + toast.info('Akun sedang menunggu verifikasi. Tidak dapat mengubah akun saat ini.', { duration: 2500 }); + return; + } localStorage.setItem('autoCheckProfile', 'true'); - // Navigate tanpa query param ke halaman profile router.push('/my/profile'); }; + if (loadingStatus) { + return ( + <div className="container flex flex-col items-center gap-4"> + <div className="py-20 text-gray-500">Memuat data...</div> + </div> + ); + } + return ( - <div className='container flex flex-col items-center gap-4'> + <div + className={`container flex flex-col items-center gap-4 pb-20 ${ + switchStatus === 'pending' + ? 'min-h-[calc(100vh-80px)] md:min-h-[calc(100vh-100px)] lg:min-h-[calc(100vh-120px)]' + : 'min-h-screen' + }`} + > <div className={`flex ${ isMobile ? 'w-full' : 'w-2/3' @@ -51,8 +84,11 @@ const FinishTempo = ({ query }) => { > {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'} + {switchStatus === 'pending' + ? 'Form Pengajuan Tempo Kamu Belum Dapat Dilakukan' + : query?.status == 'switch-account' && + 'Form Pengajuan Tempo Kamu Gagal Dilakukan' + } {query?.status == 'review' && 'Pengajuan Tempo dalam Proses Verifikasi'} {query?.status == 'approve' && 'Pengajuan Tempo Berhasil'} @@ -96,8 +132,11 @@ 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'} + {switchStatus === 'pending' + ? 'Proses perubahan ke akun bisnis sedang kami review, mohon menunggu hingga 2x24 jam' + : 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' && @@ -106,10 +145,12 @@ const FinishTempo = ({ query }) => { 'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'} </div> - <hr className="border-gray-300 w-full" /> + {switchStatus !== 'pending' && ( + <hr className="border-gray-300 w-full" /> + )} {/* Video panduan khusus tampil saat status switch-account */} - {query?.status === 'switch-account' && ( + {query?.status === 'switch-account' && switchStatus !== 'pending' && ( <div className="w-full max-w-3xl mx-auto px-4 text-center text-gray-700 mb-6"> <div className="mb-3 font-medium"> <h1 @@ -137,27 +178,23 @@ const FinishTempo = ({ query }) => { )} {/* Tombol dengan behavior berbeda jika status switch-account */} - {query?.status === 'switch-account' ? ( + {query?.status === 'switch-account' && switchStatus !== 'pending' ? ( <button onClick={handleSwitchAccountClick} - className='btn-solid-red rounded-md text-base flex flex-row items-center justify-center mb-10' + className="btn-solid-red rounded-md text-base flex flex-row items-center justify-center mb-10" > Ubah Akun - <ChevronRightIcon className='w-5' /> + <ChevronRightIcon className="w-5" /> </button> - ) : ( + ) : query?.status !== 'switch-account' && ( <Link - href={ - query?.status === 'approve' - ? '/my/tempo/' - : '/' - } - className='btn-solid-red rounded-md text-base flex flex-row items-center justify-center mb-10' + href={query?.status === 'approve' ? '/my/tempo/' : '/'} + className="btn-solid-red rounded-md text-base flex flex-row items-center justify-center mb-10" > {query?.status === 'approve' ? 'Lihat Detail Tempo' : 'Kembali Ke Beranda'} - <ChevronRightIcon className='w-5' /> + <ChevronRightIcon className="w-5" /> </Link> )} </div> |
