- env.ts: added 10 missing Zod-validated env vars (imager, paypal currency, argon2/bcrypt params) - Migrated 6 modules from process.env to validated env.* (auth, proxy-auth, paypal, password, redis, imager, moderation, alert, logger) - Replaced console.warn/error with pino logger in 9 server-side modules - Removed 50+ dead exports (SWF wrappers, coalesceHotelName, signIn, isStaff re-export, formatTimestamp, Skeleton/SkeletonCard, 4 unused housekeeping sections) - Consolidated date formatting: 28 files migrated to shared formatDate() from @/lib/format-date - Wired 4 radio/settings API routes through cached siteSettings service instead of raw Prisma queries - Added getMany()/getAll() helpers to SiteSettings service - Removed 88 dead Prisma model definitions (schema 2763→1846 lines) - Created admin action-helper.ts with wrapAction() for standardized error handling - Fixed useEffect dependency arrays in 4 data-heavy components - Replaced raw btn CSS classes with shadcn Button component across admin pages - Stripped dead i18n namespaces (common, pages.client) from all 22 translation files - Removed 2 dead scripts (create-release.sh, check-local-imports.ts) - Fixed knip.json configuration - Added 7 new test suites: format-date, paypal, moderation, alert, webhook, action-helper, and fixed password.test.ts for env mocking - All 358 tests passing across 72 test files - TypeScript: 0 errors
68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import Link from "next/link";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { Button } from "@/components/ui/button";
|
|
import { fetchAdminList } from "@/lib/admin-list";
|
|
import { PERMS } from "@/lib/permissions";
|
|
import { PollsTable } from "./polls-table";
|
|
|
|
export default async function PollsPage({
|
|
params: paramsPromise,
|
|
searchParams,
|
|
}: {
|
|
params: Promise<{ locale: string }>;
|
|
searchParams: Promise<Record<string, string>>;
|
|
}) {
|
|
const t = await getTranslations("pages.admin.polls");
|
|
const result = await fetchAdminList(
|
|
{
|
|
permission: PERMS.POLLS_VIEW,
|
|
model: "websitePoll",
|
|
searchFields: ["title"],
|
|
defaultSort: { createdAt: "desc" },
|
|
mapRow: (p: {
|
|
id: number;
|
|
title: string;
|
|
status: string;
|
|
showResults: number;
|
|
multipleChoice: number;
|
|
startsAt: Date | null;
|
|
endsAt: Date | null;
|
|
createdAt: Date;
|
|
}) => ({
|
|
id: p.id,
|
|
title: p.title,
|
|
status: p.status,
|
|
showResults: p.showResults,
|
|
multipleChoice: p.multipleChoice,
|
|
startsAt: p.startsAt,
|
|
endsAt: p.endsAt,
|
|
createdAt: p.createdAt,
|
|
}),
|
|
},
|
|
paramsPromise,
|
|
searchParams,
|
|
);
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="flex justify-end">
|
|
<Button variant="default" asChild>
|
|
<Link href="/admin/polls/create">
|
|
{t("newPoll")}
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
|
|
<PollsTable
|
|
data={{
|
|
rows: result.rows,
|
|
total: result.total,
|
|
page: result.page,
|
|
perPage: result.perPage,
|
|
lastPage: result.lastPage,
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|