import { ChangeEvent, useEffect, useMemo, useState } from "react"; import FormBisnis from "./FormBisnis"; import Form from "./Form"; import TermCondition from "./TermCondition"; import FormCaptcha from "./FormCaptcha"; import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react' import React from "react"; import { ChevronDownIcon, ChevronRightIcon } from '@heroicons/react/24/outline'; import { useRegisterStore } from "../stores/useRegisterStore"; import { useMutation } from "react-query"; import { RegisterProps } from "~/types/auth"; import { registerUser } from "~/services/auth"; import router from "next/router"; import toast from "react-hot-toast"; import { useRouter } from "next/router"; import { UseToastOptions, useToast } from "@chakra-ui/react"; import Link from "next/link"; const RegistrasiBisnis = () => { const [isPKP, setIsPKP] = useState(true); const [isTerdaftar, setIsTerdaftar] = useState(false); const [isIndividuRequired, setIsIndividuRequired] = useState(true); const [isDropIndividu, setIsDropIndividu] = useState(true); const [isBisnisClicked, setisBisnisClicked] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); const { form, formBisnis, isCheckedTNC, isValidCaptcha, errors, updateFormBisnis, validateFormBisnis, validate, } = useRegisterStore() const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]) const toast = useToast() const mutation = useMutation({ mutationFn: (data: RegisterProps) => registerUser(data) }) useEffect(() => { if (selectedValue === "PKP") { updateFormBisnis("is_pkp", 'true'); validateFormBisnis(); } else { updateFormBisnis("is_pkp", 'false'); validateFormBisnis(); } }, [selectedValue,]); const handleChange = (value: string) => { setSelectedValue(value); if (value === "PKP") { validateFormBisnis(); setIsIndividuRequired(true); setIsPKP(true); } else { setIsPKP(false); setIsIndividuRequired(false); // Hide and make optional the Individu form setIsPKP(false); } }; const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); if (value === "true") { setIsTerdaftar(true); } else { setIsTerdaftar(false); } }; const handleClick = () => { setIsDropIndividu(!isDropIndividu) }; const handleClickBisnis = () => { setisBisnisClicked(!isBisnisClicked) }; const handleSubmit = async () => { console.log("form",form) console.log("form Bisnis",formBisnis) }; return ( <>
Data Akun
{isDropIndividu ? (Data Bisnis
{isBisnisClicked ? (Bisnis Terdaftar di Indoteknik?
Tipe Bisnis