summaryrefslogtreecommitdiff
path: root/src-migrate/modules/register/components/FormBisnis.tsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-26 11:59:57 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-26 11:59:57 +0700
commit54b6b618effc8416027ed884be1d6d37257c26c4 (patch)
treeee02fc830ac6eaf4b6652032b33d0c6ecdd25cc8 /src-migrate/modules/register/components/FormBisnis.tsx
parentad3038d8902245ba0ec4122dc9795cda3906ba0e (diff)
<iman> update fungsion component
Diffstat (limited to 'src-migrate/modules/register/components/FormBisnis.tsx')
-rw-r--r--src-migrate/modules/register/components/FormBisnis.tsx39
1 files changed, 10 insertions, 29 deletions
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<FormProps> = ({ type, required, isPKP }) => {
const {
form,
- isCheckedTNC,
- isValidCaptcha,
errors,
updateForm,
validate
} = useRegisterStore()
const { control, watch, setValue } = useForm();
const [selectedCategory, setSelectedCategory] = useState<string>('');
- const [selectedCompanyId, setSelectedCompanyId] = useState<string>('');
const [industries, setIndustries] = useState<industry_id[]>([]);
const [companyTypes, setCompanyTypes] = useState<companyType[]>([]);
- const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
const router = useRouter();
const toast = useToast();
@@ -60,7 +57,6 @@ const form: React.FC<FormProps> = ({ 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<FormProps> = ({ 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<HTMLInputElement>) => {
- // 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<FormProps> = ({ type, required, isPKP }) => {
{isPKP && !required && !!errors.sppkp_document && <span className="form-msg-danger">{errors.sppkp_document}</span>}
</div>
-
- {/* <button
- type="submit"
- className="btn-yellow w-full mt-2"
- disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha}
- >
- {mutation.isLoading ? 'Loading...' : 'Daftar'}
- </button> */}
</form>
)
}