From 7647104348478302778c0afbd3a3d1b2637bc03b Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Mon, 11 Aug 2025 15:35:25 +0700 Subject: (andri) set true checklist ubah ke akun bisnis --- src/lib/pengajuan-tempo/component/FinishTempo.jsx | 58 ++++++++++------ src/pages/my/profile.jsx | 80 +++++++++++++++-------- 2 files changed, 93 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index 84c80e60..9d912b1a 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -8,6 +8,7 @@ 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'; const FinishTempo = ({ query }) => { const [data, setData] = useState(); @@ -15,6 +16,8 @@ const FinishTempo = ({ query }) => { 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,6 +29,14 @@ const FinishTempo = ({ query }) => { fetchData(); }, [query]); + // Handler khusus untuk tombol Ubah Akun + const handleSwitchAccountClick = () => { + // Set flag di localStorage + localStorage.setItem('autoCheckProfile', 'true'); + // Navigate tanpa query param ke halaman profile + router.push('/my/profile'); + }; + return (
{ {query?.status == 'approve' && 'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'}
- - {query?.status === 'switch-account' - ? 'Ubah Akun' - : query?.status === 'approve' - ? 'Lihat Detail Tempo' - : 'Kembali Ke Beranda'} - - + + {/* Tombol dengan behavior berbeda jika status switch-account */} + {query?.status === 'switch-account' ? ( + + ) : ( + + {query?.status === 'approve' + ? 'Lihat Detail Tempo' + : 'Kembali Ke Beranda'} + + + )} + {/* Video panduan khusus tampil saat status switch-account */} {query?.status === 'switch-account' && ( -
-
+
+

Agar tidak bingung saat mengubah akun,

Yuk pelajari dulu langkah-langkah pengajuan tempo lewat video berikut

diff --git a/src/pages/my/profile.jsx b/src/pages/my/profile.jsx index 859b6960..663ff97a 100644 --- a/src/pages/my/profile.jsx +++ b/src/pages/my/profile.jsx @@ -14,19 +14,26 @@ import { Checkbox } from '@chakra-ui/react'; import { useState, useEffect } from 'react'; import switchAccountProgresApi from '@/lib/auth/api/switchAccountProgresApi.js'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +import { useRouter } from 'next/router'; + export default function Profile() { const auth = useAuth(); const [isChecked, setIsChecked] = useState(false); const [ubahAkun, setUbahAkun] = useState(false); const [isAprove, setIsAprove] = useState(); const [changeConfirmation, setChangeConfirmation] = useState(false); - const handleChange = async () => { + const router = useRouter(); + + // Handle checkbox toggle + const handleChange = () => { if (isChecked) { - setIsChecked(!isChecked); + setIsChecked(false); } else { setChangeConfirmation(true); } }; + + // Load status dan cek localStorage "autoCheckProfile" useEffect(() => { const loadPromo = async () => { const progresSwitchAccount = await switchAccountProgresApi(); @@ -36,7 +43,28 @@ export default function Profile() { } }; loadPromo(); - }, []); + + if (typeof window !== 'undefined') { + const autoCheck = localStorage.getItem('autoCheckProfile'); + if (autoCheck === 'true') { + setIsChecked(true); + localStorage.removeItem('autoCheckProfile'); + + // Hapus query param supaya URL bersih + if (router.query.autoCheck) { + const cleanQuery = { ...router.query }; + delete cleanQuery.autoCheck; + router.replace( + { pathname: router.pathname, query: cleanQuery }, + undefined, + { shallow: true } + ); + } + } + } + }, [router]); + + // Confirm checkbox change from popup const handleConfirmSubmit = () => { setChangeConfirmation(false); setIsChecked(true); @@ -46,22 +74,22 @@ export default function Profile() { setChangeConfirmation(false)} // Menutup popup - title='Ubah type akun' + title="Ubah type akun" > -
+
Anda akan mengubah type akun anda?
-
+