import React from 'react'; import { ShoppingCart } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { EventAddonCatalogItem } from '../../api'; type Props = { addons: EventAddonCatalogItem[]; scope: 'photos' | 'guests' | 'gallery'; onCheckout: (addonKey: string) => void; busy?: boolean; t: (key: string, fallback: string) => string; }; const scopeDefaults: Record = { photos: ['extra_photos_500', 'extra_photos_2000'], guests: ['extra_guests_50', 'extra_guests_100'], gallery: ['extend_gallery_30d', 'extend_gallery_90d'], }; export function AddonsPicker({ addons, scope, onCheckout, busy, t }: Props) { const options = React.useMemo(() => { const whitelist = scopeDefaults[scope]; const filtered = addons.filter((addon) => whitelist.includes(addon.key)); return filtered.length ? filtered : addons; }, [addons, scope]); const [selected, setSelected] = React.useState(() => options[0]?.key); React.useEffect(() => { setSelected(options[0]?.key); }, [options]); if (!options.length) { return null; } return (
); }