summaryrefslogtreecommitdiff
path: root/src/lib
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/lib
parentc13bb5c6f78032695b24cf8a6c23942eb465c6d5 (diff)
<iman> update switch account
Diffstat (limited to 'src/lib')
-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
3 files changed, 10 insertions, 6 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