"use client"; import Link from "next/link"; import { useState } from "react"; import { BoltIcon, PlayIcon, XIcon } from "@/components/icons"; import { Button } from "@/components/ui"; import { useI18n } from "@/lib/i18n"; import type { HomeworkRecord } from "@/lib/schemas"; import { formatDate, truncate } from "@/lib/utils"; /** * One saved homework result in the library's Homework tab: the finished * solution or the step-by-step guide, with open + delete. */ export function HomeworkCard({ record, onDelete }: { record: HomeworkRecord; onDelete: (id: string) => void }) { const { t, plural } = useI18n(); const [confirmDelete, setConfirmDelete] = useState(false); const href = `/homework?open=${record.id}`; const preview = record.mode === "make" ? truncate(record.answer.replace(/\s+/g, " ").trim(), 150) : truncate( record.steps.map((step) => step.title).join(" · "), 150, ); return (
  • {/* Desktop: the whole card opens the result; the delete button sits above it. */}

    {truncate(record.title, 90)}

    {record.mode === "make" ? : } {t(record.mode === "make" ? "homework.history.made" : "homework.history.guide")} · {formatDate(record.updatedAt)} {record.mode === "guide" ? ( <> · {plural(record.steps.length, "homework.steps")} ) : null}

    {preview ? (

    {preview}

    ) : null}
    {confirmDelete ? (
    {t("homework.history.deleteConfirm")}
    ) : ( <> {t("homework.open")}
    {t("homework.open")}
    )}
  • ); }