summaryrefslogtreecommitdiff
path: root/src/lib/auth
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-05 09:40:32 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-05 09:40:32 +0700
commitd3e867689b9b171efb8f5a85c7a4cb39b7e7b8fd (patch)
tree1d78cf3542fe189a02a482468c8749eddfc71bae /src/lib/auth
parent555de668c83b44679af9ef34f3624a55b372cfce (diff)
<iman> update new register
Diffstat (limited to 'src/lib/auth')
-rw-r--r--src/lib/auth/components/CompanyProfile.jsx69
1 files changed, 52 insertions, 17 deletions
diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx
index a4c25e40..581c32b0 100644
--- a/src/lib/auth/components/CompanyProfile.jsx
+++ b/src/lib/auth/components/CompanyProfile.jsx
@@ -6,8 +6,10 @@ import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'
import { useEffect, useState } from 'react'
import { Controller, useForm } from 'react-hook-form'
import { toast } from 'react-hot-toast'
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
const CompanyProfile = () => {
+ const [changeConfirmation, setChangeConfirmation] = useState(false)
const auth = useAuth()
const [isOpen, setIsOpen] = useState(false)
const toggle = () => setIsOpen(!isOpen)
@@ -17,10 +19,10 @@ const CompanyProfile = () => {
companyType: '',
name: '',
taxName: '',
- npwp: ''
+ npwp: '',
+ alamat_wajib_pajak:'',
}
})
- console.log("auth",auth)
const [industries, setIndustries] = useState([])
useEffect(() => {
@@ -43,7 +45,6 @@ const CompanyProfile = () => {
useEffect(() => {
const loadProfile = async () => {
const dataProfile = await addressApi({ id: auth.parentId })
- console.log("dataProfile",dataProfile)
setValue('name', dataProfile.name)
setValue('industry', dataProfile.industryId)
setValue('companyType', dataProfile.companyTypeId)
@@ -55,24 +56,55 @@ const CompanyProfile = () => {
}, [auth, setValue])
const onSubmitHandler = async (values) => {
- const data = {
- ...values,
- id_user:auth.partnerId,
- company_type_id: values.companyType,
- industry_id: values.industry,
- tax_name: values.taxName,
- alamat_lengkap_text:values.alamat_wajib_pajak
+ if(changeConfirmation){
+ const data = {
+ ...values,
+ company_type_id: values.companyType,
+ industry_id: values.industry,
+ tax_name: values.taxName,
+ alamat_lengkap_text:values.alamat_wajib_pajak
+ }
+ const isUpdated = await odooApi('PUT', `/api/v1/partner/${auth.parentId}`, data)
+ if (isUpdated?.id) {
+ toast.success('Berhasil mengubah profil', { duration: 1500 })
+ return
+ }
+ toast.error('Terjadi kesalahan internal')
}
- const isUpdated = await odooApi('PUT', `/api/v1/partner/${auth.parentId}`, data)
- if (isUpdated?.id) {
- toast.success('Berhasil mengubah profil', { duration: 1500 })
- return
- }
- toast.error('Terjadi kesalahan internal')
+ }
+
+ const handleConfirmSubmit = () => {
+ setChangeConfirmation(false)
+ handleSubmit(onSubmitHandler)()
}
return (
<>
+ <BottomPopup
+ active={changeConfirmation}
+ close={() => setChangeConfirmation(true)}
+ title='Ubah profil Bisnis'
+ >
+ <div className='leading-7 text-gray_r-12/80'>
+ Apakah anda yakin mengubah data bisnis?
+ </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}
+ >
+ Ya, Ubah
+ </button>
+ <button
+ className='btn-light flex-1 md:flex-none'
+ type='button'
+ onClick={() => setChangeConfirmation(false)}
+ >
+ Batal
+ </button>
+ </div>
+ </BottomPopup>
<button type='button' onClick={toggle} className='p-4 flex items-center text-left w-full'>
<div>
<div className='font-semibold mb-2'>Informasi Usaha</div>
@@ -87,7 +119,10 @@ const CompanyProfile = () => {
</button>
{isOpen && (
- <form className='p-4 border-t border-gray_r-6' onSubmit={handleSubmit(onSubmitHandler)}>
+ <form className='p-4 border-t border-gray_r-6' onSubmit={(e) => {
+ e.preventDefault()
+ setChangeConfirmation(true)
+ }}>
<div className='grid grid-cols-1 sm:grid-cols-2 gap-4'>
<div>
<label className='block mb-3'>Klasifikasi Jenis Usaha</label>