import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { MessageCircleQuestion } from "lucide-react"; import { isSuperadmin } from "@peppa/core"; import { asIs } from "@peppa/shared/i18n"; import { STALE_DAYS, staleQuestions } from "@peppa/runner"; import { ago, Empty, Flash, Notice, PageHeader } from "@/components/common"; import { Button } from "@/components/ui/button"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { getT } from "@/lib/i18n"; import { closeStaleQuestionsAction } from "../actions"; export async function generateMetadata() { const t = await getT(); return { title: t("Старые вопросы — FORGE") }; } /** * PEP-279: questions nobody answered for a week — the list is the preview, the button closes them * all with their default option (no default — closed with no choice). Superadmin only. */ export default async function StaleQuestions({ searchParams }: { searchParams: Promise<{ error?: string; ok?: string }> }) { const user = await requireUser(); if (!(await isSuperadmin(db, user))) notFound(); const { error, ok } = await searchParams; const t = await getT(); const list = await staleQuestions(db); return ( {ok && {t.text(ok)}} {t("Вопросы без ответа дольше {n} дней", { n: STALE_DAYS })}}> {t("Агенты давно продолжили по рекомендованному варианту. Закройте эти вопросы этим вариантом: владельцы получат одно итоговое сообщение. Карточки «готово» не трогаются — «Принять» нажимают сами владельцы.")}{" "} {t("← Дашборд")} {list.length === 0 ? ( {t("Старых вопросов нет.")} ) : ( <>
{t("Ниже — что будет закрыто и каким вариантом.")}
)}
); }