Skip to content
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

πŸ”€ 정적 폼 생성 μ œμž‘ #78

Merged
merged 11 commits into from
Jan 19, 2025

Conversation

Ethen1264
Copy link
Contributor

@Ethen1264 Ethen1264 commented Jan 18, 2025

πŸ’‘ λ°°κ²½ 및 κ°œμš”

정적 폼 생성 μ œμž‘

πŸ“ƒ μž‘μ—…λ‚΄μš©

  • μ»΄ν¬λ„ŒνŠΈ μ œμž‘
  • λ‹€μ΄λ‚˜λ―Ή 폼 κΈ°λŠ₯ μ œμž‘

Summary by CodeRabbit

  • μƒˆλ‘œμš΄ κΈ°λŠ₯

    • 동적 양식 생성 κΈ°λŠ₯ μΆ”κ°€
    • λ‹€μ–‘ν•œ μœ ν˜•μ˜ 질문 μ˜΅μ…˜ (λ¬Έμž₯, μ²΄ν¬λ°•μŠ€, λ“œλ‘­λ‹€μš΄, 닀쀑 선택, 이미지) 지원
    • 양식 μ„Ήμ…˜ μΆ”κ°€ 및 μ‚­μ œ κΈ°λŠ₯ κ΅¬ν˜„
  • 버그 μˆ˜μ •

    • 양식 ꡬ성 μš”μ†Œμ˜ 일관성 및 μ‚¬μš©μ„± κ°œμ„ 
  • κ°œμ„  사항

    • μ•„μ΄μ½˜ 및 UI μ»΄ν¬λ„ŒνŠΈ λͺ¨λ“ˆν™”
    • 양식 μƒνƒœ 관리 μ΅œμ ν™”

@Ethen1264 Ethen1264 added ✨ Feature μ‹ κ·œ κΈ°λŠ₯ 🎨 Type: Publishing λ””μžμΈ κ΅¬ν˜„ labels Jan 18, 2025
@Ethen1264 Ethen1264 self-assigned this Jan 18, 2025
Copy link

coderabbitai bot commented Jan 18, 2025

Walkthrough

이 ν’€ λ¦¬ν€˜μŠ€νŠΈλŠ” 폼 생성 κΈ°λŠ₯을 μœ„ν•œ μƒˆλ‘œμš΄ React μ»΄ν¬λ„ŒνŠΈμ™€ κ΄€λ ¨ μœ ν‹Έλ¦¬ν‹°λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€. μ£Όμš” λ³€κ²½ 사항은 폼 생성 νŽ˜μ΄μ§€, λ‹€μ–‘ν•œ μž…λ ₯ μ˜΅μ…˜ μ»΄ν¬λ„ŒνŠΈ, μ•„μ΄μ½˜, 그리고 폼 μƒνƒœ 관리λ₯Ό μœ„ν•œ νƒ€μž… μ •μ˜λ₯Ό ν¬ν•¨ν•©λ‹ˆλ‹€. μ΄λŸ¬ν•œ 변경은 μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ˜ 폼 생성 μ›Œν¬ν”Œλ‘œμš°λ₯Ό κ°œμ„ ν•˜κ³  ν™•μž₯성을 λ†’μ΄λŠ” 데 쀑점을 λ‘‘λ‹ˆλ‹€.

Changes

파일 λ³€κ²½ μš”μ•½
src/app/(pages)/create-form/page.tsx μƒˆλ‘œμš΄ νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€
src/entities/create-form/ui/* λ‹€μ–‘ν•œ 폼 κ΄€λ ¨ UI μ»΄ν¬λ„ŒνŠΈ 생성
src/shared/assets/icons/* μƒˆλ‘œμš΄ μ•„μ΄μ½˜ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€
src/shared/types/create-form/type.ts 폼 κ΄€λ ¨ TypeScript μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
src/views/create-form/ui/createForm/index.tsx 폼 생성 메인 μ»΄ν¬λ„ŒνŠΈ κ΅¬ν˜„

Sequence Diagram

sequenceDiagram
    participant User
    participant CreateFormPage
    participant CreateForm
    participant FormContainer
    participant FormTypeSelect

    User->>CreateFormPage: νŽ˜μ΄μ§€ 접속
    CreateFormPage->>CreateForm: λ Œλ”λ§
    CreateForm->>User: 폼 생성 μΈν„°νŽ˜μ΄μŠ€ ν‘œμ‹œ
    User->>CreateForm: μƒˆ 질문 μΆ”κ°€
    CreateForm->>FormContainer: 질문 μ»¨ν…Œμ΄λ„ˆ 생성
    FormContainer->>FormTypeSelect: 폼 νƒ€μž… 선택
    User->>FormTypeSelect: 폼 νƒ€μž… 선택
    FormContainer->>User: μ„ νƒλœ νƒ€μž…μ˜ μž…λ ₯ μ˜΅μ…˜ ν‘œμ‹œ
Loading

Suggested labels

πŸ“¬ Type: API, ✨ Feature: Form Creation, πŸš€ Enhancement: UI Components

Suggested reviewers

  • answad
  • happytaeyoon

Poem

🐰 폼 λ§Œλ“œλŠ” ν† λΌμ˜ λ…Έλž˜ 🎡

μ»΄ν¬λ„ŒνŠΈ μŒ“μ•„ 폼을 짓고
μ•„μ΄μ½˜ 그리며 길을 μ—΄μ–΄
동적인 μž…λ ₯의 μ„Έκ³„μ—μ„œ
μ‚¬μš©μžμ˜ κΏˆμ„ κ·Έλ €λ‚΄λ„€
μ½”λ“œλ‘œ ν”Όμ–΄λ‚œ 창의λ ₯! 🌈

Finishing Touches

  • πŸ“ Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

🧹 Nitpick comments (11)
src/shared/types/create-form/type.ts (2)

4-8: νƒ€μž… μ•ˆμ •μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

value와 label의 νƒ€μž…μ„ 더 ꡬ체적으둜 μ •μ˜ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

export interface Option {
-  value: string;
-  label?: string;
+  value: 'SENTENCE' | 'CHECKBOX' | 'DROPDOWN' | 'MULTIPLE' | 'IMAGE';
+  label?: 'λ¬Έμž₯ν˜•' | 'μ²΄ν¬λ°•μŠ€' | 'λ“œλ‘­λ‹€μš΄' | '객관식' | '이미지';
  icon?: ReactNode;
}

10-16: 폼 μœ νš¨μ„± 검증 μ œμ•½μ‘°κ±΄μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

questions λ°°μ—΄μ˜ κΈΈμ΄λ‚˜ title의 μ΅œλŒ€ 길이 등에 λŒ€ν•œ μ œμ•½μ‘°κ±΄μ„ μΆ”κ°€ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

export interface FormValues {
  questions: {
-    title: string;
+    title: string & { maxLength?: 100 };
    formType: string;
    options: Option[];
+    maxQuestions?: number;
  }[];
}
src/views/create-form/model/selectOptionData.tsx (1)

10-16: μƒμˆ˜ 데이터 ꡬ쑰 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

μ˜΅μ…˜ 데이터λ₯Ό 더 μœ μ§€λ³΄μˆ˜ν•˜κΈ° μ‰½κ²Œ κ΅¬μ‘°ν™”ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

+export const FORM_TYPES = {
+  SENTENCE: 'SENTENCE',
+  CHECKBOX: 'CHECKBOX',
+  DROPDOWN: 'DROPDOWN',
+  MULTIPLE: 'MULTIPLE',
+  IMAGE: 'IMAGE',
+} as const;

+export const FORM_LABELS = {
+  [FORM_TYPES.SENTENCE]: 'λ¬Έμž₯ν˜•',
+  [FORM_TYPES.CHECKBOX]: 'μ²΄ν¬λ°•μŠ€',
+  [FORM_TYPES.DROPDOWN]: 'λ“œλ‘­λ‹€μš΄',
+  [FORM_TYPES.MULTIPLE]: '객관식',
+  [FORM_TYPES.IMAGE]: '이미지',
+} as const;

export const selectOptionData: Option[] = [
-  { value: 'SENTENCE', label: 'λ¬Έμž₯ν˜•', icon: <Typing /> },
+  { value: FORM_TYPES.SENTENCE, label: FORM_LABELS[FORM_TYPES.SENTENCE], icon: <Typing /> },
  // ... λ‚˜λ¨Έμ§€ μ˜΅μ…˜λ“€λ„ λ™μΌν•˜κ²Œ μˆ˜μ •
];
src/entities/create-form/index.tsx (1)

1-10: νƒ€μž… 내보내기 및 λͺ…λͺ…λœ 내보내기 κ³ λ €

ν˜„μž¬ κ΅¬ν˜„μ€ κΈ°λŠ₯μ μœΌλ‘œλŠ” λ¬Έμ œκ°€ μ—†μœΌλ‚˜, λ‹€μŒκ³Ό 같은 κ°œμ„ μ‚¬ν•­μ„ κ³ λ €ν•΄λ³΄μ„Έμš”:

  1. μ»΄ν¬λ„ŒνŠΈμ™€ κ΄€λ ¨λœ νƒ€μž…λ“€λ„ ν•¨κ»˜ 내보내면 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.
  2. Tree-shaking을 μœ„ν•΄ named export μ‚¬μš©μ„ κ³ λ €ν•΄λ³΄μ„Έμš”.
- export { default as CheckBoxOption } from './ui/CheckBoxOption';
+ export { CheckBoxOption, type CheckBoxOptionProps } from './ui/CheckBoxOption';
src/entities/create-form/ui/PictureOption/index.tsx (2)

15-19: μ ‘κ·Όμ„± 및 μœ νš¨μ„± 검사 κ°œμ„  ν•„μš”

μž…λ ₯ ν•„λ“œμ— λ‹€μŒ 사항듀을 μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

  • aria-label 속성
  • μ΅œλŒ€ 길이 μ œν•œ
  • μž…λ ₯ μœ νš¨μ„± 검사
 <input
   {...register(`questions.${index}.options.${optionIndex}.value`)}
   placeholder="λ¬Έμž₯을 μž…λ ₯ν•΄μ£Όμ„Έμš”."
+  aria-label={`사진 μ˜΅μ…˜ ${optionIndex + 1}`}
+  maxLength={100}
   className="w-[60%] text-body4 text-black"
 />

21-23: λ²„νŠΌ μ ‘κ·Όμ„± κ°œμ„  ν•„μš”

μ‚­μ œ λ²„νŠΌμ— μ ‘κ·Όμ„± 속성을 μΆ”κ°€ν•΄μ£Όμ„Έμš”:

 <button 
   type="button" 
   onClick={() => remove(optionIndex)}
+  aria-label={`μ˜΅μ…˜ ${optionIndex + 1} μ‚­μ œ`}
 >
   <XMark />
 </button>
src/shared/assets/icons/FormPicture.tsx (2)

3-6: Props μΈν„°νŽ˜μ΄μŠ€μ— color 속성 μΆ”κ°€ ν•„μš”

μž¬μ‚¬μš©μ„±μ„ 높이기 μœ„ν•΄ fill 색상을 props둜 λ°›λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

 interface Props {
   width?: string;
   height?: string;
+  color?: string;
 }

18-19: ν•˜λ“œμ½”λ”©λœ 색상값 κ°œμ„  ν•„μš”

ν˜„μž¬ ν•˜λ“œμ½”λ”©λœ #909090 색상을 props둜 λ°›μ•„ μœ μ—°ν•˜κ²Œ μ²˜λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

-        fill="#909090"
+        fill={color || '#909090'}
src/widgets/create-form/ui/FormContainer/index.tsx (1)

50-91: μ»΄ν¬λ„ŒνŠΈ 맡 둜직 μ΅œμ ν™”κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

ν˜„μž¬ μ»΄ν¬λ„ŒνŠΈ 맡이 맀 λ Œλ”λ§λ§ˆλ‹€ μž¬μƒμ„±λ˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 이λ₯Ό μ»΄ν¬λ„ŒνŠΈ μ™ΈλΆ€λ‘œ μ΄λ™ν•˜μ—¬ μ„±λŠ₯을 κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

+const COMPONENT_MAP: Record<string, React.FC<{
+  fields: any;
+  remove: any;
+  register: any;
+  index: number;
+}>> = {
+  SENTENCE: TextOption,
+  CHECKBOX: CheckBoxOption,
+  DROPDOWN: DropDownOption,
+  MULTIPLE: MultipleChoiceOption,
+  IMAGE: PictureOption,
+};

 const FormContainer = ({
   options,
   formRemove,
   index,
   register,
   setValue,
   control,
 }: Props) => {
-  const componentMap: Record<string, JSX.Element | null> = {
-    SENTENCE: (
-      <TextOption
-        fields={fields}
-        remove={remove}
-        register={register}
-        index={index}
-      />
-    ),
-    // ... other components
-  };
src/entities/create-exhibition/ui/ExpoInput/index.tsx (1)

Line range hint 114-123: ν•„λ“œ μΆ”κ°€ μ‹œ νƒ€μž… μ•ˆμ „μ„± κ°•ν™”κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

append ν•¨μˆ˜μ— μ „λ‹¬λ˜λŠ” 객체의 νƒ€μž…μ„ λͺ…μ‹œμ μœΌλ‘œ μ •μ˜ν•˜μ—¬ νƒ€μž… μ•ˆμ „μ„±μ„ κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

+type FieldData = {
+  title: string;
+  startedAt: string;
+  endedAt: string;
+  category?: 'CHOICE';
+};

 <AddItemButton
   onClick={() =>
-    append({
+    append<FieldData>({
       title: '',
       startedAt: '',
       endedAt: '',
       ...(fieldName === 'trainings' ? { category: 'CHOICE' } : {}),
     })
   }
 />
src/shared/assets/icons/ArrowUp.tsx (1)

3-3: νƒ€μž… μ •μ˜λ₯Ό μΆ”κ°€ν•΄μ£Όμ„Έμš”.

μ»΄ν¬λ„ŒνŠΈμ˜ props에 λŒ€ν•œ νƒ€μž… μ •μ˜κ°€ λˆ„λ½λ˜μ—ˆμŠ΅λ‹ˆλ‹€. νƒ€μž… μ•ˆμ •μ„±μ„ μœ„ν•΄ λ‹€μŒκ³Ό 같이 μΈν„°νŽ˜μ΄μŠ€λ₯Ό μΆ”κ°€ν•˜λŠ” 것을 μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€:

+interface ArrowUpProps {
+  fill?: string;
+}

-const ArrowUp = ({ fill = '#121212' }) => {
+const ArrowUp = ({ fill = '#121212' }: ArrowUpProps) => {
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7683573 and 6a9383a.

πŸ“’ Files selected for processing (33)
  • src/app/(pages)/create-form/page.tsx (1 hunks)
  • src/entities/create-exhibition/ui/ExpoInput/index.tsx (3 hunks)
  • src/entities/create-form/index.tsx (1 hunks)
  • src/entities/create-form/ui/CheckBoxOption/index.tsx (1 hunks)
  • src/entities/create-form/ui/CreateFormButton/index.tsx (1 hunks)
  • src/entities/create-form/ui/DeleteButton/index.tsx (1 hunks)
  • src/entities/create-form/ui/DropDownOption/index.tsx (1 hunks)
  • src/entities/create-form/ui/FormTitle/index.tsx (1 hunks)
  • src/entities/create-form/ui/FormTypeSelect/index.tsx (1 hunks)
  • src/entities/create-form/ui/MultipleChoiceOption/index.tsx (1 hunks)
  • src/entities/create-form/ui/PictureOption/index.tsx (1 hunks)
  • src/entities/create-form/ui/RequiredToggle/index.tsx (1 hunks)
  • src/entities/create-form/ui/TextOption/index.tsx (1 hunks)
  • src/shared/assets/icons/ArrowUp.tsx (2 hunks)
  • src/shared/assets/icons/CheckBoxIcon.tsx (1 hunks)
  • src/shared/assets/icons/DropDown.tsx (1 hunks)
  • src/shared/assets/icons/FormPicture.tsx (1 hunks)
  • src/shared/assets/icons/MultipleChoic.tsx (1 hunks)
  • src/shared/assets/icons/Trash.tsx (2 hunks)
  • src/shared/assets/icons/Typing.tsx (1 hunks)
  • src/shared/assets/icons/index.mdx (2 hunks)
  • src/shared/assets/icons/index.tsx (1 hunks)
  • src/shared/assets/svg/Circle.tsx (1 hunks)
  • src/shared/assets/svg/Squere.tsx (1 hunks)
  • src/shared/assets/svg/index.tsx (1 hunks)
  • src/shared/types/create-form/type.ts (1 hunks)
  • src/shared/ui/AddItemButton/index.tsx (1 hunks)
  • src/shared/ui/ToggleButton/index.tsx (1 hunks)
  • src/shared/ui/index.tsx (1 hunks)
  • src/views/create-form/index.tsx (1 hunks)
  • src/views/create-form/model/selectOptionData.tsx (1 hunks)
  • src/views/create-form/ui/createForm/index.tsx (1 hunks)
  • src/widgets/create-form/ui/FormContainer/index.tsx (1 hunks)
βœ… Files skipped from review due to trivial changes (7)
  • src/views/create-form/index.tsx
  • src/shared/assets/svg/Circle.tsx
  • src/shared/assets/icons/DropDown.tsx
  • src/app/(pages)/create-form/page.tsx
  • src/shared/assets/icons/Typing.tsx
  • src/shared/assets/svg/Squere.tsx
  • src/shared/assets/icons/CheckBoxIcon.tsx
πŸ”‡ Additional comments (6)
src/shared/assets/svg/index.tsx (1)

2-3: 내보내기 νŒ¨ν„΄μ΄ 일관성 있게 μž‘μ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

배럴(barrel) νŒ¨ν„΄μ„ μ‚¬μš©ν•˜μ—¬ SVG μ»΄ν¬λ„ŒνŠΈλ“€μ„ κΉ”λ”ν•˜κ²Œ 내보내고 μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” 쒋은 λ°©μ‹μž…λ‹ˆλ‹€.

src/shared/ui/index.tsx (1)

7-8: 변경사항이 μ μ ˆν•©λ‹ˆλ‹€.

곡유 UI μ»΄ν¬λ„ŒνŠΈμ˜ 내보내기가 μΌκ΄€λœ νŒ¨ν„΄μ„ λ”°λ₯΄κ³  μžˆμŠ΅λ‹ˆλ‹€.

src/shared/assets/icons/Trash.tsx (1)

Line range hint 3-14: κ΅¬ν˜„μ΄ 잘 λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

color prop을 ν†΅ν•œ 동적 색상 μ²˜λ¦¬κ°€ 잘 κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/views/create-form/ui/createForm/index.tsx (1)

65-69: 빈 폼 μΆ”κ°€ μ‹œ μœ νš¨μ„± 검사 ν•„μš”

μƒˆλ‘œμš΄ 폼 ν•„λ“œ μΆ”κ°€ μ‹œ 기본값에 λŒ€ν•œ μœ νš¨μ„± 검사가 ν•„μš”ν•©λ‹ˆλ‹€.

 <CreateFormButton
   onClick={() =>
-    append({ title: '', formType: 'SENTENCE', options: [] })
+    append({
+      title: '',
+      formType: 'SENTENCE',
+      options: [],
+    }, {
+      shouldValidate: true
+    })
   }
 />
src/shared/assets/icons/index.mdx (1)

26-29: μ•„μ΄μ½˜ μΆ”κ°€κ°€ 적절히 μ΄λ£¨μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€.

폼 κΈ°λŠ₯에 ν•„μš”ν•œ μƒˆλ‘œμš΄ μ•„μ΄μ½˜λ“€μ΄ 잘 μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Also applies to: 71-74

src/shared/assets/icons/ArrowUp.tsx (1)

14-14: 동적 fill 속성 κ΅¬ν˜„μ΄ 잘 λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

propsλ₯Ό 톡해 fill 색상을 λ™μ μœΌλ‘œ λ³€κ²½ν•  수 μžˆλ„λ‘ κ΅¬ν˜„ν•œ 것이 μ’‹μŠ΅λ‹ˆλ‹€. 이λ₯Ό 톡해 μ»΄ν¬λ„ŒνŠΈμ˜ μž¬μ‚¬μš©μ„±μ΄ ν–₯μƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

@@ -1 +1,3 @@
export { default as Logo } from './Logo';
export { default as Squere } from './Squere';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

'Squere' μ»΄ν¬λ„ŒνŠΈ μ΄λ¦„μ˜ μ˜€νƒ€λ₯Ό μˆ˜μ •ν•΄ μ£Όμ„Έμš”.

'Squere'λŠ” 'Square'의 μ˜€νƒ€λ‘œ λ³΄μž…λ‹ˆλ‹€. μ»΄ν¬λ„ŒνŠΈ 이름과 파일 이름을 λͺ¨λ‘ μ˜¬λ°”λ₯Έ μ˜μ–΄ 철자둜 μˆ˜μ •ν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•΄ μ£Όμ„Έμš”:

-export { default as Squere } from './Squere';
+export { default as Square } from './Square';

κ΄€λ ¨ 파일λͺ…도 Squere.tsxμ—μ„œ Square.tsx둜 변경이 ν•„μš”ν•©λ‹ˆλ‹€.

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +4 to +11
const RequiredToggle = () => {
return (
<label className="flex items-center gap-6">
<p className="text-caption2 text-black">ν•„μˆ˜</p>
<ToggleButton />
</label>
);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

μƒνƒœ 관리 및 μ ‘κ·Όμ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

ν˜„μž¬ κ΅¬ν˜„μ—λŠ” λ‹€μŒκ³Ό 같은 λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€:

  • ToggleButton의 μƒνƒœλ₯Ό μ œμ–΄ν•˜κ±°λ‚˜ 읽을 수 μ—†μŠ΅λ‹ˆλ‹€
  • onChange ν•Έλ“€λŸ¬κ°€ λˆ„λ½λ˜μ—ˆμŠ΅λ‹ˆλ‹€
  • μ ‘κ·Όμ„± 속성이 λΆ€μ‘±ν•©λ‹ˆλ‹€

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

-const RequiredToggle = () => {
+interface Props {
+  isRequired: boolean;
+  onChange: (isRequired: boolean) => void;
+}
+
+const RequiredToggle = ({ isRequired, onChange }: Props) => {
   return (
-    <label className="flex items-center gap-6">
+    <label className="flex items-center gap-6" role="switch" aria-checked={isRequired}>
       <p className="text-caption2 text-black">ν•„μˆ˜</p>
-      <ToggleButton />
+      <ToggleButton checked={isRequired} onChange={onChange} />
     </label>
   );
 };
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const RequiredToggle = () => {
return (
<label className="flex items-center gap-6">
<p className="text-caption2 text-black">ν•„μˆ˜</p>
<ToggleButton />
</label>
);
};
interface Props {
isRequired: boolean;
onChange: (isRequired: boolean) => void;
}
const RequiredToggle = ({ isRequired, onChange }: Props) => {
return (
<label className="flex items-center gap-6" role="switch" aria-checked={isRequired}>
<p className="text-caption2 text-black">ν•„μˆ˜</p>
<ToggleButton checked={isRequired} onChange={onChange} />
</label>
);
};

Comment on lines +8 to +15
const DeleteButton = ({ onClick }: Props) => {
return (
<button onClick={onClick} className="flex items-center gap-2">
<Trash color="#BDBDBD" />
<p className="text-caption2 text-gray-300">버리기</p>
</button>
);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

λ²„νŠΌμ˜ μ ‘κ·Όμ„±κ³Ό μƒν˜Έμž‘μš© μƒνƒœλ₯Ό κ°œμ„ ν•΄μ•Ό ν•©λ‹ˆλ‹€.

λ‹€μŒ 사항듀이 κ°œμ„ λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€:

  • button νƒ€μž… 속성 λˆ„λ½
  • μ ‘κ·Όμ„± 속성 λˆ„λ½
  • hover/focus μƒνƒœ μŠ€νƒ€μΌ λˆ„λ½

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

 const DeleteButton = ({ onClick }: Props) => {
   return (
     <button
+      type="button"
+      aria-label="ν•­λͺ© μ‚­μ œ"
-      className="flex items-center gap-2"
+      className="flex items-center gap-2 hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-gray-300 rounded"
       onClick={onClick}
     >
       <Trash color="#BDBDBD" />
       <p className="text-caption2 text-gray-300">버리기</p>
     </button>
   );
 };
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const DeleteButton = ({ onClick }: Props) => {
return (
<button onClick={onClick} className="flex items-center gap-2">
<Trash color="#BDBDBD" />
<p className="text-caption2 text-gray-300">버리기</p>
</button>
);
};
const DeleteButton = ({ onClick }: Props) => {
return (
<button
type="button"
aria-label="ν•­λͺ© μ‚­μ œ"
className="flex items-center gap-2 hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-gray-300 rounded"
onClick={onClick}
>
<Trash color="#BDBDBD" />
<p className="text-caption2 text-gray-300">버리기</p>
</button>
);
};

Comment on lines +7 to +16
const AddItemButton = ({ onClick }: AddItemButtonProps) => (
<button
type="button"
className="mx-auto flex items-center gap-5"
onClick={onClick}
>
<Plus fill="#448FFF" />
<div className="text-body3 text-main-600">μΆ”κ°€ν•˜κΈ°</div>
</button>
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

μ ‘κ·Όμ„±κ³Ό 일관성 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒ 사항듀이 κ°œμ„ λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€:

  • μ ‘κ·Όμ„± 속성 λˆ„λ½
  • hover/focus μƒνƒœ μŠ€νƒ€μΌ λˆ„λ½
  • ν…μŠ€νŠΈμ— div λŒ€μ‹  p νƒœκ·Έ μ‚¬μš© ν•„μš” (일관성)

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

 const AddItemButton = ({ onClick }: AddItemButtonProps) => (
   <button
     type="button"
+    aria-label="ν•­λͺ© μΆ”κ°€"
-    className="mx-auto flex items-center gap-5"
+    className="mx-auto flex items-center gap-5 hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-main-600 rounded"
     onClick={onClick}
   >
     <Plus fill="#448FFF" />
-    <div className="text-body3 text-main-600">μΆ”κ°€ν•˜κΈ°</div>
+    <p className="text-body3 text-main-600">μΆ”κ°€ν•˜κΈ°</p>
   </button>
 );
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const AddItemButton = ({ onClick }: AddItemButtonProps) => (
<button
type="button"
className="mx-auto flex items-center gap-5"
onClick={onClick}
>
<Plus fill="#448FFF" />
<div className="text-body3 text-main-600">μΆ”κ°€ν•˜κΈ°</div>
</button>
);
const AddItemButton = ({ onClick }: AddItemButtonProps) => (
<button
type="button"
aria-label="ν•­λͺ© μΆ”κ°€"
className="mx-auto flex items-center gap-5 hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-main-600 rounded"
onClick={onClick}
>
<Plus fill="#448FFF" />
<p className="text-body3 text-main-600">μΆ”κ°€ν•˜κΈ°</p>
</button>
);

Comment on lines +10 to +17
<button
onClick={onClick}
className="flex w-fit items-center gap-[10px] rounded-sm bg-main-300 px-6 py-3"
>
<Plus fill="#FFF" />
<p className="text-h4 text-white">μΆ”κ°€ν•˜κΈ°</p>
</button>
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

μ ‘κ·Όμ„±κ³Ό μœ μ§€λ³΄μˆ˜μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

  1. λ²„νŠΌμ— aria-label이 μ—†μŠ΅λ‹ˆλ‹€.
  2. ν…μŠ€νŠΈκ°€ ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
<button
  onClick={onClick}
+ aria-label="폼 ν•­λͺ© μΆ”κ°€"
  className="flex w-fit items-center gap-[10px] rounded-sm bg-main-300 px-6 py-3"
>
  <Plus fill="#FFF" />
- <p className="text-h4 text-white">μΆ”κ°€ν•˜κΈ°</p>
+ <p className="text-h4 text-white">{FORM_BUTTON_LABELS.ADD}</p>
</button>

μƒμˆ˜ 파일 생성을 μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€:

// constants.ts
export const FORM_BUTTON_LABELS = {
  ADD: 'μΆ”κ°€ν•˜κΈ°'
} as const;

Comment on lines +1 to +20
import React from 'react';

const MultipleChoic = () => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
>
<path
d="M12 2.25C10.0716 2.25 8.18657 2.82183 6.58319 3.89317C4.97982 4.96451 3.73013 6.48726 2.99218 8.26884C2.25422 10.0504 2.06114 12.0108 2.43735 13.9021C2.81355 15.7934 3.74215 17.5307 5.10571 18.8943C6.46928 20.2579 8.20656 21.1865 10.0979 21.5627C11.9892 21.9389 13.9496 21.7458 15.7312 21.0078C17.5127 20.2699 19.0355 19.0202 20.1068 17.4168C21.1782 15.8134 21.75 13.9284 21.75 12C21.7473 9.41498 20.7192 6.93661 18.8913 5.10872C17.0634 3.28084 14.585 2.25273 12 2.25ZM12 20.25C10.3683 20.25 8.77326 19.7661 7.41655 18.8596C6.05984 17.9531 5.00242 16.6646 4.378 15.1571C3.75358 13.6496 3.5902 11.9908 3.90853 10.3905C4.22685 8.79016 5.01259 7.32015 6.16637 6.16637C7.32016 5.01259 8.79017 4.22685 10.3905 3.90852C11.9909 3.59019 13.6497 3.75357 15.1571 4.37799C16.6646 5.00242 17.9531 6.05984 18.8596 7.41655C19.7661 8.77325 20.25 10.3683 20.25 12C20.2475 14.1873 19.3775 16.2843 17.8309 17.8309C16.2843 19.3775 14.1873 20.2475 12 20.25ZM16.2806 9.96937C16.3504 10.039 16.4057 10.1217 16.4434 10.2128C16.4812 10.3038 16.5006 10.4014 16.5006 10.5C16.5006 10.5986 16.4812 10.6962 16.4434 10.7872C16.4057 10.8783 16.3504 10.961 16.2806 11.0306L12.5306 14.7806C12.461 14.8504 12.3783 14.9057 12.2872 14.9434C12.1962 14.9812 12.0986 15.0006 12 15.0006C11.9014 15.0006 11.8038 14.9812 11.7128 14.9434C11.6218 14.9057 11.539 14.8504 11.4694 14.7806L7.71938 11.0306C7.57865 10.8899 7.49959 10.699 7.49959 10.5C7.49959 10.301 7.57865 10.1101 7.71938 9.96937C7.86011 9.82864 8.05098 9.74958 8.25 9.74958C8.44903 9.74958 8.6399 9.82864 8.78063 9.96937L12 13.1897L15.2194 9.96937C15.289 9.89964 15.3718 9.84432 15.4628 9.80658C15.5538 9.76884 15.6514 9.74941 15.75 9.74941C15.8486 9.74941 15.9462 9.76884 16.0372 9.80658C16.1283 9.84432 16.211 9.89964 16.2806 9.96937Z"
fill="#909090"
/>
</svg>
);
};

export default MultipleChoic;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

μ»΄ν¬λ„ŒνŠΈ 이름 및 μž¬μ‚¬μš©μ„± κ°œμ„  ν•„μš”

  1. 파일λͺ…이 "MultipleChoic"μ—μ„œ "MultipleChoice"둜 μˆ˜μ •λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
  2. FormPicture μ»΄ν¬λ„ŒνŠΈμ™€ 같이 width, height, color propsλ₯Ό μΆ”κ°€ν•˜λ©΄ μž¬μ‚¬μš©μ„±μ΄ ν–₯상될 것 κ°™μŠ΅λ‹ˆλ‹€.
-const MultipleChoic = () => {
+interface Props {
+  width?: string;
+  height?: string;
+  color?: string;
+}
+
+const MultipleChoice = ({ width = '24', height = '24', color = '#909090' }: Props) => {
   return (
     <svg
       xmlns="http://www.w3.org/2000/svg"
-      width="24"
-      height="24"
+      width={width}
+      height={height}
       viewBox="0 0 24 24"
       fill="none"
     >
       <path
         d="M12 2.25C10.0716 2.25 8.18657 2.82183 6.58319 3.89317C4.97982 4.96451 3.73013 6.48726 2.99218 8.26884C2.25422 10.0504 2.06114 12.0108 2.43735 13.9021C2.81355 15.7934 3.74215 17.5307 5.10571 18.8943C6.46928 20.2579 8.20656 21.1865 10.0979 21.5627C11.9892 21.9389 13.9496 21.7458 15.7312 21.0078C17.5127 20.2699 19.0355 19.0202 20.1068 17.4168C21.1782 15.8134 21.75 13.9284 21.75 12C21.7473 9.41498 20.7192 6.93661 18.8913 5.10872C17.0634 3.28084 14.585 2.25273 12 2.25ZM12 20.25C10.3683 20.25 8.77326 19.7661 7.41655 18.8596C6.05984 17.9531 5.00242 16.6646 4.378 15.1571C3.75358 13.6496 3.5902 11.9908 3.90853 10.3905C4.22685 8.79016 5.01259 7.32015 6.16637 6.16637C7.32016 5.01259 8.79017 4.22685 10.3905 3.90852C11.9909 3.59019 13.6497 3.75357 15.1571 4.37799C16.6646 5.00242 17.9531 6.05984 18.8596 7.41655C19.7661 8.77325 20.25 10.3683 20.25 12C20.2475 14.1873 19.3775 16.2843 17.8309 17.8309C16.2843 19.3775 14.1873 20.2475 12 20.25ZM16.2806 9.96937C16.3504 10.039 16.4057 10.1217 16.4434 10.2128C16.4812 10.3038 16.5006 10.4014 16.5006 10.5C16.5006 10.5986 16.4812 10.6962 16.4434 10.7872C16.4057 10.8783 16.3504 10.961 16.2806 11.0306L12.5306 14.7806C12.461 14.8504 12.3783 14.9057 12.2872 14.9434C12.1962 14.9812 12.0986 15.0006 12 15.0006C11.9014 15.0006 11.8038 14.9812 11.7128 14.9434C11.6218 14.9057 11.539 14.8504 11.4694 14.7806L7.71938 11.0306C7.57865 10.8899 7.49959 10.699 7.49959 10.5C7.49959 10.301 7.57865 10.1101 7.71938 9.96937C7.86011 9.82864 8.05098 9.74958 8.25 9.74958C8.44903 9.74958 8.6399 9.82864 8.78063 9.96937L12 13.1897L15.2194 9.96937C15.289 9.89964 15.3718 9.84432 15.4628 9.80658C15.5538 9.76884 15.6514 9.74941 15.75 9.74941C15.8486 9.74941 15.9462 9.76884 16.0372 9.80658C16.1283 9.84432 16.211 9.89964 16.2806 9.96937Z"
-        fill="#909090"
+        fill={color}
       />
     </svg>
   );
 };
 
-export default MultipleChoic;
+export default MultipleChoice;
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import React from 'react';
const MultipleChoic = () => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
>
<path
d="M12 2.25C10.0716 2.25 8.18657 2.82183 6.58319 3.89317C4.97982 4.96451 3.73013 6.48726 2.99218 8.26884C2.25422 10.0504 2.06114 12.0108 2.43735 13.9021C2.81355 15.7934 3.74215 17.5307 5.10571 18.8943C6.46928 20.2579 8.20656 21.1865 10.0979 21.5627C11.9892 21.9389 13.9496 21.7458 15.7312 21.0078C17.5127 20.2699 19.0355 19.0202 20.1068 17.4168C21.1782 15.8134 21.75 13.9284 21.75 12C21.7473 9.41498 20.7192 6.93661 18.8913 5.10872C17.0634 3.28084 14.585 2.25273 12 2.25ZM12 20.25C10.3683 20.25 8.77326 19.7661 7.41655 18.8596C6.05984 17.9531 5.00242 16.6646 4.378 15.1571C3.75358 13.6496 3.5902 11.9908 3.90853 10.3905C4.22685 8.79016 5.01259 7.32015 6.16637 6.16637C7.32016 5.01259 8.79017 4.22685 10.3905 3.90852C11.9909 3.59019 13.6497 3.75357 15.1571 4.37799C16.6646 5.00242 17.9531 6.05984 18.8596 7.41655C19.7661 8.77325 20.25 10.3683 20.25 12C20.2475 14.1873 19.3775 16.2843 17.8309 17.8309C16.2843 19.3775 14.1873 20.2475 12 20.25ZM16.2806 9.96937C16.3504 10.039 16.4057 10.1217 16.4434 10.2128C16.4812 10.3038 16.5006 10.4014 16.5006 10.5C16.5006 10.5986 16.4812 10.6962 16.4434 10.7872C16.4057 10.8783 16.3504 10.961 16.2806 11.0306L12.5306 14.7806C12.461 14.8504 12.3783 14.9057 12.2872 14.9434C12.1962 14.9812 12.0986 15.0006 12 15.0006C11.9014 15.0006 11.8038 14.9812 11.7128 14.9434C11.6218 14.9057 11.539 14.8504 11.4694 14.7806L7.71938 11.0306C7.57865 10.8899 7.49959 10.699 7.49959 10.5C7.49959 10.301 7.57865 10.1101 7.71938 9.96937C7.86011 9.82864 8.05098 9.74958 8.25 9.74958C8.44903 9.74958 8.6399 9.82864 8.78063 9.96937L12 13.1897L15.2194 9.96937C15.289 9.89964 15.3718 9.84432 15.4628 9.80658C15.5538 9.76884 15.6514 9.74941 15.75 9.74941C15.8486 9.74941 15.9462 9.76884 16.0372 9.80658C16.1283 9.84432 16.211 9.89964 16.2806 9.96937Z"
fill="#909090"
/>
</svg>
);
};
export default MultipleChoic;
import React from 'react';
interface Props {
width?: string;
height?: string;
color?: string;
}
const MultipleChoice = ({ width = '24', height = '24', color = '#909090' }: Props) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
>
<path
d="M12 2.25C10.0716 2.25 8.18657 2.82183 6.58319 3.89317C4.97982 4.96451 3.73013 6.48726 2.99218 8.26884C2.25422 10.0504 2.06114 12.0108 2.43735 13.9021C2.81355 15.7934 3.74215 17.5307 5.10571 18.8943C6.46928 20.2579 8.20656 21.1865 10.0979 21.5627C11.9892 21.9389 13.9496 21.7458 15.7312 21.0078C17.5127 20.2699 19.0355 19.0202 20.1068 17.4168C21.1782 15.8134 21.75 13.9284 21.75 12C21.7473 9.41498 20.7192 6.93661 18.8913 5.10872C17.0634 3.28084 14.585 2.25273 12 2.25ZM12 20.25C10.3683 20.25 8.77326 19.7661 7.41655 18.8596C6.05984 17.9531 5.00242 16.6646 4.378 15.1571C3.75358 13.6496 3.5902 11.9908 3.90853 10.3905C4.22685 8.79016 5.01259 7.32015 6.16637 6.16637C7.32016 5.01259 8.79017 4.22685 10.3905 3.90852C11.9909 3.59019 13.6497 3.75357 15.1571 4.37799C16.6646 5.00242 17.9531 6.05984 18.8596 7.41655C19.7661 8.77325 20.25 10.3683 20.25 12C20.2475 14.1873 19.3775 16.2843 17.8309 17.8309C16.2843 19.3775 14.1873 20.2475 12 20.25ZM16.2806 9.96937C16.3504 10.039 16.4057 10.1217 16.4434 10.2128C16.4812 10.3038 16.5006 10.4014 16.5006 10.5C16.5006 10.5986 16.4812 10.6962 16.4434 10.7872C16.4057 10.8783 16.3504 10.961 16.2806 11.0306L12.5306 14.7806C12.461 14.8504 12.3783 14.9057 12.2872 14.9434C12.1962 14.9812 12.0986 15.0006 12 15.0006C11.9014 15.0006 11.8038 14.9812 11.7128 14.9434C11.6218 14.9057 11.539 14.8504 11.4694 14.7806L7.71938 11.0306C7.57865 10.8899 7.49959 10.699 7.49959 10.5C7.49959 10.301 7.57865 10.1101 7.71938 9.96937C7.86011 9.82864 8.05098 9.74958 8.25 9.74958C8.44903 9.74958 8.6399 9.82864 8.78063 9.96937L12 13.1897L15.2194 9.96937C15.289 9.89964 15.3718 9.84432 15.4628 9.80658C15.5538 9.76884 15.6514 9.74941 15.75 9.74941C15.8486 9.74941 15.9462 9.76884 16.0372 9.80658C16.1283 9.84432 16.211 9.89964 16.2806 9.96937Z"
fill={color}
/>
</svg>
);
};
export default MultipleChoice;

Comment on lines +24 to +41
const onSubmit = (data: FormValues) => {
const formattedData = data.questions.map((question) => ({
title: question.title,
formType: question.formType,
jsonData: JSON.stringify(
question.options.reduce(
(acc, option, index) => {
acc[(index + 1).toString()] = option.value;
return acc;
},
{} as Record<string, string>,
),
),
}));

console.log(formattedData);
// μ„œλ²„μ— μ „μ†‘ν•˜λŠ” μ½”λ“œ μΆ”κ°€ κ°€λŠ₯
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

onSubmit ν•¨μˆ˜ κ°œμ„  ν•„μš”

  1. ν”„λ‘œλ•μ…˜ μ½”λ“œμ—μ„œλŠ” console.logλ₯Ό μ œκ±°ν•΄μ•Ό ν•©λ‹ˆλ‹€.
  2. μ„œλ²„ 제좜 둜직 κ΅¬ν˜„μ΄ ν•„μš”ν•©λ‹ˆλ‹€.
  3. μ—λŸ¬ μ²˜λ¦¬κ°€ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
 const onSubmit = (data: FormValues) => {
+  try {
     const formattedData = data.questions.map((question) => ({
       title: question.title,
       formType: question.formType,
       jsonData: JSON.stringify(
         question.options.reduce(
           (acc, option, index) => {
             acc[(index + 1).toString()] = option.value;
             return acc;
           },
           {} as Record<string, string>,
         ),
       ),
     }));

-    console.log(formattedData);
-    // μ„œλ²„μ— μ „μ†‘ν•˜λŠ” μ½”λ“œ μΆ”κ°€ κ°€λŠ₯
+    // TODO: API 호좜 κ΅¬ν˜„
+    return await submitForm(formattedData);
+  } catch (error) {
+    // TODO: μ—λŸ¬ 처리 κ΅¬ν˜„
+    console.error('폼 제좜 쀑 였λ₯˜ λ°œμƒ:', error);
+    throw error;
+  }
 };

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +40 to +52
<button
type="button"
onClick={() => setIsOpen(!isOpen)}
className="flex w-full items-center justify-between rounded-md border-1 border-solid border-gray-100 bg-white px-3 py-[10px]"
>
<div className="flex items-center">
{selectedOption?.icon && (
<span className="mr-2">{selectedOption.icon}</span>
)}
<span className="text-h5 text-gray-500">{selectedOption?.label}</span>
</div>
{isOpen ? <ArrowUp fill="#909090" /> : <ArrowDown fill="#909090" />}
</button>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

λ“œλ‘­λ‹€μš΄ μ ‘κ·Όμ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

ν‚€λ³΄λ“œ λ„€λΉ„κ²Œμ΄μ…˜κ³Ό ARIA 속성이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 슀크린 리더 μ‚¬μš©μžλ₯Ό μœ„ν•΄ λ‹€μŒ 사항듀을 μΆ”κ°€ν•΄μ£Όμ„Έμš”:

  • aria-expanded
  • aria-haspopup
  • aria-label
  • ν‚€λ³΄λ“œ 이벀트 ν•Έλ“€λŸ¬
 <button
   type="button"
   onClick={() => setIsOpen(!isOpen)}
+  aria-expanded={isOpen}
+  aria-haspopup="listbox"
+  aria-label="폼 νƒ€μž… 선택"
+  onKeyDown={(e) => {
+    if (e.key === 'Enter' || e.key === ' ') {
+      setIsOpen(!isOpen);
+    }
+  }}
   className="flex w-full items-center justify-between rounded-md border-1 border-solid border-gray-100 bg-white px-3 py-[10px]"
 >
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button
type="button"
onClick={() => setIsOpen(!isOpen)}
className="flex w-full items-center justify-between rounded-md border-1 border-solid border-gray-100 bg-white px-3 py-[10px]"
>
<div className="flex items-center">
{selectedOption?.icon && (
<span className="mr-2">{selectedOption.icon}</span>
)}
<span className="text-h5 text-gray-500">{selectedOption?.label}</span>
</div>
{isOpen ? <ArrowUp fill="#909090" /> : <ArrowDown fill="#909090" />}
</button>
<button
type="button"
onClick={() => setIsOpen(!isOpen)}
aria-expanded={isOpen}
aria-haspopup="listbox"
aria-label="폼 νƒ€μž… 선택"
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
setIsOpen(!isOpen);
}
}}
className="flex w-full items-center justify-between rounded-md border-1 border-solid border-gray-100 bg-white px-3 py-[10px]"
>
<div className="flex items-center">
{selectedOption?.icon && (
<span className="mr-2">{selectedOption.icon}</span>
)}
<span className="text-h5 text-gray-500">{selectedOption?.label}</span>
</div>
{isOpen ? <ArrowUp fill="#909090" /> : <ArrowDown fill="#909090" />}
</button>

Comment on lines +53 to +70
{isOpen && (
<ul className="absolute z-30 mt-1 flex w-full flex-col items-center gap-[10px] rounded-md border-1 border-solid border-gray-100 bg-white py-[30px] shadow-lg">
{options.map((option) => (
<li
key={option.value}
onClick={() => {
setSelectedOption(option);
setValue(`questions.${index}.formType`, option.value);
setIsOpen(false);
}}
className="flex w-full cursor-pointer items-center justify-center p-2 text-h5 text-gray-500 hover:bg-gray-100"
>
{option.icon && <span className="mr-2">{option.icon}</span>}
{option.label}
</li>
))}
</ul>
)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

λ“œλ‘­λ‹€μš΄ λͺ©λ‘μ˜ μ ‘κ·Όμ„±κ³Ό ν‚€λ³΄λ“œ μΈν„°λž™μ…˜ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

λ“œλ‘­λ‹€μš΄ λͺ©λ‘μ— μ μ ˆν•œ ARIA 속성과 ν‚€λ³΄λ“œ λ„€λΉ„κ²Œμ΄μ…˜μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

-{isOpen && (
+{isOpen && (
+  <ul
+    role="listbox"
+    aria-label="폼 νƒ€μž… μ˜΅μ…˜"
+    className="absolute z-30 mt-1 flex w-full flex-col items-center gap-[10px] rounded-md border-1 border-solid border-gray-100 bg-white py-[30px] shadow-lg"
+  >
    {options.map((option) => (
      <li
        key={option.value}
+       role="option"
+       aria-selected={selectedOption?.value === option.value}
+       tabIndex={0}
        onClick={() => {
          setSelectedOption(option);
          setValue(`questions.${index}.formType`, option.value);
          setIsOpen(false);
        }}
+       onKeyDown={(e) => {
+         if (e.key === 'Enter' || e.key === ' ') {
+           setSelectedOption(option);
+           setValue(`questions.${index}.formType`, option.value);
+           setIsOpen(false);
+         }
+       }}
        className="flex w-full cursor-pointer items-center justify-center p-2 text-h5 text-gray-500 hover:bg-gray-100"
      >
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{isOpen && (
<ul className="absolute z-30 mt-1 flex w-full flex-col items-center gap-[10px] rounded-md border-1 border-solid border-gray-100 bg-white py-[30px] shadow-lg">
{options.map((option) => (
<li
key={option.value}
onClick={() => {
setSelectedOption(option);
setValue(`questions.${index}.formType`, option.value);
setIsOpen(false);
}}
className="flex w-full cursor-pointer items-center justify-center p-2 text-h5 text-gray-500 hover:bg-gray-100"
>
{option.icon && <span className="mr-2">{option.icon}</span>}
{option.label}
</li>
))}
</ul>
)}
{isOpen && (
<ul
role="listbox"
aria-label="폼 νƒ€μž… μ˜΅μ…˜"
className="absolute z-30 mt-1 flex w-full flex-col items-center gap-[10px] rounded-md border-1 border-solid border-gray-100 bg-white py-[30px] shadow-lg"
>
{options.map((option) => (
<li
key={option.value}
role="option"
aria-selected={selectedOption?.value === option.value}
tabIndex={0}
onClick={() => {
setSelectedOption(option);
setValue(`questions.${index}.formType`, option.value);
setIsOpen(false);
}}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
setSelectedOption(option);
setValue(`questions.${index}.formType`, option.value);
setIsOpen(false);
}
}}
className="flex w-full cursor-pointer items-center justify-center p-2 text-h5 text-gray-500 hover:bg-gray-100"
>
{option.icon && <span className="mr-2">{option.icon}</span>}
{option.label}
</li>
))}
</ul>
)}

Comment on lines +93 to +97
const renderOptionComponent = () => {
return selectedOption?.value
? componentMap[selectedOption.value] || null
: null;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

renderOptionComponent ν•¨μˆ˜μ˜ νƒ€μž… μ•ˆμ „μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

μ„ νƒλœ μ˜΅μ…˜μ˜ valueκ°€ μœ νš¨ν•œ μ»΄ν¬λ„ŒνŠΈ νƒ€μž…μΈμ§€ ν™•μΈν•˜λŠ” νƒ€μž… κ°€λ“œκ°€ ν•„μš”ν•©λ‹ˆλ‹€.

+type ComponentType = keyof typeof COMPONENT_MAP;

+const isValidComponentType = (value: string): value is ComponentType => {
+  return value in COMPONENT_MAP;
+};

 const renderOptionComponent = () => {
-  return selectedOption?.value
-    ? componentMap[selectedOption.value] || null
-    : null;
+  if (!selectedOption?.value || !isValidComponentType(selectedOption.value)) {
+    return null;
+  }
+  const Component = COMPONENT_MAP[selectedOption.value];
+  return (
+    <Component
+      fields={fields}
+      remove={remove}
+      register={register}
+      index={index}
+    />
+  );
 };

Committable suggestion skipped: line range outside the PR's diff.

@Ethen1264 Ethen1264 merged commit c6ca3c9 into develop Jan 19, 2025
2 checks passed
@Ethen1264 Ethen1264 deleted the feature/dynamic-form branch January 23, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature μ‹ κ·œ κΈ°λŠ₯ 🎨 Type: Publishing λ””μžμΈ κ΅¬ν˜„
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants