Closed cdrice26 closed 3 months ago
Wow, that's a really creative way of refactoring, cool! There were some minor TS errors so I changed the UserSelectedMeals class to have the accurate type by adding back the individual fields and removing the constructor (it technically isn't needed). I also added a weekday type since you refer to it in the DayEditor. Looks good to merge to me!
Interesting that there were TS errors, I wasn't getting those, and there was a Weekday type (though it looks like you essentially just put in the same thing I had) - wonder if Git had something goofy going on here. But it still works and looks nice and my way of using the constructor probably wasn't idiomatic anyway so we'll go with what you did:).
I accidentally removed your weekday type while working on the userSelectedMeals object, oops. but with the userSelectedMeals class, the [key: string]: MealReference[]
wasn't specific enough for the deference and map functions you created.
I changed UserMealsObject so that it can just rely on WEEKDAYS for its properties. I also refactored the logic of mapping over it and extracted two functions, mapUserMeals and dereferenceMeal, to make it easier to understand. Unit tests for these functions are included.