Skip to content

Conversation

@ChoYenii
Copy link
Contributor

@ChoYenii ChoYenii commented Nov 6, 2024

๐Ÿ”– Issue Ticket

Ticket

โœ๏ธ Description

๋ฆฌ๋ทฐ ์ž‘์„ฑ ๋ชจ๋‹ฌ์—์„œ ํผ ์ปดํฌ๋„ŒํŠธ์˜ api ๊ด€๋ จ ํ•จ์ˆ˜๋Š” swagger ๋ฐ›๊ณ  ์–ด์ฐจํ”ผ ๋‹ค์‹œ ํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™์•„ ์ฃผ์„ ์ฒ˜๋ฆฌํ•ด๋‘” ๊ฒƒ๋„ ์‚ญ์ œ ํ•ด๋’€์Šต๋‹ˆ๋‹ค

โœ… Checklist

PR

  • Branch Convention ํ™•์ธ

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

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

Test

  • ๋กœ์ปฌ ์ž‘๋™ ํ™•์ธ
    ์Šคํฌ๋ฆฐ์ƒท 2024-11-06 150201

Summary by CodeRabbit

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

    • ์‚ฌ์šฉ์ž ๋ฆฌ๋ทฐ ์ œ์ถœ์„ ์œ„ํ•œ ReviewForm ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€.
    • ์‚ฌ์šฉ์ž ๊ฒฝํ—˜ ํ‰๊ฐ€๋ฅผ ์œ„ํ•œ ButtonHearts ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€.
    • ๋ฆฌ๋ทฐ ๋ชจ๋‹ฌ์„ ํ‘œ์‹œํ•˜๋Š” ReviewingModal ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€.
  • ๋ฌธ์„œํ™”

    • ReviewingModal ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ Storybook ์Šคํ† ๋ฆฌ ์ถ”๊ฐ€.

@github-actions
Copy link

github-actions bot commented Nov 6, 2024

@ChoYenii ChoYenii force-pushed the Feat/CR-63/ReviewingModal branch from ca771d0 to df0f555 Compare November 6, 2024 08:24
@github-actions
Copy link

github-actions bot commented Nov 6, 2024

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.

import Button from '@/src/components/common/input/button';

์œผ๋กœ ๊ณ ์น˜๋ฉด ๋ ๊ฒƒ๊ฐ™์•„์—ฌ

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2024

Walkthrough

์ด๋ฒˆ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์—์„œ๋Š” ์ƒˆ๋กœ์šด React ์ปดํฌ๋„ŒํŠธ์ธ ButtonHearts, ReviewForm, ๋ฐ ReviewingModal์ด ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ButtonHearts๋Š” ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ํ‰๊ฐ€ํ•˜๊ธฐ ์œ„ํ•œ ํ•˜ํŠธ ๋ฒ„ํŠผ์„ ์ œ๊ณตํ•˜๋ฉฐ, ReviewForm์€ ๋ฆฌ๋ทฐ๋ฅผ ์ œ์ถœํ•˜๊ธฐ ์œ„ํ•œ ํผ์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ReviewingModal์€ ๋ฆฌ๋ทฐ ํผ์„ ํฌํ•จํ•˜๋Š” ๋ชจ๋‹ฌ ๋‹ค์ด์–ผ๋กœ๊ทธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ์ปดํฌ๋„ŒํŠธ๋Š” ์ƒํƒœ ๊ด€๋ฆฌ ๋ฐ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๋Šฅ์„ ๊ฐ–์ถ”๊ณ  ์žˆ์œผ๋ฉฐ, Storybook์„ ํ†ตํ•ด ReviewingModal์˜ ์Šคํ† ๋ฆฌ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Changes

ํŒŒ์ผ ๊ฒฝ๋กœ ๋ณ€๊ฒฝ ์š”์•ฝ
src/components/my-page/reviewing-modal/button-hearts.tsx ์ƒˆ๋กœ์šด ์ปดํฌ๋„ŒํŠธ ButtonHearts ์ถ”๊ฐ€, ์ƒํƒœ ๊ด€๋ฆฌ ๋ฐ ํด๋ฆญ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ ๊ธฐ๋Šฅ ํฌํ•จ.
src/components/my-page/reviewing-modal/review-form.tsx ์ƒˆ๋กœ์šด ์ปดํฌ๋„ŒํŠธ ReviewForm ์ถ”๊ฐ€, ๋ฆฌ๋ทฐ ์ž…๋ ฅ ๋ฐ ์ œ์ถœ ๊ธฐ๋Šฅ์„ ์œ„ํ•œ ํผ ๊ตฌ์„ฑ.
src/components/my-page/reviewing-modal/reviewing-modal.stories.tsx ReviewingModal์˜ Storybook ์Šคํ† ๋ฆฌ ์ถ”๊ฐ€, ๋ชจ๋‹ฌ ์—ด๊ธฐ/๋‹ซ๊ธฐ ์ƒํƒœ ๊ด€๋ฆฌ ๊ธฐ๋Šฅ ํฌํ•จ.
src/components/my-page/reviewing-modal/reviewing-modal.tsx ์ƒˆ๋กœ์šด ์ปดํฌ๋„ŒํŠธ ReviewingModal ์ถ”๊ฐ€, ๋ชจ๋‹ฌ ๋‹ค์ด์–ผ๋กœ๊ทธ ๋ฐ ReviewForm ํฌํ•จ.

Poem

๐Ÿ‡
ํ•˜ํŠธ๊ฐ€ ๋ฐ˜์ง, ๋ฆฌ๋ทฐ๊ฐ€ ์‘ฅ!
์ƒˆ๋กœ์šด ๋ชจ๋‹ฌ ์†์—, ๊ธฐ์จ์ด ์‘ฅ!
ํด๋ฆญ ํด๋ฆญ, ๋งˆ์Œ์˜ ์†Œ๋ฆฌ,
๋ฆฌ๋ทฐ๋ฅผ ๋‚จ๊ฒจ, ๋ชจ๋‘์˜ ๊ธฐ์จ์ด!
์ฝ”๋“œ๊ฐ€ ์ถค์ถ”๊ณ , ๋งˆ์Œ๋„ ๋›ฐ๋„ค!
ํ•จ๊ป˜ํ•˜๋Š” ์ˆœ๊ฐ„, ์ฆ๊ฑฐ์›€์ด ๊ฐ€๋“ํ•ด!
๐ŸŒŸ


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.

@github-actions
Copy link

github-actions bot commented Nov 7, 2024

@github-actions
Copy link

github-actions bot commented Nov 7, 2024

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

๐Ÿงน Outside diff range and nitpick comments (9)
src/components/my-page/reviewing-modal/reviewing-modal.tsx (2)

7-10: ์ธํ„ฐํŽ˜์ด์Šค์— JSDoc ๋ฌธ์„œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

props์˜ ๋ชฉ์ ๊ณผ ์‚ฌ์šฉ๋ฒ•์„ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก JSDoc ๋ฌธ์„œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฌธ์„œ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด์„ธ์š”:

+/**
+ * ๋ฆฌ๋ทฐ ์ž‘์„ฑ ๋ชจ๋‹ฌ ์ปดํฌ๋„ŒํŠธ์˜ props ์ธํ„ฐํŽ˜์ด์Šค
+ */
 export interface ReviewingModalProps {
+  /** ๋ชจ๋‹ฌ์˜ ํ‘œ์‹œ ์—ฌ๋ถ€๋ฅผ ์ œ์–ดํ•˜๋Š” ์ƒํƒœ ๊ฐ’ */
   opened: boolean;
+  /** ๋ชจ๋‹ฌ์„ ๋‹ซ๋Š” ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜ */
   close: () => void;
 }

12-36: ์ฝ”๋“œ ํ’ˆ์งˆ ๊ฐœ์„ ์„ ์œ„ํ•œ ์ œ์•ˆ์‚ฌํ•ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

  1. ํ•˜๋“œ์ฝ”๋”ฉ๋œ ๋ฌธ์ž์—ด๊ณผ ์Šคํƒ€์ผ ๊ฐ’๋“ค์„ ์ƒ์ˆ˜๋กœ ๋ถ„๋ฆฌํ•˜๋ฉด ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ๋” ์šฉ์ดํ•ด์งˆ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  2. close ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ ์—๋Ÿฌ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์„ ํ•ด๋ณด์„ธ์š”:

+const MODAL_CONSTANTS = {
+  TITLE: '๋ฆฌ๋ทฐ ์“ฐ๊ธฐ',
+  PADDING: 24,
+  RADIUS: 12,
+  OVERLAY_OPACITY: 0.5,
+  TITLE_FONT_SIZE: '1.125rem',
+} as const;

 export default function ReviewingModal({ opened, close }: ReviewingModalProps) {
+  const handleClose = () => {
+    try {
+      close();
+    } catch (error) {
+      console.error('๋ชจ๋‹ฌ ๋‹ซ๊ธฐ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
+    }
+  };
+
   return (
     <Modal
       opened={opened}
       centered
-      title="๋ฆฌ๋ทฐ ์“ฐ๊ธฐ"
-      onClose={close}
+      title={MODAL_CONSTANTS.TITLE}
+      onClose={handleClose}
       size="auto"
-      padding={24}
-      radius={12}
-      overlayProps={{ backgroundOpacity: 0.5 }}
+      padding={MODAL_CONSTANTS.PADDING}
+      radius={MODAL_CONSTANTS.RADIUS}
+      overlayProps={{ backgroundOpacity: MODAL_CONSTANTS.OVERLAY_OPACITY }}
       styles={{
         title: {
           fontWeight: 600,
-          fontSize: '1.125rem',
+          fontSize: MODAL_CONSTANTS.TITLE_FONT_SIZE,
         },
         body: {
           fontFamily: 'var(--font-pretendard)',
         },
       }}
     >
-      <ReviewForm onCancel={close} />
+      <ReviewForm onCancel={handleClose} />
     </Modal>
   );
 }
src/components/my-page/reviewing-modal/reviewing-modal.stories.tsx (3)

7-13: ์Šคํ† ๋ฆฌ๋ถ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๊ฐœ์„  ์ œ์•ˆ

ํ˜„์žฌ ๊ตฌ์„ฑ์€ ์ข‹์ง€๋งŒ, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฐœ์„ ์‚ฌํ•ญ์„ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”:

 const meta: Meta<typeof ReviewingModal> = {
   title: 'Modal/ReviewingModal',
   component: ReviewingModal,
-  argTypes: { opened: { control: 'boolean' } },
+  argTypes: {
+    opened: { control: 'boolean', description: '๋ชจ๋‹ฌ์˜ ํ‘œ์‹œ ์—ฌ๋ถ€๋ฅผ ์ œ์–ดํ•ฉ๋‹ˆ๋‹ค' },
+    close: { description: '๋ชจ๋‹ฌ ๋‹ซ๊ธฐ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜' }
+  },
+  parameters: {
+    docs: {
+      description: {
+        component: '์‚ฌ์šฉ์ž ๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅ๋ฐ›๊ธฐ ์œ„ํ•œ ๋ชจ๋‹ฌ ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค.'
+      }
+    }
+  }
 };

14-39: ํ…œํ”Œ๋ฆฟ ์ปดํฌ๋„ŒํŠธ ๊ฐœ์„  ์ œ์•ˆ

ํ˜„์žฌ ๊ตฌํ˜„์€ ์ž˜ ๋˜์–ด ์žˆ์ง€๋งŒ, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฐœ์„ ์‚ฌํ•ญ์„ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”:

 const Template: StoryFn<ReviewingModalProps> = function GatheringDetailModalStory({
   opened,
 }: ReviewingModalProps) {
   const [isOpened, setIsOpened] = useState(opened);
+  const [isLoading, setIsLoading] = useState(false);
 
   const handleOpen = () => {
     action('Modal Opened')();
     setIsOpened(true);
   };
 
   const handleClose = () => {
     action('Modal Closed')();
     setIsOpened(false);
   };
 
   useEffect(() => {
     setIsOpened(opened);
   }, [opened]);
 
   return (
-    <>
+    <ErrorBoundary fallback={<div>์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค</div>}>
       <Button onClick={handleOpen}>Open Modal</Button>
-      <ReviewingModal opened={isOpened} close={handleClose} />
-    </>
+      <ReviewingModal
+        opened={isOpened}
+        close={handleClose}
+        isLoading={isLoading}
+      />
+    </ErrorBoundary>
   );
 };

41-41: ๊ธฐ๋ณธ ์Šคํ† ๋ฆฌ์— ์ดˆ๊ธฐ๊ฐ’ ์ถ”๊ฐ€ ์ œ์•ˆ

์Šคํ† ๋ฆฌ์˜ ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ฃผ๊ธฐ ์œ„ํ•ด args๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

 export const Default = Template.bind({});
+Default.args = {
+  opened: false
+};
src/components/my-page/reviewing-modal/button-hearts.tsx (2)

6-8: ์ธํ„ฐํŽ˜์ด์Šค ๋ฌธ์„œํ™” ๋ฐ ํƒ€์ž… ์ œํ•œ ๊ฐœ์„  ํ•„์š”

Props ์ธํ„ฐํŽ˜์ด์Šค์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฐœ์„ ์‚ฌํ•ญ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

  • JSDoc ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ปดํฌ๋„ŒํŠธ์˜ ์šฉ๋„์™€ ์‚ฌ์šฉ๋ฒ•์„ ๋ช…ํ™•ํžˆ ์„ค๋ช…
  • score ํƒ€์ž…์„ 1-5 ๋ฒ”์œ„๋กœ ์ œํ•œํ•˜์—ฌ ํƒ€์ž… ์•ˆ์ •์„ฑ ๊ฐ•ํ™”
+/**
+ * ํ•˜ํŠธ ๋ฒ„ํŠผ์„ ํ†ตํ•ด 1-5์  ์‚ฌ์ด์˜ ์ ์ˆ˜๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค.
+ */
 interface ButtonHeartsProps {
+  /** ์„ ํƒ๋œ ์ ์ˆ˜(1-5)๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ */
-  onChange: (score: number) => void;
+  onChange: (score: 1 | 2 | 3 | 4 | 5) => void;
 }

10-11: ์ƒํƒœ ๊ด€๋ฆฌ ๊ฐ€๋…์„ฑ ๊ฐœ์„  ์ œ์•ˆ

์ƒํƒœ ๊ด€๋ฆฌ์˜ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•œ ๊ฐœ์„ ์‚ฌํ•ญ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

  • ์ƒํƒœ ๋ณ€์ˆ˜๋ช…์„ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณ€๊ฒฝ (์˜ˆ: selectedHearts)
  • ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ ์ƒ์ˆ˜๋กœ ๋ถ„๋ฆฌ
+const INITIAL_HEARTS_STATE = Array(5).fill(false);
+
 export default function ButtonHearts({ onChange }: ButtonHeartsProps) {
-  const [clickedArray, setClickedArray] = useState<boolean[]>(Array(5).fill(false));
+  const [selectedHearts, setSelectedHearts] = useState<boolean[]>(INITIAL_HEARTS_STATE);
src/components/my-page/reviewing-modal/review-form.tsx (2)

7-14: ํƒ€์ž… ์ •์˜์— ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์ œ์•ฝ ์กฐ๊ฑด ์ถ”๊ฐ€ ํ•„์š”

FormValues ํƒ€์ž…์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ œ์•ฝ ์กฐ๊ฑด์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  • reviewText์˜ ์ตœ์†Œ/์ตœ๋Œ€ ๊ธธ์ด
  • score์˜ ์œ ํšจํ•œ ๋ฒ”์œ„ (์˜ˆ: 1-5)
 type FormValues = {
-  reviewText: string;
-  score: number;
+  reviewText: string & { minLength: 10; maxLength: 500 };
+  score: number & { min: 1; max: 5 };
 };

21-30: API ์—ฐ๋™ ๊ตฌํ˜„ ํ•„์š”

TODO ์ฃผ์„์— ์–ธ๊ธ‰๋œ API ์—ฐ๋™์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Swagger ๋ฌธ์„œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‹ค์Œ ์ž‘์—…์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

  • API ํ˜ธ์ถœ ํ•จ์ˆ˜ ๊ตฌํ˜„
  • ์—๋Ÿฌ ์ฒ˜๋ฆฌ
  • ๋กœ๋”ฉ ์ƒํƒœ ๊ด€๋ฆฌ

API ์—ฐ๋™ ๊ตฌํ˜„์— ๋„์›€์ด ํ•„์š”ํ•˜์‹œ๋‹ค๋ฉด ์ œ๊ฐ€ ๋„์™€๋“œ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. GitHub ์ด์Šˆ๋ฅผ ์ƒ์„ฑํ•ด๋“œ๋ฆด๊นŒ์š”?

๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 4b3679b and 0095a26.

๐Ÿ“’ Files selected for processing (4)
  • src/components/my-page/reviewing-modal/button-hearts.tsx (1 hunks)
  • src/components/my-page/reviewing-modal/review-form.tsx (1 hunks)
  • src/components/my-page/reviewing-modal/reviewing-modal.stories.tsx (1 hunks)
  • src/components/my-page/reviewing-modal/reviewing-modal.tsx (1 hunks)
๐Ÿ”‡ Additional comments (2)
src/components/my-page/reviewing-modal/reviewing-modal.tsx (1)

1-6: ์ฝ”๋“œ๊ฐ€ ๊น”๋”ํ•˜๊ณ  ํ•„์š”ํ•œ import๋“ค์ด ์ž˜ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค!

ํด๋ผ์ด์–ธํŠธ ์‚ฌ์ด๋“œ ๋ Œ๋”๋ง์„ ์œ„ํ•œ 'use client' ์ง€์‹œ๋ฌธ๊ณผ ํ•„์š”ํ•œ ์˜์กด์„ฑ๋“ค์ด ์ ์ ˆํ•˜๊ฒŒ import ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

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

1-6: ์ž„ํฌํŠธ ๊ตฌ๋ฌธ์ด ์ž˜ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค!

ํ•„์š”ํ•œ ๋ชจ๋“  ์˜์กด์„ฑ์ด ๋…ผ๋ฆฌ์ ์ธ ์ˆœ์„œ๋กœ ์ž˜ ์ž„ํฌํŠธ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

Comment on lines +13 to +16
const handleClick = (index: number) => {
setClickedArray((prev) => prev.map((_, i) => i <= index));
onChange(index + 1);
};
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๊ฐœ์„  ํ•„์š”

์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ์˜ ์•ˆ์ •์„ฑ๊ณผ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•œ ๊ฐœ์„ ์‚ฌํ•ญ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

  • ์ ์ˆ˜ ๊ณ„์‚ฐ ๋กœ์ง์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ถ„๋ฆฌ
  • ํƒ€์ž… ์•ˆ์ •์„ฑ ๊ฐ•ํ™”
+const calculateScore = (index: number): 1 | 2 | 3 | 4 | 5 => {
+  return (index + 1) as 1 | 2 | 3 | 4 | 5;
+};
+
-  const handleClick = (index: number) => {
+  const handleClick = (index: 0 | 1 | 2 | 3 | 4) => {
     setClickedArray((prev) => prev.map((_, i) => i <= index));
-    onChange(index + 1);
+    onChange(calculateScore(index));
   };
๐Ÿ“ 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 handleClick = (index: number) => {
setClickedArray((prev) => prev.map((_, i) => i <= index));
onChange(index + 1);
};
const calculateScore = (index: number): 1 | 2 | 3 | 4 | 5 => {
return (index + 1) as 1 | 2 | 3 | 4 | 5;
};
const handleClick = (index: 0 | 1 | 2 | 3 | 4) => {
setClickedArray((prev) => prev.map((_, i) => i <= index));
onChange(calculateScore(index));
};

Comment on lines +18 to +34
return (
<div className="flex w-full flex-col items-start justify-between gap-[12px]">
<p className="font-base font-semibold">๋งŒ์กฑ์Šค๋Ÿฌ์šด ๊ฒฝํ—˜์ด์—ˆ๋‚˜์š”?</p>
<div>
{Array.from({ length: 5 }).map((_, index) => (
<button type="button" onClick={() => handleClick(index)} key={`btn ${index + 1}`}>
<Image
src={clickedArray[index] ? activeHeart : defaultHeart}
width={24}
height={24}
alt="heartbtn"
/>
</button>
))}
</div>
</div>
);
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-label ์ถ”๊ฐ€
  • ๋” ๋ช…ํ™•ํ•œ ์ด๋ฏธ์ง€ ๋Œ€์ฒด ํ…์ŠคํŠธ
  • ํ˜„์žฌ ์„ ํƒ๋œ ์ ์ˆ˜ ์ƒํƒœ ์Œ์„ฑ ์•ˆ๋‚ด
 <div className="flex w-full flex-col items-start justify-between gap-[12px]">
-  <p className="font-base font-semibold">๋งŒ์กฑ์Šค๋Ÿฌ์šด ๊ฒฝํ—˜์ด์—ˆ๋‚˜์š”?</p>
+  <p className="font-base font-semibold" id="rating-description">๋งŒ์กฑ์Šค๋Ÿฌ์šด ๊ฒฝํ—˜์ด์—ˆ๋‚˜์š”?</p>
   <div>
     {Array.from({ length: 5 }).map((_, index) => (
       <button
         type="button"
         onClick={() => handleClick(index)}
         key={`btn ${index + 1}`}
+        aria-label={`${index + 1}์  ์„ ํƒ`}
+        aria-pressed={clickedArray[index]}
+        aria-describedby="rating-description"
       >
         <Image
           src={clickedArray[index] ? activeHeart : defaultHeart}
           width={24}
           height={24}
-          alt="heartbtn"
+          alt={clickedArray[index] ? '์ฑ„์›Œ์ง„ ํ•˜ํŠธ' : '๋นˆ ํ•˜ํŠธ'}
         />
       </button>
     ))}
   </div>
 </div>
๐Ÿ“ 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
return (
<div className="flex w-full flex-col items-start justify-between gap-[12px]">
<p className="font-base font-semibold">๋งŒ์กฑ์Šค๋Ÿฌ์šด ๊ฒฝํ—˜์ด์—ˆ๋‚˜์š”?</p>
<div>
{Array.from({ length: 5 }).map((_, index) => (
<button type="button" onClick={() => handleClick(index)} key={`btn ${index + 1}`}>
<Image
src={clickedArray[index] ? activeHeart : defaultHeart}
width={24}
height={24}
alt="heartbtn"
/>
</button>
))}
</div>
</div>
);
return (
<div className="flex w-full flex-col items-start justify-between gap-[12px]">
<p className="font-base font-semibold" id="rating-description">๋งŒ์กฑ์Šค๋Ÿฌ์šด ๊ฒฝํ—˜์ด์—ˆ๋‚˜์š”?</p>
<div>
{Array.from({ length: 5 }).map((_, index) => (
<button
type="button"
onClick={() => handleClick(index)}
key={`btn ${index + 1}`}
aria-label={`${index + 1}์  ์„ ํƒ`}
aria-pressed={clickedArray[index]}
aria-describedby="rating-description"
>
<Image
src={clickedArray[index] ? activeHeart : defaultHeart}
width={24}
height={24}
alt={clickedArray[index] ? '์ฑ„์›Œ์ง„ ํ•˜ํŠธ' : '๋นˆ ํ•˜ํŠธ'}
/>
</button>
))}
</div>
</div>
);

Comment on lines +16 to +20
export default function ReviewForm({ onCancel }: ReviewProps) {
const { register, handleSubmit } = useForm<FormValues>();
const [textReview, setTextReview] = useState<string>('');
const [point, setPoint] = useState<number>(0);

Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํผ ์ดˆ๊ธฐํ™” ๋ฐ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์„ค์ • ๊ฐœ์„  ํ•„์š”

useForm ํ›…์˜ ๊ธฐ๋ณธ ์˜ต์…˜์ด ์„ค์ •๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์‚ฌํ•ญ๋“ค์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  • defaultValues ์„ค์ •
  • mode ์„ค์ • (์˜ˆ: onChange)
  • ํ•„์ˆ˜ ํ•„๋“œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ
-  const { register, handleSubmit } = useForm<FormValues>();
+  const { register, handleSubmit } = useForm<FormValues>({
+    defaultValues: {
+      reviewText: '',
+      score: 0
+    },
+    mode: 'onChange'
+  });

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

Comment on lines +32 to +69
return (
<form className="flex h-[308px] w-[472px] flex-col justify-between gap-[24px]">
<ButtonHearts onChange={handleScoreChange} />
<Textarea
placeholder="๋‚จ๊ฒจ์ฃผ์‹  ๋ฆฌ๋ทฐ๋Š” ํ”„๋กœ๊ทธ๋žจ ์šด์˜ ๋ฐ ๋‹ค๋ฅธ ํšŒ์› ๋ถ„๋“ค๊ป˜ ํฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค."
inputClassNames="w-[471px] h-[120px] bg-gray-50 text-gray-400"
value={textReview}
onChange={handleTextChange}
register={register('reviewText')}
label="๊ฒฝํ—˜์— ๋Œ€ํ•ด ๋‚จ๊ฒจ์ฃผ์„ธ์š”"
styles={{
input: {
'::placeholder': {
color: 'gray - 400',
fontWeight: 500,
fontSize: '1rem',
},
},
label: {
fontWeight: 600,
fontSize: '1rem',
},
}}
/>
<input type="hidden" value={point} {...register('score')} />
<div className="font-base flex justify-between gap-[16px] font-semibold">
<Button
onClick={onCancel}
className="h-[44px] w-[228px] border border-blue-500 bg-white text-blue-500"
>
์ทจ์†Œ
</Button>
<Button type="submit" className="h-[44px] w-[228px] border-none bg-blue-500 text-white">
๋ฆฌ๋ทฐ ๋“ฑ๋ก
</Button>
</div>
</form>
);
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. ์ ‘๊ทผ์„ฑ:
  • form์— aria-label ์ถ”๊ฐ€
  • ๋ฒ„ํŠผ์— aria-label ์ถ”๊ฐ€
  • ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ ํ‘œ์‹œ ์˜์—ญ ์ถ”๊ฐ€
  1. ์Šคํƒ€์ผ๋ง:
  • gray - 400์— ์žˆ๋Š” ๋ถˆํ•„์š”ํ•œ ๊ณต๋ฐฑ ์ œ๊ฑฐ
  • ๋งค์ง ๋„˜๋ฒ„(ํฌ๊ธฐ๊ฐ’) ์ƒ์ˆ˜๋กœ ๋ถ„๋ฆฌ
-    <form className="flex h-[308px] w-[472px] flex-col justify-between gap-[24px]">
+    <form 
+      className="flex h-[308px] w-[472px] flex-col justify-between gap-[24px]"
+      aria-label="๋ฆฌ๋ทฐ ์ž‘์„ฑ ํผ"
+    >
-              color: 'gray - 400',
+              color: 'gray-400',

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

@ChoYenii ChoYenii merged commit 07587a7 into develop Nov 7, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants