From 31ef67c8c2c3d80bf0c0cc040e551b4a45c3dedc Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 27 Sep 2024 15:36:39 +0700 Subject: update form bisnis to switch account --- .../modules/register/components/FormBisnis.tsx | 126 +++++++++++++++++++-- 1 file changed, 115 insertions(+), 11 deletions(-) (limited to 'src-migrate/modules') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index d4fdbbbd..ad92948e 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -24,10 +24,15 @@ import { Controller, useForm } from 'react-hook-form'; import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; import odooApi from '~/libs/odooApi'; import { toast } from 'react-hot-toast'; -import { EyeIcon } from '@heroicons/react/24/outline'; +import { + EyeIcon, + CheckCircleIcon, + XCircleIcon, +} from '@heroicons/react/24/outline'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; import Image from 'next/image'; import useDevice from '@/core/hooks/useDevice'; +import useAuth from '@/core/hooks/useAuth'; interface FormProps { type: string; required: boolean; @@ -101,14 +106,16 @@ const form: React.FC = ({ useEffect(() => { if (form.company_type_id) { setValue('companyType', parseInt(form.company_type_id)); + updateForm('sppkp_document', 'fileBase64.jpg'); } - }, []); + }, [form.company_type_id]); useEffect(() => { if (form.industry_id) { setValue('industry_id', parseInt(form.industry_id)); } - }, []); + }, [form.industry_id]); + console.log('form', form); useEffect(() => { const loadIndustries = async () => { const dataIndustries = await odooApi('GET', '/api/v1/partner/industry'); @@ -230,7 +237,7 @@ const form: React.FC = ({ toast({ ...toastProps, title: - 'Format file yang diijinkan adalah .pdf, .doc, .docx, .png, .jpg, atau .jpeg', + 'Format file yang diijinkan adalah .pdf, .png, .jpg, atau .jpeg', status: 'error', }); event.target.value = ''; @@ -238,10 +245,10 @@ const form: React.FC = ({ } // Check for file size - if (file.size > 5000000) { + if (file.size > 2000000) { toast({ ...toastProps, - title: 'Maksimal ukuran file adalah 5MB', + title: 'Maksimal ukuran file adalah 2MB', status: 'error', }); event.target.value = ''; @@ -320,7 +327,6 @@ const form: React.FC = ({ validate(); } }; - useEffect(() => {}, [watch('industry_id'), industries]); const handleIndustriIdChange = (event: MouseEvent) => { const selectedIndustriIdValue = watch('industry_id'); @@ -334,13 +340,65 @@ const form: React.FC = ({ } }; + const [fileUrl, setFileUrl] = useState(''); + const [popUpNPWP, setPopUpNpwp] = useState(false); + const [popSppkp, setPopUpSppkp] = useState(false); + const [hasNPWP, sethasNpwp] = useState(false); + const [hasSPPKP, sethasSPPKP] = useState(false); + const [fileUrlSppkp, setFileUrlSppkp] = useState(''); + + useEffect(() => { + const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/download/npwp/109119`; + if (url) { + setFileUrl(url); + sethasNpwp(true); + } + const urlSppkp = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/download/sppkp/109119`; + if (urlSppkp) { + setFileUrlSppkp(urlSppkp); + sethasSPPKP(true); + } + }, []); + return ( <> + setPopUpNpwp(false)} + > +
+ +
+
+ setPopUpSppkp(false)} + > +
+ +
+
setIsExample(false)} + close={() => setPopUpNpwp(false)} >
= ({ ref={docsNpwpRef} readOnly={required} onChange={handleFileChange} - accept='.pdf,.doc,.docx,.png,.jpg,.jpeg' // Filter file types + accept='.pdf,.png,.jpg,.jpeg' // Filter file types /> {chekValid && isPKP && !required && !!errors.npwp_document && ( {errors.npwp_document} )} + + Format: .pdf, .png, .jpg, atau .jpeg, Maks 2MB + + {hasNPWP && ( +
+
+
+ + Dokumen sudah diupload +
+
+ setPopUpNpwp(true)} + className={`w-6 mr-2 hover:scale-110 transition-transform duration-200}`} + /> + sethasNpwp(false)} + className='w-6 hover:scale-110 transition-transform duration-200' + /> +
+
+
+ )}
-