// ── Predict Basket Page ───────────────────────────────────────────────────────
function ScoreBar({ score }) {
const pct = Math.round(score * 100);
const color = pct >= 70 ? "#16a34a" : pct >= 40 ? "#f59e0b" : "#d1d5db";
return (
{/* Header */}
Spesa
{error && (
Errore di caricamento: {error}
)}
{/* Shopping list — manual items */}
Lista della spesa
{data?.shopping_list?.length > 0 ? (
{data.shopping_list.map((s) => (
-
{s.item_text}
))}
) : (
Nessun articolo — aggiungi cose che non vuoi dimenticare.
)}
{/* Predicted meta-items */}
{!data ? (
Caricamento…
) : data.predictions.length === 0 ? (
Nessuna previsione — servono almeno 3 acquisti negli ultimi 6 mesi per
gli articoli abbinati.
) : (
Probabilmente hai bisogno di
{data?.chains && (
)}
In base ai tuoi acquisti in tutte le catene.
{chain !== "all" && (
<>
{" "}
Mostrando ciò che è disponibile a{" "}
{chain}.
>
)}
{data.predictions.map((p) => {
const key = `meta-${p.meta_item}`;
return (
toggleCheck(key)}
colors={colors}
/>
);
})}
{checkedCount > 0 && (
{checkedCount}{" "}
{checkedCount !== 1
? "articoli selezionati"
: "articolo selezionato"}
)}
)}
);
}