import { apiFetch } from '../_lib/api'; import { redirect } from 'next/navigation'; import { getToken } from '../_lib/api'; import { DraftCard } from '../admin/drafts/DraftCard'; import Link from 'next/link'; type DraftType = 'EVENT' | 'SEVA_TASK' | 'FAQ_ITEM'; interface Draft { id: string; type: DraftType; status: string; proposedJson: Record; confidence: number | null; createdAt: string; sourceMessage: { id: string; content: string; senderName: string | null; createdAt: string; }; } const TABS: { label: string; value: DraftType | 'ALL' }[] = [ { label: 'All', value: 'ALL' }, { label: 'Events', value: 'EVENT' }, { label: 'Seva Tasks', value: 'SEVA_TASK' }, { label: 'FAQs', value: 'FAQ_ITEM' }, ]; async function fetchDrafts(type?: DraftType): Promise { const query = new URLSearchParams({ status: 'PENDING_REVIEW' }); if (type) query.set('type', type); const res = await apiFetch(`/admin/drafts?${query}`); if (!res.ok) return []; return (await res.json()) as Draft[]; } export default async function TenantDraftsPage({ searchParams, }: { searchParams: Promise<{ type?: string }>; }) { const token = await getToken(); if (!token) redirect('/login'); const { type } = await searchParams; const activeType = (type as DraftType) ?? undefined; const drafts = await fetchDrafts(activeType); return (

AI Content Drafts

Events, seva tasks, and FAQs auto-detected from your group messages

{TABS.map((tab) => { const href = tab.value === 'ALL' ? '/drafts' : `/drafts?type=${tab.value}`; const isActive = (tab.value === 'ALL' && !activeType) || tab.value === activeType; return ( {tab.label} ); })}
{drafts.length === 0 ? (

No pending drafts

Drafts appear here when the AI detects events, volunteer asks, or FAQ patterns in your group messages.

) : (
{drafts.map((d) => ( ))}
)}
); }