From 016cbe790dd698ee258f17c8218ef6fdc667ad0d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 27 Sep 2024 17:00:00 +0700 Subject: update switch account --- src/lib/auth/components/CompanyProfile.jsx | 2 +- src/lib/auth/components/Menu.jsx | 187 ++++++++++++++++++---------- src/lib/auth/components/PersonalProfile.jsx | 106 +++++++--------- src/lib/auth/components/SwitchAccount.jsx | 114 ++++++++++------- 4 files changed, 241 insertions(+), 168 deletions(-) (limited to 'src/lib/auth') diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx index 6065efde..cd55072c 100644 --- a/src/lib/auth/components/CompanyProfile.jsx +++ b/src/lib/auth/components/CompanyProfile.jsx @@ -296,7 +296,7 @@ const CompanyProfile = () => { )} - {isOpen && } + {isOpen && } ); }; diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index f475db1f..ddbb0760 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -1,76 +1,137 @@ -import Link from '@/core/components/elements/Link/Link' -import { useRouter } from 'next/router' -import ImageNext from 'next/image' -import whatsappUrl from '@/core/utils/whatsappUrl' +import Link from '@/core/components/elements/Link/Link'; +import { useRouter } from 'next/router'; +import ImageNext from 'next/image'; +import whatsappUrl from '@/core/utils/whatsappUrl'; +import useAuth from '@/core/hooks/useAuth'; +import Divider from '@/core/components/elements/Divider/Divider'; const Menu = () => { - const router = useRouter() - - const routeStartWith = (route) => router.pathname.startsWith(route) - + const router = useRouter(); + const auth = useAuth(); + const routeStartWith = (route) => router.pathname.startsWith(route); return (
-
Menu
- -
- -

Daftar Quotation

-
-
- -
- -

Daftar Transaksi

-
-
- -
- -

Daftar Pengiriman

-
-
- -
- -

Invoice & Faktur Pajak

-
-
- -
- -

Wishlist

-
-
+
+
Akun Saya
+ {auth?.company && ( +
Akun Bisnis
+ )} + {!auth?.company && ( +
Akun Individu
+ )} +
+
Menu
+
+ +
+ +

Daftar Quotation

+
+
+ +
+ +

Daftar Transaksi

+
+
+ +
+ +

Daftar Pengiriman

+
+
+ +
+ +

Invoice & Faktur Pajak

+
+
+ +
+ +

Wishlist

+
+
+
Pusat Bantuan
- +
- +

Layanan Pelanggan

Pengaturan Akun
- -
- -

Daftar Alamat

-
-
- -
- -

Profil Saya

-
-
- +
+ +
+ +

Daftar Alamat

+
+
+ +
+ +

Profil Saya

+
+
+ +
- ) -} + ); +}; const LinkItem = ({ children, ...props }) => ( ( > {children} -) +); -export default Menu +export default Menu; diff --git a/src/lib/auth/components/PersonalProfile.jsx b/src/lib/auth/components/PersonalProfile.jsx index ce27c650..3053255d 100644 --- a/src/lib/auth/components/PersonalProfile.jsx +++ b/src/lib/auth/components/PersonalProfile.jsx @@ -48,11 +48,7 @@ const PersonalProfile = () => { return ( <> - + - {isOpen && ( -
-
-
- - -
-
- - -
-
- - -
-
- - -
+ +
+
+ + +
+
+ +
- - - )} +
+ + +
+
+ + +
+
+ + ); }; diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index fa1d3924..d76d1f0e 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -14,7 +14,8 @@ import { registerUser } from '~/services/auth'; import { useMutation } from 'react-query'; import { isValid } from 'zod'; import useDevice from '@/core/hooks/useDevice'; -const SwitchAccount = () => { +import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +const SwitchAccount = ({ company_type }) => { const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); const [isOpen, setIsOpen] = useState(true); @@ -25,6 +26,7 @@ const SwitchAccount = () => { const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); const [selectedValue, setSelectedValue] = useState('PKP'); const [buttonSubmitClick, setButtonSubmitClick] = useState(false); + const [changeConfirmation, setChangeConfirmation] = useState(false); const { register, setValue, handleSubmit } = useForm({ defaultValues: { email: '', @@ -74,7 +76,6 @@ const SwitchAccount = () => { const dataProfile = await addressApi({ id: auth.parentId ? auth.parentId : auth.parent_id, }); - console.log('dataProfile', dataProfile); if (dataProfile?.companyType === 'nonpkp') { setSelectedValue('PKP'); } @@ -120,6 +121,7 @@ const SwitchAccount = () => { } }; const onSubmitHandler = async (values) => { + setChangeConfirmation(false); // let data = { ...form, id: `${auth.partnerId}` }; const data = form; if (!isFormValid) { @@ -151,11 +153,32 @@ const SwitchAccount = () => { return ( <> - + +
+ +
{ *Perubahan akun tidak dapat diubah kembali
-
- {!isOpen && } - {isOpen && } -
- + - {isOpen && ( -
-
-

- Bisnis Terdaftar di Indoteknik? -

- - - - Sudah Terdaftar - - - Belum Terdaftar - - - -
+
+
+

+ Bisnis Terdaftar di Indoteknik? +

+ + + + Sudah Terdaftar + + + Belum Terdaftar + + + +
+ {!isTerdaftar && (

Tipe Bisnis

@@ -199,37 +215,43 @@ const SwitchAccount = () => { PKP - - Non-PKP - + {!(company_type === 'nonpkp') && ( + + Non-PKP + + )}
- -
+ )} + +
+
+
+
- )} +
); }; -- cgit v1.2.3