import { useState } from "preact/hooks"; import type { Meal } from "../../lib/types"; import type { UserLocation } from "../../lib/use-location"; import { PlaceCard } from "../shared/PlaceCard"; export function FoodTab({ meals, location }: { meals: Meal[]; location: UserLocation | null }) { const [expandedIdx, setExpandedIdx] = useState(null); const totalCandidates = meals.reduce((n, m) => n + m.candidates.length, 0); return (
{meals.length} meals ยท {totalCandidates} options
{meals.map(meal => (
{meal.label}
{meal.budget && (
${meal.budget}/person
)}
{meal.sub &&
{meal.sub}
} {meal.preferences &&
{meal.preferences}
} {meal.notes &&
{meal.notes}
}
{meal.candidates.map(place => { const uid = meal.id + ":" + place.name; const isSelected = (meal.selected || []).includes(place.name); return (
{isSelected &&
Selected
} setExpandedIdx(expandedIdx === uid ? null : uid)} location={location} />
); })}
))} {meals.length === 0 && (
No meals planned yet.
)}
); }