Skip to content

Commit

Permalink
fix(funnel) : 페이지 퍼널 순서 변경
Browse files Browse the repository at this point in the history
Refs:[#4,#5]
  • Loading branch information
최현우 committed Dec 12, 2023
1 parent a6988f0 commit 12e6771
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
13 changes: 10 additions & 3 deletions component/form/UserAgreementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import MainButton from "../button/MainButton";

interface UserAgreementFormPropsType {
setFunnel: React.Dispatch<React.SetStateAction<string>>;
setProgress: React.Dispatch<React.SetStateAction<number>>;
}

const UserAgreementForm = ({ setFunnel }: UserAgreementFormPropsType) => {
const UserAgreementForm = ({
setFunnel,
setProgress,
}: UserAgreementFormPropsType) => {
const [checkedItems, setCheckedItems] = useState([false, false, false]);
const allChecked = checkedItems.every(Boolean);
const isIndeterminate = checkedItems.some(Boolean) && !allChecked;

console.log();
return (
<>
<Box as="section" alignSelf={"flex-start"}>
Expand Down Expand Up @@ -116,8 +119,12 @@ const UserAgreementForm = ({ setFunnel }: UserAgreementFormPropsType) => {
w={"100%"}
h={"52px"}
isDisabled={checkedItems.filter((ele) => ele).length !== 3}
onClick={() => {
setFunnel("userInfo");
setProgress((oldState) => oldState + 33.3);
}}
>
동의하고 시작하기
다음으로
</MainButton>
</ButtonGroup>
</>
Expand Down
9 changes: 8 additions & 1 deletion component/form/UserInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import MainInput from "../input/MainInput";
import MainButton from "../button/MainButton";
import { SubmitHandler, useForm } from "react-hook-form";
import { UserInfoType } from "@/app/signup/page";

function RadioCard(props: any) {
const { getInputProps, getRadioProps } = useRadio(props);
Expand Down Expand Up @@ -48,9 +49,14 @@ function RadioCard(props: any) {
interface UserInfoFormPropsType {
setFunnel: React.Dispatch<React.SetStateAction<string>>;
setProgress: React.Dispatch<React.SetStateAction<number>>;
setUserInfo: React.Dispatch<React.SetStateAction<UserInfoType>>;
}

const UserInfoForm = ({ setFunnel, setProgress }: UserInfoFormPropsType) => {
const UserInfoForm = ({
setFunnel,
setProgress,
setUserInfo,
}: UserInfoFormPropsType) => {
const options = ["남성", "여성"];

const { getRootProps, getRadioProps, value } = useRadioGroup({
Expand All @@ -65,6 +71,7 @@ const UserInfoForm = ({ setFunnel, setProgress }: UserInfoFormPropsType) => {

const onSubmit: SubmitHandler<SignUpFormType> = (data) => {
console.log(data, value);

setFunnel("userPhysics");
setProgress((oldState) => oldState + 33.3);
};
Expand Down
32 changes: 27 additions & 5 deletions src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ import UserPhysicForm from "../../../component/form/UserPhysicForm";
import UserAgreementForm from "../../../component/form/UserAgreementForm";
import { SubmitHandler, useForm } from "react-hook-form";

export interface UserInfoType {
userName: string;
gender: string;
age: number;
height: number;
weight: number;
targetWeight: number;
}

const Page = () => {
const [progress, setProgress] = useState<number>(33.3);
const { funnel, setFunnel } = useFunnel("userInfo");
const [userInfo, setUserInfo] = useState<UserInfoType>({
userName: "",
gender: "",
age: 0,
height: 0,
weight: 0,
targetWeight: 0,
});
const { funnel, setFunnel } = useFunnel("userAgreement");

return (
<>
Expand All @@ -20,6 +37,7 @@ const Page = () => {
isAnimated={true}
value={progress}
/>

<Flex
flexDir={"column"}
w={"100%"}
Expand All @@ -30,15 +48,19 @@ const Page = () => {
margin={"0 auto"}
alignItems={"center"}
>
{funnel === "userAgreement" && (
<UserAgreementForm setFunnel={setFunnel} setProgress={setProgress} />
)}
{funnel === "userInfo" && (
<UserInfoForm setFunnel={setFunnel} setProgress={setProgress} />
<UserInfoForm
setFunnel={setFunnel}
setProgress={setProgress}
setUserInfo={setUserInfo}
/>
)}
{funnel === "userPhysics" && (
<UserPhysicForm setFunnel={setFunnel} setProgress={setProgress} />
)}
{funnel === "userAgreement" && (
<UserAgreementForm setFunnel={setFunnel} />
)}
</Flex>
</>
);
Expand Down

0 comments on commit 12e6771

Please sign in to comment.