-
Notifications
You must be signed in to change notification settings - Fork 1
#3 [CHORE] 온보딩 페이지 마무리 #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const MultiSelect = ({ title }: { title: string }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface MultiSelectProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options?: string[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const MultiSelect = ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options = ['10대 이하', '20대', '30대', '40대', '50대', '60대 이상'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: MultiSelectProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [selectedOptions, setSelectedOptions] = useState<string[]>([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const toggleOption = (option: string) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSelectedOptions((prev) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prev.includes(option) ? prev.filter((item) => item !== option) : [...prev, option], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col gap-6"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {/* 제목 */} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p className="text-[24px] font-semibold">{title}을 선택하세요</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {/* 입력칸 */} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <input type="text" className="rounded-xl border border-gray-200 px-2 py-4 text-[20px]" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {/* 6개 그리드 버튼 */} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="grid grid-cols-2 gap-4 md:grid-cols-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {options.map((option, index) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key={index} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => toggleOption(option)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={`rounded-xl border-2 px-4 py-8 text-[18px] font-medium duration-200 ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectedOptions.includes(option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? 'border-[#0D2D84] bg-[#0D2D84] text-white' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : 'border-gray-200 bg-white text-gray-700 hover:bg-gray-50' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {option} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 접근성 개선을 위해 버튼 상태 속성을 추가하세요. 선택 가능한 버튼들에 다음과 같이 접근성 속성을 추가하세요: <button
key={index}
onClick={() => toggleOption(option)}
+ aria-pressed={selectedOptions.includes(option)}
className={`rounded-xl border-2 px-4 py-8 text-[18px] font-medium duration-200 ${
selectedOptions.includes(option)
? 'border-[#0D2D84] bg-[#0D2D84] text-white'
: 'border-gray-200 bg-white text-gray-700 hover:bg-gray-50'
}`}
>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
선택된 값을 부모 컴포넌트로 전달하는 방법이 없습니다.
selectedOptions상태가 컴포넌트 내부에만 존재하고 부모로 노출되지 않아,Onboarding.tsx에서 사용자가 선택한 타겟층 데이터를 수집할 수 없습니다. 이는 폼 제출 시 필수 데이터가 누락되는 치명적인 문제입니다.다음과 같이
onChange콜백을 추가하세요:interface MultiSelectProps { title: string; options?: string[]; + value?: string[]; + onChange?: (selected: string[]) => void; } const MultiSelect = ({ title, options = ['10대 이하', '20대', '30대', '40대', '50대', '60대 이상'], + value = [], + onChange, }: MultiSelectProps) => { - const [selectedOptions, setSelectedOptions] = useState<string[]>([]); + const selectedOptions = value; const toggleOption = (option: string) => { - setSelectedOptions((prev) => - prev.includes(option) ? prev.filter((item) => item !== option) : [...prev, option], - ); + const newSelection = selectedOptions.includes(option) + ? selectedOptions.filter((item) => item !== option) + : [...selectedOptions, option]; + onChange?.(newSelection); };📝 Committable suggestion
🤖 Prompt for AI Agents