-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/115/reviewing form api #161
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
Conversation
Walkthrough์ด ๋ณ๊ฒฝ ์ฌํญ์ Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
๐storybook: https://67206cc6ff9d7a05a3528ff8-etmpgotgra.chromatic.com/ |
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.
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 ๊ตฌํ ์ํคํ ์ฒ ๊ฐ์ ์ ์
- ์ค์ ์ง์ค์ ์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ๋ณ๋์ ์๋ฌ ํธ๋ค๋ฌ ์ ํธ๋ฆฌํฐ๋ฅผ ๊ตฌํํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
- API ์๋ต ํ์ ์ ๋ช ์์ ์ผ๋ก ์ ์ํ๊ณ ๋ฌธ์ํํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
- 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
๐ 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
| export interface PostReviewParams { | ||
| gatheringId?: number; | ||
| point: number; | ||
| reviewText: string; | ||
| } |
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.
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.
| export interface PostReviewParams { | |
| gatheringId?: number; | |
| point: number; | |
| reviewText: string; | |
| } | |
| export interface PostReviewParams { | |
| gatheringId: number; | |
| point: number; | |
| reviewText: string; | |
| } |
| 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; | ||
| } |
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.
๐ ๏ธ Refactor suggestion
API ์์ฒญ ๋ณธ๋ฌธ์ ํ๋๋ช ๋ถ์ผ์น ๋ฐ ์ค๋ฅ ์ฒ๋ฆฌ ๊ฐ์ ํ์
-
์ธํฐํ์ด์ค์ API ์์ฒญ ๋ณธ๋ฌธ์ ํ๋๋ช ์ด ์ผ์นํ์ง ์์ต๋๋ค:
pointโratereviewTextโcomment
-
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.
| 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('๋ฆฌ๋ทฐ๋ฅผ ๋ฑ๋กํ๋ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.'); | |
| } | |
| } |
| const { | ||
| field: { value: scoreValue, onChange: setScore }, | ||
| } = useController({ name: 'score', control, defaultValue: 0 }); |
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.
์ ์(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
| onError: (error: ApiError) => { | ||
| // eslint-disable-next-line no-console | ||
| console.error(error); | ||
| }, |
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.
๐ ๏ธ Refactor suggestion
์๋ฌ ๋ฐ์ ์ ์ฌ์ฉ์์๊ฒ ์ค๋ฅ ๋ฉ์์ง๋ฅผ ํ์ํ์ญ์์ค
ํ์ฌ ์๋ฌ ๋ฐ์ ์ console.error(error);๋ก๋ง ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค. ์ฌ์ฉ์์๊ฒ ์๋ฌ๊ฐ ๋ฐ์ํ์์ ์๋ฆด ์ ์๋๋ก UI ์์ ์ ์ ํ ์ค๋ฅ ๋ฉ์์ง๋ฅผ ํ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์๋ฌ ๋ฉ์์ง๋ฅผ ์ฌ์ฉ์์๊ฒ ํ์ํ๊ธฐ ์ํด ์๋ฆผ ๋๋ ์๋ฌ ํ์ ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์ ๊ฒฝํ์ ํฅ์์ํฌ ์ ์์ต๋๋ค.
|
|
||
| interface ReviewProps { | ||
| interface ReviewFormProps { | ||
| gatheringId?: number; |
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.
gatheringId๋ฅผ ํ์ ํ๋กํผํฐ๋ก ์ง์ ํ์ญ์์ค
ํ์ฌ gatheringId๊ฐ ์ ํ์ (?)์ผ๋ก ์ ์๋์ด ์์ง๋ง, ๋ฆฌ๋ทฐ ์์ฑ์ ํ์์ ์ธ ๊ฐ์ด๋ฏ๋ก ํ์ ํ๋กํผํฐ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์์ ํ์ญ์์ค:
interface ReviewFormProps {
- gatheringId?: number;
+ gatheringId: number;
onCancel: () => void;
}Committable suggestion skipped: line range outside the PR's diff.
|
๐storybook: https://67206cc6ff9d7a05a3528ff8-fbmzqtpntn.chromatic.com/ |
yulrang
left a comment
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.
์๋๋ค์~~~ ๋ ์ด์์ ํ์ผ๋ง ์์ ํ๋ฉด ๋ ๊ฒ๊ฐ์์ฌ
|
๐storybook: https://67206cc6ff9d7a05a3528ff8-mhsucoevgh.chromatic.com/ |
๐ Issue Ticket
Ticket
โ๏ธ Description
๋ฆฌ๋ทฐ ๊ฐ๋ฅ ์ฝ์ ๋ชฉ๋ก์์ ์์ฑ ๋ชจ๋ฌ์ ๋์ฐ๊ณ
๋ฆฌ๋ทฐ POST ์์ฒญ ํจ์๋ฅผ ๋ชจ๋ฌ๊ณผ ์ฐ๊ฒฐํ์ต๋๋ค
โ Checklist
PR
Test
๋ฌด์ฌํ ํฌ์คํธ ๋จ์ ์ค์จ๊ฑฐ์์ ํ์ธํจ
Summary by CodeRabbit
์๋ก์ด ๊ธฐ๋ฅ
ReviewingModal์์ReviewForm์gatheringId๋ฅผ ์ ๋ฌํ๋๋ก ์์ ๋์์ต๋๋ค.๋ฒ๊ทธ ์์
๋ฌธ์ํ