diff --git a/src/frontend/src/features/notes/components/MealsList.tsx b/src/frontend/src/features/notes/components/MealsList.tsx index 550adb5be..5179b7c46 100644 --- a/src/frontend/src/features/notes/components/MealsList.tsx +++ b/src/frontend/src/features/notes/components/MealsList.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import { Meals } from '../models'; +import { getMealTypes } from '../models'; import MealsListItem from './MealsListItem'; const MealsList: React.FC = () => { return ( - {Meals.get().map((mealType, index) => ( + {getMealTypes().map((mealType, index) => ( ))} diff --git a/src/frontend/src/features/notes/components/MealsListItem.tsx b/src/frontend/src/features/notes/components/MealsListItem.tsx index 52194a66f..e05017766 100644 --- a/src/frontend/src/features/notes/components/MealsListItem.tsx +++ b/src/frontend/src/features/notes/components/MealsListItem.tsx @@ -2,7 +2,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import { Accordion, AccordionDetails, AccordionSummary, Typography } from '@mui/material'; import type React from 'react'; import { useMemo, useState } from 'react'; -import { Meals, type MealType } from '../models'; +import { getMealName, type MealType } from '../models'; import NotesTable from './NotesTable'; interface MealsListItemProps { @@ -11,7 +11,7 @@ interface MealsListItemProps { const MealsListItem: React.FC = ({ mealType }: MealsListItemProps) => { const [expanded, setExpanded] = useState(true); - const mealName = useMemo(() => Meals.getName(mealType), [mealType]); + const mealName = useMemo(() => getMealName(mealType), [mealType]); const handleAccordionChange = (): void => { setExpanded(!expanded); diff --git a/src/frontend/src/features/notes/meals.ts b/src/frontend/src/features/notes/meals.ts deleted file mode 100644 index 18b9ca5aa..000000000 --- a/src/frontend/src/features/notes/meals.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { MealType } from './models'; - -const AVAILABLE_MEALS: Map = new Map([ - [MealType.Breakfast, 'Breakfast'], - [MealType.SecondBreakfast, 'Second breakfast'], - [MealType.Lunch, 'Lunch'], - [MealType.AfternoonSnack, 'Afternoon snack'], - [MealType.Dinner, 'Dinner'], -]); - -export const get = (): MealType[] => Array.from(AVAILABLE_MEALS.keys()); - -export const getName = (mealType: MealType): string => { - const mealName = AVAILABLE_MEALS.get(mealType); - - if (!mealName) { - throw new Error(`Meal type = '${mealType}' doesn't exist`); - } - - return mealName; -}; diff --git a/src/frontend/src/features/notes/models.ts b/src/frontend/src/features/notes/models.ts index 61144da85..79e37bddb 100644 --- a/src/frontend/src/features/notes/models.ts +++ b/src/frontend/src/features/notes/models.ts @@ -6,6 +6,26 @@ export enum MealType { Dinner = 5, } +const AVAILABLE_MEALS: Map = new Map([ + [MealType.Breakfast, 'Breakfast'], + [MealType.SecondBreakfast, 'Second breakfast'], + [MealType.Lunch, 'Lunch'], + [MealType.AfternoonSnack, 'Afternoon snack'], + [MealType.Dinner, 'Dinner'], +]); + +export const getMealTypes = (): MealType[] => Array.from(AVAILABLE_MEALS.keys()); + +export const getMealName = (mealType: MealType): string => { + const mealName = AVAILABLE_MEALS.get(mealType); + + if (!mealName) { + throw new Error(`Meal type = '${mealType}' doesn't exist`); + } + + return mealName; +}; + export interface NoteItem { id: number; mealType: MealType; @@ -23,5 +43,3 @@ export interface NoteCreateEdit { productQuantity: number; displayOrder: number; } - -export * as Meals from './meals';