From d3e867689b9b171efb8f5a85c7a4cb39b7e7b8fd Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 5 Sep 2024 09:40:32 +0700 Subject: update new register --- src/lib/auth/components/CompanyProfile.jsx | 69 ++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 17 deletions(-) (limited to 'src/lib') 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 ( <> + setChangeConfirmation(true)} + title='Ubah profil Bisnis' + > +
+ Apakah anda yakin mengubah data bisnis? +
+
+ + +
+
{isOpen && ( -
+ { + e.preventDefault() + setChangeConfirmation(true) + }}>
-- cgit v1.2.3