"use client"; import type { PriceOffer, PriceSearchResponse } from "@/src/types/priceSearch"; const CONFIDENCE_LABELS: Record = { high: "Alta", medium: "Media", low: "Bassa", }; const CONFIDENCE_STYLES: Record = { high: "bg-green-500/15 text-green-400 border-green-500/30", medium: "bg-yellow-500/15 text-yellow-400 border-yellow-500/30", low: "bg-zinc-500/15 text-zinc-400 border-zinc-500/30", }; function formatPrice(price: number | null, currency: string) { if (price === null) return "N/D"; return new Intl.NumberFormat("it-IT", { style: "currency", currency, }).format(price); } interface PriceSearchPanelProps { isLoading: boolean; error: string | null; result: PriceSearchResponse | null; onApplyPrice: (price: number) => void; onCancel: () => void; } export default function PriceSearchPanel({ isLoading, error, result, onApplyPrice, onCancel, }: PriceSearchPanelProps) { if (!isLoading && !error && !result) return null; return (

Ricerca prezzi online

{isLoading && ( )}
{isLoading && (
Ricerca in corso… può richiedere fino a 30 secondi
)} {error && (
{error}
)} {result && ( <>

Query: {result.query}

{result.offers.length === 0 ? (

Nessuna offerta trovata.

) : (
    {result.offers.map((offer, index) => (
  • {offer.vendor} {CONFIDENCE_LABELS[offer.confidence]}

    {offer.title}

    {offer.shippingNote && (

    {offer.shippingNote}

    )}
    {formatPrice(offer.price, offer.currency)}
    Apri {offer.price !== null && ( )}
  • ))}
)}

{result.disclaimer}

)}
); }