Every module had buttons that rendered visually but did nothing when clicked. Server actions existed for all of them. Created client components with dialogs/forms and wired them in. BOOKINGS MODULE: - BookingStatusActions: Check-in/Check-out/Cancel buttons now call updateBookingStatus server action with loading states + toast - CreateRoomDialog: 'Neues Zimmer' opens dialog with room number, name, capacity, price/night fields → calls createRoom - CreateGuestDialog: 'Neuer Gast' opens dialog with first/last name, email, phone fields → calls createGuest COURSES MODULE: - EnrollParticipantDialog: 'Teilnehmer anmelden' on participants page opens dialog with first/last name, email, phone → calls enrollParticipant EVENTS MODULE: - EventRegistrationDialog: 'Anmeldung' button on event detail opens dialog with participant data + DOB → calls registerForEvent - CreateHolidayPassDialog: 'Neuer Ferienpass' opens dialog with name, year, description, price, date range → calls createHolidayPass NEWSLETTER MODULE: - CreateTemplateDialog: 'Neue Vorlage' opens dialog with name, subject, HTML body → calls createTemplate SITE-BUILDER MODULE: - Posts 'Neuer Beitrag' button now links to /posts/new page All dialogs use German labels, helpful placeholders, loading spinners, toast notifications, and form validation appropriate for association board members (Vereinsvorstände, 40-65, moderate tech skills).
105 lines
3.3 KiB
TypeScript
105 lines
3.3 KiB
TypeScript
import Link from 'next/link';
|
|
|
|
import { Plus } from 'lucide-react';
|
|
import { getTranslations } from 'next-intl/server';
|
|
|
|
interface SitePost {
|
|
id: string;
|
|
title: string;
|
|
status: string;
|
|
created_at: string | null;
|
|
}
|
|
|
|
import { formatDate } from '@kit/shared/dates';
|
|
import { createSiteBuilderApi } from '@kit/site-builder/api';
|
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|
import { Badge } from '@kit/ui/badge';
|
|
import { Button } from '@kit/ui/button';
|
|
|
|
import { AccountNotFound } from '~/components/account-not-found';
|
|
import { CmsPageShell } from '~/components/cms-page-shell';
|
|
import { EmptyState } from '~/components/empty-state';
|
|
|
|
interface Props {
|
|
params: Promise<{ account: string }>;
|
|
}
|
|
|
|
export default async function PostsManagerPage({ params }: Props) {
|
|
const { account } = await params;
|
|
const client = getSupabaseServerClient();
|
|
const t = await getTranslations('siteBuilder');
|
|
|
|
const { data: acct } = await client
|
|
.from('accounts')
|
|
.select('id')
|
|
.eq('slug', account)
|
|
.single();
|
|
if (!acct) return <AccountNotFound />;
|
|
|
|
const api = createSiteBuilderApi(client);
|
|
const posts = await api.listPosts(acct.id);
|
|
|
|
return (
|
|
<CmsPageShell
|
|
account={account}
|
|
title={t('posts.title')}
|
|
description={t('posts.manage')}
|
|
>
|
|
<div className="space-y-6">
|
|
<div className="flex justify-end">
|
|
<Button data-test="site-new-post-btn" asChild>
|
|
<Link href={`/home/${account}/site-builder/posts/new`}>
|
|
<Plus className="mr-2 h-4 w-4" />
|
|
{t('posts.newPost')}
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
{posts.length === 0 ? (
|
|
<EmptyState
|
|
title={t('posts.noPosts2')}
|
|
description={t('posts.noPostDesc')}
|
|
actionLabel={t('posts.createPostLabel')}
|
|
/>
|
|
) : (
|
|
<div className="overflow-x-auto rounded-md border">
|
|
<table className="w-full min-w-[640px] text-sm">
|
|
<thead>
|
|
<tr className="bg-muted/50 border-b">
|
|
<th scope="col" className="p-3 text-left">
|
|
{t('posts.colTitle')}
|
|
</th>
|
|
<th scope="col" className="p-3 text-left">
|
|
{t('posts.colStatus')}
|
|
</th>
|
|
<th scope="col" className="p-3 text-left">
|
|
{t('posts.colCreated')}
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{(posts as SitePost[]).map((post) => (
|
|
<tr key={post.id} className="hover:bg-muted/30 border-b">
|
|
<td className="p-3 font-medium">{post.title}</td>
|
|
<td className="p-3">
|
|
<Badge
|
|
variant={
|
|
post.status === 'published' ? 'default' : 'secondary'
|
|
}
|
|
>
|
|
{post.status}
|
|
</Badge>
|
|
</td>
|
|
<td className="text-muted-foreground p-3 text-xs">
|
|
{formatDate(post.created_at)}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</CmsPageShell>
|
|
);
|
|
}
|