Wire orphan routes into hub tabs, group Radio into primary/tools rows, show theme/language once on desktop, and remove duplicate page titles under AdminHubChrome. Co-authored-by: Cursor <[email protected]>
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import Link from "next/link";
|
|
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 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 asChild>
|
|
<Link href="/admin/polls/create">New Poll</Link>
|
|
</Button>
|
|
</div>
|
|
|
|
<PollsTable
|
|
data={{
|
|
rows: result.rows,
|
|
total: result.total,
|
|
page: result.page,
|
|
perPage: result.perPage,
|
|
lastPage: result.lastPage,
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|