summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-23 13:15:02 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-23 13:15:02 +0700
commitf0f002ff77481db91d264069d09f580d58001a8c (patch)
treecb3b916a1688c17407d1a831e36c12c6021feac3 /src
parentc13bb5c6f78032695b24cf8a6c23942eb465c6d5 (diff)
<iman> update switch account
Diffstat (limited to 'src')
-rw-r--r--src/lib/auth/api/switchAccountApi.js2
-rw-r--r--src/lib/auth/api/switchAccountProgresApi.js2
-rw-r--r--src/lib/auth/components/SwitchAccount.jsx12
-rw-r--r--src/pages/my/profile.jsx4
4 files changed, 13 insertions, 7 deletions
diff --git a/src/lib/auth/api/switchAccountApi.js b/src/lib/auth/api/switchAccountApi.js
index 9b772d20..79ca2553 100644
--- a/src/lib/auth/api/switchAccountApi.js
+++ b/src/lib/auth/api/switchAccountApi.js
@@ -5,7 +5,7 @@ const switchAccountApi = async ({ data }) => {
const auth = getAuth();
const switchAccount = await odooApi(
'PUT',
- `/api/v1/user/${auth.partner_id}/switch`,
+ `/api/v1/user/${auth.partnerId}/switch`,
data
);
return switchAccount;
diff --git a/src/lib/auth/api/switchAccountProgresApi.js b/src/lib/auth/api/switchAccountProgresApi.js
index 23e06742..ba1c35fa 100644
--- a/src/lib/auth/api/switchAccountProgresApi.js
+++ b/src/lib/auth/api/switchAccountProgresApi.js
@@ -6,7 +6,7 @@ const switchAccountProgresApi = async () => {
console.log('auth', auth);
const switchAccount = await odooApi(
'GET',
- `/api/v1/user/${auth.partner_id}/switch_progres`
+ `/api/v1/user/${auth.partnerId}/switch_progres`
);
console.log('switchAccount', switchAccount);
return switchAccount;
diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx
index b7b67864..bc9dee36 100644
--- a/src/lib/auth/components/SwitchAccount.jsx
+++ b/src/lib/auth/components/SwitchAccount.jsx
@@ -22,6 +22,7 @@ const SwitchAccount = () => {
const [isChecked, setIsChecked] = useState(false);
const [selectedValueBisnis, setSelectedValueBisnis] = useState('false');
const [selectedValue, setSelectedValue] = useState('PKP');
+ const [buttonSubmitClick, setButtonSubmitClick] = useState(false);
const { register, setValue, handleSubmit } = useForm({
defaultValues: {
email: '',
@@ -99,20 +100,22 @@ const SwitchAccount = () => {
};
console.log('auth', auth);
const onSubmitHandler = async (values) => {
- let data = form;
- console.log('data', data);
+ // let data = { ...form, id: `${auth.partnerId}` };
+ const data = form;
if (!isFormValid) {
- console.log('masih ada yang belum valid');
setNotValid(true);
+ setButtonSubmitClick(!buttonSubmitClick);
return;
} else {
+ setButtonSubmitClick(!buttonSubmitClick);
setNotValid(false);
}
// if (!values.password) delete data.password;
+ console.log('data', data);
const isUpdated = await switchAccountApi({ data });
console.log('isupdate', isUpdated);
- if (isUpdated.switch === 'Pending') {
+ if (isUpdated?.switch === 'Pending') {
// setAuth(isUpdated.user);
// setValue('password', '');
toast.success('Berhasil mengubah akun', { duration: 1500 });
@@ -181,6 +184,7 @@ const SwitchAccount = () => {
required={isTerdaftar}
isPKP={isPKP}
chekValid={notValid}
+ buttonSubmitClick={buttonSubmitClick}
/>
<div className='flex justify-end mb-4 mr-4'>
<button
diff --git a/src/pages/my/profile.jsx b/src/pages/my/profile.jsx
index 4beaae5f..13cab06d 100644
--- a/src/pages/my/profile.jsx
+++ b/src/pages/my/profile.jsx
@@ -16,6 +16,7 @@ import switchAccountProgresApi from '@/lib/auth/api/switchAccountProgresApi.js';
export default function Profile() {
const auth = useAuth();
const [isChecked, setIsChecked] = useState(false);
+ const [ubahAkun, setUbahAkun] = useState(false);
const [isAprove, setIsAprove] = useState('unknown');
const handleChange = async () => {
setIsChecked(!isChecked);
@@ -25,6 +26,7 @@ export default function Profile() {
const progresSwitchAccount = await switchAccountProgresApi();
if (progresSwitchAccount) {
setIsAprove(progresSwitchAccount.status);
+ setUbahAkun(progresSwitchAccount.status === 'unknown');
}
console.log('progresSwitchAccount', progresSwitchAccount);
};
@@ -48,7 +50,7 @@ export default function Profile() {
<Menu />
</div>
<div className='w-9/12 bg-white border border-gray_r-6 rounded'>
- {!auth?.parentId && isAprove == 'unknown' && (
+ {!auth?.parentId && ubahAkun && (
<div className='text-sm p-4 flex items-center'>
<Checkbox
borderColor='gray.600'