summaryrefslogtreecommitdiff
path: root/src/lib/pengajuan-tempo/component
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-08-15 10:23:38 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-08-15 10:23:38 +0000
commit5ef267f76486ed590c00d3c37cccde5c713491cd (patch)
tree4a3cf919743ac45d4ecb8d01fdf7ef51685ca16a /src/lib/pengajuan-tempo/component
parent4d7e2f7b6e92cbe700e5b8fcea006b3d70ed81f9 (diff)
parentb1bdfbb9f780a1a1305e02c4b9c338b98c7a4556 (diff)
Merged in tempo-v2 (pull request #442)
Tempo v2
Diffstat (limited to 'src/lib/pengajuan-tempo/component')
-rw-r--r--src/lib/pengajuan-tempo/component/FinishTempo.jsx130
-rw-r--r--src/lib/pengajuan-tempo/component/PengajuanTempo.jsx1
2 files changed, 109 insertions, 22 deletions
diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx
index aacb9ef3..abf218d9 100644
--- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx
@@ -8,13 +8,19 @@ import useAuth from '@/core/hooks/useAuth';
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();
const so_order = query?.order_id?.replaceAll('-', '/');
+ const router = useRouter();
+
useEffect(() => {
const fetchData = async () => {
const fetchedData = await odooApi(
@@ -26,8 +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 = () => {
+ if (switchStatus === 'pending') {
+ toast.info('Akun sedang menunggu verifikasi. Tidak dapat mengubah akun saat ini.', { duration: 2500 });
+ return;
+ }
+ localStorage.setItem('autoCheckProfile', 'true');
+ 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'
@@ -40,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'}
@@ -85,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' &&
@@ -94,23 +144,59 @@ const FinishTempo = ({ query }) => {
{query?.status == 'approve' &&
'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'}
</div>
- <Link
- href={
- query?.status === 'switch-account'
- ? '/my/profile'
- : query?.status === 'approve'
- ? '/my/tempo/'
- : '/'
- }
- className='btn-solid-red rounded-md text-base flex flex-row items-center justify-center'
- >
- {query?.status === 'switch-account'
- ? 'Ubah Akun'
- : query?.status === 'approve'
- ? 'Lihat Detail Tempo'
- : 'Kembali Ke Beranda'}
- <ChevronRightIcon className='w-5' />
- </Link>
+
+ {switchStatus !== 'pending' && (
+ <hr className="border-gray-300 w-full" />
+ )}
+
+ {/* Video panduan khusus tampil saat 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
+ className={`text-red-500 text-center font-semibold ${
+ isMobile ? 'text-lg' : 'text-3xl'
+ }`}
+ // Mengganti py-4 dengan my-6 supaya jarak vertikalnya sama dengan hr
+ style={{ marginTop: 24, marginBottom: 24 }}
+ >
+ Video Panduan Pengajuan Tempo
+ </h1>
+ </div>
+ <div className="relative" style={{ paddingTop: '56.25%' /* 16:9 aspect ratio */ }}>
+ <iframe
+ src="https://www.youtube.com/embed/m15f8-eLqUc?si=frNbGnJu1zjINnDT"
+ title="YouTube video player"
+ frameBorder="0"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
+ allowFullScreen
+ referrerPolicy="strict-origin-when-cross-origin"
+ className="absolute top-0 left-0 w-full h-full rounded-md shadow-lg"
+ ></iframe>
+ </div>
+ </div>
+ )}
+
+ {/* Tombol dengan behavior berbeda jika 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"
+ >
+ Ubah Akun
+ <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"
+ >
+ {query?.status === 'approve'
+ ? 'Lihat Detail Tempo'
+ : 'Kembali Ke Beranda'}
+ <ChevronRightIcon className="w-5" />
+ </Link>
+ )}
</div>
);
};
diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
index ae3d97fd..096fe1ed 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -40,6 +40,7 @@ const PengajuanTempo = () => {
const { form, errors, validate, updateForm } = usePengajuanTempoStore();
const { control, watch, setValue, setError } = useForm();
const auth = useAuth();
+ console.log('auth', auth);
const router = useRouter();
const [BannerTempo, setBannerTempo] = useState();
const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } =