diff --git a/client/src/components/classes/DashboardBlurb.tsx b/client/src/components/classes/DashboardBlurb.tsx
index 562004a7..cb517403 100644
--- a/client/src/components/classes/DashboardBlurb.tsx
+++ b/client/src/components/classes/DashboardBlurb.tsx
@@ -92,7 +92,7 @@ export default function DashboardBlurb(props: DashboardBlurbProps) {
- {this.state.error.name} {this.state.error.message} ++ {this.state.error.name}: {this.state.error.message}{this.state.error.stack} diff --git a/client/src/components/layout/PeriodActionButton.tsx b/client/src/components/layout/PeriodActionButton.tsx new file mode 100644 index 00000000..d5b2d045 --- /dev/null +++ b/client/src/components/layout/PeriodActionButton.tsx @@ -0,0 +1,77 @@ +import { ReactNode, useContext, useState } from 'react'; +import { DateTime } from 'luxon'; +import MenuModal from '../lists/MenuModal'; +import MenuContext from '../../contexts/MenuContext'; + + +type ActionButtonProps = { + children: ReactNode, + now: boolean, + note?: string, + onClick?: () => void +} +function ActionButton(props: ActionButtonProps) { + const { children, now, note, onClick } = props; + return ( + + ) +} + +type PeriodActionButtonProps = { + date: DateTime, + name: string, + now: boolean, + note?: string +} +export default function PeriodActionButton(props: PeriodActionButtonProps) { + const { name } = props; + + if (name === 'PRIME' || name === 'Study Hall') + return+ + if (name === 'Brunch' || name === 'Lunch') + return + + return <>> +} + +function FlexiSCHEDAction(props: PeriodActionButtonProps) { + return ( + + + FlexiSCHED + + + ) +} + +function MenuAction(props: PeriodActionButtonProps) { + const { name, date } = props; + const { menu } = useContext(MenuContext); + const [modal, setModal] = useState(false); + + const formatted = date.toFormat('MM-dd'); + const meal = name.toLowerCase() as 'brunch' | 'lunch'; + + if (formatted in menu && menu[formatted][meal]) + return ( + <> +setModal(true)}> + Menu + ++ > + ) + + return <>> +} \ No newline at end of file diff --git a/client/src/components/lists/MenuModal.tsx b/client/src/components/lists/MenuModal.tsx new file mode 100644 index 00000000..0b4d4fc3 --- /dev/null +++ b/client/src/components/lists/MenuModal.tsx @@ -0,0 +1,55 @@ +import { useState } from 'react'; +import { Dialog } from '@headlessui/react'; + +import NutritionModal from './NutritionModal'; +import CenteredModal from '../layout/CenteredModal'; +import { DangerOutlineButton } from '../layout/OutlineButton'; + +import type { Entry } from '../../contexts/MenuContext'; + + +type MenuModalProps = { + name: string, + items: { [item: string]: Entry }, + isOpen: boolean, + setIsOpen: (open: boolean) => void +} +export default function MenuModal(props: MenuModalProps) { + const { name, items, isOpen, setIsOpen } = props; + const [nutritionModal, setNutritionModal] = useState (null); + + return ( + + + ) +} diff --git a/client/src/components/lists/NutritionModal.tsx b/client/src/components/lists/NutritionModal.tsx new file mode 100644 index 00000000..27bebe0e --- /dev/null +++ b/client/src/components/lists/NutritionModal.tsx @@ -0,0 +1,144 @@ +import { ReactNode } from 'react'; +import { Dialog } from '@headlessui/react'; + +import CenteredModal from '../layout/CenteredModal'; +import { DangerOutlineButton } from '../layout/OutlineButton'; + +import type { Entry } from '../../contexts/MenuContext'; + + +type ItemProps = { + children: ReactNode, + value?: number, + dv?: number +} +function Item(props: ItemProps) { + const { children, value, dv } = props; + + if (value === null) + return <>> + + return ( + <> ++ {name} Menu + + ++ {Object.entries(items).map(([item, nutrition]) => ( + + +++ ))} +nutrition && setNutritionModal(item)} + > + {item} ++ {nutrition && ( +setNutritionModal(null)} + /> + )} + + +setIsOpen(false)}> + Close + +
++ {children} + {dv && {Math.floor((value! / dv) * 100)}%} ++ > + ) +} + +type NutritionModalProps = { + item: string, + nutrition: Entry, + isOpen: boolean, + setIsOpen: (open: boolean) => void +} +export default function NutritionModal(props: NutritionModalProps) { + const { + item, + nutrition: { + serving, + nutrition, + ingredients + }, + isOpen, + setIsOpen + } = props; + + return ( ++ + ) +} diff --git a/client/src/components/lists/PillClubComponent.tsx b/client/src/components/lists/PillClubComponent.tsx index 91cd5169..8884309f 100644 --- a/client/src/components/lists/PillClubComponent.tsx +++ b/client/src/components/lists/PillClubComponent.tsx @@ -9,7 +9,7 @@ export default function PillClubComponent(props: Club & {id: string}) { return ( <> - setModal(true)}> + setModal(true)}> {name}+ {item} + + ++ {nutrition ? ( + <> + Nutrition Facts + + +
+ {serving && serving.serving_size_amount && serving.serving_size_unit && ( + <> ++ Serving size + {serving.serving_size_amount} {serving.serving_size_unit} ++
+ > + )} + {nutrition.calories && ( + <> ++ Calories + {nutrition.calories} ++
+ > + )} ++ % Daily Value* ++ +- +
+Total Fat {nutrition.g_fat}g
+- +
+Saturated Fat {nutrition.g_saturated_fat}g
+- +
+ +Trans Fat {nutrition.g_trans_fat}g
+- +
+ +Cholesterol {nutrition.mg_cholesterol}mg
+- +
+ +Sodium {nutrition.mg_sodium}mg
+- +
+Total Carbohydrate {nutrition.g_carbs}g
+- +
+Dietary Fiber {nutrition.g_fiber}g
+- +
+Total Sugars {nutrition.g_sugar}g
+- +
+ +Includes {nutrition.g_added_sugar}g Added Sugars
+- +
+ +Protein {nutrition.g_protein}g
+- +
+ > + ) : ( ++ * Percent Daily Values are based on a 2,000 calorie diet. +
+No nutrition information available.
+ )} + + {ingredients && ( + <> +
+ Ingredients +{ingredients}
+ > + )} ++ +setIsOpen(false)}> + Close + +diff --git a/client/src/components/schedule/Period.tsx b/client/src/components/schedule/Period.tsx index 0db0a20d..36e7a524 100644 --- a/client/src/components/schedule/Period.tsx +++ b/client/src/components/schedule/Period.tsx @@ -5,6 +5,7 @@ import {DateTime} from 'luxon'; // Components import PillClubComponent from '../lists/PillClubComponent'; +import PeriodActionButton from '../layout/PeriodActionButton'; // Contexts import UserDataContext from '../../contexts/UserDataContext'; @@ -53,7 +54,7 @@ export default function Period(props: PeriodProps) { <> {id ? ( - + {name} ) : name} @@ -80,7 +81,7 @@ export default function Period(props: PeriodProps) { {({open}) => (<>
{header} - + {note} @@ -108,6 +109,8 @@ export default function Period(props: PeriodProps) { />
School ends at {end.toFormat(format)} today.
@@ -62,7 +67,7 @@ export default function Periods(props: PeriodsProps) { grades={grades} /> ))} - > +