Skip to content

[refactor] 지원서 타입 분리#450

Merged
seongwon030 merged 12 commits intodevelop-fefrom
refactor/#449-type-separation-FE-126
May 31, 2025
Merged

[refactor] 지원서 타입 분리#450
seongwon030 merged 12 commits intodevelop-fefrom
refactor/#449-type-separation-FE-126

Conversation

@seongwon030
Copy link
Member

@seongwon030 seongwon030 commented May 31, 2025

#️⃣연관된 이슈

ex) #449

📝작업 내용

  • QuestionType 열거형 타입 정의 (SHORT_TEXT, LONG_TEXT, CHOICE 등)
  • Question 인터페이스 구현 (id, title, description 등의 속성 포함)
  • QuestionBuilderProps 인터페이스 구현 (컴포넌트 제어를 위한 콜백 함수 포함)
  • ShortTextProps, ChoiceProps 등 구체적인 질문 컴포넌트 Props 인터페이스 정의
  • 가독성 향상을 위한 onChange 콜백 함수 구조 통일 및 네이밍 개선
    • 모든 컴포넌트에서 일관된 onChange 콜백 패턴 적용
    • 명확한 의미 전달을 위해 onTitleChange, onDescriptionChange 등 구체적인 함수명 사용
    • 콜백 함수의 매개변수 타입 명확히 지정하여 타입 안전성 강화

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

  • Refactor

    • 질문 생성 및 편집 컴포넌트의 props와 타입 명칭을 일관성 있게 변경하고 중앙 타입 정의 파일로 통합하였습니다.
    • 스타일 관련 코드가 별도의 스타일 파일로 분리되어 유지보수가 용이해졌습니다.
  • New Features

    • 질문 제목, 설명, 선택지 등 주요 UI 요소에 새로운 스타일이 적용되어 시각적 일관성이 향상되었습니다.
  • Documentation

    • 코드 내 타입 및 props 명칭이 명확해져 문서화 및 이해가 쉬워졌습니다.

seongwon030 and others added 12 commits May 31, 2025 15:27
- QuestionTitle 컴포넌트
- Choice 컴포넌트
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
- 프로퍼티에서 객체로 변경

Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
- ShortTextProps, ChoiceProps를 QuestionComponentProps으로 확장

Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
Co-Authored-By: 김준서 Junseo Kim <semiwest2@gmail.com>
@seongwon030 seongwon030 requested a review from oesnuj May 31, 2025 06:42
@seongwon030 seongwon030 added 🔨 Refactor 코드 리팩토링 💻 FE Frontend labels May 31, 2025
@netlify
Copy link

netlify bot commented May 31, 2025

Deploy Preview for moadong ready!

Name Link
🔨 Latest commit 3047bd2
🔍 Latest deploy log https://app.netlify.com/projects/moadong/deploys/683aa4e684f3cf00081db61d
😎 Deploy Preview https://deploy-preview-450--moadong.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 46
Accessibility: 87
Best Practices: 92
SEO: 92
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 31, 2025

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • 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

Walkthrough

이 PR은 지원서(Question) 관련 타입 정의를 중앙화된 파일(@/types/application)로 분리하고, 기존 컴포넌트에서 로컬 타입 선언을 제거하여 해당 타입을 import하도록 리팩토링합니다. 또한, 일부 prop 이름을 명확하게 변경하고 스타일 관련 코드를 별도의 파일로 분리합니다.

Changes

파일(그룹) 변경 요약
frontend/src/types/application.ts Question, QuestionType 등 지원서 관련 타입 및 인터페이스 신규 정의 및 export
frontend/src/pages/AdminPage/application/CreateForm.tsx
.../components/QuestionBuilder/QuestionBuilder.tsx
.../fields/ShortText.tsx
.../fields/Choice.tsx
Question, QuestionType 등 로컬 타입 선언 제거, 중앙 타입 파일에서 import로 대체
.../components/QuestionBuilder/QuestionBuilder.tsx
.../fields/Choice.tsx
.../fields/ShortText.tsx
props 구조 변경: requiredoptions 객체, prop 이름 명확화(onChangeonTitleChange 등)
.../components/QuestionDescription/QuestionDescription.tsx
.../components/QuestionTitle/QuestionTitle.tsx
.../fields/ShortText.tsx
.../fields/Choice.tsx
prop 이름 변경: onChangeonDescriptionChange, onTitleChange 등 일관성 부여
.../components/QuestionTitle/QuestionTitle.styles.ts
.../fields/Choice.styles.ts
스타일 컴포넌트 분리 및 신규 정의, 기존 인라인 스타일 제거

Sequence Diagram(s)

sequenceDiagram
  participant AdminPage
  participant CreateForm
  participant QuestionBuilder
  participant QuestionTitle
  participant QuestionDescription
  participant ShortText/Choice

  AdminPage->>CreateForm: 렌더링
  CreateForm->>QuestionBuilder: questions 배열 전달 (with options)
  QuestionBuilder->>QuestionTitle: id, title, options, onTitleChange 등 전달
  QuestionBuilder->>QuestionDescription: description, onDescriptionChange 전달
  QuestionBuilder->>ShortText/Choice: type, options, 기타 props 전달
  ShortText/Choice->>QuestionTitle/QuestionDescription: props 전달 및 렌더링
Loading

Assessment against linked issues

Objective Addressed Explanation
지원서 타입 분리 (FE-126)

Assessment against linked issues: Out-of-scope changes

(해당 PR에서 명확히 범위를 벗어난 변경사항은 발견되지 않았습니다.)

Possibly related PRs

  • Moadong/moadong#445: 이 PR에서 리팩토링된 Question 컴포넌트 및 CreateForm의 초기 구현과 직접적으로 연관되어 있습니다.

Suggested labels

🎨 Design

Suggested reviewers

  • oesnuj
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

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.

@seongwon030 seongwon030 linked an issue May 31, 2025 that may be closed by this pull request
2 tasks
Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

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

페어프로그래밍 재밌었습니다
다음 작업도 화이팅~~ 🚀 🚀

@seongwon030 seongwon030 merged commit 329ce53 into develop-fe May 31, 2025
6 of 8 checks passed
@seongwon030 seongwon030 deleted the refactor/#449-type-separation-FE-126 branch May 31, 2025 06:45
Copy link
Contributor

@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: 2

🧹 Nitpick comments (4)
frontend/src/types/application.ts (2)

10-19: Question 인터페이스의 options 구조를 확장 가능하게 개선하는 것을 고려해보세요.

현재 optionsrequired만 포함하고 있지만, 향후 다른 옵션들(예: placeholder, validation rules 등)이 추가될 수 있습니다.

 export interface Question {
   id: number;
   title: string;
   description: string;
   type: QuestionType;
   options: {
     required: boolean;
+    placeholder?: string;
+    validation?: {
+      minLength?: number;
+      maxLength?: number;
+      pattern?: string;
+    };
   };
   items?: { value: string }[];
 }

29-37: QuestionComponentProps 인터페이스가 export되지 않았습니다.

이 인터페이스가 다른 컴포넌트에서도 사용될 가능성이 있다면 export하는 것을 고려해보세요.

-interface QuestionComponentProps {
+export interface QuestionComponentProps {
frontend/src/pages/AdminPage/application/fields/Choice.styles.ts (2)

3-13: AddItemButton 스타일 확인 및 테마 변수 적용 제안
현재 패딩·색상·여백이 하드코딩되어 있습니다. 유지보수를 위해 theme의 spacing, color 변수를 참조하도록 리팩토링을 고려해 보세요.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 3-3: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L3
Added line #L3 was not covered by tests


22-30: DeleteButton에 호버/포커스 상태 추가 제안
현재 포인터 커서만 지정되어 있어 접근성 향상을 위해 :hover:focus 시 배경・테두리 색 변화를 추가하면 좋습니다.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 22-22: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L22
Added line #L22 was not covered by tests

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7dac224 and 3047bd2.

📒 Files selected for processing (9)
  • frontend/src/pages/AdminPage/application/CreateForm.tsx (3 hunks)
  • frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx (4 hunks)
  • frontend/src/pages/AdminPage/application/components/QuestionDescription/QuestionDescription.tsx (3 hunks)
  • frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts (1 hunks)
  • frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.tsx (1 hunks)
  • frontend/src/pages/AdminPage/application/fields/Choice.styles.ts (1 hunks)
  • frontend/src/pages/AdminPage/application/fields/Choice.tsx (2 hunks)
  • frontend/src/pages/AdminPage/application/fields/ShortText.tsx (3 hunks)
  • frontend/src/types/application.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/pages/AdminPage/application/CreateForm.tsx (1)
frontend/src/types/application.ts (1)
  • Question (10-19)
🪛 GitHub Check: codecov/patch
frontend/src/pages/AdminPage/application/fields/Choice.tsx

[warning] 1-1: frontend/src/pages/AdminPage/application/fields/Choice.tsx#L1
Added line #L1 was not covered by tests


[warning] 57-57: frontend/src/pages/AdminPage/application/fields/Choice.tsx#L57
Added line #L57 was not covered by tests


[warning] 65-65: frontend/src/pages/AdminPage/application/fields/Choice.tsx#L65
Added line #L65 was not covered by tests

frontend/src/pages/AdminPage/application/fields/Choice.styles.ts

[warning] 1-1: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L1
Added line #L1 was not covered by tests


[warning] 3-3: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L3
Added line #L3 was not covered by tests


[warning] 15-15: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L15
Added line #L15 was not covered by tests


[warning] 22-22: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L22
Added line #L22 was not covered by tests

frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.tsx

[warning] 1-1: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.tsx#L1
Added line #L1 was not covered by tests

frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts

[warning] 1-1: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L1
Added line #L1 was not covered by tests


[warning] 3-3: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L3
Added line #L3 was not covered by tests


[warning] 9-9: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L9
Added line #L9 was not covered by tests


[warning] 16-16: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L16
Added line #L16 was not covered by tests


[warning] 25-25: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L25
Added line #L25 was not covered by tests

🔇 Additional comments (17)
frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts (1)

1-31: 스타일 컴포넌트 분리가 잘 구현되었습니다.

인라인 스타일 컴포넌트를 별도 파일로 분리하여 코드의 가독성과 유지보수성이 향상되었습니다. 각 스타일 컴포넌트들이 의미적으로 명확하게 명명되어 있고, 스타일 정의도 일관성 있게 작성되었습니다.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1-1: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L1
Added line #L1 was not covered by tests


[warning] 3-3: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L3
Added line #L3 was not covered by tests


[warning] 9-9: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L9
Added line #L9 was not covered by tests


[warning] 16-16: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L16
Added line #L16 was not covered by tests


[warning] 25-25: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.styles.ts#L25
Added line #L25 was not covered by tests

frontend/src/types/application.ts (1)

1-8: QuestionType 유니온 타입이 잘 정의되었습니다.

다양한 질문 유형을 포괄하는 타입이 명확하게 정의되어 있어 타입 안전성이 보장됩니다.

frontend/src/pages/AdminPage/application/components/QuestionDescription/QuestionDescription.tsx (1)

6-6: props 이름이 더 명확하게 개선되었습니다.

onChange에서 onDescriptionChange로 변경하여 콜백 함수의 목적이 더 명확해졌습니다. 이는 다른 컴포넌트들과의 일관성도 향상시킵니다.

Also applies to: 22-22, 31-31

frontend/src/pages/AdminPage/application/CreateForm.tsx (2)

6-7: 중앙화된 타입 정의 사용이 잘 적용되었습니다.

기존 로컬 타입 정의를 제거하고 중앙화된 타입을 import하여 코드의 일관성과 유지보수성이 향상되었습니다.


12-12: 명시적 id 필드 추가가 좋은 개선입니다.

질문 객체에 명시적인 id 필드를 추가하여 데이터 구조가 더 명확해졌습니다.

Also applies to: 21-21

frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.tsx (3)

1-1: 스타일 분리가 잘 이루어졌습니다.

스타일 컴포넌트들을 별도 파일로 분리하여 관심사 분리가 개선되었습니다.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1-1: frontend/src/pages/AdminPage/application/components/QuestionTitle/QuestionTitle.tsx#L1
Added line #L1 was not covered by tests


8-8: prop 이름 변경이 명확성을 향상시킵니다.

onChangeonTitleChange로 변경한 것은 해당 콜백의 목적을 더 명확하게 표현합니다. 다른 컴포넌트들과의 일관성도 개선되었습니다.

Also applies to: 16-16, 27-27


19-21: 스타일 컴포넌트 사용이 일관성 있게 적용되었습니다.

모든 스타일 컴포넌트가 Styled namespace를 통해 일관성 있게 사용되고 있습니다.

Also applies to: 29-30

frontend/src/pages/AdminPage/application/fields/Choice.tsx (3)

6-6: 타입 중앙화가 성공적으로 이루어졌습니다.

ChoiceProps@/types/application에서 import하여 타입 정의가 중앙화되었습니다. 이는 코드 일관성과 유지보수성을 크게 향상시킵니다.


49-49: prop 이름이 명확하게 개선되었습니다.

onTitleChangeonDescriptionChange로 변경된 prop 이름들이 각각의 역할을 더 명확하게 표현합니다.

Also applies to: 54-54


1-1: 스타일 분리와 컴포넌트 사용이 올바르게 적용되었습니다.

스타일 컴포넌트들이 별도 파일로 분리되었고, Styled namespace를 통해 일관성 있게 사용되고 있습니다.

Also applies to: 57-57, 65-67, 73-75

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1-1: frontend/src/pages/AdminPage/application/fields/Choice.tsx#L1
Added line #L1 was not covered by tests

frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx (2)

6-7: 타입 정의 중앙화가 성공적으로 완료되었습니다.

QuestionTypeQuestionBuilderProps@/types/application에서 import하여 타입 정의의 일관성이 향상되었습니다.


13-13: options 패턴으로 변경이 잘 구현되었습니다.

required boolean prop을 options?.required 패턴으로 변경한 것은 향후 확장성을 고려한 좋은 설계입니다. 옵셔널 체이닝을 통해 안전하게 처리되고 있습니다.

Also applies to: 44-44, 58-58, 104-104, 107-107

frontend/src/pages/AdminPage/application/fields/ShortText.tsx (2)

5-5: 타입 중앙화가 올바르게 적용되었습니다.

ShortTextProps@/types/application에서 import하여 타입 정의의 중앙화가 완료되었습니다.


14-14: prop 이름 변경이 일관성 있게 적용되었습니다.

onAnswerChange, onTitleChange, onDescriptionChange로 변경된 prop 이름들이 각각의 역할을 명확하게 표현하며, 다른 컴포넌트들과의 일관성도 유지되고 있습니다.

Also applies to: 25-25, 30-30, 34-34

frontend/src/pages/AdminPage/application/fields/Choice.styles.ts (2)

1-2: styled-components import 승인 및 테스트 커버리지 경고 무시
스타일 컴포넌트 파일은 UI 렌더링 전용이므로 유닛 테스트에서 커버하지 않아도 무방합니다. 코드 커버리지 경고는 무시하셔도 좋습니다.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1-1: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L1
Added line #L1 was not covered by tests


15-20: ItemWrapper 스타일 승인
flex 레이아웃과 gap 설정이 적절하며, 읽기 쉬운 구조입니다.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 15-15: frontend/src/pages/AdminPage/application/fields/Choice.styles.ts#L15
Added line #L15 was not covered by tests

Comment on lines +21 to +27
export interface QuestionBuilderProps extends Question {
onTitleChange: (value: string) => void;
onDescriptionChange: (value: string) => void;
onItemsChange?: (newItems: { value: string }[]) => void;
onTypeChange?: (type: QuestionType) => void;
onRequiredChange?: (required: boolean) => void;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

콜백 함수들의 필수/선택 여부를 검토해보세요.

일부 중요한 콜백 함수들이 선택적(optional)으로 정의되어 있는데, 실제 사용 시 필수적일 수 있습니다. 실제 사용 패턴을 확인하여 적절한 타입 정의를 적용하세요.

다음 스크립트로 실제 사용 패턴을 확인해보세요:


🏁 Script executed:

#!/bin/bash
# Description: QuestionBuilderProps의 콜백 함수 사용 패턴 확인

# QuestionBuilder 컴포넌트에서 이러한 콜백들이 어떻게 사용되는지 확인
rg -A 10 -B 5 "QuestionBuilderProps" --type ts --type tsx

Length of output: 85


tsx 파일도 포함해 전체 파일에서 검색해 보겠습니다. 다음 스크립트를 실행해 주세요:


🏁 Script executed:

#!/bin/bash
# QuestionBuilderProps의 사용 패턴을 전체 파일에서 확인
rg -A 10 -B 5 "QuestionBuilderProps"

Length of output: 4534


QuestionBuilder 컴포넌트 내부에서 콜백들이 실제로 어떻게 호출되는지 확인해 보겠습니다. 다음 스크립트를 실행해 주세요:


🏁 Script executed:

#!/bin/bash
# QuestionBuilder 컴포넌트에서 콜백 호출 패턴 확인

rg -n -C3 "onTitleChange" frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx
rg -n -C3 "onDescriptionChange" frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx
rg -n -C3 "onItemsChange" frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx
rg -n -C3 "onTypeChange" frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx
rg -n -C3 "onRequiredChange" frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx

Length of output: 3785


AdminPage에서 QuestionBuilder가 어떻게 사용되며 콜백이 실제로 모두 전달되는지 확인해보겠습니다. 아래 스크립트를 실행해주세요:


🏁 Script executed:

#!/bin/bash
# QuestionBuilder 사용 위치 및 전달되는 props 확인
rg -n "<QuestionBuilder" -n frontend/src/pages/AdminPage

Length of output: 143


CreateForm.tsx에서 QuestionBuilder에 전달되는 모든 props를 확인해보겠습니다. 다음 스크립트를 실행해주세요:


🏁 Script executed:

#!/bin/bash
# CreateForm에서 QuestionBuilder 호출부 확인 (90~140행)
sed -n '90,140p' frontend/src/pages/AdminPage/application/CreateForm.tsx

Length of output: 1035


QuestionBuilderProps 콜백 함수 필수화 제안

CreateForm.tsx에서 QuestionBuilder를 사용할 때 모든 콜백(onItemsChange, onTypeChange, onRequiredChange)이 항상 전달되므로, 인터페이스에서 선택(optional)으로 정의된 부분을 필수(required)로 변경하는 것이 안전합니다.아울러 컴포넌트 내 optional chaining(?.)도 제거하여 타입·실행 일관성을 맞출 수 있습니다.

수정 대상:

  • frontend/src/types/application.ts (QuestionBuilderProps 정의)
  • frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx (optional chaining 제거)

예시 diff (application.ts):

 export interface QuestionBuilderProps extends Question {
   onTitleChange: (value: string) => void;
   onDescriptionChange: (value: string) => void;
-  onItemsChange?: (newItems: { value: string }[]) => void;
-  onTypeChange?: (type: QuestionType) => void;
-  onRequiredChange?: (required: boolean) => void;
+  onItemsChange: (newItems: { value: string }[]) => void;
+  onTypeChange: (type: QuestionType) => void;
+  onRequiredChange: (required: boolean) => void;
 }

QuestionBuilder.tsx 내:

  • onTypeChange?.('CHOICE')onTypeChange('CHOICE')
  • onTypeChange?.('MULTI_CHOICE')onTypeChange('MULTI_CHOICE')
  • onTypeChange?.(selectedType)onTypeChange(selectedType)
  • onRequiredChange?.(!options?.required)onRequiredChange(!options.required)

이렇게 변경하면 타입스크립트 레벨에서 누락된 콜백 전달을 방지하고, 컴포넌트 내부에서 불필요한 optional chaining을 제거할 수 있습니다.

📝 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
export interface QuestionBuilderProps extends Question {
onTitleChange: (value: string) => void;
onDescriptionChange: (value: string) => void;
onItemsChange?: (newItems: { value: string }[]) => void;
onTypeChange?: (type: QuestionType) => void;
onRequiredChange?: (required: boolean) => void;
}
export interface QuestionBuilderProps extends Question {
onTitleChange: (value: string) => void;
onDescriptionChange: (value: string) => void;
onItemsChange: (newItems: { value: string }[]) => void;
onTypeChange: (type: QuestionType) => void;
onRequiredChange: (required: boolean) => void;
}
🤖 Prompt for AI Agents
In frontend/src/types/application.ts lines 21 to 27, the callback functions
onItemsChange, onTypeChange, and onRequiredChange are currently optional but are
always passed in actual usage. Change their definitions to required (remove the
optional '?') to reflect this. Then, in
frontend/src/pages/AdminPage/application/components/QuestionBuilder/QuestionBuilder.tsx,
remove all optional chaining (?.) when calling these callbacks to ensure
consistent typing and execution.

title={question.title}
description={question.description}
required={question.options?.required ?? false}
options={question.options ?? false}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

options prop의 타입 불일치를 수정해야 합니다.

question.options ?? false는 타입 불일치를 발생시킵니다. Question 인터페이스에 따르면 options는 객체여야 하는데, fallback으로 false(boolean)를 전달하고 있습니다.

다음과 같이 수정하세요:

-          options={question.options ?? false}
+          options={question.options ?? { required: false }}

또는 QuestionBuilder 컴포넌트에서 options가 실제로 어떤 타입을 기대하는지 확인이 필요합니다.

다음 스크립트로 QuestionBuilder의 props 타입을 확인해보세요:


🏁 Script executed:

#!/bin/bash
# Description: QuestionBuilder 컴포넌트의 options prop 타입 확인

# QuestionBuilder 컴포넌트의 인터페이스 정의 확인
ast-grep --pattern 'interface $_ {
  $$$
  options: $_
  $$$
}'

# QuestionBuilder 컴포넌트에서 options prop 사용 방법 확인
rg -A 5 -B 5 "options.*:" frontend/src/pages/AdminPage/application/components/QuestionBuilder/

Length of output: 710


QuestionBuilder 컴포넌트의 props 타입 정의를 찾을 수 없어 타입 확인이 불가능합니다. 아래 스크립트로 컴포넌트 파일 경로를 탐색하고, props 인터페이스를 조회해 주세요:


🏁 Script executed:

#!/bin/bash
# 1. QuestionBuilder 컴포넌트 파일 경로 찾기
echo "== QuestionBuilder 파일 경로 =="
fd --hidden --full-path QuestionBuilder -t f

# 2. 첫 번째로 찾은 파일을 열어 상단 200줄 출력
FILE=$(fd --hidden --full-path QuestionBuilder -t f | head -n1)
echo "== 파일: $FILE =="
sed -n '1,200p' "$FILE"

# 3. props 인터페이스 또는 타입 선언 조회
echo "== props 인터페이스/타입 검색 =="
rg -A3 -B3 "interface .*QuestionBuilder" "$FILE"
rg -A3 -B3 "type .*QuestionBuilderProps" "$FILE"
rg -A3 -B3 "QuestionBuilder\s*[:=]\s*React\.(FC|FunctionComponent)" -n "$FILE"

Length of output: 3402


아직 QuestionBuilder.tsx 파일의 props 타입을 확인하지 못했습니다. 아래 스크립트로 실제 컴포넌트 파일에서 options 타입 정의를 조회해 주세요:


🏁 Script executed:

#!/bin/bash
# 1. QuestionBuilder.tsx 파일 경로 찾기
echo "== QuestionBuilder.tsx 파일 경로 =="
fd --hidden -t f 'QuestionBuilder.tsx'

# 2. 상단 200줄 출력하여 props 선언 확인
FILE=$(fd --hidden -t f 'QuestionBuilder.tsx' | head -n1)
echo "== 파일: $FILE =="
sed -n '1,200p' "$FILE"

# 3. props 인터페이스/타입 및 options 사용 검색
echo "== props 인터페이스/타입 선언 =="
rg -C3 "interface .*Props" "$FILE"
rg -C3 "type .*Props" "$FILE"
rg -C3 "QuestionBuilder\s*[:=]\s*React\.(FC|FunctionComponent)" -n "$FILE"

echo "== options prop 사용 검색 =="
rg -C3 "options" "$FILE"

Length of output: 5857


아래 스크립트로 QuestionBuilderProps에서 options의 정확한 타입 선언을 확인해주세요:


🏁 Script executed:

#!/bin/bash
# QuestionBuilderProps 타입 정의 조회
echo "== QuestionBuilderProps 정의 =="
rg -n "QuestionBuilderProps" -C5 frontend/src/types/application.ts || true

Length of output: 533


options prop 타입 일치하도록 기본값 수정 필요

QuestionBuilderPropsoptions{ required: boolean } 객체 타입이기 때문에 boolean(false)을 넘기면 타입 불일치가 발생합니다. 기본값으로 객체를 전달하도록 수정하세요.

  • 수정 위치: frontend/src/pages/AdminPage/application/CreateForm.tsx (113행)
-          options={question.options ?? false}
+          options={question.options ?? { required: false }}
📝 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
options={question.options ?? false}
options={question.options ?? { required: false }}
🤖 Prompt for AI Agents
In frontend/src/pages/AdminPage/application/CreateForm.tsx at line 113, the
options prop is assigned a fallback value of false, causing a type mismatch
since options expects an object type like { required: boolean }. Fix this by
changing the fallback from false to an object with the appropriate shape, for
example { required: false }, to match the expected type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FE Frontend 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] FE-126 지원서 타입 분리

2 participants

Comments