summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndoteknik . <andrifebriyadiputra@gmail.com>2025-08-15 13:58:59 +0700
committerIndoteknik . <andrifebriyadiputra@gmail.com>2025-08-15 13:58:59 +0700
commitb1bdfbb9f780a1a1305e02c4b9c338b98c7a4556 (patch)
tree720aa9eeb0ec98a559f6a1653533185479590cc8 /src
parent1085602ad84e73692e3ab8b9141c5f61381a8cea (diff)
(andri) fix switch account
Diffstat (limited to 'src')
-rw-r--r--src/lib/auth/api/checkParentStatusApi.js13
-rw-r--r--src/lib/auth/components/SwitchAccount.jsx10
-rw-r--r--src/lib/pengajuan-tempo/component/PengajuanTempo.jsx1
-rw-r--r--src/pages/my/profile.jsx9
4 files changed, 25 insertions, 8 deletions
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() {
<p className="ml-2">Ubah ke akun bisnis</p>
</div>
))}
- {isChecked && (
+ {isChecked && ubahAkun !== 'pending' && (
<div>
- <SwitchAccount company_type="nonpkp" />
+ <SwitchAccount company_type="nonpkp" setIsAprove={setIsAprove} setUbahAkun={setUbahAkun}/>
<Divider />
</div>
)}
@@ -148,9 +149,9 @@ export default function Profile() {
<p className="ml-2">Ubah ke akun bisnis</p>
</div>
))}
- {isChecked && (
+ {isChecked && ubahAkun !== 'pending' && (
<div>
- <SwitchAccount company_type="nonpkp" />
+ <SwitchAccount company_type="nonpkp" setIsAprove={setIsAprove} setUbahAkun={setUbahAkun}/>
<Divider />
</div>
)}