- Mapped 'Photobooth' and 'Guests' grid items to correct translation keys - Localized pulse strip labels (Fotos, Gäste) - Updated readiness hook to use translated CTAs
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { TenantEvent } from '../../api';
|
|
import { adminPath } from '../../constants';
|
|
|
|
export type ReadinessStep = {
|
|
id: string;
|
|
label: string;
|
|
isComplete: boolean;
|
|
ctaLabel: string;
|
|
targetPath: string;
|
|
priority: number; // Lower is higher priority
|
|
};
|
|
|
|
export type ReadinessStatus = {
|
|
steps: ReadinessStep[];
|
|
totalSteps: number;
|
|
completedSteps: number;
|
|
progress: number; // 0 to 1
|
|
nextStep: ReadinessStep | null;
|
|
isReady: boolean;
|
|
};
|
|
|
|
// We pass `t` (translation function) to localise the return values
|
|
export function useEventReadiness(event: TenantEvent | null, t: (key: string, fallback?: string) => string): ReadinessStatus {
|
|
if (!event) {
|
|
return { steps: [], totalSteps: 0, completedSteps: 0, progress: 0, nextStep: null, isReady: false };
|
|
}
|
|
|
|
const settings = (event.settings ?? {}) as Record<string, unknown>;
|
|
|
|
// 1. Basics: Date & Location
|
|
const hasDate = Boolean(event.event_date);
|
|
const hasLocation = Boolean(
|
|
(settings.location as string) ||
|
|
(settings.address as string) ||
|
|
(settings.city as string)
|
|
);
|
|
|
|
// 2. Engagement: Tasks (only if tasks are enabled)
|
|
const tasksEnabled = event.engagement_mode !== 'photo_only';
|
|
const hasTasks = (event.tasks_count ?? 0) > 0;
|
|
|
|
// 3. Access: QR / Invites
|
|
const hasInvite = (event.active_invites_count ?? 0) > 0 || (event.total_invites_count ?? 0) > 0;
|
|
|
|
const steps: ReadinessStep[] = [
|
|
{
|
|
id: 'basics',
|
|
label: t('management:events.form.date', 'Date & Location'),
|
|
isComplete: hasDate && hasLocation,
|
|
ctaLabel: t('management:events.actions.edit', 'Set Date & Location'),
|
|
targetPath: `/mobile/events/${event.slug}/edit`,
|
|
priority: 1
|
|
},
|
|
{
|
|
id: 'access',
|
|
label: t('management:invites.badge', 'QR Codes'),
|
|
ctaLabel: t('management:invites.actions.create', 'Get QR Code'),
|
|
isComplete: hasInvite,
|
|
targetPath: `/mobile/events/${event.slug}/qr`,
|
|
priority: 3
|
|
}
|
|
];
|
|
|
|
if (tasksEnabled) {
|
|
steps.push({
|
|
id: 'tasks',
|
|
label: t('management:tasks.badge', 'Photo Tasks'),
|
|
isComplete: hasTasks,
|
|
ctaLabel: t('management:tasks.actions.assign', 'Add Photo Tasks'),
|
|
targetPath: `/mobile/events/${event.slug}/tasks`,
|
|
priority: 2
|
|
});
|
|
}
|
|
|
|
// Sort by priority
|
|
steps.sort((a, b) => a.priority - b.priority);
|
|
|
|
const completedSteps = steps.filter(s => s.isComplete).length;
|
|
const totalSteps = steps.length;
|
|
const nextStep = steps.find(s => !s.isComplete) ?? null;
|
|
|
|
return {
|
|
steps,
|
|
totalSteps,
|
|
completedSteps,
|
|
progress: totalSteps > 0 ? completedSteps / totalSteps : 0,
|
|
nextStep,
|
|
isReady: !nextStep
|
|
};
|
|
}
|