-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/profile builder #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d24e1ef
feat: page.tsx형식 통일 및 profile-builder 디자인시작
dasosann d4bde27
feat: profile-builder 제작
dasosann e34076f
feat: 주석 복원
dasosann abf19d6
feat: 관심사 분리
dasosann 0756296
feat: implement multi-step profile builder screen with basic informat…
dasosann 8775b96
fix: 드롭다운버튼으로 변경
dasosann 834a939
feat: hobby select 및 css설정
dasosann 742478e
feat: 검색 컴포넌트 추가 및 검색기능연결
dasosann 6219f03
feat: 검색기능 추가 및 연결
dasosann 88aec54
feat: 코드리뷰 반영
dasosann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,5 @@ | ||
| import React from "react"; | ||
| import ScreenOnBoarding from "./_components/ScreenOnBoarding"; | ||
|
|
||
| const page = () => { | ||
| export default function OnboardingPage() { | ||
| return <ScreenOnBoarding />; | ||
| }; | ||
|
|
||
| export default page; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import ScreenLoginPage from "@/app/_components/ScreenLoginPage"; | ||
|
|
||
| export default function Home() { | ||
| export default function HomePage() { | ||
| return <ScreenLoginPage />; | ||
| } |
246 changes: 246 additions & 0 deletions
246
app/profile-builder/_components/ScreenProfileBuilder.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,246 @@ | ||
| "use client"; | ||
|
|
||
| import React, { useActionState, useEffect, useState } from "react"; | ||
| import Button from "@/components/ui/Button"; | ||
| import { useProfile } from "@/providers/profile-provider"; | ||
| import { | ||
| profileBuilderAction, | ||
| type ProfileBuilderState, | ||
| } from "@/lib/actions/profileBuilderAction"; | ||
| import { majorCategories, universities } from "@/lib/constants/majors"; | ||
| import ProgressStepBar from "@/components/ui/ProgressStepBar"; | ||
| import Step1Basic from "./Step1Basic"; | ||
| import Step2Gender from "./Step2Gender"; | ||
| import Step3MBTI from "./Step3MBTI"; | ||
| import Step4ContactFrequency from "./Step4ContactFrequency"; | ||
|
|
||
| const initialState: ProfileBuilderState = { | ||
| success: false, | ||
| message: "", | ||
| }; | ||
|
|
||
| export const ScreenProfileBuilder = () => { | ||
| const { profile, updateProfile, isReady } = useProfile(); | ||
| const [state, formAction, isPending] = useActionState( | ||
| profileBuilderAction, | ||
| initialState, | ||
| ); | ||
| const [currentStep, setCurrentStep] = useState(1); | ||
| const [selectedUniversity, setSelectedUniversity] = useState<string>( | ||
| profile.university || "가톨릭대학교", | ||
| ); | ||
| const [selectedDepartment, setSelectedDepartment] = useState<string>(""); | ||
| const [selectedMajor, setSelectedMajor] = useState<string>(""); | ||
| const [selectedGender, setSelectedGender] = useState<string>(""); | ||
| const [selectedMBTI, setSelectedMBTI] = useState<string>(""); | ||
| const [selectedFrequency, setSelectedFrequency] = useState<string>(""); | ||
|
|
||
| // 성공 시 Context 업데이트 및 다음 페이지로 이동 | ||
| useEffect(() => { | ||
| if (state.success && state.data) { | ||
| updateProfile(state.data); | ||
| // TODO: 다음 온보딩 페이지로 이동 | ||
| // router.push("/next-step"); | ||
| console.log("Profile updated:", state.data); | ||
| } | ||
| }, [state.success, state.data, updateProfile]); | ||
|
|
||
| // localStorage 로딩 전에는 스켈레톤 UI 표시 | ||
| if (!isReady) { | ||
| return ( | ||
| <div className="relative flex min-h-screen animate-pulse flex-col bg-white px-4 pb-32"> | ||
| {/* 헤더 스켈레톤 */} | ||
| <div className="mt-16 mb-8"> | ||
| <div className="mb-2 h-8 w-48 rounded bg-gray-200" /> | ||
| <div className="mb-1 h-4 w-full rounded bg-gray-200" /> | ||
| <div className="h-4 w-3/4 rounded bg-gray-200" /> | ||
| </div> | ||
|
|
||
| {/* 폼 스켈레톤 */} | ||
| <div className="flex flex-col gap-6"> | ||
| {/* 나이 */} | ||
| <div className="flex flex-col gap-2"> | ||
| <div className="h-5 w-12 rounded bg-gray-200" /> | ||
| <div className="h-12 w-full rounded bg-gray-200" /> | ||
| </div> | ||
|
|
||
| {/* 학교 */} | ||
| <div className="flex flex-col gap-2"> | ||
| <div className="h-5 w-12 rounded bg-gray-200" /> | ||
| <div className="h-12 w-full rounded bg-gray-200" /> | ||
| </div> | ||
|
|
||
| {/* 학과 / 전공 */} | ||
| <div className="grid grid-cols-2 gap-3"> | ||
| <div className="flex flex-col gap-2"> | ||
| <div className="h-5 w-12 rounded bg-gray-200" /> | ||
| <div className="h-12 w-full rounded bg-gray-200" /> | ||
| </div> | ||
| <div className="flex flex-col gap-2"> | ||
| <div className="h-5 w-12 rounded bg-gray-200" /> | ||
| <div className="h-12 w-full rounded bg-gray-200" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* 버튼 스켈레톤 */} | ||
| <div className="fixed right-4 bottom-6 left-4 h-12 rounded-[16px] bg-gray-200" /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // 연도 옵션 생성 (1997 ~ 2020) - 1997년생부터 가입 가능 | ||
| const yearOptions = Array.from({ length: 24 }, (_, i) => ({ | ||
| value: String(1997 + i), | ||
| label: `${1997 + i}년`, | ||
| })); | ||
|
|
||
| // 대학 옵션 | ||
| const universityOptions = universities.map((uni) => ({ | ||
| value: uni, | ||
| label: uni, | ||
| })); | ||
|
|
||
| // 선택된 학교에 따른 계열(학과) 옵션 | ||
| const getDepartmentOptions = () => { | ||
| const university = majorCategories.find( | ||
| (cat) => cat.label === selectedUniversity, | ||
| ); | ||
|
|
||
| if (!university) return []; | ||
|
|
||
| return university.departments.map((dept) => ({ | ||
| value: dept.label, | ||
| label: dept.label, | ||
| })); | ||
| }; | ||
|
|
||
| // 선택된 계열에 따른 전공 옵션 | ||
| const getMajorOptions = () => { | ||
| const university = majorCategories.find( | ||
| (cat) => cat.label === selectedUniversity, | ||
| ); | ||
|
|
||
| if (!university) return []; | ||
|
|
||
| const department = university.departments.find( | ||
| (dept) => dept.label === selectedDepartment, | ||
| ); | ||
|
|
||
| if (!department) return []; | ||
|
|
||
| return department.majors.map((major) => ({ | ||
| value: major, | ||
| label: major, | ||
| })); | ||
| }; | ||
|
|
||
| const departmentOptions = getDepartmentOptions(); | ||
| const majorOptions = getMajorOptions(); | ||
|
|
||
| const handleNext = () => { | ||
| if (currentStep < 4) { | ||
| setCurrentStep(currentStep + 1); | ||
| } | ||
| }; | ||
|
|
||
| const getStepTitle = () => { | ||
| switch (currentStep) { | ||
| case 1: | ||
| return "전공이 어떻게 되세요?"; | ||
| case 2: | ||
| return "성별을 알려주세요"; | ||
| case 3: | ||
| return "본인의 MBTI를 알려 주세요"; | ||
| case 4: | ||
| return "연락빈도를 알려 주세요"; | ||
| default: | ||
| return " "; | ||
| } | ||
| }; | ||
|
dasosann marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <form | ||
| action={currentStep === 4 ? formAction : undefined} | ||
| onSubmit={(e) => { | ||
| if (currentStep < 4) { | ||
| e.preventDefault(); | ||
| handleNext(); | ||
| } | ||
| }} | ||
| className="relative flex min-h-screen flex-col bg-white px-4 pb-32" | ||
| > | ||
| {/* 헤더 영역 */} | ||
| <ProgressStepBar currentStep={1} totalSteps={3} /> | ||
|
dasosann marked this conversation as resolved.
|
||
| <div className="mt-8 mb-10 text-center"> | ||
| <h1 className="typo-24-700 text-color-gray-900 mb-2"> | ||
| {getStepTitle()} | ||
| </h1> | ||
| <p className="typo-14-400 text-color-text-caption2"> | ||
| 정보를 정확하게 입력했는지 확인해 주세요. | ||
| <br /> | ||
| 별로 오래 걸리지 않아요! | ||
| </p> | ||
| </div> | ||
|
|
||
| {/* 폼 영역 */} | ||
| <div className="flex flex-col gap-6"> | ||
| {/* Step 4: currentStep >= 4일 때 표시 */} | ||
| {currentStep >= 4 && ( | ||
| <Step4ContactFrequency | ||
| onFrequencySelect={setSelectedFrequency} | ||
| defaultValue={selectedFrequency} | ||
| /> | ||
| )} | ||
|
|
||
| {/* Step 3: currentStep >= 3일 때 표시 */} | ||
| {currentStep >= 3 && ( | ||
| <Step3MBTI | ||
| onMBTISelect={setSelectedMBTI} | ||
| defaultValue={selectedMBTI} | ||
| /> | ||
| )} | ||
|
|
||
| {/* Step 2: currentStep >= 2일 때 표시 */} | ||
| {currentStep >= 2 && ( | ||
| <Step2Gender | ||
| onGenderSelect={setSelectedGender} | ||
| defaultValue={selectedGender} | ||
| /> | ||
| )} | ||
|
|
||
| {/* Step 1: 항상 표시 */} | ||
| <Step1Basic | ||
| yearOptions={yearOptions} | ||
| universityOptions={universityOptions} | ||
| departmentOptions={departmentOptions} | ||
| majorOptions={majorOptions} | ||
| selectedUniversity={selectedUniversity} | ||
| selectedDepartment={selectedDepartment} | ||
| selectedMajor={selectedMajor} | ||
| onUniversityChange={setSelectedUniversity} | ||
| onDepartmentChange={(value) => { | ||
| setSelectedDepartment(value); | ||
| setSelectedMajor(""); | ||
| }} | ||
| onMajorChange={setSelectedMajor} | ||
| errors={state.errors} | ||
| /> | ||
| </div> | ||
|
|
||
| {/* 하단 고정 버튼 */} | ||
| <Button | ||
| type={currentStep === 4 ? "submit" : "button"} | ||
| fixed | ||
| bottom={24} | ||
| sideGap={16} | ||
| safeArea | ||
| disabled={isPending} | ||
| onClick={currentStep < 4 ? handleNext : undefined} | ||
| className="bg-button-primary text-button-primary-text-default" | ||
| > | ||
| {isPending ? "처리 중..." : currentStep === 4 ? "완료" : "다음으로"} | ||
| </Button> | ||
| </form> | ||
| ); | ||
| }; | ||
|
dasosann marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.