Rebuild app IA and polish pantry, chips, and food data.
Introduce the four-tab hubs (Jetzt/Küche/Planen/Wissen), frosted ingredient flyouts with caution reasons, structured nutrition fields with protein sorting, and disabled coming-soon nav tiles. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,36 +1,35 @@
|
||||
import type { MealType, TimeSlot } from "@/types/domain"
|
||||
import type { MealTime, MealType } from "@/types/domain"
|
||||
|
||||
export interface TimeContext {
|
||||
slot: TimeSlot
|
||||
mealTime: MealTime
|
||||
mealType: MealType
|
||||
hour: number
|
||||
minute: number
|
||||
}
|
||||
|
||||
/** Local-time meal context for the suggestion engine. */
|
||||
/**
|
||||
* Local-time meal context for the suggestion engine.
|
||||
* until 10:30 → breakfast · until 14:30 → lunch · until 17:30 → snack · else dinner
|
||||
*/
|
||||
export function getTimeContext(date = new Date()): TimeContext {
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const minutes = hour * 60 + minute
|
||||
|
||||
if (hour >= 6 && hour < 11) {
|
||||
return { slot: "morning", mealType: "half", hour, minute }
|
||||
}
|
||||
if (hour >= 11 && hour < 15) {
|
||||
return { slot: "midday", mealType: "full", hour, minute }
|
||||
}
|
||||
if (hour >= 15 && hour < 18) {
|
||||
return { slot: "afternoon", mealType: "half", hour, minute }
|
||||
}
|
||||
if (hour >= 18 && hour < 22) {
|
||||
return { slot: "evening", mealType: "full", hour, minute }
|
||||
}
|
||||
let mealTime: MealTime
|
||||
if (minutes < 10 * 60 + 30) mealTime = "breakfast"
|
||||
else if (minutes < 14 * 60 + 30) mealTime = "lunch"
|
||||
else if (minutes < 17 * 60 + 30) mealTime = "snack"
|
||||
else mealTime = "dinner"
|
||||
|
||||
// Late night / early morning: lean snack context
|
||||
return { slot: "afternoon", mealType: "half", hour, minute }
|
||||
const mealType: MealType =
|
||||
mealTime === "breakfast" || mealTime === "snack" ? "half" : "full"
|
||||
|
||||
return { mealTime, mealType, hour, minute }
|
||||
}
|
||||
|
||||
export function formatClock(hour: number, minute: number, lang: "de" | "en"): string {
|
||||
export function formatClock(hour: number, minute: number): string {
|
||||
const hh = String(hour).padStart(2, "0")
|
||||
const mm = String(minute).padStart(2, "0")
|
||||
return lang === "de" ? `${hh}:${mm}` : `${hh}:${mm}`
|
||||
return `${hh}:${mm}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user