peppa/apps/web/app/(app)/feedback/page.tsx
peppa-bot f3d10a4c25 PEP-243: платформа называется FORGE — название во всех текстах для людей и подсказках агентам, адрес forge.telecom.quest
«Peppa FACTORY» → «FORGE» в экранах, сообщениях, словарях en/kk, шаблоне и тестах; «Пеппа» → «FORGE» в подсказках
агентам и правилах; логотип, значок, версия кэша service worker; в словаре старые названия — в «Нельзя».
Внутренние имена (CLI peppa, PEPPA_*, MCP-сервер peppa, ключи PEP-N) не меняются. Второй адрес — в mac-route.sh.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 11:18:49 +05:00

53 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import { FEEDBACK_ADMIN_STATUS, FEEDBACK_STATUSES, isFeedbackStatus, isSuperadmin, listAllFeedback, listUserFeedback } from "@peppa/core";
import { AdminFeedbackCard, MyFeedbackCard } from "@/components/Feedback";
import { Empty, Flash, PageHeader, Section } from "@/components/common";
import { Workspace } from "@/components/Workspace";
import { requireUser } from "@/lib/auth";
import { db } from "@/lib/db";
import { getT } from "@/lib/i18n";
import { cn } from "@/lib/utils";
/**
* PEP-143: «Обращения». Everybody sees their own reports and where they stand; the superadmin
* also sees everybody's, filtered by status, and decides on them.
*/
export default async function FeedbackPage({ searchParams }: { searchParams: Promise<{ error?: string; status?: string; id?: string }> }) {
const user = await requireUser();
const t = await getT();
const { error, status, id } = await searchParams;
const superadmin = await isSuperadmin(db, user);
const mine = await listUserFeedback(db, user.id);
const filter = isFeedbackStatus(status) ? status : null;
const all = superadmin ? await listAllFeedback(db, { status: filter }) : [];
// A link from a message opens one report first.
const focus = Number(id);
const sorted = Number.isInteger(focus) ? [...all].sort((a, b) => Number(b.id === focus) - Number(a.id === focus)) : all;
const back = `/feedback${filter ? `?status=${filter}` : ""}`;
const tab = (href: string, label: string, active: boolean) => (
<Link key={href} href={href} aria-current={active ? "page" : undefined} className={cn("rounded-full border px-3 py-1 text-sm text-muted-foreground hover:text-foreground hover:no-underline", active && "border-primary/40 bg-primary/10 font-medium text-foreground")}>
{label}
</Link>
);
return (
<Workspace>
<div className="max-w-3xl">
<Flash error={error} />
<PageHeader title={t("Обращения")}>{t("Здесь всё, что вы сообщили о проблемах в FORGE, и что с этим стало. Новое обращение — кнопка «Сообщить о проблеме» внизу любой страницы.")}</PageHeader>
{superadmin && (
<Section title={t("Обращения пользователей")} count={all.length}>
<nav aria-label={t("Статус")} className="mb-1 flex flex-wrap gap-2">
{tab("/feedback", t("Все"), !filter)}
{FEEDBACK_STATUSES.map((s) => tab(`/feedback?status=${s}`, t.text(FEEDBACK_ADMIN_STATUS[s]), filter === s))}
</nav>
{sorted.length === 0 ? <Empty>{t("Таких обращений нет.")}</Empty> : sorted.map((f) => <AdminFeedbackCard key={f.id} f={f} back={back} />)}
</Section>
)}
<Section title={t("Ваши обращения")} count={mine.length}>
{mine.length === 0 ? <Empty>{t("Вы пока ничего не сообщали. Заметили проблему — нажмите «Сообщить о проблеме».")}</Empty> : mine.map((f) => <MyFeedbackCard key={f.id} f={f} />)}
</Section>
</div>
</Workspace>
);
}