diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-20 11:47:29 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-20 11:47:29 +0700 |
| commit | cf0f7a934bcf256d1daeee98e9f66397fb64b1ee (patch) | |
| tree | 41320c6a46d38487efe996c7fd5de2f067067ce4 /src-migrate/modules/register/components/RegistrasiBisnis.tsx | |
| parent | 00df44e6f25eaeabc56ebba8b4e9b1cb692928d7 (diff) | |
<iman> update new register
Diffstat (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx')
| -rw-r--r-- | src-migrate/modules/register/components/RegistrasiBisnis.tsx | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 217b4c79..c093d556 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useMemo, useState } from "react"; import FormBisnis from "./FormBisnis"; import Form from "./Form"; import TermCondition from "./TermCondition"; @@ -9,6 +9,10 @@ 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"; const RegistrasiBisnis = () => { const [isPKP, setIsPKP] = useState(false); @@ -16,6 +20,18 @@ const RegistrasiBisnis = () => { const [isIndividuRequired, setIsIndividuRequired] = useState(true); const [isBisnisRequired, setIsBisnisRequired] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); + const { + form, + isCheckedTNC, + isValidCaptcha, + errors, + updateForm, + validate, + } = useRegisterStore() + const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]) + const mutation = useMutation({ + mutationFn: (data: RegisterProps) => registerUser(data) + }) const handleChange = (value: string) => { setSelectedValue(value); @@ -38,8 +54,8 @@ const RegistrasiBisnis = () => { return ( <> - <div> - <p className="text-black font-bold">Tipe Bisnis</p> + <div className="mt-4"> + <p className="text-black font-bold mb-2">Tipe Bisnis</p> <RadioGroup onChange={handleChange} value={selectedValue}> <Stack direction='row'> <Radio value='PKP'>PKP</Radio> @@ -98,6 +114,13 @@ const RegistrasiBisnis = () => { </div> <FormCaptcha /> <TermCondition /> + <button + type="submit" + className="btn-yellow w-full mt-2" + disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha} + > + {mutation.isLoading ? 'Loading...' : 'Daftar'} + </button> </> ); }; |
