diff --git a/src/app/(app)/caregiver/orders/[id]/page.tsx b/src/app/(app)/caregiver/orders/[id]/page.tsx index 8a9cdcb..5916551 100644 --- a/src/app/(app)/caregiver/orders/[id]/page.tsx +++ b/src/app/(app)/caregiver/orders/[id]/page.tsx @@ -211,6 +211,181 @@ const defaultDinner: DinnerOptions = { additions: { sugar: false, sweetener: false }, } +// ============================================ +// MEAL OPTIONS CONFIGURATION +// ============================================ + +interface OptionItem { + key: string + label: string +} + +interface OptionSection { + title: string + columns: 1 | 2 | 3 + options: OptionItem[] +} + +// Breakfast configuration +const breakfastConfig: Record = { + bread: { + title: 'Bread (Brot)', + columns: 2, + options: [ + { key: 'breadRoll', label: 'Bread Roll' }, + { key: 'wholeGrainRoll', label: 'Whole Grain Roll' }, + { key: 'greyBread', label: 'Grey Bread' }, + { key: 'wholeGrainBread', label: 'Whole Grain' }, + { key: 'whiteBread', label: 'White Bread' }, + { key: 'crispbread', label: 'Crispbread' }, + ], + }, + preparation: { + title: 'Preparation', + columns: 3, + options: [ + { key: 'porridge', label: 'Porridge' }, + { key: 'sliced', label: 'Sliced' }, + { key: 'spread', label: 'Spread' }, + ], + }, + spreads: { + title: 'Spreads', + columns: 2, + options: [ + { key: 'butter', label: 'Butter' }, + { key: 'margarine', label: 'Margarine' }, + { key: 'jam', label: 'Jam' }, + { key: 'diabeticJam', label: 'Diabetic Jam' }, + { key: 'honey', label: 'Honey' }, + { key: 'cheese', label: 'Cheese' }, + { key: 'quark', label: 'Quark' }, + { key: 'sausage', label: 'Sausage' }, + ], + }, + beverages: { + title: 'Beverages', + columns: 2, + options: [ + { key: 'coffee', label: 'Coffee' }, + { key: 'tea', label: 'Tea' }, + { key: 'hotMilk', label: 'Hot Milk' }, + { key: 'coldMilk', label: 'Cold Milk' }, + ], + }, + additions: { + title: 'Additions', + columns: 3, + options: [ + { key: 'sugar', label: 'Sugar' }, + { key: 'sweetener', label: 'Sweetener' }, + { key: 'coffeeCreamer', label: 'Creamer' }, + ], + }, +} + +// Lunch configuration +const lunchConfig = { + portionSizes: [ + { value: 'small', label: 'Small' }, + { value: 'large', label: 'Large' }, + { value: 'vegetarian', label: 'Vegetarian' }, + ] as const, + mealOptions: { + title: 'Meal Options', + columns: 2 as const, + options: [ + { key: 'soup', label: 'Soup' }, + { key: 'dessert', label: 'Dessert' }, + ], + }, + specialPreparations: { + title: 'Special Preparations', + columns: 2 as const, + options: [ + { key: 'pureedFood', label: 'Pureed Food' }, + { key: 'pureedMeat', label: 'Pureed Meat' }, + { key: 'slicedMeat', label: 'Sliced Meat' }, + { key: 'mashedPotatoes', label: 'Mashed Potatoes' }, + ], + }, + restrictions: { + title: 'Restrictions', + columns: 3 as const, + options: [ + { key: 'noFish', label: 'No Fish' }, + { key: 'fingerFood', label: 'Finger Food' }, + { key: 'onlySweet', label: 'Only Sweet' }, + ], + }, +} + +// Dinner configuration +const dinnerConfig: Record = { + bread: { + title: 'Bread', + columns: 2, + options: [ + { key: 'greyBread', label: 'Grey Bread' }, + { key: 'wholeGrainBread', label: 'Whole Grain' }, + { key: 'whiteBread', label: 'White Bread' }, + { key: 'crispbread', label: 'Crispbread' }, + ], + }, + preparation: { + title: 'Preparation', + columns: 2, + options: [ + { key: 'spread', label: 'Spread' }, + { key: 'sliced', label: 'Sliced' }, + ], + }, + spreads: { + title: 'Spreads', + columns: 2, + options: [ + { key: 'butter', label: 'Butter' }, + { key: 'margarine', label: 'Margarine' }, + ], + }, + additionalItems: { + title: 'Additional Items', + columns: 3, + options: [ + { key: 'soup', label: 'Soup' }, + { key: 'porridge', label: 'Porridge' }, + { key: 'noFish', label: 'No Fish' }, + ], + }, + beverages: { + title: 'Beverages', + columns: 2, + options: [ + { key: 'tea', label: 'Tea' }, + { key: 'cocoa', label: 'Cocoa' }, + { key: 'hotMilk', label: 'Hot Milk' }, + { key: 'coldMilk', label: 'Cold Milk' }, + ], + }, + additions: { + title: 'Additions', + columns: 2, + options: [ + { key: 'sugar', label: 'Sugar' }, + { key: 'sweetener', label: 'Sweetener' }, + ], + }, +} + +// Helper to get grid columns class +const getGridCols = (cols: 1 | 2 | 3) => { + switch (cols) { + case 1: return 'grid-cols-1' + case 2: return 'grid-cols-1 sm:grid-cols-2' + case 3: return 'grid-cols-1 sm:grid-cols-3' + } +} + function CheckboxOption({ id, label, @@ -978,8 +1153,8 @@ export default function OrderDetailPage() { {/* Meal Form Sheet */} - - + + {editingMeal ? 'Edit' : 'Add'} {getMealTypeLabel(order.mealType)} Meal @@ -988,7 +1163,7 @@ export default function OrderDetailPage() { -
+
{/* Image Upload Section */} {isDraft && (
@@ -1125,67 +1300,100 @@ export default function OrderDetailPage() { />
+ {/* Bread */} -
-

Bread (Brot)

-
- setBreakfast({ ...breakfast, bread: { ...breakfast.bread, breadRoll: v } })} /> - setBreakfast({ ...breakfast, bread: { ...breakfast.bread, wholeGrainRoll: v } })} /> - setBreakfast({ ...breakfast, bread: { ...breakfast.bread, greyBread: v } })} /> - setBreakfast({ ...breakfast, bread: { ...breakfast.bread, wholeGrainBread: v } })} /> - setBreakfast({ ...breakfast, bread: { ...breakfast.bread, whiteBread: v } })} /> - setBreakfast({ ...breakfast, bread: { ...breakfast.bread, crispbread: v } })} /> +

{breakfastConfig.bread.title}

+
+ {breakfastConfig.bread.options.map(({ key, label }) => ( + setBreakfast({ ...breakfast, bread: { ...breakfast.bread, [key]: v } })} + /> + ))}
+ {/* Preparation */} -
-

Preparation

-
- setBreakfast({ ...breakfast, porridge: v })} /> - setBreakfast({ ...breakfast, preparation: { ...breakfast.preparation, sliced: v } })} /> - setBreakfast({ ...breakfast, preparation: { ...breakfast.preparation, spread: v } })} /> +

{breakfastConfig.preparation.title}

+
+ {breakfastConfig.preparation.options.map(({ key, label }) => { + const isTopLevel = key === 'porridge' + const checked = isTopLevel + ? breakfast.porridge + : breakfast.preparation[key as keyof typeof breakfast.preparation] + return ( + { + if (isTopLevel) { + setBreakfast({ ...breakfast, porridge: v }) + } else { + setBreakfast({ ...breakfast, preparation: { ...breakfast.preparation, [key]: v } }) + } + }} + /> + ) + })}
+ {/* Spreads */} -
-

Spreads

-
- setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, butter: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, margarine: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, jam: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, diabeticJam: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, honey: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, cheese: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, quark: v } })} /> - setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, sausage: v } })} /> +

{breakfastConfig.spreads.title}

+
+ {breakfastConfig.spreads.options.map(({ key, label }) => ( + setBreakfast({ ...breakfast, spreads: { ...breakfast.spreads, [key]: v } })} + /> + ))}
+ {/* Beverages */} -
-

Beverages

-
- setBreakfast({ ...breakfast, beverages: { ...breakfast.beverages, coffee: v } })} /> - setBreakfast({ ...breakfast, beverages: { ...breakfast.beverages, tea: v } })} /> - setBreakfast({ ...breakfast, beverages: { ...breakfast.beverages, hotMilk: v } })} /> - setBreakfast({ ...breakfast, beverages: { ...breakfast.beverages, coldMilk: v } })} /> +

{breakfastConfig.beverages.title}

+
+ {breakfastConfig.beverages.options.map(({ key, label }) => ( + setBreakfast({ ...breakfast, beverages: { ...breakfast.beverages, [key]: v } })} + /> + ))}
+ {/* Additions */} -
-

Additions

-
- setBreakfast({ ...breakfast, additions: { ...breakfast.additions, sugar: v } })} /> - setBreakfast({ ...breakfast, additions: { ...breakfast.additions, sweetener: v } })} /> - setBreakfast({ ...breakfast, additions: { ...breakfast.additions, coffeeCreamer: v } })} /> +

{breakfastConfig.additions.title}

+
+ {breakfastConfig.additions.options.map(({ key, label }) => ( + setBreakfast({ ...breakfast, additions: { ...breakfast.additions, [key]: v } })} + /> + ))}
@@ -1194,63 +1402,78 @@ export default function OrderDetailPage() { {/* LUNCH OPTIONS */} {order.mealType === 'lunch' && ( <> + {/* Portion Size */}

Portion Size

setLunch({ ...lunch, portionSize: v as 'small' | 'large' | 'vegetarian' })} - className="grid gap-2 grid-cols-3" + className="grid gap-2 grid-cols-1 sm:grid-cols-3" > - {[ - { value: 'small', label: 'Small' }, - { value: 'large', label: 'Large' }, - { value: 'vegetarian', label: 'Vegetarian' }, - ].map(({ value, label }) => ( + {lunchConfig.portionSizes.map(({ value, label }) => (
setLunch({ ...lunch, portionSize: value as 'small' | 'large' | 'vegetarian' })} + onClick={() => setLunch({ ...lunch, portionSize: value })} > - - + +
))}
+ {/* Meal Options */} -
-

Meal Options

-
- setLunch({ ...lunch, soup: v })} /> - setLunch({ ...lunch, dessert: v })} /> +

{lunchConfig.mealOptions.title}

+
+ {lunchConfig.mealOptions.options.map(({ key, label }) => ( + ]} + onCheckedChange={(v) => setLunch({ ...lunch, [key]: v })} + /> + ))}
+ {/* Special Preparations */} -
-

Special Preparations

-
- setLunch({ ...lunch, specialPreparations: { ...lunch.specialPreparations, pureedFood: v } })} /> - setLunch({ ...lunch, specialPreparations: { ...lunch.specialPreparations, pureedMeat: v } })} /> - setLunch({ ...lunch, specialPreparations: { ...lunch.specialPreparations, slicedMeat: v } })} /> - setLunch({ ...lunch, specialPreparations: { ...lunch.specialPreparations, mashedPotatoes: v } })} /> +

{lunchConfig.specialPreparations.title}

+
+ {lunchConfig.specialPreparations.options.map(({ key, label }) => ( + setLunch({ ...lunch, specialPreparations: { ...lunch.specialPreparations, [key]: v } })} + /> + ))}
+ {/* Restrictions */} -
-

Restrictions

-
- setLunch({ ...lunch, restrictions: { ...lunch.restrictions, noFish: v } })} /> - setLunch({ ...lunch, restrictions: { ...lunch.restrictions, fingerFood: v } })} /> - setLunch({ ...lunch, restrictions: { ...lunch.restrictions, onlySweet: v } })} /> +

{lunchConfig.restrictions.title}

+
+ {lunchConfig.restrictions.options.map(({ key, label }) => ( + setLunch({ ...lunch, restrictions: { ...lunch.restrictions, [key]: v } })} + /> + ))}
@@ -1269,68 +1492,105 @@ export default function OrderDetailPage() { />
+ {/* Bread */} -
-

Bread

-
- setDinner({ ...dinner, bread: { ...dinner.bread, greyBread: v } })} /> - setDinner({ ...dinner, bread: { ...dinner.bread, wholeGrainBread: v } })} /> - setDinner({ ...dinner, bread: { ...dinner.bread, whiteBread: v } })} /> - setDinner({ ...dinner, bread: { ...dinner.bread, crispbread: v } })} /> +

{dinnerConfig.bread.title}

+
+ {dinnerConfig.bread.options.map(({ key, label }) => ( + setDinner({ ...dinner, bread: { ...dinner.bread, [key]: v } })} + /> + ))}
+ {/* Preparation */} -
-

Preparation

-
- setDinner({ ...dinner, preparation: { ...dinner.preparation, spread: v } })} /> - setDinner({ ...dinner, preparation: { ...dinner.preparation, sliced: v } })} /> +

{dinnerConfig.preparation.title}

+
+ {dinnerConfig.preparation.options.map(({ key, label }) => ( + setDinner({ ...dinner, preparation: { ...dinner.preparation, [key]: v } })} + /> + ))}
+ {/* Spreads */} -
-

Spreads

-
- setDinner({ ...dinner, spreads: { ...dinner.spreads, butter: v } })} /> - setDinner({ ...dinner, spreads: { ...dinner.spreads, margarine: v } })} /> +

{dinnerConfig.spreads.title}

+
+ {dinnerConfig.spreads.options.map(({ key, label }) => ( + setDinner({ ...dinner, spreads: { ...dinner.spreads, [key]: v } })} + /> + ))}
+ {/* Additional Items */} -
-

Additional Items

-
- setDinner({ ...dinner, soup: v })} /> - setDinner({ ...dinner, porridge: v })} /> - setDinner({ ...dinner, noFish: v })} /> +

{dinnerConfig.additionalItems.title}

+
+ {dinnerConfig.additionalItems.options.map(({ key, label }) => ( + ]} + onCheckedChange={(v) => setDinner({ ...dinner, [key]: v })} + /> + ))}
+ {/* Beverages */} -
-

Beverages

-
- setDinner({ ...dinner, beverages: { ...dinner.beverages, tea: v } })} /> - setDinner({ ...dinner, beverages: { ...dinner.beverages, cocoa: v } })} /> - setDinner({ ...dinner, beverages: { ...dinner.beverages, hotMilk: v } })} /> - setDinner({ ...dinner, beverages: { ...dinner.beverages, coldMilk: v } })} /> +

{dinnerConfig.beverages.title}

+
+ {dinnerConfig.beverages.options.map(({ key, label }) => ( + setDinner({ ...dinner, beverages: { ...dinner.beverages, [key]: v } })} + /> + ))}
+ {/* Additions */} -
-

Additions

-
- setDinner({ ...dinner, additions: { ...dinner.additions, sugar: v } })} /> - setDinner({ ...dinner, additions: { ...dinner.additions, sweetener: v } })} /> +

{dinnerConfig.additions.title}

+
+ {dinnerConfig.additions.options.map(({ key, label }) => ( + setDinner({ ...dinner, additions: { ...dinner.additions, [key]: v } })} + /> + ))}
@@ -1339,7 +1599,7 @@ export default function OrderDetailPage() {
{isDraft && ( -
+