feat: add admin content module pages
Local Build and Deploy / deploy (push) Successful in 47s

This commit is contained in:
Simo committed 2026-07-12 15:27:07 +02:00
1 parent f422bb4a0b
commit 2606092337
24 files changed
+2892

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
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 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>
)
}