From b1bdfbb9f780a1a1305e02c4b9c338b98c7a4556 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Fri, 15 Aug 2025 13:58:59 +0700 Subject: (andri) fix switch account --- src/lib/auth/api/checkParentStatusApi.js | 13 +++++++++++++ src/lib/auth/components/SwitchAccount.jsx | 10 ++++++---- src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 1 + src/pages/my/profile.jsx | 9 +++++---- 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 src/lib/auth/api/checkParentStatusApi.js (limited to 'src') diff --git a/src/lib/auth/api/checkParentStatusApi.js b/src/lib/auth/api/checkParentStatusApi.js new file mode 100644 index 00000000..aa2eb1b6 --- /dev/null +++ b/src/lib/auth/api/checkParentStatusApi.js @@ -0,0 +1,13 @@ +import odooApi from '@/core/api/odooApi'; +import { getAuth } from '@/core/utils/auth'; + +const checkParentStatusApi = async () => { + const auth = getAuth(); + const checkParentStatus = await odooApi( + 'GET', + `/api/v1/user/${auth.partnerId}/parent_status` + ); + return checkParentStatus; +}; + +export default checkParentStatusApi; \ No newline at end of file diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index 80bc584f..840758c9 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -16,7 +16,7 @@ import { isValid } from 'zod'; import Spinner from "@/core/components/elements/Spinner/LogoSpinner"; import useDevice from '@/core/hooks/useDevice'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; -const SwitchAccount = ({ company_type }) => { +const SwitchAccount = ({ company_type, setIsAprove, setUbahAkun }) => { const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); const [isOpen, setIsOpen] = useState(true); @@ -152,21 +152,23 @@ const SwitchAccount = ({ company_type }) => { try { const isUpdated = await switchAccountApi({ data }); - if (isUpdated?.switch === 'Pending') { + if (isUpdated?.switch === 'pending') { toast.success('Berhasil mengajukan ubah akun', { duration: 1500 }); if (typeof window !== 'undefined') { localStorage.setItem('autoCheckProfile', 'true'); } setTimeout(() => { + setIsAprove('pending'); + setUbahAkun('pending'); window.location.reload(); }, 1500); } else { - toast.error('Gagal mengubah akun. Silakan coba lagi nanti.'); + toast.error('Gagal mengubah akun. Silakan coba lagi nanti atau hubungi admin jika masalah tetap terjadi.'); setIsLoadingPopup(false); } } catch (error) { console.error(error); - toast.error('Terjadi kesalahan saat menghubungi server.'); + toast.error('Terjadi kesalahan saat menghubungi server, silahkan cek internet Anda atau hubungi admin Indoteknik.'); setIsLoadingPopup(false); } }; diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index d59bfd75..3dac0015 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 } = useForm(); const auth = useAuth(); + console.log('auth', auth); const router = useRouter(); const [BannerTempo, setBannerTempo] = useState(); const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } = diff --git a/src/pages/my/profile.jsx b/src/pages/my/profile.jsx index 887489e0..b65a5e4d 100644 --- a/src/pages/my/profile.jsx +++ b/src/pages/my/profile.jsx @@ -18,6 +18,7 @@ import { useRouter } from 'next/router'; export default function Profile() { const auth = useAuth(); + console.log('auth', auth); const [isChecked, setIsChecked] = useState(false); const [ubahAkun, setUbahAkun] = useState(false); const [isAprove, setIsAprove] = useState(); @@ -111,9 +112,9 @@ export default function Profile() {

Ubah ke akun bisnis

))} - {isChecked && ( + {isChecked && ubahAkun !== 'pending' && (
- +
)} @@ -148,9 +149,9 @@ export default function Profile() {

Ubah ke akun bisnis

))} - {isChecked && ( + {isChecked && ubahAkun !== 'pending' && (
- +
)} -- cgit v1.2.3