Skip to content

Commit

Permalink
refactor(frontend): enum for moods
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Sep 14, 2024
1 parent bfe6626 commit d24ebc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 7 additions & 0 deletions apps/frontend/app/lib/generals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 4 additions & 9 deletions apps/frontend/app/routes/_dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import { match } from "ts-pattern";
import { joinURL, withQuery } from "ufo";
import {
LOGO_IMAGE_URL,
ThreePointSmileyRating,
Verb,
getLot,
getVerb,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d24ebc3

Please sign in to comment.