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) => ( {label} ); return (
{t("Здесь всё, что вы сообщили о проблемах в FORGE, и что с этим стало. Новое обращение — кнопка «Сообщить о проблеме» внизу любой страницы.")} {superadmin && (
{sorted.length === 0 ? {t("Таких обращений нет.")} : sorted.map((f) => )}
)}
{mine.length === 0 ? {t("Вы пока ничего не сообщали. Заметили проблему — нажмите «Сообщить о проблеме».")} : mine.map((f) => )}
); }