From 54b6b618effc8416027ed884be1d6d37257c26c4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 26 Aug 2024 11:59:57 +0700 Subject: update fungsion component --- .../modules/register/components/FormBisnis.tsx | 39 ++++++---------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'src-migrate/modules/register/components/FormBisnis.tsx') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 5d15ab6c..1d0c930f 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -10,6 +10,7 @@ import getFileBase64 from '@/core/utils/getFileBase64' 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'; interface FormProps { type: string; @@ -31,19 +32,15 @@ interface companyType { const form: React.FC = ({ type, required, isPKP }) => { const { form, - isCheckedTNC, - isValidCaptcha, errors, updateForm, validate } = useRegisterStore() const { control, watch, setValue } = useForm(); const [selectedCategory, setSelectedCategory] = useState(''); - const [selectedCompanyId, setSelectedCompanyId] = useState(''); const [industries, setIndustries] = useState([]); const [companyTypes, setCompanyTypes] = useState([]); - const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); const router = useRouter(); const toast = useToast(); @@ -60,7 +57,6 @@ const form: React.FC = ({ type, required, isPKP }) => { const selectedCompanyType = companyTypes.find(company => company.value === watch('companyType')); if (selectedCompanyType) { updateForm("company_type_id", `${selectedCompanyType?.value}`); - setSelectedCompanyId(selectedCompanyType?.label) validate(); } }, [watch('companyType'), companyTypes]); @@ -87,33 +83,26 @@ const form: React.FC = ({ type, required, isPKP }) => { updateForm('type_acc',`business`) updateForm('is_pkp',`${isPKP}`) updateForm(name, value); - updateForm('name',form.name); - updateForm('email',form.email); - updateForm('password',form.password); - updateForm('phone',form.phone); validate(); }; const handleFileChange = async (event: ChangeEvent) => { - // const file = poFile.current.files[0]; - // const name = poNumber.current.value; - // if (typeof file === 'undefined' || !name) { - // toast.error('Nomor dan Dokumen PO harus diisi'); - // return; - // } - // if (file.size > 5000000) { - // toast.error('Maksimal ukuran file adalah 5MB'); - // return; - // } - // const data = { name, file: await getFileBase64(file) }; + const toastProps: UseToastOptions = { + duration: 5000, + isClosable: true + }; let fileBase64 = ''; const { name} = event.target; const file = event.target.files?.[0]; if (file) { if (typeof file !== 'undefined') { if (file.size > 5000000) { - // toast.error('Maksimal ukuran file adalah 5MB') + toast({ + ...toastProps, + title: 'Maksimal ukuran file adalah 5MB', + status: 'warning' + }); return; } fileBase64 = await getFileBase64(file); @@ -310,14 +299,6 @@ const form: React.FC = ({ type, required, isPKP }) => { {isPKP && !required && !!errors.sppkp_document && {errors.sppkp_document}} - - {/* */} ) } -- cgit v1.2.3