From d24ebc3c09a4c9744d51fe77c983ef654c60b6a3 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Sat, 14 Sep 2024 13:38:32 +0530 Subject: [PATCH] refactor(frontend): enum for moods --- apps/frontend/app/lib/generals.ts | 7 +++++++ apps/frontend/app/routes/_dashboard.tsx | 13 ++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/frontend/app/lib/generals.ts b/apps/frontend/app/lib/generals.ts index e1638657af..6710a53809 100644 --- a/apps/frontend/app/lib/generals.ts +++ b/apps/frontend/app/lib/generals.ts @@ -86,6 +86,13 @@ export enum TimeSpan { AllTime = "All Time", } + +export enum ThreePointSmileyRating { + Happy = "Happy", + Neutral = "Neutral", + Sad = "Sad", +} + export const getSetColor = (l: SetLot) => match(l) .with(SetLot.WarmUp, () => "yellow") diff --git a/apps/frontend/app/routes/_dashboard.tsx b/apps/frontend/app/routes/_dashboard.tsx index 68c1017c4b..d458980778 100644 --- a/apps/frontend/app/routes/_dashboard.tsx +++ b/apps/frontend/app/routes/_dashboard.tsx @@ -105,6 +105,7 @@ import { match } from "ts-pattern"; import { joinURL, withQuery } from "ufo"; import { LOGO_IMAGE_URL, + ThreePointSmileyRating, Verb, getLot, getVerb, @@ -1170,16 +1171,10 @@ const NewProgressUpdateForm = ({ const convertDecimalToThreePointSmiley = (rating: number) => inRange(rating, 0, 33.4) - ? "Sad" + ? ThreePointSmileyRating.Sad : inRange(rating, 33.4, 66.7) - ? "Neutral" - : "Happy"; - -enum ThreePointSmileyRating { - Happy = "Happy", - Neutral = "Neutral", - Sad = "Sad", -} + ? ThreePointSmileyRating.Neutral + : ThreePointSmileyRating.Happy; const convertThreePointSmileyToDecimal = (rating: ThreePointSmileyRating) => rating === ThreePointSmileyRating.Happy