refactor: codebase and some fixes
This commit is contained in:
271
src/lib/constants/meal-options.ts
Normal file
271
src/lib/constants/meal-options.ts
Normal file
@@ -0,0 +1,271 @@
|
||||
export interface OptionItem {
|
||||
key: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface OptionSection {
|
||||
title: string
|
||||
columns: 1 | 2 | 3
|
||||
options: OptionItem[]
|
||||
}
|
||||
|
||||
export interface BreakfastOptions {
|
||||
accordingToPlan: boolean
|
||||
bread: {
|
||||
breadRoll: boolean
|
||||
wholeGrainRoll: boolean
|
||||
greyBread: boolean
|
||||
wholeGrainBread: boolean
|
||||
whiteBread: boolean
|
||||
crispbread: boolean
|
||||
}
|
||||
porridge: boolean
|
||||
preparation: { sliced: boolean; spread: boolean }
|
||||
spreads: {
|
||||
butter: boolean
|
||||
margarine: boolean
|
||||
jam: boolean
|
||||
diabeticJam: boolean
|
||||
honey: boolean
|
||||
cheese: boolean
|
||||
quark: boolean
|
||||
sausage: boolean
|
||||
}
|
||||
beverages: { coffee: boolean; tea: boolean; hotMilk: boolean; coldMilk: boolean }
|
||||
additions: { sugar: boolean; sweetener: boolean; coffeeCreamer: boolean }
|
||||
}
|
||||
|
||||
export interface LunchOptions {
|
||||
portionSize: 'small' | 'large' | 'vegetarian'
|
||||
soup: boolean
|
||||
dessert: boolean
|
||||
specialPreparations: {
|
||||
pureedFood: boolean
|
||||
pureedMeat: boolean
|
||||
slicedMeat: boolean
|
||||
mashedPotatoes: boolean
|
||||
}
|
||||
restrictions: { noFish: boolean; fingerFood: boolean; onlySweet: boolean }
|
||||
}
|
||||
|
||||
export interface DinnerOptions {
|
||||
accordingToPlan: boolean
|
||||
bread: { greyBread: boolean; wholeGrainBread: boolean; whiteBread: boolean; crispbread: boolean }
|
||||
preparation: { spread: boolean; sliced: boolean }
|
||||
spreads: { butter: boolean; margarine: boolean }
|
||||
soup: boolean
|
||||
porridge: boolean
|
||||
noFish: boolean
|
||||
beverages: { tea: boolean; cocoa: boolean; hotMilk: boolean; coldMilk: boolean }
|
||||
additions: { sugar: boolean; sweetener: boolean }
|
||||
}
|
||||
|
||||
export const DEFAULT_BREAKFAST: BreakfastOptions = {
|
||||
accordingToPlan: false,
|
||||
bread: {
|
||||
breadRoll: false,
|
||||
wholeGrainRoll: false,
|
||||
greyBread: false,
|
||||
wholeGrainBread: false,
|
||||
whiteBread: false,
|
||||
crispbread: false,
|
||||
},
|
||||
porridge: false,
|
||||
preparation: { sliced: false, spread: false },
|
||||
spreads: {
|
||||
butter: false,
|
||||
margarine: false,
|
||||
jam: false,
|
||||
diabeticJam: false,
|
||||
honey: false,
|
||||
cheese: false,
|
||||
quark: false,
|
||||
sausage: false,
|
||||
},
|
||||
beverages: { coffee: false, tea: false, hotMilk: false, coldMilk: false },
|
||||
additions: { sugar: false, sweetener: false, coffeeCreamer: false },
|
||||
}
|
||||
|
||||
export const DEFAULT_LUNCH: LunchOptions = {
|
||||
portionSize: 'large',
|
||||
soup: false,
|
||||
dessert: true,
|
||||
specialPreparations: {
|
||||
pureedFood: false,
|
||||
pureedMeat: false,
|
||||
slicedMeat: false,
|
||||
mashedPotatoes: false,
|
||||
},
|
||||
restrictions: { noFish: false, fingerFood: false, onlySweet: false },
|
||||
}
|
||||
|
||||
export const DEFAULT_DINNER: DinnerOptions = {
|
||||
accordingToPlan: false,
|
||||
bread: { greyBread: false, wholeGrainBread: false, whiteBread: false, crispbread: false },
|
||||
preparation: { spread: false, sliced: false },
|
||||
spreads: { butter: false, margarine: false },
|
||||
soup: false,
|
||||
porridge: false,
|
||||
noFish: false,
|
||||
beverages: { tea: false, cocoa: false, hotMilk: false, coldMilk: false },
|
||||
additions: { sugar: false, sweetener: false },
|
||||
}
|
||||
|
||||
export const BREAKFAST_CONFIG: Record<string, OptionSection> = {
|
||||
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' },
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
export const LUNCH_CONFIG = {
|
||||
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' },
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
export const DINNER_CONFIG: Record<string, OptionSection> = {
|
||||
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' },
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
export const getGridColsClass = (cols: 1 | 2 | 3): string => {
|
||||
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'
|
||||
}
|
||||
}
|
||||
88
src/lib/constants/meal.ts
Normal file
88
src/lib/constants/meal.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { Sunrise, Sun, Moon, Pencil, Send, ChefHat, Check, type LucideIcon } from 'lucide-react'
|
||||
|
||||
export type MealType = 'breakfast' | 'lunch' | 'dinner'
|
||||
export type OrderStatus = 'draft' | 'submitted' | 'preparing' | 'completed'
|
||||
|
||||
export interface MealTypeConfig {
|
||||
value: MealType
|
||||
label: string
|
||||
sublabel?: string
|
||||
icon: LucideIcon
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface StatusConfig {
|
||||
value: OrderStatus
|
||||
label: string
|
||||
icon: LucideIcon
|
||||
bgColor: string
|
||||
textColor: string
|
||||
borderColor: string
|
||||
dotColor: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export const MEAL_TYPES: MealTypeConfig[] = [
|
||||
{ value: 'breakfast', label: 'Breakfast', sublabel: 'Frühstück', icon: Sunrise, color: 'text-orange-500' },
|
||||
{ value: 'lunch', label: 'Lunch', sublabel: 'Mittagessen', icon: Sun, color: 'text-yellow-500' },
|
||||
{ value: 'dinner', label: 'Dinner', sublabel: 'Abendessen', icon: Moon, color: 'text-indigo-500' },
|
||||
]
|
||||
|
||||
export const ORDER_STATUSES: StatusConfig[] = [
|
||||
{
|
||||
value: 'draft',
|
||||
label: 'Draft',
|
||||
icon: Pencil,
|
||||
bgColor: 'bg-gray-50',
|
||||
textColor: 'text-gray-700',
|
||||
borderColor: 'border-gray-200',
|
||||
dotColor: 'bg-gray-400',
|
||||
description: 'In progress',
|
||||
},
|
||||
{
|
||||
value: 'submitted',
|
||||
label: 'Submitted',
|
||||
icon: Send,
|
||||
bgColor: 'bg-blue-50',
|
||||
textColor: 'text-blue-700',
|
||||
borderColor: 'border-blue-200',
|
||||
dotColor: 'bg-blue-500',
|
||||
description: 'Sent to kitchen',
|
||||
},
|
||||
{
|
||||
value: 'preparing',
|
||||
label: 'Preparing',
|
||||
icon: ChefHat,
|
||||
bgColor: 'bg-yellow-50',
|
||||
textColor: 'text-yellow-700',
|
||||
borderColor: 'border-yellow-200',
|
||||
dotColor: 'bg-yellow-500',
|
||||
description: 'Being prepared',
|
||||
},
|
||||
{
|
||||
value: 'completed',
|
||||
label: 'Completed',
|
||||
icon: Check,
|
||||
bgColor: 'bg-green-50',
|
||||
textColor: 'text-green-700',
|
||||
borderColor: 'border-green-200',
|
||||
dotColor: 'bg-green-500',
|
||||
description: 'Finished',
|
||||
},
|
||||
]
|
||||
|
||||
export const getMealTypeConfig = (type: MealType): MealTypeConfig | undefined => {
|
||||
return MEAL_TYPES.find((m) => m.value === type)
|
||||
}
|
||||
|
||||
export const getStatusConfig = (status: OrderStatus): StatusConfig | undefined => {
|
||||
return ORDER_STATUSES.find((s) => s.value === status)
|
||||
}
|
||||
|
||||
export const getMealTypeLabel = (type: MealType): string => {
|
||||
return getMealTypeConfig(type)?.label ?? type
|
||||
}
|
||||
|
||||
export const getStatusLabel = (status: OrderStatus): string => {
|
||||
return getStatusConfig(status)?.label ?? status
|
||||
}
|
||||
Reference in New Issue
Block a user