diff options
Diffstat (limited to 'src/pages/my')
| -rw-r--r-- | src/pages/my/menu.jsx | 13 | ||||
| -rw-r--r-- | src/pages/my/profile.jsx | 107 | ||||
| -rw-r--r-- | src/pages/my/tempo/index.jsx | 51 |
3 files changed, 168 insertions, 3 deletions
diff --git a/src/pages/my/menu.jsx b/src/pages/my/menu.jsx index 1b35d6ba..2a46d866 100644 --- a/src/pages/my/menu.jsx +++ b/src/pages/my/menu.jsx @@ -90,6 +90,19 @@ export default function Menu() { <p>Invoice & Faktur Pajak</p> </div> </LinkItem> + {(auth?.partnerTempo || auth?.tempoProgres == 'review') && ( + <LinkItem href='/my/tempo'> + {' '} + <div className='flex gap-x-3 items-center'> + <ImageNext + src='/images/icon/icon_tempo.svg' + width={18} + height={20} + /> + <p>Pembayaran Tempo</p> + </div> + </LinkItem> + )} <LinkItem href='/my/wishlist'> <div className='flex gap-x-3 items-center'> <ImageNext 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 />} diff --git a/src/pages/my/tempo/index.jsx b/src/pages/my/tempo/index.jsx new file mode 100644 index 00000000..5fb9deba --- /dev/null +++ b/src/pages/my/tempo/index.jsx @@ -0,0 +1,51 @@ +import Seo from '@/core/components/Seo'; +import AppLayout from '@/core/components/layouts/AppLayout'; +import BasicLayout from '@/core/components/layouts/BasicLayout'; +import DesktopView from '@/core/components/views/DesktopView'; +import MobileView from '@/core/components/views/MobileView'; +import IsAuth from '@/lib/auth/components/IsAuth'; +import InvoicesComponent from '@/lib/tempo/components/Tempo'; +import { getAuth } from '~/libs/auth'; +import { useRouter } from 'next/router'; +import { useEffect, useState } from 'react'; +export default function MyTempo() { + const auth = getAuth(); + const router = useRouter(); + const [isLoading, setIsLoading] = useState(true); + useEffect(() => { + if (!auth) { + const nextUrl = encodeURIComponent(router.asPath); + router.push(`/login?next=${nextUrl}`); + } + // else if ( + // (auth.tempoProgres === '' || auth.tempoProgres === 'rejected') && + // !auth.company + // ) { + // router.push('/pengajuan-tempo'); + // } + else { + setIsLoading(false); + } + }, [auth]); + + if (isLoading || !auth) { + return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia + } + return ( + <IsAuth> + <Seo title='Tempo - Indoteknik.com' /> + + <MobileView> + <AppLayout title='Pembayaran Tempo'> + <InvoicesComponent /> + </AppLayout> + </MobileView> + + <DesktopView> + <BasicLayout> + <InvoicesComponent /> + </BasicLayout> + </DesktopView> + </IsAuth> + ); +} |
