From b1bdfbb9f780a1a1305e02c4b9c338b98c7a4556 Mon Sep 17 00:00:00 2001
From: "Indoteknik ." <andrifebriyadiputra@gmail.com>
Date: Fri, 15 Aug 2025 13:58:59 +0700
Subject: (andri) fix switch account

---
 src/lib/auth/components/SwitchAccount.jsx | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/lib/auth/components/SwitchAccount.jsx')

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);
     }
   };
-- 
cgit v1.2.3

