This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
@@ -5,63 +5,65 @@ import { PERMS } from "@/lib/permissions";
|
||||
import { PollsTable } from "./polls-table";
|
||||
|
||||
export default async function PollsPage({
|
||||
params: paramsPromise,
|
||||
searchParams,
|
||||
params: paramsPromise,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ locale: string }>;
|
||||
searchParams: Promise<Record<string, string>>;
|
||||
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,
|
||||
);
|
||||
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 items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight">Polls</h1>
|
||||
<p className="text-muted-foreground">Manage community polls and surveys</p>
|
||||
</div>
|
||||
<Button asChild>
|
||||
<Link href="/admin/polls/create">New Poll</Link>
|
||||
</Button>
|
||||
</div>
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight">Polls</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Manage community polls and surveys
|
||||
</p>
|
||||
</div>
|
||||
<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>
|
||||
);
|
||||
<PollsTable
|
||||
data={{
|
||||
rows: result.rows,
|
||||
total: result.total,
|
||||
page: result.page,
|
||||
perPage: result.perPage,
|
||||
lastPage: result.lastPage,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user