import { Bell, ChevronRight, Compass, Search, ShoppingCart, Zap, type LucideIcon } from 'lucide-react' import { useState } from 'react' import { Link, useNavigate } from 'react-router' import { duration } from '../plan/PlanPage.tsx' import { supplyRunScreen } from '../shopping/api.ts' import buttonStyles from '../ui/Button.module.css' import { EmptyState } from '../ui/EmptyState.tsx' import { ErrorBanner } from '../ui/ErrorBanner.tsx' import { Icon } from '../ui/Icon.tsx' import { IconButton } from '../ui/IconButton.tsx' import { Photo } from '../ui/Photo.tsx' import { Skeleton } from '../ui/Skeleton.tsx' import { useHome, type Home, type Origin, type Tonight } from './api.ts' import styles from './HomePage.module.css' import { RotationCheck } from './RotationCheck.tsx' import { UpdatesSheet } from './UpdatesSheet.tsx' const ORIGIN_LABEL: Record = { regular: 'Regular', side_quest: 'Side quest' } // meta is the Tonight card's "Regular · 40 min" line, the time only when // the recipe says it. function meta({ origin, minutes_total }: Tonight): string { return minutes_total === null ? ORIGIN_LABEL[origin] : `${ORIGIN_LABEL[origin]} · ${duration(minutes_total)}` } // TonightCard is the dinner planned for today: its washed photo, name and // meta line, and the dark Recipe pill to its recipe. function TonightCard({ tonight }: { tonight: Tonight }) { return (

{tonight.name}

{meta(tonight)}
Recipe
) } // NoPlan stands in for the Tonight card when today has no plan. function NoPlan() { const navigate = useNavigate() return (
void navigate('/plan') }}> Draft this week's dinners and tonight's quest shows up here.
) } // StatusRow is one neutral row under the tiles: a grape-700 icon, its line // and a chevron, linking to the screen it is about. function StatusRow({ to, icon, children }: { to: string; icon: LucideIcon; children: string }) { return (
  • {children}
  • ) } // StatusRows are the rows that apply: Side quests waiting in the deck, and // a Supply run ready. With neither, there are no rows. function StatusRows({ home }: { home: Home }) { const count = home.sideQuestCount const list = home.shoppingList if (count === 0 && !list.ready) return null return ( ) } // Tiles are the two shortcuts, Quick dinner and Cook from what I have. function Tiles() { return (
    Quick dinner Cook from what I have
    ) } // HomePage is mock 1g, Home: today's date over "Tonight's quest" and the // Recent updates bell, the Tonight card (or the way to plan the week), the // Quick dinner and Cook from what I have tiles, and the status rows, all // from GET /api/v1/home. Above the tiles is the Rotation check, "Keep it in // rotation?", while a tried dinner waits for the household's answer. // // The bell carries a grape dot while there are unread updates and opens the // Recent updates sheet, which marks them seen. export function HomePage() { const home = useHome() const data = home.data const [updatesOpen, setUpdatesOpen] = useState(false) return (
    {data !== undefined ? (

    {data.dateLabel}

    ) : ( home.isPending && )}

    Tonight's quest

    setUpdatesOpen(true)} > {data?.unread && }
    {home.isPending && } {home.isError && ( void home.refetch()}>Couldn't load tonight's quest. {home.error.message} )} {data !== undefined && (data.tonight === null ? : )} {home.isPending && ( )} {data !== undefined && } setUpdatesOpen(false)} />
    ) }