// Rôle : fin d'une partie de la Carte du jour : résultat, description, réponse détaillée, gains et résultat à partager. import { useState } from "react"; import { SubjectChips } from "./DailyFeedback.jsx"; import { dailyKnowledge } from "./dailyKnowledge.js"; import { dailyShareText, fillTemplate, formatCountdown, formatStreak } from "./dailyShare.js"; import { DailyTrack } from "./DailyTrack.jsx"; import { formatStardust } from "./stardustFormat.js"; function wonTitle(count, content) { return count === 1 ? content.wonFirstTitle : fillTemplate(content.wonTitle, { count }); } export function DailyResult({ catalog, card, daily, content, now }) { const [copied, setCopied] = useState(false); const won = daily.status === "won"; const collection = catalog.collections.find((item) => item.id === card?.collectionId)?.name; const { subject, theme } = daily.answerClues; // Après une défaite, ce que les essais et l'indice ont trouvé reste en vert, le reste est en gris. const known = dailyKnowledge(daily.guesses, daily.hints.find((hint) => hint.id === "theme")?.value ?? null); async function share() { const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` }); try { await navigator.clipboard.writeText(text); setCopied(true); } catch { setCopied(false); } } return

{won ? wonTitle(daily.guesses.length, content) : content.lostTitle}

{daily.hints.length > 0 && {fillTemplate(daily.hints.length > 1 ? content.hintsUsedMany : content.hintsUsedOne, { count: daily.hints.length })}}
{card?.description &&

{card.description}

}

{content.answerTitle}

{subject.length > 0 && <>
{content.columnSubject}
step.label)} isFound={(index) => won || index < known.path.length} />
} {theme && <>
{content.columnTheme}
won || Boolean(known.theme)} />{card && « {card.name.slice(...theme.span)} »}
} {collection && <>
{content.hints.collection.title}
{collection}
}
{won && }
{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}
; }