tenant admin startseite schicker gestaltet und super-admin und tenant admin (filament) aufgesplittet.

Es gibt nun task collections und vordefinierte tasks für alle. Onboarding verfeinert und webseite-carousel gefixt (logging später entfernen!)
This commit is contained in:
Codex Agent
2025-10-14 15:17:52 +02:00
parent 64a5411fb9
commit 1a4bdb1fe1
92 changed files with 6027 additions and 515 deletions

View File

@@ -0,0 +1,384 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { format } from 'date-fns';
import { de, enGB } from 'date-fns/locale';
import type { Locale } from 'date-fns';
import { Palette, Plus, Power, Smile } from 'lucide-react';
import { AdminLayout } from '../components/AdminLayout';
import {
getEmotions,
createEmotion,
updateEmotion,
TenantEmotion,
EmotionPayload,
} from '../api';
import { isAuthError } from '../auth/tokens';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch';
const DEFAULT_COLOR = '#6366f1';
type EmotionFormState = {
name: string;
description: string;
icon: string;
color: string;
is_active: boolean;
sort_order: number;
};
const INITIAL_FORM_STATE: EmotionFormState = {
name: '',
description: '',
icon: 'lucide-smile',
color: DEFAULT_COLOR,
is_active: true,
sort_order: 0,
};
export default function EmotionsPage(): JSX.Element {
const { t, i18n } = useTranslation('management');
const [emotions, setEmotions] = React.useState<TenantEmotion[]>([]);
const [loading, setLoading] = React.useState(true);
const [error, setError] = React.useState<string | null>(null);
const [dialogOpen, setDialogOpen] = React.useState(false);
const [saving, setSaving] = React.useState(false);
const [form, setForm] = React.useState<EmotionFormState>(INITIAL_FORM_STATE);
React.useEffect(() => {
let cancelled = false;
async function load() {
setLoading(true);
setError(null);
try {
const data = await getEmotions();
if (!cancelled) {
setEmotions(data);
}
} catch (err) {
if (!isAuthError(err)) {
setError(t('emotions.errors.load'));
}
} finally {
if (!cancelled) {
setLoading(false);
}
}
}
void load();
return () => {
cancelled = true;
};
}, [t]);
function openCreateDialog() {
setForm(INITIAL_FORM_STATE);
setDialogOpen(true);
}
async function handleCreate(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!form.name.trim()) {
setError(t('emotions.errors.nameRequired'));
return;
}
setSaving(true);
setError(null);
const payload: EmotionPayload = {
name: form.name.trim(),
description: form.description.trim() || null,
icon: form.icon.trim() || 'lucide-smile',
color: form.color.trim() || DEFAULT_COLOR,
is_active: form.is_active,
sort_order: form.sort_order,
};
try {
const created = await createEmotion(payload);
setEmotions((prev) => [created, ...prev]);
setDialogOpen(false);
} catch (err) {
if (!isAuthError(err)) {
setError(t('emotions.errors.create'));
}
} finally {
setSaving(false);
}
}
async function toggleEmotion(emotion: TenantEmotion) {
try {
const updated = await updateEmotion(emotion.id, { is_active: !emotion.is_active });
setEmotions((prev) => prev.map((item) => (item.id === updated.id ? updated : item)));
} catch (err) {
if (!isAuthError(err)) {
setError(t('emotions.errors.toggle'));
}
}
}
const locale = i18n.language.startsWith('en') ? enGB : de;
return (
<AdminLayout
title={t('emotions.title') ?? 'Emotions'}
subtitle={t('emotions.subtitle') ?? ''}
actions={
<Button
className="bg-gradient-to-r from-pink-500 via-fuchsia-500 to-purple-500 text-white shadow-lg shadow-pink-500/20"
onClick={openCreateDialog}
>
<Plus className="h-4 w-4" />
{t('emotions.actions.create')}
</Button>
}
>
{error && (
<Alert variant="destructive">
<AlertTitle>{t('emotions.errors.genericTitle')}</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)}
<Card className="border-0 bg-white/85 shadow-xl shadow-pink-100/60">
<CardHeader>
<CardTitle className="text-xl text-slate-900">{t('emotions.title')}</CardTitle>
<CardDescription className="text-sm text-slate-600">{t('emotions.subtitle')}</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
{loading ? (
<EmotionSkeleton />
) : emotions.length === 0 ? (
<EmptyEmotionsState />
) : (
<div className="grid gap-4 sm:grid-cols-2">
{emotions.map((emotion) => (
<EmotionCard
key={emotion.id}
emotion={emotion}
onToggle={() => toggleEmotion(emotion)}
locale={locale}
canToggle={!emotion.is_global}
/>
))}
</div>
)}
</CardContent>
</Card>
<EmotionDialog
open={dialogOpen}
onOpenChange={setDialogOpen}
form={form}
setForm={setForm}
saving={saving}
onSubmit={handleCreate}
/>
</AdminLayout>
);
}
function EmotionCard({
emotion,
onToggle,
locale,
canToggle,
}: {
emotion: TenantEmotion;
onToggle: () => void;
locale: Locale;
canToggle: boolean;
}) {
const { t } = useTranslation('management');
const updatedLabel = emotion.updated_at
? format(new Date(emotion.updated_at), 'PP', { locale })
: null;
return (
<Card className="border border-slate-100 bg-white/90 shadow-sm">
<CardHeader className="space-y-3">
<div className="flex items-center gap-2">
<Badge
variant="outline"
className={emotion.is_global ? 'border-indigo-200 text-indigo-600' : 'border-pink-200 text-pink-600'}
>
{emotion.is_global ? t('emotions.scope.global') : t('emotions.scope.tenant')}
</Badge>
<Badge variant="secondary" className="bg-slate-100 text-slate-700">
{emotion.event_types.map((type) => type.name).join(', ') || t('emotions.labels.noEventType')}
</Badge>
</div>
<CardTitle className="flex items-center gap-2 text-lg text-slate-900">
<Smile className="h-4 w-4" />
{emotion.name}
</CardTitle>
{emotion.description && (
<CardDescription className="text-sm text-slate-600">{emotion.description}</CardDescription>
)}
</CardHeader>
<CardContent className="flex items-center justify-between text-xs text-slate-500">
<div className="flex items-center gap-2">
<Palette className="h-4 w-4" />
<span>{emotion.color}</span>
</div>
{updatedLabel && <span>{t('emotions.labels.updated', { date: updatedLabel })}</span>}
</CardContent>
<CardFooter className="flex items-center justify-between border-t border-slate-100 bg-slate-50/60 px-4 py-3">
<span className="text-xs text-slate-500">
{emotion.is_active ? t('emotions.status.active') : t('emotions.status.inactive')}
</span>
<Button
variant="outline"
size="sm"
onClick={onToggle}
disabled={!canToggle}
className={!canToggle ? 'pointer-events-none opacity-60' : ''}
>
<Power className="mr-2 h-4 w-4" />
{emotion.is_active ? t('emotions.actions.disable') : t('emotions.actions.enable')}
</Button>
</CardFooter>
</Card>
);
}
function EmptyEmotionsState() {
const { t } = useTranslation('management');
return (
<div className="flex flex-col items-center justify-center gap-4 rounded-2xl border border-dashed border-indigo-200 bg-indigo-50/40 p-12 text-center">
<div className="rounded-full bg-white p-4 shadow-inner">
<Smile className="h-8 w-8 text-indigo-500" />
</div>
<div className="space-y-1">
<h3 className="text-lg font-semibold text-slate-800">{t('emotions.empty.title')}</h3>
<p className="text-sm text-slate-600">{t('emotions.empty.description')}</p>
</div>
</div>
);
}
function EmotionSkeleton() {
return (
<div className="grid gap-4 sm:grid-cols-2">
{Array.from({ length: 4 }).map((_, index) => (
<div key={index} className="animate-pulse rounded-2xl border border-slate-100 bg-white/80 p-6 shadow-sm">
<div className="mb-3 h-4 w-24 rounded bg-slate-200" />
<div className="mb-2 h-5 w-40 rounded bg-slate-200" />
<div className="h-16 rounded bg-slate-100" />
</div>
))}
</div>
);
}
function EmotionDialog({
open,
onOpenChange,
form,
setForm,
saving,
onSubmit,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
form: EmotionFormState;
setForm: React.Dispatch<React.SetStateAction<EmotionFormState>>;
saving: boolean;
onSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
}) {
const { t } = useTranslation('management');
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>{t('emotions.dialogs.createTitle')}</DialogTitle>
</DialogHeader>
<form className="space-y-4" onSubmit={onSubmit}>
<div className="space-y-2">
<Label htmlFor="emotion-name">{t('emotions.dialogs.name')}</Label>
<Input
id="emotion-name"
value={form.name}
onChange={(event) => setForm((prev) => ({ ...prev, name: event.target.value }))}
required
/>
</div>
<div className="space-y-2">
<Label htmlFor="emotion-description">{t('emotions.dialogs.description')}</Label>
<textarea
id="emotion-description"
value={form.description}
onChange={(event) => setForm((prev) => ({ ...prev, description: event.target.value }))}
className="min-h-[80px] w-full rounded-md border border-slate-200 bg-white/80 p-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"
/>
</div>
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="emotion-icon">{t('emotions.dialogs.icon')}</Label>
<Input
id="emotion-icon"
value={form.icon}
onChange={(event) => setForm((prev) => ({ ...prev, icon: event.target.value }))}
/>
</div>
<div className="space-y-2">
<Label htmlFor="emotion-color">{t('emotions.dialogs.color')}</Label>
<Input
id="emotion-color"
value={form.color}
onChange={(event) => setForm((prev) => ({ ...prev, color: event.target.value }))}
placeholder="#6366f1"
/>
</div>
</div>
<div className="flex items-center justify-between rounded-lg border border-indigo-100 bg-indigo-50/60 p-3">
<div>
<Label htmlFor="emotion-active" className="text-sm font-medium text-slate-800">
{t('emotions.dialogs.activeLabel')}
</Label>
<p className="text-xs text-slate-500">{t('emotions.dialogs.activeDescription')}</p>
</div>
<Switch
id="emotion-active"
checked={form.is_active}
onCheckedChange={(checked) => setForm((prev) => ({ ...prev, is_active: Boolean(checked) }))}
/>
</div>
<DialogFooter className="flex justify-end gap-2">
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
{t('emotions.dialogs.cancel')}
</Button>
<Button type="submit" disabled={saving}>
{saving ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
{t('emotions.dialogs.submit')}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}

View File

@@ -0,0 +1,492 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { format } from 'date-fns';
import { de, enGB } from 'date-fns/locale';
import { Layers, Library, Loader2, Plus } from 'lucide-react';
import { AdminLayout } from '../components/AdminLayout';
import {
getTaskCollections,
importTaskCollection,
getEvents,
PaginationMeta,
TenantEvent,
TenantTaskCollection,
} from '../api';
import { ADMIN_TASKS_PATH } from '../constants';
import { isAuthError } from '../auth/tokens';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
const DEFAULT_PAGE_SIZE = 12;
type ScopeFilter = 'all' | 'global' | 'tenant';
type CollectionsState = {
items: TenantTaskCollection[];
meta: PaginationMeta | null;
};
export default function TaskCollectionsPage(): JSX.Element {
const navigate = useNavigate();
const { t, i18n } = useTranslation('management');
const [collectionsState, setCollectionsState] = React.useState<CollectionsState>({ items: [], meta: null });
const [page, setPage] = React.useState(1);
const [search, setSearch] = React.useState('');
const [scope, setScope] = React.useState<ScopeFilter>('all');
const [loading, setLoading] = React.useState(true);
const [error, setError] = React.useState<string | null>(null);
const [successMessage, setSuccessMessage] = React.useState<string | null>(null);
const [dialogOpen, setDialogOpen] = React.useState(false);
const [selectedCollection, setSelectedCollection] = React.useState<TenantTaskCollection | null>(null);
const [events, setEvents] = React.useState<TenantEvent[]>([]);
const [selectedEventSlug, setSelectedEventSlug] = React.useState('');
const [importing, setImporting] = React.useState(false);
const [eventsLoading, setEventsLoading] = React.useState(false);
const [eventError, setEventError] = React.useState<string | null>(null);
const [reloadToken, setReloadToken] = React.useState(0);
const scopeParam = React.useMemo(() => {
if (scope === 'global') return 'global';
if (scope === 'tenant') return 'tenant';
return undefined;
}, [scope]);
React.useEffect(() => {
let cancelled = false;
async function loadCollections() {
setLoading(true);
setError(null);
try {
const result = await getTaskCollections({
page,
per_page: DEFAULT_PAGE_SIZE,
search: search.trim() || undefined,
scope: scopeParam,
});
if (cancelled) return;
setCollectionsState({ items: result.data, meta: result.meta });
} catch (err) {
if (cancelled) return;
if (!isAuthError(err)) {
setError(t('collections.notifications.error'));
}
} finally {
if (!cancelled) {
setLoading(false);
}
}
}
void loadCollections();
return () => {
cancelled = true;
};
}, [page, search, scopeParam, reloadToken, t]);
React.useEffect(() => {
if (successMessage) {
const timeout = setTimeout(() => setSuccessMessage(null), 4000);
return () => clearTimeout(timeout);
}
return undefined;
}, [successMessage]);
async function ensureEventsLoaded() {
if (events.length > 0 || eventsLoading) {
return;
}
setEventsLoading(true);
setEventError(null);
try {
const result = await getEvents();
setEvents(result);
} catch (err) {
if (!isAuthError(err)) {
setEventError(t('collections.errors.eventsLoad'));
}
} finally {
setEventsLoading(false);
}
}
function openImportDialog(collection: TenantTaskCollection) {
setSelectedCollection(collection);
setSelectedEventSlug('');
setDialogOpen(true);
void ensureEventsLoaded();
}
async function handleImport(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!selectedCollection || !selectedEventSlug) {
setEventError(t('collections.errors.selectEvent'));
return;
}
setImporting(true);
setEventError(null);
try {
await importTaskCollection(selectedCollection.id, selectedEventSlug);
setSuccessMessage(t('collections.notifications.imported'));
setDialogOpen(false);
setReloadToken((token) => token + 1);
} catch (err) {
if (!isAuthError(err)) {
setEventError(t('collections.notifications.error'));
}
} finally {
setImporting(false);
}
}
const showEmpty = !loading && collectionsState.items.length === 0;
return (
<AdminLayout
title={t('collections.title') ?? 'Task Collections'}
subtitle={t('collections.subtitle') ?? ''}
actions={
<div className="flex flex-wrap gap-2">
<Button variant="outline" onClick={() => navigate(ADMIN_TASKS_PATH)}>
<Library className="mr-2 h-4 w-4" />
{t('collections.actions.openTasks')}
</Button>
<Button
className="bg-gradient-to-r from-pink-500 via-fuchsia-500 to-purple-500 text-white shadow-lg shadow-pink-500/20"
onClick={() => navigate(ADMIN_TASKS_PATH)}
>
<Plus className="mr-2 h-4 w-4" />
{t('collections.actions.create')}
</Button>
</div>
}
>
{error && (
<Alert variant="destructive">
<AlertTitle>{t('collections.notifications.error')}</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)}
{successMessage && (
<Alert className="border-l-4 border-green-500 bg-green-50 text-sm text-green-900">
<AlertTitle>{t('collections.notifications.imported')}</AlertTitle>
<AlertDescription>{successMessage}</AlertDescription>
</Alert>
)}
<Card className="border-0 bg-white/85 shadow-xl shadow-pink-100/60">
<CardHeader>
<CardTitle className="text-xl text-slate-900">{t('collections.title')}</CardTitle>
<CardDescription className="text-sm text-slate-600">{t('collections.subtitle')}</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
<Input
value={search}
onChange={(event) => {
setPage(1);
setSearch(event.target.value);
}}
placeholder={t('collections.filters.search') ?? 'Search collections'}
className="w-full lg:max-w-md"
/>
<div className="flex flex-wrap gap-3">
<Select
value={scope}
onValueChange={(value) => {
setScope(value as ScopeFilter);
setPage(1);
}}
>
<SelectTrigger className="w-[220px]">
<SelectValue placeholder={t('collections.filters.scope')} />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">{t('collections.filters.allScopes')}</SelectItem>
<SelectItem value="global">{t('collections.filters.globalOnly')}</SelectItem>
<SelectItem value="tenant">{t('collections.filters.tenantOnly')}</SelectItem>
</SelectContent>
</Select>
</div>
</div>
{loading ? (
<CollectionSkeleton />
) : showEmpty ? (
<EmptyCollectionsState onCreate={() => navigate(ADMIN_TASKS_PATH)} />
) : (
<div className="grid gap-4 sm:grid-cols-2">
{collectionsState.items.map((collection) => (
<CollectionCard
key={collection.id}
collection={collection}
onImport={() => openImportDialog(collection)}
/>
))}
</div>
)}
{collectionsState.meta && collectionsState.meta.last_page > 1 && (
<div className="flex items-center justify-between">
<Button
variant="outline"
disabled={page <= 1}
onClick={() => setPage((prev) => Math.max(prev - 1, 1))}
>
{t('collections.pagination.prev')}
</Button>
<span className="text-xs text-slate-500">
{t('collections.pagination.page', {
current: collectionsState.meta.current_page,
total: collectionsState.meta.last_page,
})}
</span>
<Button
variant="outline"
disabled={page >= collectionsState.meta.last_page}
onClick={() => setPage((prev) => Math.min(prev + 1, collectionsState.meta!.last_page))}
>
{t('collections.pagination.next')}
</Button>
</div>
)}
</CardContent>
</Card>
<ImportDialog
open={dialogOpen}
onOpenChange={setDialogOpen}
collection={selectedCollection}
events={events}
eventError={eventError}
eventsLoading={eventsLoading}
selectedEventSlug={selectedEventSlug}
onEventChange={setSelectedEventSlug}
onSubmit={handleImport}
importing={importing}
/>
</AdminLayout>
);
}
function CollectionCard({
collection,
onImport,
}: {
collection: TenantTaskCollection;
onImport: () => void;
}) {
const { t, i18n } = useTranslation('management');
const locale = i18n.language.startsWith('en') ? enGB : de;
const updatedLabel = collection.updated_at
? format(new Date(collection.updated_at), 'PP', { locale })
: null;
const scopeLabel = collection.is_global ? t('collections.scope.global') : t('collections.scope.tenant');
const eventTypeLabel = collection.event_type?.name ?? t('collections.filters.allEventTypes');
return (
<Card className="border border-slate-100 bg-white/90 shadow-sm">
<CardHeader className="space-y-3">
<div className="flex items-center gap-2">
<Badge
variant="outline"
className={collection.is_global ? 'border-indigo-200 text-indigo-600' : 'border-pink-200 text-pink-600'}
>
{scopeLabel}
</Badge>
{eventTypeLabel && (
<Badge variant="secondary" className="bg-slate-100 text-slate-700">
{eventTypeLabel}
</Badge>
)}
</div>
<CardTitle className="text-lg text-slate-900">{collection.name}</CardTitle>
{collection.description && (
<CardDescription className="text-sm text-slate-600">
{collection.description}
</CardDescription>
)}
</CardHeader>
<CardContent className="flex items-center justify-between text-sm text-slate-500">
<div className="flex items-center gap-2">
<Layers className="h-4 w-4" />
<span>{t('collections.labels.taskCount', { count: collection.tasks_count })}</span>
</div>
{updatedLabel && <span>{t('collections.labels.updated', { date: updatedLabel })}</span>}
</CardContent>
<CardFooter className="flex justify-end">
<Button variant="outline" onClick={onImport}>
{t('collections.actions.import')}
</Button>
</CardFooter>
</Card>
);
}
function EmptyCollectionsState({ onCreate }: { onCreate: () => void }) {
const { t } = useTranslation('management');
return (
<div className="flex flex-col items-center justify-center gap-4 rounded-2xl border border-dashed border-pink-200 bg-pink-50/40 p-12 text-center">
<div className="rounded-full bg-white p-4 shadow-inner">
<Layers className="h-8 w-8 text-pink-500" />
</div>
<div className="space-y-1">
<h3 className="text-lg font-semibold text-slate-800">{t('collections.empty.title')}</h3>
<p className="text-sm text-slate-600">{t('collections.empty.description')}</p>
</div>
<div className="flex gap-2">
<Button onClick={onCreate}>
<Plus className="mr-2 h-4 w-4" />
{t('collections.actions.create')}
</Button>
</div>
</div>
);
}
function CollectionSkeleton() {
return (
<div className="grid gap-4 sm:grid-cols-2">
{Array.from({ length: 4 }).map((_, index) => (
<div key={index} className="animate-pulse rounded-2xl border border-slate-100 bg-white/80 p-6 shadow-sm">
<div className="mb-3 h-4 w-24 rounded bg-slate-200" />
<div className="mb-2 h-5 w-40 rounded bg-slate-200" />
<div className="h-16 rounded bg-slate-100" />
</div>
))}
</div>
);
}
function ImportDialog({
open,
onOpenChange,
collection,
events,
eventsLoading,
eventError,
selectedEventSlug,
onEventChange,
onSubmit,
importing,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
collection: TenantTaskCollection | null;
events: TenantEvent[];
eventsLoading: boolean;
eventError: string | null;
selectedEventSlug: string;
onEventChange: (value: string) => void;
onSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
importing: boolean;
}) {
const { t, i18n } = useTranslation('management');
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>{t('collections.dialogs.importTitle')}</DialogTitle>
</DialogHeader>
<form className="space-y-4" onSubmit={onSubmit}>
<div className="space-y-2">
<Label htmlFor="collection-name">{t('collections.dialogs.collectionLabel')}</Label>
<Input id="collection-name" value={collection?.name ?? ''} readOnly disabled className="bg-slate-100" />
</div>
<div className="space-y-2">
<Label htmlFor="collection-event">{t('collections.dialogs.selectEvent')}</Label>
<Select
value={selectedEventSlug}
onValueChange={onEventChange}
disabled={eventsLoading || events.length === 0}
>
<SelectTrigger id="collection-event">
<SelectValue placeholder={t('collections.dialogs.selectEvent') ?? 'Event auswählen'} />
</SelectTrigger>
<SelectContent>
{events.map((event) => (
<SelectItem key={event.slug} value={event.slug}>
{formatEventLabel(event, i18n.language)}
</SelectItem>
))}
</SelectContent>
</Select>
{events.length === 0 && !eventsLoading && (
<p className="text-xs text-slate-500">
{t('collections.errors.noEvents') ?? 'Noch keine Events vorhanden.'}
</p>
)}
{eventError && <p className="text-xs text-red-500">{eventError}</p>}
</div>
<DialogFooter className="flex justify-end gap-2">
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
{t('collections.dialogs.cancel')}
</Button>
<Button type="submit" disabled={importing || !selectedEventSlug}>
{importing ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
{t('collections.dialogs.submit')}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}
function formatEventLabel(event: TenantEvent, language: string): string {
const locales = [language, language?.split('-')[0], 'de', 'en'].filter(Boolean) as string[];
let name: string | undefined;
if (typeof event.name === 'string') {
name = event.name;
} else if (event.name && typeof event.name === 'object') {
for (const locale of locales) {
const value = (event.name as Record<string, string>)[locale!];
if (value) {
name = value;
break;
}
}
if (!name) {
const first = Object.values(event.name as Record<string, string>)[0];
if (first) {
name = first;
}
}
}
const eventDate = event.event_date ? new Date(event.event_date) : null;
if (!eventDate) {
return name ?? event.slug;
}
const locale = language.startsWith('en') ? enGB : de;
return `${name ?? event.slug} (${format(eventDate, 'PP', { locale })})`;
}

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { CheckCircle2, Circle, Loader2, Pencil, Plus, Trash2 } from 'lucide-react';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
@@ -23,7 +24,7 @@ import {
updateTask,
} from '../api';
import { isAuthError } from '../auth/tokens';
import { ADMIN_EVENTS_PATH } from '../constants';
import { ADMIN_EVENTS_PATH, ADMIN_TASK_COLLECTIONS_PATH } from '../constants';
type TaskFormState = {
title: string;
@@ -43,6 +44,7 @@ const INITIAL_FORM: TaskFormState = {
export default function TasksPage() {
const navigate = useNavigate();
const { t } = useTranslation('common');
const [tasks, setTasks] = React.useState<TenantTask[]>([]);
const [meta, setMeta] = React.useState<PaginationMeta | null>(null);
const [page, setPage] = React.useState(1);
@@ -150,6 +152,9 @@ export default function TasksPage() {
}
async function toggleCompletion(task: TenantTask) {
if (task.tenant_id === null) {
return;
}
try {
const updated = await updateTask(task.id, { is_completed: !task.is_completed });
setTasks((prev) => prev.map((entry) => (entry.id === updated.id ? updated : entry)));
@@ -165,13 +170,18 @@ export default function TasksPage() {
title="Task Bibliothek"
subtitle="Weise Aufgaben zu und tracke Fortschritt rund um deine Events."
actions={
<Button
className="bg-gradient-to-r from-pink-500 via-fuchsia-500 to-purple-500 text-white shadow-lg shadow-pink-500/20"
onClick={openCreate}
>
<Plus className="h-4 w-4" />
Neuer Task
</Button>
<div className="flex flex-wrap gap-2">
<Button variant="outline" onClick={() => navigate(ADMIN_TASK_COLLECTIONS_PATH)}>
{t('navigation.collections')}
</Button>
<Button
className="bg-gradient-to-r from-pink-500 via-fuchsia-500 to-purple-500 text-white shadow-lg shadow-pink-500/20"
onClick={openCreate}
>
<Plus className="h-4 w-4" />
Neu
</Button>
</div>
}
>
{error && (
@@ -269,25 +279,34 @@ function TaskRow({
}) {
const assignedCount = task.assigned_events_count ?? task.assigned_events?.length ?? 0;
const completed = task.is_completed;
const isGlobal = task.tenant_id === null;
return (
<div className="flex flex-col gap-3 rounded-2xl border border-slate-100 bg-white/90 p-4 shadow-sm sm:flex-row sm:items-center sm:justify-between">
<div className="flex flex-1 items-start gap-3">
<button
type="button"
onClick={onToggle}
className="rounded-full border border-pink-200 bg-white/80 p-2 text-pink-600 shadow-sm transition hover:bg-pink-50"
onClick={isGlobal ? undefined : onToggle}
aria-disabled={isGlobal}
className={`rounded-full border border-pink-200 bg-white/80 p-2 text-pink-600 shadow-sm transition ${
isGlobal ? 'opacity-50 cursor-not-allowed' : 'hover:bg-pink-50'
}`}
>
{completed ? <CheckCircle2 className="h-5 w-5" /> : <Circle className="h-5 w-5" />}
</button>
<div className="space-y-1">
<div className="flex items-center gap-2">
<div className="flex flex-wrap items-center gap-2">
<p className={`text-sm font-semibold ${completed ? 'text-slate-500 line-through' : 'text-slate-900'}`}>
{task.title}
</p>
<Badge variant="outline" className="border-pink-200 text-pink-600">
{mapPriority(task.priority)}
</Badge>
{isGlobal && (
<Badge variant="secondary" className="bg-slate-100 text-slate-600">
Global
</Badge>
)}
</div>
{task.description && <p className="text-xs text-slate-600">{task.description}</p>}
<div className="flex flex-wrap items-center gap-3 text-xs text-slate-500">
@@ -297,10 +316,16 @@ function TaskRow({
</div>
</div>
<div className="flex flex-wrap items-center gap-2">
<Button variant="outline" size="sm" onClick={onEdit}>
<Button variant="outline" size="sm" onClick={onEdit} disabled={isGlobal} className={isGlobal ? 'opacity-50' : ''}>
<Pencil className="h-4 w-4" />
</Button>
<Button variant="outline" size="sm" onClick={onDelete} className="text-rose-600">
<Button
variant="outline"
size="sm"
onClick={onDelete}
className={`text-rose-600 ${isGlobal ? 'opacity-50' : ''}`}
disabled={isGlobal}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>

View File

@@ -0,0 +1,115 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Sparkles, Users, Camera, Heart, ArrowRight } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { ADMIN_HOME_PATH } from '../constants';
import { useAuth } from '../auth/context';
const highlights = [
{
icon: Sparkles,
title: 'Momente lenken, nicht das Handy',
description:
'Fotospiel liefert euch spielerische Aufgaben, damit eure Gäste das Fest genießen und gleichzeitig emotionale Motive festhalten.',
},
{
icon: Users,
title: 'Alle Gäste auf einer Reise',
description:
'Einladungslinks und QR-Codes führen direkt in eure Event-Galerie. Kein Technik-Know-how nötig nur teilen und loslegen.',
},
{
icon: Camera,
title: 'Live-Galerie und Moderation',
description:
'Sammelt Bilder in Echtzeit, markiert Highlights und entscheidet gemeinsam, welche Erinnerungen groß rauskommen.',
},
];
export default function WelcomeTeaserPage() {
const navigate = useNavigate();
const { login } = useAuth();
return (
<div className="min-h-screen bg-gradient-to-br from-rose-50 via-white to-sky-50 text-slate-800">
<header className="mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 pb-12 pt-16 text-center md:pt-20">
<div className="mx-auto w-fit rounded-full border border-rose-100 bg-white/80 px-4 py-1 text-sm font-medium text-rose-500 shadow-sm">
Willkommen bei Fotospiel
</div>
<h1 className="font-display text-4xl font-semibold tracking-tight text-slate-900 md:text-5xl">
Eure Gäste als Geschichtenerzähler ohne Technikstress
</h1>
<p className="mx-auto max-w-2xl text-base leading-relaxed text-slate-600 md:text-lg">
Dieses Kontrollzentrum zeigt euch, wie ihr Fotospiel für Hochzeit, Jubiläum oder Team-Event einsetzt.
Wir führen euch Schritt für Schritt durch Aufgaben, Event-Setup und Einladungen.
</p>
<div className="flex flex-col justify-center gap-3 md:flex-row">
<button
type="button"
className="group inline-flex items-center justify-center gap-2 rounded-full border border-transparent bg-white px-6 py-3 text-base font-semibold text-rose-500 shadow-sm transition hover:border-rose-200 hover:text-rose-600"
onClick={() => login(ADMIN_HOME_PATH)}
>
Ich habe bereits Zugang
<ArrowRight className="h-4 w-4 transition group-hover:translate-x-0.5" />
</button>
</div>
</header>
<main className="mx-auto w-full max-w-5xl space-y-12 px-6 pb-16">
<section className="grid gap-6 rounded-3xl border border-white/60 bg-white/80 p-6 shadow-xl shadow-rose-100/40 backdrop-blur-md md:grid-cols-3 md:p-8">
{highlights.map((item) => (
<article key={item.title} className="flex flex-col gap-4 rounded-2xl bg-white/70 p-5 shadow-sm">
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-rose-100 text-rose-500">
<item.icon className="h-6 w-6" />
</div>
<h2 className="text-lg font-semibold text-slate-900">{item.title}</h2>
<p className="text-sm leading-relaxed text-slate-600">{item.description}</p>
</article>
))}
</section>
<section className="grid gap-8 rounded-3xl border border-sky-100 bg-gradient-to-br from-white via-sky-50 to-white p-6 shadow-lg md:grid-cols-2 md:p-10">
<div className="space-y-5">
<div className="inline-flex items-center gap-2 rounded-full bg-sky-100 px-3 py-1 text-xs font-semibold text-sky-700">
<Heart className="h-4 w-4" />
So startet ihr
</div>
<h2 className="text-2xl font-semibold text-slate-900 md:text-3xl">In drei Schritten zu eurer Story</h2>
<ol className="space-y-4 text-sm leading-relaxed text-slate-600">
<li>
<span className="font-semibold text-slate-900">1. Aufgaben entdecken&nbsp;</span>
Stellt euer erstes Aufgabenpaket zusammen, das zu eurer Feier passt.
</li>
<li>
<span className="font-semibold text-slate-900">2. Event anlegen&nbsp;</span>
Benennt euer Event, legt Farben fest und erstellt den QR-Einladungslink.
</li>
<li>
<span className="font-semibold text-slate-900">3. Link teilen&nbsp;</span>
Gäste scannen, laden Fotos hoch und ihr entscheidet, was in euer Album kommt.
</li>
</ol>
</div>
<aside className="space-y-4 rounded-2xl border border-rose-100 bg-white/90 p-6 text-sm leading-relaxed text-slate-600 shadow-md">
<p>
Ihr könnt jederzeit unterbrechen und später weiter machen. Falls ihr Fragen habt, meldet euch unter{' '}
<a className="font-medium text-rose-500 underline" href="mailto:hallo@fotospiel.de">
hallo@fotospiel.de
</a>
.
</p>
<p>
Nach dem Login geleiten wir euch automatisch zur geführten Einrichtung. Dort entscheidet ihr auch,
wann eure Gästegalerie sichtbar wird.
</p>
</aside>
</section>
</main>
<footer className="border-t border-white/60 bg-white/70 py-6 text-center text-xs text-slate-500">
Fotospiel Eure Gäste gestalten eure Lieblingsmomente
</footer>
</div>
);
}