"use client"; import Link from "next/link"; import { useEffect, useMemo, useState } from "react"; import { ArrowRight, CheckCircle2, Home, MapPin, Phone, Sparkles, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Progress } from "@/components/ui/progress"; type UserRoleDto = | "SUPERADMIN" | "ADMIN" | "KOORDINATOR" | "ERZIEHER" | "ELTERN"; type OnboardingDialogProps = { user: { phone: string | null; street: string | null; postalCode: string | null; city: string | null; familyId: string | null; role: UserRoleDto; }; family: { childrenCount: number; } | null; }; const HIDE_ONBOARDING_DIALOG_KEY = "hideOnboardingDialog"; export function OnboardingDialog({ user, family }: OnboardingDialogProps) { const [open, setOpen] = useState(false); const status = useMemo(() => { const hasPhone = !!user.phone?.trim(); const hasAddress = !!user.street?.trim() && !!user.postalCode?.trim() && !!user.city?.trim(); const needsFamilyData = user.role !== "ERZIEHER"; const hasFamilyAndChildren = !needsFamilyData || (!!user.familyId && !!family?.childrenCount); const missingItems = [ !hasPhone ? { label: "Telefonnummer fehlt", icon: Phone } : null, !hasAddress ? { label: "Adresse fehlt", icon: MapPin } : null, !hasFamilyAndChildren ? { label: "Haushalts-/Kinderdaten unvollständig", icon: Home } : null, ].filter(Boolean) as { label: string; icon: typeof Phone }[]; const completedCount = [hasPhone, hasAddress, hasFamilyAndChildren].filter( Boolean, ).length; const progress = completedCount === 3 ? 100 : completedCount * 33; return { completedCount, progress, missingItems, hasFamilyAndChildren, isComplete: completedCount === 3, }; }, [family?.childrenCount, user]); useEffect(() => { if (status.isComplete) return; const hidden = localStorage.getItem(HIDE_ONBOARDING_DIALOG_KEY); if (hidden !== "true") { const timer = window.setTimeout(() => setOpen(true), 0); return () => window.clearTimeout(timer); } }, [status.isComplete]); if (status.isComplete) { return null; } const ctaLabel = status.hasFamilyAndChildren ? "Kontaktdaten hinterlegen" : "Haushalt & Kinder einrichten"; function hidePermanently() { localStorage.setItem(HIDE_ONBOARDING_DIALOG_KEY, "true"); setOpen(false); } return (
Dein Kita-Profil ist fast bereit Vervollständige die wichtigsten Daten, damit Notdienst, Adressbuch und Familienverwaltung reibungslos funktionieren.
Profil-Fortschritt {status.completedCount}/3 erledigt

{status.progress}% vollständig

Noch offen

    {status.missingItems.map(({ label, icon: Icon }) => (
  • {label}
  • ))}

Du kannst die App weiter nutzen. Diese Erinnerung hilft nur beim sauberen Einrichten der wichtigsten MVP-Daten.

); }