From 6fdef6deeaa9ff46f14b0eeb73ae71f24f793081 Mon Sep 17 00:00:00 2001 From: Jeongmin Lee Date: Mon, 7 Oct 2024 00:56:32 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80=20UI=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=8D=BC=EB=B8=94=EB=A6=AC?= =?UTF-8?q?=EC=8B=B1=20#51?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_components/MypageSettingsKeywords.tsx | 118 ++++++++++++++++++ .../_components/MypageSettingsProfile.tsx | 61 +++++++++ .../_components/MypageSettingsTab.tsx | 85 +++++++++++++ src/app/mypage/settings/page.tsx | 21 ++++ src/app/mypage/settings/view.tsx | 35 ++++++ src/validations/ProfileUpdateSchema.ts | 26 ++++ 6 files changed, 346 insertions(+) create mode 100644 src/app/mypage/settings/_components/MypageSettingsKeywords.tsx create mode 100644 src/app/mypage/settings/_components/MypageSettingsProfile.tsx create mode 100644 src/app/mypage/settings/_components/MypageSettingsTab.tsx create mode 100644 src/app/mypage/settings/page.tsx create mode 100644 src/app/mypage/settings/view.tsx create mode 100644 src/validations/ProfileUpdateSchema.ts diff --git a/src/app/mypage/settings/_components/MypageSettingsKeywords.tsx b/src/app/mypage/settings/_components/MypageSettingsKeywords.tsx new file mode 100644 index 0000000..c265d94 --- /dev/null +++ b/src/app/mypage/settings/_components/MypageSettingsKeywords.tsx @@ -0,0 +1,118 @@ +"use client"; + +import { zodResolver } from "@hookform/resolvers/zod"; +import { FC } from "react"; +import { Controller, useForm } from "react-hook-form"; + +import { + FestivalCategory, + FestivalCompanion, + FestivalMood, + FestivalPriority, +} from "@/apis/onboarding/onboardingType"; +import { BasicButton } from "@/components/core/Button"; +import { + CategoryKeywordInput, + MoodKeywordInput, +} from "@/components/core/Input"; +import { PriorityKeywordInput } from "@/components/core/Input/KeywordInput"; +import CompanionKeywordInput from "@/components/core/Input/KeywordInput/ConpanionKeywordInput"; +import { + ProfileUpdateSchema, + ProfileUpdateSchemaType, +} from "@/validations/ProfileUpdateSchema"; + +interface Props { + categories: Array; + companions: Array; + priorities: Array; + moods: Array; +} + +const MypageSettingsKeywords: FC = ({ + categories, + companions, + priorities, + moods, +}) => { + const { handleSubmit, control } = useForm({ + defaultValues: { + categoryIds: [], + moodIds: [], + companionIds: [], + priorityIds: [], + }, + resolver: zodResolver(ProfileUpdateSchema), + }); + + const onSubmit = (data: ProfileUpdateSchemaType) => { + console.log(data); + }; + + return ( +
+ ( + + )} + /> + + ( + + )} + /> + ( + + )} + /> + ( + + )} + /> + + + + ); +}; + +export default MypageSettingsKeywords; diff --git a/src/app/mypage/settings/_components/MypageSettingsProfile.tsx b/src/app/mypage/settings/_components/MypageSettingsProfile.tsx new file mode 100644 index 0000000..ad9f22e --- /dev/null +++ b/src/app/mypage/settings/_components/MypageSettingsProfile.tsx @@ -0,0 +1,61 @@ +"use client"; + +import React from "react"; +import { Controller, useForm } from "react-hook-form"; + +import { BasicButton } from "@/components/core/Button"; +import { TextInput } from "@/components/core/Input"; + +const MypageSettingsProfile = () => { + const { control, handleSubmit } = useForm({ + values: { + nickname: "", + statusMessage: "", + }, + }); + + const onSubmit = () => {}; + + return ( +
+ ( + + )} + /> + + ( + + )} + /> + + + + ); +}; + +export default MypageSettingsProfile; diff --git a/src/app/mypage/settings/_components/MypageSettingsTab.tsx b/src/app/mypage/settings/_components/MypageSettingsTab.tsx new file mode 100644 index 0000000..78d6f50 --- /dev/null +++ b/src/app/mypage/settings/_components/MypageSettingsTab.tsx @@ -0,0 +1,85 @@ +"use client"; + +import * as Tabs from "@radix-ui/react-tabs"; +import { FC } from "react"; + +import { + FestivalCategory, + FestivalCompanion, + FestivalMood, + FestivalPriority, +} from "@/apis/onboarding/onboardingType"; + +import MypageSettingsKeywords from "./MypageSettingsKeywords"; +import MypageSettingsProfile from "./MypageSettingsProfile"; + +interface Props { + categories: Array; + companions: Array; + priorities: Array; + moods: Array; +} + +const MypageSettingsTab: FC = ({ + categories, + companions, + priorities, + moods, +}) => { + const TabList = [ + { + name: "기본정보", + contentComponent: , + }, + { + name: "맞춤 필터", + contentComponent: ( + + ), + }, + ]; + + const handleTabChange = () => { + const tabElement = document.getElementById(`tab`); + if (tabElement) { + tabElement.scrollIntoView({ behavior: "smooth" }); + } + }; + + return ( + + + {TabList.map(({ name }, index) => ( + + {name} + + ))} + + {TabList.map(({ name, contentComponent }) => ( + + {contentComponent} + + ))} + + ); +}; + +export default MypageSettingsTab; diff --git a/src/app/mypage/settings/page.tsx b/src/app/mypage/settings/page.tsx new file mode 100644 index 0000000..f3e7dc4 --- /dev/null +++ b/src/app/mypage/settings/page.tsx @@ -0,0 +1,21 @@ +import { getOnboardingData } from "@/apis/onboarding/onboarding"; +import { DefaultHeader } from "@/layout/Mobile/MobileHeader"; + +import MypageSettingsView from "./view"; + +export default async function MypageSettingsPage() { + const { moods, categories, companions, priorities } = + await getOnboardingData(); + + return ( +
+ + +
+ ); +} diff --git a/src/app/mypage/settings/view.tsx b/src/app/mypage/settings/view.tsx new file mode 100644 index 0000000..7a925e0 --- /dev/null +++ b/src/app/mypage/settings/view.tsx @@ -0,0 +1,35 @@ +import { FC } from "react"; + +import { + FestivalCategory, + FestivalCompanion, + FestivalMood, + FestivalPriority, +} from "@/apis/onboarding/onboardingType"; + +import MypageSettingsTab from "./_components/MypageSettingsTab"; + +interface Props { + categories: Array; + companions: Array; + priorities: Array; + moods: Array; +} + +const MypageSettingsView: FC = ({ + categories, + companions, + priorities, + moods, +}) => { + return ( + + ); +}; + +export default MypageSettingsView; diff --git a/src/validations/ProfileUpdateSchema.ts b/src/validations/ProfileUpdateSchema.ts new file mode 100644 index 0000000..dfef722 --- /dev/null +++ b/src/validations/ProfileUpdateSchema.ts @@ -0,0 +1,26 @@ +import { z } from "zod"; + +import { ONBOARDING_SETTING } from "@/config"; + +const MoodsSchema = z + .array(z.number()) + .min(ONBOARDING_SETTING.MOOD_MIN, "at least three items"); + +const PrioritiesSchema = z + .array(z.number()) + .min(ONBOARDING_SETTING.PRIORITY_MIN, "at least one item"); + +const companionsSchema = z.array(z.number()).min(1, "at least one item"); + +const CategoriesSchema = z + .array(z.number()) + .min(ONBOARDING_SETTING.CATEGORY_MIN, "at least two items"); + +export const ProfileUpdateSchema = z.object({ + categoryIds: CategoriesSchema, + moodIds: MoodsSchema, + companionIds: companionsSchema, + priorityIds: PrioritiesSchema, +}); + +export type ProfileUpdateSchemaType = z.output;