import Link from "next/link"; import { FEEDBACK_ADMIN_STATUS, FEEDBACK_KIND, FEEDBACK_SIZE, FEEDBACK_USER_STATUS, feedbackTitle, type FeedbackView } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { ago, Disclosure } from "@/components/common"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { getT } from "@/lib/i18n"; import { fixFeedbackAction, linkFeedbackAction, rejectFeedbackAction } from "@/app/(app)/actions"; const TONE = { received: "muted", analyzed: "info", planned: "info", fixed: "ok", rejected: "warn" } as const; function Shots({ f, label }: { f: FeedbackView; label: (n: number) => string }) { if (!f.screenshots.length) return null; return (
{f.screenshots.map((s, i) => ( {label(i ))}
); } /** PEP-143: the author's own report — what they wrote, where it stands, what they were answered. */ export async function MyFeedbackCard({ f }: { f: FeedbackView }) { const t = await getT(); return (
{feedbackTitle(f)} {t.text(FEEDBACK_USER_STATUS[f.status])} {ago(f.createdAt, t)}
{f.text.includes("\n") &&

{f.text}

} t("Скриншот {n}", { n })} /> {f.status === "fixed" &&

{t("Исправили. Спасибо, что сообщили.")}

} {f.status === "rejected" &&

{f.rejectReason ? t("Решили пока не исправлять. Причина: {reason}", { reason: f.rejectReason }) : t("Решили пока не исправлять.")}

}
); } /** PEP-143: a report for the superadmin — who, where, what, the agent's analysis and the decision. */ export async function AdminFeedbackCard({ f, back }: { f: FeedbackView; back: string }) { const t = await getT(); const a = f.analysis; const c = f.context; const open = f.status === "received" || f.status === "analyzed"; const fields = { feedbackId: f.id, back }; return (
№{f.id} {f.authorName && f.authorName.toLowerCase() !== f.authorLogin.toLowerCase() ? `${f.authorName} (${f.authorLogin})` : f.authorLogin} {f.via === "telegram" ? "Telegram" : t("веб")} {a && {t.text(FEEDBACK_KIND[a.kind])}} {t.text(FEEDBACK_ADMIN_STATUS[f.status])} {ago(f.createdAt, t)}
{f.text ?

{f.text}

:

{t("Скриншот без подписи")}

} t("Скриншот {n}", { n })} /> {(c.url || c.userAgent || c.errors?.length) && (
{c.projectKey && (<>
{t("Проект")}
{c.taskKey ?? c.projectKey}
)} {c.mode && (<>
{t("Вид")}
{c.mode === "engineer" ? t("Инженер") : t("Продакт")}
)} {c.locale && (<>
{t("Язык")}
{c.locale}
)} {c.viewport && (<>
{t("Окно")}
{c.viewport}
)} {c.userAgent && (<>
{t("Браузер")}
{c.userAgent}
)} {c.errors?.map((e, i) => (
{t("Ошибка")}
{e.type}: {e.message}
))}
)} {a ? (

{t("Суть")}: {a.summary}

{a.cause &&

{t("Вероятная причина")}: {a.cause}

} {!a.confident &&

{t("Агент не уверен в разборе — проверьте сами.")}

} {a.options.map((o, i) => (
{t("Вариант {n}", { n: i + 1 })} {o.title} {a.recommended === i + 1 && {t("рекомендуем")}} {t.text(FEEDBACK_SIZE[o.size])} {f.optionIndex === i + 1 && {t("выбран")}}

{o.what}

{o.pros &&

➕ {o.pros}

} {o.cons &&

➖ {o.cons}

} {open && (
)}
))}
) : ( f.status !== "received" &&

{f.analysisError ? t("Разбора нет: агент не смог ответить.") : t("Разбора нет.")}

)} {f.status === "received" &&

{t("Агент обратной связи разбирает обращение…")}

} {f.taskKey && (

{t("Задача")}: {f.taskKey} {f.taskTitle}

)} {f.status === "rejected" &&

{f.rejectReason ? t("Не исправляем. Причина: {reason}", { reason: f.rejectReason }) : t("Не исправляем.")}

} {open && (
{!a?.options.length && (
)}
)}
); }