From 00df44e6f25eaeabc56ebba8b4e9b1cb692928d7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 20 Aug 2024 10:27:32 +0700 Subject: add new register --- .../register/components/RegistrasiBisnis.tsx | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src-migrate/modules/register/components/RegistrasiBisnis.tsx (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx new file mode 100644 index 00000000..217b4c79 --- /dev/null +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -0,0 +1,105 @@ +import { useState } from "react"; +import FormBisnis from "./FormBisnis"; +import Form from "./Form"; +import TermCondition from "./TermCondition"; +import FormCaptcha from "./FormCaptcha"; +import { Radio, RadioGroup, Stack, Divider } from '@chakra-ui/react' +import React from "react"; +import { + ChevronDownIcon, + ChevronRightIcon +} from '@heroicons/react/24/outline'; + +const RegistrasiBisnis = () => { + const [isPKP, setIsPKP] = useState(false); + const [isTerdaftar, setIsTerdaftar] = useState(false); + const [isIndividuRequired, setIsIndividuRequired] = useState(true); + const [isBisnisRequired, setIsBisnisRequired] = useState(true); + const [selectedValue, setSelectedValue] = useState('PKP'); + + const handleChange = (value: string) => { + setSelectedValue(value); + if (value === "PKP") { + setIsPKP(true); + setIsIndividuRequired(true); // Show and require Individu form + } else { + setIsPKP(false); + setIsIndividuRequired(false); // Hide and make optional the Individu form + } + }; + + const handleClick = () => { + setIsIndividuRequired(!isIndividuRequired) + }; + + const handleClickBisnis = () => { + setIsBisnisRequired(!isBisnisRequired) + }; + + return ( + <> +
+

Tipe Bisnis

+ + + PKP + Non-PKP + + +
+
+
+
+

Data Akun

+ {isIndividuRequired ? ( +
+ +
+ ) : ( + + )} +
+ {isIndividuRequired && ( +
+ +
+
+ )} +
+
+
+
+
+

Data Bisnis

+ {isBisnisRequired ? ( +
+ +
+ ) : ( + + )} +
+ {isBisnisRequired && ( +
+ +
+

Bisnis Terdaftar di Indoteknik?

+ + + Sudah Terdaftar + Belum Terdaftar + + +
+ +
+ )} +
+
+ + + + ); +}; + +export default RegistrasiBisnis; -- cgit v1.2.3 From cf0f7a934bcf256d1daeee98e9f66397fb64b1ee Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 20 Aug 2024 11:47:29 +0700 Subject: update new register --- .../register/components/RegistrasiBisnis.tsx | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') 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 ( <> -
-

Tipe Bisnis

+
+

Tipe Bisnis

PKP @@ -98,6 +114,13 @@ const RegistrasiBisnis = () => {
+ ); }; -- cgit v1.2.3 From 1d3f68f4a61bb084938523dea2869087f915bf61 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 20 Aug 2024 15:21:31 +0700 Subject: update new register --- .../register/components/RegistrasiBisnis.tsx | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index c093d556..2c429f2d 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -20,8 +20,10 @@ const RegistrasiBisnis = () => { const [isIndividuRequired, setIsIndividuRequired] = useState(true); const [isBisnisRequired, setIsBisnisRequired] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); + const [selectedValueBisnis, setSelectedValueBisnis] = useState('true'); const { form, + formBisnis, isCheckedTNC, isValidCaptcha, errors, @@ -44,6 +46,15 @@ const RegistrasiBisnis = () => { } }; + const handleChangeBisnis = (value: string) => { + setSelectedValueBisnis(value); + if (value === "true") { + setIsBisnisRequired(true); // Show and require Individu form + } else { + setIsBisnisRequired(false); // Hide and make optional the Individu form + } + }; + const handleClick = () => { setIsIndividuRequired(!isIndividuRequired) }; @@ -52,6 +63,15 @@ const RegistrasiBisnis = () => { setIsBisnisRequired(!isBisnisRequired) }; + const handleSubmit = () => { + console.log("form",form) + console.log("form Bisnis",formBisnis) + }; + console.log("isFormValid",isFormValid) + console.log("isCheckedTNC",isCheckedTNC) + console.log("mutation.isLoading",mutation.isLoading) + console.log("isValidCaptcha",isValidCaptcha) + return ( <>
@@ -100,7 +120,7 @@ const RegistrasiBisnis = () => {

Bisnis Terdaftar di Indoteknik?

- + Sudah Terdaftar Belum Terdaftar @@ -112,15 +132,16 @@ const RegistrasiBisnis = () => { )}
- + ); }; -- cgit v1.2.3 From 0427b70917d7623d5de1969b99e9c198c38ccca7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 20 Aug 2024 15:53:01 +0700 Subject: { )}
+

+ - ); }; -- cgit v1.2.3 From 2f106583f644e29019828a9e8ed82e23c7c67d0a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 21 Aug 2024 10:01:27 +0700 Subject: update view new register --- .../register/components/RegistrasiBisnis.tsx | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index e454ff9c..91bf128f 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -3,7 +3,7 @@ import FormBisnis from "./FormBisnis"; import Form from "./Form"; import TermCondition from "./TermCondition"; import FormCaptcha from "./FormCaptcha"; -import { Radio, RadioGroup, Stack, Divider } from '@chakra-ui/react' +import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react' import React from "react"; import { ChevronDownIcon, @@ -18,7 +18,7 @@ const RegistrasiBisnis = () => { const [isPKP, setIsPKP] = useState(false); const [isTerdaftar, setIsTerdaftar] = useState(false); const [isIndividuRequired, setIsIndividuRequired] = useState(true); - const [isBisnisRequired, setIsBisnisRequired] = useState(true); + const [isBisnisClicked, setisBisnisClicked] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); const [selectedValueBisnis, setSelectedValueBisnis] = useState('true'); const { @@ -49,9 +49,9 @@ const RegistrasiBisnis = () => { const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); if (value === "true") { - setIsBisnisRequired(true); // Show and require Individu form + setIsTerdaftar(true); } else { - setIsBisnisRequired(false); // Hide and make optional the Individu form + setIsTerdaftar(true); } }; @@ -60,7 +60,7 @@ const RegistrasiBisnis = () => { }; const handleClickBisnis = () => { - setIsBisnisRequired(!isBisnisRequired) + setisBisnisClicked(!isBisnisClicked) }; const handleSubmit = () => { @@ -77,16 +77,18 @@ const RegistrasiBisnis = () => {

Tipe Bisnis

- - PKP - Non-PKP + + PKP + Non-PKP
-

Data Akun

+

+ Data Akun +

{isIndividuRequired ? (
@@ -106,8 +108,10 @@ const RegistrasiBisnis = () => {
-

Data Bisnis

- {isBisnisRequired ? ( +

+ Data Bisnis +

+ {isBisnisClicked ? (
@@ -115,15 +119,15 @@ const RegistrasiBisnis = () => { )}
- {isBisnisRequired && ( + {isBisnisClicked && (
-

Bisnis Terdaftar di Indoteknik?

+

Bisnis Terdaftar di Indoteknik?

- Sudah Terdaftar - Belum Terdaftar + Sudah Terdaftar + Belum Terdaftar
@@ -135,14 +139,16 @@ const RegistrasiBisnis = () => {

- + ); }; -- cgit v1.2.3 From 2ffc49bb65a16f07cf5a3b7e4926c34ea07b9460 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 21 Aug 2024 17:10:13 +0700 Subject: update new register --- .../register/components/RegistrasiBisnis.tsx | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 91bf128f..235e158a 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from "react"; +import { ChangeEvent, useEffect, useMemo, useState } from "react"; import FormBisnis from "./FormBisnis"; import Form from "./Form"; import TermCondition from "./TermCondition"; @@ -13,14 +13,19 @@ 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(false); + const [isPKP, setIsPKP] = useState(true); const [isTerdaftar, setIsTerdaftar] = useState(false); const [isIndividuRequired, setIsIndividuRequired] = useState(true); const [isBisnisClicked, setisBisnisClicked] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); - const [selectedValueBisnis, setSelectedValueBisnis] = useState('true'); + const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); const { form, formBisnis, @@ -28,17 +33,30 @@ const RegistrasiBisnis = () => { isValidCaptcha, errors, updateForm, + 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") { - setIsPKP(true); + validateFormBisnis(); setIsIndividuRequired(true); // Show and require Individu form } else { setIsPKP(false); @@ -51,7 +69,7 @@ const RegistrasiBisnis = () => { if (value === "true") { setIsTerdaftar(true); } else { - setIsTerdaftar(true); + setIsTerdaftar(false); } }; @@ -63,15 +81,10 @@ const RegistrasiBisnis = () => { setisBisnisClicked(!isBisnisClicked) }; - const handleSubmit = () => { + const handleSubmit = async () => { console.log("form",form) console.log("form Bisnis",formBisnis) }; - console.log("isFormValid",isFormValid) - console.log("isCheckedTNC",isCheckedTNC) - console.log("mutation.isLoading",mutation.isLoading) - console.log("isValidCaptcha",isValidCaptcha) - return ( <>
@@ -131,7 +144,7 @@ const RegistrasiBisnis = () => {
- +
)}
-- cgit v1.2.3 From 6623dba2f6cd4a4ca7b25f7086991afef092cd26 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 22 Aug 2024 15:48:00 +0700 Subject: update new register view --- .../register/components/RegistrasiBisnis.tsx | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 235e158a..55180297 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -23,6 +23,7 @@ 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'); @@ -53,14 +54,16 @@ const RegistrasiBisnis = () => { } }, [selectedValue,]); - const handleChange = (value: string) => { + const handleChange = (value: string) => { setSelectedValue(value); if (value === "PKP") { validateFormBisnis(); - setIsIndividuRequired(true); // Show and require Individu form + setIsIndividuRequired(true); + setIsPKP(true); } else { setIsPKP(false); setIsIndividuRequired(false); // Hide and make optional the Individu form + setIsPKP(false); } }; @@ -74,7 +77,7 @@ const RegistrasiBisnis = () => { }; const handleClick = () => { - setIsIndividuRequired(!isIndividuRequired) + setIsDropIndividu(!isDropIndividu) }; const handleClickBisnis = () => { @@ -87,22 +90,14 @@ const RegistrasiBisnis = () => { }; return ( <> -
-

Tipe Bisnis

- - - PKP - Non-PKP - - -
+

Data Akun

- {isIndividuRequired ? ( + {isDropIndividu ? (
@@ -110,10 +105,10 @@ const RegistrasiBisnis = () => { )}
- {isIndividuRequired && ( + {isDropIndividu && (
- +
)}
@@ -144,7 +139,16 @@ const RegistrasiBisnis = () => {
- +
+

Tipe Bisnis

+ + + PKP + Non-PKP + + +
+
)}
-- cgit v1.2.3 From fb346e50e06ed68508662ca3d004db2c2cc117eb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 22 Aug 2024 16:48:03 +0700 Subject: update new register --- src-migrate/modules/register/components/RegistrasiBisnis.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 55180297..12ec7ba2 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -33,7 +33,6 @@ const RegistrasiBisnis = () => { isCheckedTNC, isValidCaptcha, errors, - updateForm, updateFormBisnis, validateFormBisnis, validate, @@ -108,7 +107,7 @@ const RegistrasiBisnis = () => { {isDropIndividu && (
- +
)}
-- cgit v1.2.3 From 0bca1bfb2bc7e52a31dde39602dd599d7c640e73 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 24 Aug 2024 08:46:44 +0700 Subject: update new register --- .../register/components/RegistrasiBisnis.tsx | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 12ec7ba2..6ace27f9 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -86,6 +86,42 @@ const RegistrasiBisnis = () => { const handleSubmit = async () => { console.log("form",form) console.log("form Bisnis",formBisnis) + const response = await mutation.mutateAsync(formBisnis) + + console.log("response",response) + + if (response?.register === true) { + const urlParams = new URLSearchParams({ + activation: 'otp', + email: form.email, + redirect: (router.query?.next || '/') as string + }) + router.push(`${router.route}?${urlParams}`) + } + + const toastProps: UseToastOptions = { + duration: 5000, + isClosable: true + } + + switch (response?.reason) { + case 'EMAIL_USED': + toast({ + ...toastProps, + title: 'Email sudah digunakan', + status: 'warning' + }) + break; + case 'NOT_ACTIVE': + const activationUrl = `${router.route}?activation=email` + toast({ + ...toastProps, + title: 'Akun belum aktif', + description: <>Akun sudah terdaftar namun belum aktif. Klik untuk aktivasi akun, + status: 'warning' + }) + break + } }; return ( <> -- cgit v1.2.3 From f0cde08a3fda95b1738a765358022241aea404bf Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 26 Aug 2024 10:28:15 +0700 Subject: update logic new register validation --- .../register/components/RegistrasiBisnis.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 6ace27f9..b8ea5fff 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -29,13 +29,11 @@ const RegistrasiBisnis = () => { const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); const { form, - formBisnis, isCheckedTNC, isValidCaptcha, errors, - updateFormBisnis, - validateFormBisnis, validate, + updateForm } = useRegisterStore() const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]) const toast = useToast() @@ -45,18 +43,18 @@ const RegistrasiBisnis = () => { useEffect(() => { if (selectedValue === "PKP") { - updateFormBisnis("is_pkp", 'true'); - validateFormBisnis(); + updateForm("is_pkp", 'true'); + validate(); } else { - updateFormBisnis("is_pkp", 'false'); - validateFormBisnis(); + updateForm("is_pkp", 'false'); + validate(); } }, [selectedValue,]); const handleChange = (value: string) => { setSelectedValue(value); if (value === "PKP") { - validateFormBisnis(); + validate(); setIsIndividuRequired(true); setIsPKP(true); } else { @@ -68,9 +66,12 @@ const RegistrasiBisnis = () => { const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); + console.log('value',value) if (value === "true") { + updateForm('is_terdaftar','true') setIsTerdaftar(true); } else { + updateForm('is_terdaftar','false') setIsTerdaftar(false); } }; @@ -85,8 +86,8 @@ const RegistrasiBisnis = () => { const handleSubmit = async () => { console.log("form",form) - console.log("form Bisnis",formBisnis) - const response = await mutation.mutateAsync(formBisnis) + console.log("form Bisnis",form) + const response = await mutation.mutateAsync(form) console.log("response",response) -- cgit v1.2.3 From ad3038d8902245ba0ec4122dc9795cda3906ba0e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 26 Aug 2024 10:52:10 +0700 Subject: update new register handling validation --- src-migrate/modules/register/components/RegistrasiBisnis.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index b8ea5fff..c158e2f4 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -58,19 +58,22 @@ const RegistrasiBisnis = () => { setIsIndividuRequired(true); setIsPKP(true); } else { + validate(); setIsPKP(false); setIsIndividuRequired(false); // Hide and make optional the Individu form setIsPKP(false); } }; - + const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); console.log('value',value) if (value === "true") { + validate(); updateForm('is_terdaftar','true') setIsTerdaftar(true); } else { + validate(); updateForm('is_terdaftar','false') setIsTerdaftar(false); } -- cgit v1.2.3 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 --- .../register/components/RegistrasiBisnis.tsx | 59 +--------------------- 1 file changed, 2 insertions(+), 57 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index c158e2f4..443ff0a0 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -14,7 +14,6 @@ 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"; @@ -22,7 +21,6 @@ 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'); @@ -55,19 +53,16 @@ const RegistrasiBisnis = () => { setSelectedValue(value); if (value === "PKP") { validate(); - setIsIndividuRequired(true); setIsPKP(true); } else { validate(); setIsPKP(false); - setIsIndividuRequired(false); // Hide and make optional the Individu form setIsPKP(false); } }; const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); - console.log('value',value) if (value === "true") { validate(); updateForm('is_terdaftar','true') @@ -87,46 +82,6 @@ const RegistrasiBisnis = () => { setisBisnisClicked(!isBisnisClicked) }; - const handleSubmit = async () => { - console.log("form",form) - console.log("form Bisnis",form) - const response = await mutation.mutateAsync(form) - - console.log("response",response) - - if (response?.register === true) { - const urlParams = new URLSearchParams({ - activation: 'otp', - email: form.email, - redirect: (router.query?.next || '/') as string - }) - router.push(`${router.route}?${urlParams}`) - } - - const toastProps: UseToastOptions = { - duration: 5000, - isClosable: true - } - - switch (response?.reason) { - case 'EMAIL_USED': - toast({ - ...toastProps, - title: 'Email sudah digunakan', - status: 'warning' - }) - break; - case 'NOT_ACTIVE': - const activationUrl = `${router.route}?activation=email` - toast({ - ...toastProps, - title: 'Akun belum aktif', - description: <>Akun sudah terdaftar namun belum aktif. Klik untuk aktivasi akun, - status: 'warning' - }) - break - } - }; return ( <> @@ -192,19 +147,9 @@ const RegistrasiBisnis = () => { )}
+

- - - + ); }; -- cgit v1.2.3 From 0b5f187f45e0bbf111e11a94415f20d5e34f7c5c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 27 Aug 2024 14:51:14 +0700 Subject: update new field register --- src-migrate/modules/register/components/RegistrasiBisnis.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 443ff0a0..1d8317f1 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -48,6 +48,16 @@ const RegistrasiBisnis = () => { validate(); } }, [selectedValue,]); + + useEffect(() => { + if (isTerdaftar) { + updateForm("is_terdaftar", 'true'); + validate(); + } else { + updateForm("is_terdaftar", 'false'); + validate(); + } + }, [isTerdaftar,]); const handleChange = (value: string) => { setSelectedValue(value); @@ -65,11 +75,9 @@ const RegistrasiBisnis = () => { setSelectedValueBisnis(value); if (value === "true") { validate(); - updateForm('is_terdaftar','true') setIsTerdaftar(true); } else { validate(); - updateForm('is_terdaftar','false') setIsTerdaftar(false); } }; -- cgit v1.2.3 From 6ff5efdb4b7eec25f991f5bfcc02b4a3f883981b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 11 Sep 2024 10:04:31 +0700 Subject: update error handling hanya muncul saat button daftar di click --- .../register/components/RegistrasiBisnis.tsx | 190 ++++++++++++--------- 1 file changed, 108 insertions(+), 82 deletions(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 1d8317f1..36476ab9 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -1,67 +1,60 @@ -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 { useRouter } from "next/router"; -import { UseToastOptions, useToast } from "@chakra-ui/react"; -import Link from "next/link"; - -const RegistrasiBisnis = () => { +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 { useRouter } from 'next/router'; +import { UseToastOptions, useToast } from '@chakra-ui/react'; +import Link from 'next/link'; +interface FormProps { + chekValid: boolean; +} +const RegistrasiBisnis: React.FC = ({ chekValid }) => { const [isPKP, setIsPKP] = useState(true); const [isTerdaftar, setIsTerdaftar] = useState(false); const [isDropIndividu, setIsDropIndividu] = useState(true); const [isBisnisClicked, setisBisnisClicked] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); - const { - form, - isCheckedTNC, - isValidCaptcha, - errors, - validate, - updateForm - } = useRegisterStore() - const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]) - const toast = useToast() + const { form, isCheckedTNC, isValidCaptcha, errors, validate, updateForm } = + useRegisterStore(); + const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); + const toast = useToast(); const mutation = useMutation({ - mutationFn: (data: RegisterProps) => registerUser(data) - }) + mutationFn: (data: RegisterProps) => registerUser(data), + }); useEffect(() => { - if (selectedValue === "PKP") { - updateForm("is_pkp", 'true'); + if (selectedValue === 'PKP') { + updateForm('is_pkp', 'true'); validate(); } else { - updateForm("is_pkp", 'false'); + updateForm('is_pkp', 'false'); validate(); } - }, [selectedValue,]); - + }, [selectedValue]); + useEffect(() => { if (isTerdaftar) { - updateForm("is_terdaftar", 'true'); + updateForm('is_terdaftar', 'true'); validate(); } else { - updateForm("is_terdaftar", 'false'); + updateForm('is_terdaftar', 'false'); validate(); } - }, [isTerdaftar,]); + }, [isTerdaftar]); - const handleChange = (value: string) => { + const handleChange = (value: string) => { setSelectedValue(value); - if (value === "PKP") { + if (value === 'PKP') { validate(); setIsPKP(true); } else { @@ -70,10 +63,10 @@ const RegistrasiBisnis = () => { setIsPKP(false); } }; - + const handleChangeBisnis = (value: string) => { setSelectedValueBisnis(value); - if (value === "true") { + if (value === 'true') { validate(); setIsTerdaftar(true); } else { @@ -83,81 +76,114 @@ const RegistrasiBisnis = () => { }; const handleClick = () => { - setIsDropIndividu(!isDropIndividu) + setIsDropIndividu(!isDropIndividu); }; const handleClickBisnis = () => { - setisBisnisClicked(!isBisnisClicked) + setisBisnisClicked(!isBisnisClicked); }; return ( <> - -
-
-
-

+

+
+
+

Data Akun

{isDropIndividu ? ( -
- +
+
) : ( - + )}
{isDropIndividu && (
- - + +
)}
-
-
-
-

+

+
+
+

Data Bisnis

{isBisnisClicked ? ( -
- +
+
) : ( - + )}
{isBisnisClicked && (
- +
-

Bisnis Terdaftar di Indoteknik?

- +

+ Bisnis Terdaftar di Indoteknik? +

+ - Sudah Terdaftar - Belum Terdaftar + + Sudah Terdaftar + + + Belum Terdaftar +
-
-

Tipe Bisnis

- - - PKP - Non-PKP - - -
- +
+

Tipe Bisnis

+ + + + PKP + + + Non-PKP + + + +
+
)}
- -

- + +

); }; -- cgit v1.2.3 From aaf907c834343970e1d30b3ef49c13ed5f9d34ed Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 17 Sep 2024 09:01:04 +0700 Subject: add focus error when button submit click --- src-migrate/modules/register/components/RegistrasiBisnis.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index 36476ab9..ce4d3972 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -16,8 +16,12 @@ import { UseToastOptions, useToast } from '@chakra-ui/react'; import Link from 'next/link'; interface FormProps { chekValid: boolean; + buttonSubmitClick: boolean; } -const RegistrasiBisnis: React.FC = ({ chekValid }) => { +const RegistrasiBisnis: React.FC = ({ + chekValid, + buttonSubmitClick, +}) => { const [isPKP, setIsPKP] = useState(true); const [isTerdaftar, setIsTerdaftar] = useState(false); const [isDropIndividu, setIsDropIndividu] = useState(true); @@ -113,6 +117,7 @@ const RegistrasiBisnis: React.FC = ({ chekValid }) => { required={true} isBisnisRegist={true} chekValid={chekValid} + buttonSubmitClick={buttonSubmitClick} />
)} @@ -177,6 +182,7 @@ const RegistrasiBisnis: React.FC = ({ chekValid }) => { required={isTerdaftar} isPKP={isPKP} chekValid={chekValid} + buttonSubmitClick={buttonSubmitClick} />
)} -- cgit v1.2.3