diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-01-15 10:02:39 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-01-15 10:02:39 +0000 |
| commit | 8035f129863f0a401f529cc0cd69a2131ccaba80 (patch) | |
| tree | 21e0300680a724c8a24ed815ea4e9a32ab13a895 /src/pages | |
| parent | 7a14ed5ccdde86d0400d6aa02ac866317d4add63 (diff) | |
| parent | 98236a47c3558c4b701009a275c7ae917ee8bf67 (diff) | |
Merged in Feature/switch-account (pull request #402)
Feature/switch account
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/my/profile.jsx | 107 |
1 files changed, 104 insertions, 3 deletions
diff --git a/src/pages/my/profile.jsx b/src/pages/my/profile.jsx index 7cf1bcbb..eaf3341c 100644 --- a/src/pages/my/profile.jsx +++ b/src/pages/my/profile.jsx @@ -5,19 +5,96 @@ import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import useAuth from '@/core/hooks/useAuth'; import CompanyProfile from '@/lib/auth/components/CompanyProfile'; +import SwitchAccount from '@/lib/auth/components/SwitchAccount'; import IsAuth from '@/lib/auth/components/IsAuth'; import Menu from '@/lib/auth/components/Menu'; import PersonalProfile from '@/lib/auth/components/PersonalProfile'; -import Seo from '@/core/components/Seo'; - +// import StatusSwitchAccount from '@/lib/auth/components/StatusSwitchAccount'; +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'; 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 () => { + if (isChecked) { + setIsChecked(!isChecked); + } else { + setChangeConfirmation(true); + } + }; + useEffect(() => { + const loadPromo = async () => { + const progresSwitchAccount = await switchAccountProgresApi(); + if (progresSwitchAccount) { + setIsAprove(progresSwitchAccount.status); + setUbahAkun(progresSwitchAccount.status); + } + }; + loadPromo(); + }, []); + const handleConfirmSubmit = () => { + setChangeConfirmation(false); + setIsChecked(true); + }; return ( <> - <Seo title='Profile - Indoteknik.com' /> + <BottomPopup + active={changeConfirmation} + close={() => setChangeConfirmation(false)} // Menutup popup + title='Ubah type akun' + > + <div className='leading-7 text-gray_r-12/80'> + Anda akan mengubah type akun anda? + </div> + <div className='flex mt-6 gap-x-4 md:justify-end'> + <button + className='btn-solid-red flex-1 md:flex-none' + type='button' + onClick={handleConfirmSubmit} + > + Yakin + </button> + <button + className='btn-light flex-1 md:flex-none' + type='button' + onClick={() => setChangeConfirmation(false)} + > + Batal + </button> + </div> + </BottomPopup> <IsAuth> <MobileView> <AppLayout title='Akun Saya'> + {!auth?.parentId && !ubahAkun && ( + <div className='text-sm p-4 flex items-center'> + <Checkbox + borderColor='gray.600' + colorScheme='red' + size='lg' + isChecked={isChecked} + onChange={handleChange} + /> + <p className='ml-2'>Ubah ke akun bisnis</p> + </div> + )} + {isChecked && ( + <div> + <SwitchAccount company_type='nonpkp' /> + <Divider /> + </div> + )} + {/* {!auth?.parentId + ? auth?.parentId + : auth?.parent_id && + isAprove != 'unknown' && ( + <StatusSwitchAccount status={isAprove} /> + )} */} <PersonalProfile /> <Divider /> {auth?.parentId && <CompanyProfile />} @@ -31,6 +108,30 @@ export default function Profile() { <Menu /> </div> <div className='w-9/12 bg-white border border-gray_r-6 rounded'> + {!auth?.parentId && !ubahAkun && ( + <div className='text-sm p-4 flex items-center'> + <Checkbox + borderColor='gray.600' + colorScheme='red' + size='lg' + isChecked={isChecked} + onChange={handleChange} + /> + <p className='ml-2'>Ubah ke akun bisnis</p> + </div> + )} + {isChecked && ( + <div> + <SwitchAccount company_type='nonpkp' /> + <Divider /> + </div> + )} + {/* {!auth?.parentId + ? auth?.parentId + : auth?.parent_id && + isAprove != 'unknown' && ( + <StatusSwitchAccount status={isAprove} /> + )} */} <PersonalProfile /> <Divider /> {auth?.parentId && <CompanyProfile />} |
