import React from 'react';
import { useTranslation } from 'react-i18next';
import {
AlertTriangle,
Camera,
ClipboardList,
PlugZap,
QrCode,
Sparkles,
CalendarDays,
} from 'lucide-react';
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import type { TenantEvent, DashboardSummary } from '../../api';
import type { LimitWarning } from '../../lib/limitWarnings';
import { resolveEventDisplayName, formatEventDate, formatEventStatusLabel, resolveEngagementMode } from '../../lib/events';
type DashboardEventFocusCardProps = {
event: TenantEvent | null;
limitWarnings: LimitWarning[];
summary: DashboardSummary | null;
dateLocale: string;
onCreateEvent: () => void;
onOpenEvent: () => void;
onOpenPhotos: () => void;
onOpenInvites: () => void;
onOpenTasks: () => void;
onOpenPhotobooth: () => void;
};
export function DashboardEventFocusCard({
event,
limitWarnings,
summary,
dateLocale,
onCreateEvent,
onOpenEvent,
onOpenPhotos,
onOpenInvites,
onOpenTasks,
onOpenPhotobooth,
}: DashboardEventFocusCardProps) {
const { t } = useTranslation('dashboard', { keyPrefix: 'dashboard.eventFocus' });
const { t: tc } = useTranslation('common');
if (!event) {
return (
{t('empty.eyebrow', 'Noch kein Event aktiv')}
{t('empty.title', 'Leg mit deinem ersten Event los')}
{t('empty.description', 'Importiere ein Aufgaben-Set, lege Branding fest und teile sofort den Gästelink.')}
);
}
const eventName = resolveEventDisplayName(event);
const dateLabel = formatEventDate(event.event_date, dateLocale) ?? t('noDate', 'Kein Datum gesetzt');
const statusLabel = formatEventStatusLabel(event.status ?? null, tc);
const isLive = Boolean(event.is_active || event.status === 'published');
const engagementMode = resolveEngagementMode(event);
const overviewStats = [
{
key: 'uploads',
label: t('stats.uploads', 'Uploads gesamt'),
value: Number(event.photo_count ?? 0).toLocaleString(),
},
{
key: 'likes',
label: t('stats.likes', 'Likes'),
value: Number(event.like_count ?? 0).toLocaleString(),
},
{
key: 'tasks',
label: t('stats.tasks', 'Aktive Aufgaben'),
value: Number(event.tasks_count ?? 0).toLocaleString(),
},
{
key: 'invites',
label: t('stats.invites', 'QR-Codes live'),
value: Number(event.active_invites_count ?? event.total_invites_count ?? 0).toLocaleString(),
},
];
const quickActions = [
{
key: 'photos',
label: t('actions.photos', 'Uploads prüfen'),
description: t('actions.photosHint', 'Neueste Uploads ansehen und verstecken.'),
icon: Camera,
handler: onOpenPhotos,
disabled: !isLive,
},
{
key: 'invites',
label: t('actions.invites', 'QR-Codes'),
description: t('actions.invitesHint', 'Layouts exportieren oder Links kopieren.'),
icon: QrCode,
handler: onOpenInvites,
},
{
key: 'tasks',
label: t('actions.tasks', 'Aufgaben-Sets & Emotionen'),
description: t('actions.tasksHint', 'Kollektionen importieren und Emotionen aktivieren.'),
icon: ClipboardList,
handler: onOpenTasks,
},
{
key: 'photobooth',
label: t('actions.photobooth', 'Photobooth binden'),
description: t('actions.photoboothHint', 'FTP-Daten freigeben und Rate-Limit prüfen.'),
icon: PlugZap,
handler: onOpenPhotobooth,
},
];
return (
{t('eyebrow', 'Aktuelles Event')}
{eventName}
{t('dateLabel', { defaultValue: 'Eventdatum: {{date}}', date: dateLabel })}
{statusLabel}
{isLive ? t('badges.live', 'Live für Gäste') : t('badges.hidden', 'Noch versteckt')}
{engagementMode === 'photo_only' ? (
{t('badges.photoOnly', 'Nur Foto-Modus')}
) : (
{t('badges.missionMode', 'Mission Cards aktiv')}
)}
{overviewStats.map((stat) => (
{stat.label}
{stat.value}
))}
{quickActions.map((action) => (
))}
);
}