Skip to content

Conversation

@ChoYenii
Copy link
Contributor

@ChoYenii ChoYenii commented Nov 21, 2024

๐Ÿ”– Issue Ticket

Ticket

โœ๏ธ Description

๋ฆฌ๋ทฐ ๊ฐ€๋Šฅ ์•ฝ์† ๋ชฉ๋ก์—์„œ ์ž‘์„ฑ ๋ชจ๋‹ฌ์„ ๋„์šฐ๊ณ 
๋ฆฌ๋ทฐ POST ์š”์ฒญ ํ•จ์ˆ˜๋ฅผ ๋ชจ๋‹ฌ๊ณผ ์—ฐ๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค

โœ… Checklist

PR

  • Branch Convention ํ™•์ธ

    feat/ ํ”ผ์ณ, fix/ ๋ฒ„๊ทธ ์ˆ˜์ •, refactor/ ๊ฐœ์„ 

  • Base Branch ํ™•์ธ
  • ์ ์ ˆํ•œ Label ์ง€์ •
  • Assignee ๋ฐ Reviewer ์ง€์ •

Test

  • ๋กœ์ปฌ ์ž‘๋™ ํ™•์ธ
    ์Šคํฌ๋ฆฐ์ƒท 2024-11-21 150236
    ๋ฌด์‚ฌํžˆ ํฌ์ŠคํŠธ ๋จ์„ ์Šค์›จ๊ฑฐ์—์„œ ํ™•์ธํ•จ

Summary by CodeRabbit

  • ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ

    • ๋ฆฌ๋ทฐ๋ฅผ ๊ฒŒ์‹œํ•˜๊ธฐ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์ธํ„ฐํŽ˜์ด์Šค์™€ ๋น„๋™๊ธฐ ํ•จ์ˆ˜๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    • ๋ฆฌ๋ทฐ ํผ์—์„œ ์ ์ˆ˜์™€ ๋ฆฌ๋ทฐ ํ…์ŠคํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ด ๊ฐœ์„ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    • ReviewingModal์—์„œ ReviewForm์— gatheringId๋ฅผ ์ „๋‹ฌํ•˜๋„๋ก ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ฒ„๊ทธ ์ˆ˜์ •

    • ๋ฆฌ๋ทฐ ํ…์ŠคํŠธ์˜ ๊ธธ์ด๋ฅผ 300์ž๋กœ ์ œํ•œํ•˜๋Š” ๊ธฐ๋Šฅ์ด ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ฌธ์„œํ™”

    • ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ์ปดํฌ๋„ŒํŠธ์™€ ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

@ChoYenii ChoYenii linked an issue Nov 21, 2024 that may be closed by this pull request
3 tasks
@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ PostReviewParams๋ผ๋Š” ์ƒˆ๋กœ์šด ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ •์˜ํ•˜๊ณ , ์ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฆฌ๋ทฐ๋ฅผ ๊ฒŒ์‹œํ•˜๋Š” ๋น„๋™๊ธฐ ํ•จ์ˆ˜ postReview๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ, MyPage ์ปดํฌ๋„ŒํŠธ์— children์„ ๋‘ ๋ฒˆ ๋ Œ๋”๋งํ•˜๋„๋ก ์ˆ˜์ •ํ•˜๊ณ , ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ณ€๊ฒฝํ•˜๋ฉฐ, ์ƒํƒœ ๊ด€๋ฆฌ๋ฅผ ๊ฐœ์„ ํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ReviewingModal ์ปดํฌ๋„ŒํŠธ์—์„œ ReviewForm์— gatheringId๋ฅผ ์ „๋‹ฌํ•˜๋„๋ก ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Changes

ํŒŒ์ผ ๊ฒฝ๋กœ ๋ณ€๊ฒฝ ์š”์•ฝ
src/_apis/review/review-apis.ts - ์ธํ„ฐํŽ˜์ด์Šค ์ถ”๊ฐ€: PostReviewParams
- ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€: postReview(params: PostReviewParams): Promise<ResponseType>
src/app/(crew)/my-page/layout.tsx - ์ž„ํฌํŠธ ์ถ”๊ฐ€: import { ReactNode } from 'react';
- children์„ ๋‘ ๋ฒˆ ๋ Œ๋”๋งํ•˜๋„๋ก ์ˆ˜์ •
src/components/my-page/reviewing-modal/review-form.tsx - ์ธํ„ฐํŽ˜์ด์Šค ์ด๋ฆ„ ๋ณ€๊ฒฝ: ReviewProps โ†’ ReviewFormProps
- ์ƒˆ๋กœ์šด ์†์„ฑ ์ถ”๊ฐ€: gatheringId
- ์ƒํƒœ ๊ด€๋ฆฌ ๊ฐœ์„  ๋ฐ ์ œ์ถœ ํ•ธ๋“ค๋Ÿฌ ์ถ”๊ฐ€
src/components/my-page/reviewing-modal/reviewing-modal.tsx - ReviewForm ํ˜ธ์ถœ ์‹œ gatheringId ์ถ”๊ฐ€: <ReviewForm gatheringId={gatheringId} onCancel={close} />

Possibly related PRs

  • Feat/CR-63/ReviewingModalย #68: ReviewForm ์ปดํฌ๋„ŒํŠธ์— ์ƒˆ๋กœ์šด ์„ ํƒ์  ์†์„ฑ gatheringId๊ฐ€ ์ถ”๊ฐ€๋˜์–ด, ๋ฉ”์ธ PR์˜ PostReviewParams ์ธํ„ฐํŽ˜์ด์Šค์™€ postReview ํ•จ์ˆ˜์™€ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.
  • Feat/139/gathering card UI - ๋ชจ๋‹ฌ API ์—ฐ๊ฒฐย #141: ScheduledGatheringCardContainer๊ฐ€ crewId์™€ id๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ์ž„ ์„ธ๋ถ€์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋„๋ก ์ˆ˜์ •๋˜์–ด, ๋ฉ”์ธ PR์˜ postReview ํ•จ์ˆ˜์—์„œ ๋„์ž…๋œ gatheringId ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

Suggested labels

api, components, refactor

Suggested reviewers

  • yulrang
  • HaeJungg

๐Ÿฐ ์ƒˆ๋กœ์šด ๋ฆฌ๋ทฐ๊ฐ€ ์˜ฌ ๋•Œ๋งˆ๋‹ค,
gatheringId์™€ ํ•จ๊ป˜ ๋‹ค๊ฐ€์™€,
ReviewForm์— ๋‹ด์•„๋‚ผ ์ด์•ผ๊ธฐ,
๋‘ ๋ฒˆ์˜ ๋ Œ๋”๋ง, ๋” ํ’์„ฑํ•œ ์„ธ์ƒ์œผ๋กœ!
ํ•จ๊ป˜ ๋‚˜๋ˆ„๋Š” ์ด ์ˆœ๊ฐ„๋“ค,
์ฆ๊ฑฐ์šด ๋ฆฌ๋ทฐ์˜ ์‹œ๊ฐ„ ๋˜๊ธธ! ๐ŸŒŸ


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 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.

@ChoYenii ChoYenii added the api label Nov 21, 2024
@github-actions
Copy link

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: 6

๐Ÿงน Outside diff range and nitpick comments (3)
src/app/(crew)/my-page/layout.tsx (1)

13-13: ๋ถˆํ•„์š”ํ•œ ๋นˆ div ํƒœ๊ทธ๋ฅผ ์ œ๊ฑฐํ•ด์ฃผ์„ธ์š”

๋นˆ div ํƒœ๊ทธ๋Š” ์•„๋ฌด๋Ÿฐ ๋ชฉ์ ๋„ ์—†์œผ๋ฉฐ DOM์„ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ๋ณต์žกํ•˜๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

src/_apis/review/review-apis.ts (1)

1-20: API ๊ตฌํ˜„ ์•„ํ‚คํ…์ฒ˜ ๊ฐœ์„  ์ œ์•ˆ

  1. ์ค‘์•™ ์ง‘์ค‘์‹ ์—๋Ÿฌ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋ณ„๋„์˜ ์—๋Ÿฌ ํ•ธ๋“ค๋Ÿฌ ์œ ํ‹ธ๋ฆฌํ‹ฐ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”.
  2. API ์‘๋‹ต ํƒ€์ž…์„ ๋ช…์‹œ์ ์œผ๋กœ ์ •์˜ํ•˜๊ณ  ๋ฌธ์„œํ™”ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
  3. API ์š”์ฒญ/์‘๋‹ต์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๊ณ„์ธต ์ถ”๊ฐ€๋ฅผ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”.

์˜ˆ์‹œ ๊ตฌํ˜„์ด ํ•„์š”ํ•˜์‹œ๋‹ค๋ฉด ๋ง์”€ํ•ด ์ฃผ์„ธ์š”.

src/components/my-page/reviewing-modal/review-form.tsx (1)

56-57: ๋ถˆํ•„์š”ํ•œ ์ฝ˜์†” ๋กœ๊ทธ๋ฅผ ์ œ๊ฑฐํ•˜์‹ญ์‹œ์˜ค

console.log(data);๋Š” ๋””๋ฒ„๊น… ์šฉ๋„๋กœ ๋ณด์ž…๋‹ˆ๋‹ค. ๋ฐฐํฌ ์‹œ์—๋Š” ๋ถˆํ•„์š”ํ•œ ์ฝ˜์†” ๋กœ๊ทธ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

์ฝ˜์†” ๋กœ๊ทธ๋ฅผ ์ œ๊ฑฐํ•˜๊ฑฐ๋‚˜ ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๋กœ๊น… ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ๊ทธ๋ฅผ ๊ด€๋ฆฌํ•˜์‹ญ์‹œ์˜ค.

๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 6971d02 and 99f1b4c.

๐Ÿ“’ Files selected for processing (4)
  • src/_apis/review/review-apis.ts (1 hunks)
  • src/app/(crew)/my-page/layout.tsx (2 hunks)
  • src/components/my-page/reviewing-modal/review-form.tsx (3 hunks)
  • src/components/my-page/reviewing-modal/reviewing-modal.tsx (1 hunks)
๐Ÿ”‡ Additional comments (1)
src/components/my-page/reviewing-modal/reviewing-modal.tsx (1)

34-34: ์ฝ”๋“œ๊ฐ€ ์ž˜ ๊ตฌํ˜„๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

ReviewForm ์ปดํฌ๋„ŒํŠธ์— gatheringId prop์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ „๋‹ฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ์ธํ„ฐํŽ˜์ด์Šค ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

โœ… Verification successful

ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ •์˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค

ReviewFormProps ์ธํ„ฐํŽ˜์ด์Šค์— gatheringId๊ฐ€ ์„ ํƒ์  ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ •์˜๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ปดํฌ๋„ŒํŠธ ์‚ฌ์šฉ ํŒจํ„ด๋„ ์ผ๊ด€์„ฑ ์žˆ๊ฒŒ ๊ตฌํ˜„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ์ธํ„ฐํŽ˜์ด์Šค ๋ณ€๊ฒฝ์‚ฌํ•ญ ํ™•์ธ

# ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ํƒ€์ž… ์ •์˜ ํ™•์ธ
ast-grep --pattern 'interface ReviewFormProps {
  $$$
}'

# ReviewForm ์ปดํฌ๋„ŒํŠธ์˜ ์‚ฌ์šฉ ํŒจํ„ด ํ™•์ธ
rg '<ReviewForm' -A 2

Length of output: 651

Comment on lines +3 to +7
export interface PostReviewParams {
gatheringId?: number;
point: number;
reviewText: string;
}
Copy link

Choose a reason for hiding this comment

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

โš ๏ธ Potential issue

gatheringId๋ฅผ ํ•„์ˆ˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

gatheringId๊ฐ€ ์„ ํƒ์  ๋งค๊ฐœ๋ณ€์ˆ˜(optional)๋กœ ์ •์˜๋˜์–ด ์žˆ์ง€๋งŒ, API ์—”๋“œํฌ์ธํŠธ URL์—์„œ๋Š” ํ•„์ˆ˜๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋Ÿฐํƒ€์ž„ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

export interface PostReviewParams {
-  gatheringId?: number;
+  gatheringId: number;
  point: number;
  reviewText: string;
}
๐Ÿ“ 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 PostReviewParams {
gatheringId?: number;
point: number;
reviewText: string;
}
export interface PostReviewParams {
gatheringId: number;
point: number;
reviewText: string;
}

Comment on lines +9 to +20
export async function postReview(params: PostReviewParams): Promise<ResponseType> {
const { gatheringId, point, reviewText } = params;

const response = await fetchApi<ResponseType>(`/api/review/${gatheringId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ rate: point, comment: reviewText }),
});
return response;
}
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

API ์š”์ฒญ ๋ณธ๋ฌธ์˜ ํ•„๋“œ๋ช… ๋ถˆ์ผ์น˜ ๋ฐ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ ๊ฐœ์„  ํ•„์š”

  1. ์ธํ„ฐํŽ˜์ด์Šค์™€ API ์š”์ฒญ ๋ณธ๋ฌธ์˜ ํ•„๋“œ๋ช…์ด ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค:

    • point โ†’ rate
    • reviewText โ†’ comment
  2. API ํ˜ธ์ถœ ์‹คํŒจ์— ๋Œ€ํ•œ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

export async function postReview(params: PostReviewParams): Promise<ResponseType> {
  const { gatheringId, point, reviewText } = params;

+ try {
    const response = await fetchApi<ResponseType>(`/api/review/${gatheringId}`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
-     body: JSON.stringify({ rate: point, comment: reviewText }),
+     body: JSON.stringify({ point, reviewText }),
    });
    return response;
+ } catch (error) {
+   console.error('๋ฆฌ๋ทฐ ๋“ฑ๋ก ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
+   throw new Error('๋ฆฌ๋ทฐ๋ฅผ ๋“ฑ๋กํ•˜๋Š” ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.');
+ }
}

๋˜ํ•œ, API ์‘๋‹ต ํƒ€์ž…์„ ๋ช…์‹œ์ ์œผ๋กœ ์ •์˜ํ•˜๊ณ  ResponseType์„ ๊ตฌ์ฒด์ ์ธ ํƒ€์ž…์œผ๋กœ ๋Œ€์ฒดํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“ 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 async function postReview(params: PostReviewParams): Promise<ResponseType> {
const { gatheringId, point, reviewText } = params;
const response = await fetchApi<ResponseType>(`/api/review/${gatheringId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ rate: point, comment: reviewText }),
});
return response;
}
export async function postReview(params: PostReviewParams): Promise<ResponseType> {
const { gatheringId, point, reviewText } = params;
try {
const response = await fetchApi<ResponseType>(`/api/review/${gatheringId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ point, reviewText }),
});
return response;
} catch (error) {
console.error('๋ฆฌ๋ทฐ ๋“ฑ๋ก ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
throw new Error('๋ฆฌ๋ทฐ๋ฅผ ๋“ฑ๋กํ•˜๋Š” ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.');
}
}

Comment on lines +24 to +26
const {
field: { value: scoreValue, onChange: setScore },
} = useController({ name: 'score', control, defaultValue: 0 });
Copy link

Choose a reason for hiding this comment

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

โš ๏ธ Potential issue

์ ์ˆ˜(score) ํ•„๋“œ๊ฐ€ ํผ์— ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋“ฑ๋ก๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค

ํ˜„์žฌ useController ํ›…์—์„œ field๋ฅผ ๊ตฌ์กฐ ๋ถ„ํ•ดํ•˜์—ฌ value์™€ onChange๋งŒ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ <input> ์š”์†Œ์—์„œ field ์ „์ฒด๋ฅผ spreadํ•˜์—ฌ ํผ์— ํ•„๋“œ๋ฅผ ๋“ฑ๋กํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด score ๊ฐ’์ด ํผ ์ œ์ถœ ์‹œ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค.

์ˆ˜์ •์„ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค:

- const {
-   field: { value: scoreValue, onChange: setScore },
- } = useController({ name: 'score', control, defaultValue: 0 });

- <input type="hidden" value={scoreValue} />
+ const { field } = useController({ name: 'score', control, defaultValue: 0 });

+ <input type="hidden" {...field} />

Also applies to: 88-88

Comment on lines +49 to +52
onError: (error: ApiError) => {
// eslint-disable-next-line no-console
console.error(error);
},
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ ์‚ฌ์šฉ์ž์—๊ฒŒ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ํ‘œ์‹œํ•˜์‹ญ์‹œ์˜ค

ํ˜„์žฌ ์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ console.error(error);๋กœ๋งŒ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์—๊ฒŒ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Œ์„ ์•Œ๋ฆด ์ˆ˜ ์žˆ๋„๋ก UI ์ƒ์— ์ ์ ˆํ•œ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด ์•Œ๋ฆผ ๋˜๋Š” ์—๋Ÿฌ ํ‘œ์‹œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


interface ReviewProps {
interface ReviewFormProps {
gatheringId?: number;
Copy link

Choose a reason for hiding this comment

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

โš ๏ธ Potential issue

gatheringId๋ฅผ ํ•„์ˆ˜ ํ”„๋กœํผํ‹ฐ๋กœ ์ง€์ •ํ•˜์‹ญ์‹œ์˜ค

ํ˜„์žฌ gatheringId๊ฐ€ ์„ ํƒ์ (?)์œผ๋กœ ์ •์˜๋˜์–ด ์žˆ์ง€๋งŒ, ๋ฆฌ๋ทฐ ์ž‘์„ฑ์— ํ•„์ˆ˜์ ์ธ ๊ฐ’์ด๋ฏ€๋กœ ํ•„์ˆ˜ ํ”„๋กœํผํ‹ฐ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜์‹ญ์‹œ์˜ค:

interface ReviewFormProps {
-  gatheringId?: number;
+  gatheringId: number;
  onCancel: () => void;
}

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

@github-actions
Copy link

Copy link
Contributor

@yulrang yulrang left a comment

Choose a reason for hiding this comment

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

์ž˜๋˜๋„ค์š”~~~ ๋ ˆ์ด์•„์›ƒ ํŒŒ์ผ๋งŒ ์ˆ˜์ •ํ•˜๋ฉด ๋ ๊ฒƒ๊ฐ™์•„์—ฌ

@github-actions
Copy link

@ChoYenii ChoYenii merged commit 59eaf95 into develop Nov 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

๋ฆฌ๋ทฐ ์ž‘์„ฑ ๋ชจ๋‹ฌ api ์—ฐ๊ฒฐ

4 participants