From c9380ee99631c4be21c09f22d41ad5e93b3603a9 Mon Sep 17 00:00:00 2001 From: hain-tain Date: Mon, 1 Apr 2024 17:07:20 +0900 Subject: [PATCH] =?UTF-8?q?refactor(MovieRating):=20=EB=B3=84=EC=A0=90=20t?= =?UTF-8?q?ext=20=EB=B0=8F=20number=20=EA=B3=84=EC=82=B0=ED=95=B4=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=ED=95=A8=EC=88=98=20constants=20>=20rating=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MovieDetailModal/MovieRating.ts | 23 +++-------------- src/constants/rating.ts | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/components/MovieMain/MovieListBox/MovieDetailModal/MovieRating.ts b/src/components/MovieMain/MovieListBox/MovieDetailModal/MovieRating.ts index 50633f7ee..4acddb596 100644 --- a/src/components/MovieMain/MovieListBox/MovieDetailModal/MovieRating.ts +++ b/src/components/MovieMain/MovieListBox/MovieDetailModal/MovieRating.ts @@ -1,3 +1,5 @@ +import { getRatingNumber, getRatingText } from "../../../../constants/rating"; + import createElement from "../../../utils/createElement"; import generateStarRangeInput from "../../../common/generateStarRangeInput"; @@ -76,28 +78,11 @@ class MovieRating { } private ratingNumber(rating: number) { - return String(rating * 2); + return String(getRatingNumber(rating)); } private ratingText(rating: number) { - switch (rating) { - case 1: - return "최악이예요"; - case 2: - return "별로예요"; - - case 3: - return "보통이에요"; - - case 4: - return "재미있어요"; - - case 5: - return "명작이에요"; - - default: - return "별점을 매겨보세요"; - } + return getRatingText(rating); } } diff --git a/src/constants/rating.ts b/src/constants/rating.ts index 91735de61..a6efab1ef 100644 --- a/src/constants/rating.ts +++ b/src/constants/rating.ts @@ -1,2 +1,27 @@ export const DEFAULT_RATING = 0; export const MAX_RATING = 5; + +export const getRatingNumber = (rating: number) => { + return rating * 2; +}; + +export const getRatingText = (rating: number) => { + switch (rating) { + case 1: + return "최악이예요"; + case 2: + return "별로예요"; + + case 3: + return "보통이에요"; + + case 4: + return "재미있어요"; + + case 5: + return "명작이에요"; + + default: + return "별점을 매겨보세요"; + } +};