import { Banknote, Receipt } from "lucide-react";
import { Divider, Group, Paper, Stack, Text } from "@mantine/core";
import type { BookingDetail } from "@/types/booking";
import { SectionCard } from "./detail/SectionCard";
import { detailStyles } from "./detail/booking-detail.styles";
export function BookingPricingSummary({ booking }: { booking: BookingDetail }) {
const computed = Number(booking.totalAmount);
// The booking price is computed from the contract and is NOT staff-editable.
// A historical `adjustedTotalAmount` (from before adjustments were removed)
// is still shown read-only so old records render correctly.
const isAdjusted =
booking.adjustedTotalAmount !== null &&
booking.adjustedTotalAmount !== undefined;
const effective = isAdjusted ? Number(booking.adjustedTotalAmount) : computed;
const lineItems = booking.pricingBreakdown?.lineItems ?? [];
const fmt = (n: number) =>
`${booking.paymentCurrency} ${n.toLocaleString(undefined, { minimumFractionDigits: 2 })}`;
return (
{isAdjusted ? "Adjusted total" : "Total amount"}
{fmt(effective)}
{isAdjusted && (
Computed: {fmt(computed)}
{booking.adjustmentReason ? ` ยท ${booking.adjustmentReason}` : ""}
)}
{booking.pnrCode &&
}
{lineItems.length > 0 && (
<>
Price breakdown
{lineItems.map((li, i) => (
{li.description}
{Number(li.amount).toLocaleString()} {li.currency}
))}
>
)}
);
}
function Row({ label, value, mono }: { label: string; value: string; mono?: boolean }) {
return (
{label}
{value}
);
}