import { Plus, Pencil, Trash2 } from 'lucide-react' import { useTripStore } from '../../store/tripStore' import { useSettingsStore } from '../../store/settingsStore' import { useTranslation } from '../../i18n' import { formatMoney } from '../../utils/formatters' import { catMeta } from '../Budget/costsCategories' import type { BudgetItem } from '../../types' /** * The Costs block inside a booking modal. Replaces the old inline price + budget * category fields: when no expense is linked yet it offers a "create expense" * button (the modal saves the booking first, then opens the full Costs editor); * once linked it shows the expense with edit / remove actions. */ export function BookingCostsSection({ reservationId, onCreate, onEdit, onRemove }: { reservationId: number | null onCreate: () => void onEdit: (item: BudgetItem) => void onRemove: (item: BudgetItem) => void }) { const { t, locale } = useTranslation() const budgetItems = useTripStore(s => s.budgetItems) const trip = useTripStore(s => s.trip) const displayCurrency = useSettingsStore(s => s.settings.default_currency) const base = (displayCurrency || trip?.currency || 'EUR').toUpperCase() const linked = reservationId ? budgetItems.find(i => i.reservation_id === reservationId) : null const labelCls = 'block text-[11px] font-semibold uppercase tracking-[0.08em] text-content-faint mb-[6px]' if (linked) { const meta = catMeta(linked.category) const Icon = meta.Icon return (
{linked.name}
{t(meta.labelKey)}
{formatMoney(linked.total_price, linked.currency || base, locale)}
) } return (
{t('reservations.createExpenseHint')}
) }