"use client"; import { useState } from "react"; import { ChevronDown } from "lucide-react"; interface IncludedService { name: string; description: string | null; } interface ActiveOffer { id: string; public_name: string; // micro offer public name — NOT shown to client (T-05-10) offer_name: string; // macro public_name — shown as heading offer_type: string; // una_tantum | retainer cumulative_price: string; // sum of service prices accepted_total: string | null; services: IncludedService[]; } interface OffersSectionProps { offers: ActiveOffer[]; } function OfferCard({ offer }: { offer: ActiveOffer }) { const [open, setOpen] = useState(false); const price = parseFloat(offer.cumulative_price); const hasPrice = price > 0; const hasServices = offer.services.length > 0; return (
{/* Main info rows */}
{/* Heading: macro public name */}

{offer.offer_name}

{/* "Valore incluso" — hidden when 0 */} {hasPrice && (
Valore incluso €{price.toFixed(2)}
)} {/* "Prezzo finale" */} {offer.accepted_total && (
Prezzo finale €{parseFloat(offer.accepted_total).toFixed(2)}
)}
{/* Accordion "Cosa è compreso" — only when there are services */} {hasServices && (
{open && ( )}
)}
); } export function OffersSection({ offers }: OffersSectionProps) { if (offers.length === 0) return null; return (
{offers.map((offer) => ( ))}
); }