import { useState, useEffect } from "react"; import { useQuery } from "@tanstack/react-query"; import { queryClient } from "@/client/rpc-client"; import { useAuth } from "@/client/components/auth-provider"; import { LoginForm } from "@/client/components/login-form"; import { UserProfile } from "@/client/components/user-profile"; import { BookingForm } from "@/client/components/booking-form"; import { AdminTreatments } from "@/client/components/admin-treatments"; import { AdminBookings } from "@/client/components/admin-bookings"; import { AdminCalendar } from "@/client/components/admin-calendar"; import { InitialDataLoader } from "@/client/components/initial-data-loader"; import { AdminAvailability } from "@/client/components/admin-availability"; import { AdminGallery } from "@/client/components/admin-gallery"; import { AdminReviews } from "@/client/components/admin-reviews"; import BookingStatusPage from "@/client/components/booking-status-page"; import ReviewSubmissionPage from "@/client/components/review-submission-page"; import LegalPage from "@/client/components/legal-page"; import { ProfileLanding } from "@/client/components/profile-landing"; import { PWAInstallPrompt } from "@/client/components/pwa-install-prompt"; function App() { const { user, isLoading, isOwner } = useAuth(); const [activeTab, setActiveTab] = useState<"profile-landing" | "booking" | "admin-treatments" | "admin-bookings" | "admin-calendar" | "admin-availability" | "admin-gallery" | "admin-reviews" | "profile" | "legal">("profile-landing"); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const { data: socialMedia } = useQuery( queryClient.social.getSocialMedia.queryOptions() ); const hasSocialMedia = (socialMedia as any)?.tiktokProfile || (socialMedia as any)?.instagramProfile; // Prevent background scroll when menu is open useEffect(() => { document.body.classList.toggle('overflow-hidden', isMobileMenuOpen); return () => document.body.classList.remove('overflow-hidden'); }, [isMobileMenuOpen]); // Handle booking status page const path = window.location.pathname; const PwaPrompt = ; if (path.startsWith('/booking/')) { const token = path.split('/booking/')[1]; if (token) { return <> {PwaPrompt} ; } } // Handle review submission page if (path.startsWith('/review/')) { const token = path.split('/review/')[1]; if (token) { return <> {PwaPrompt} ; } } // Show loading spinner while checking authentication if (isLoading) { return (
Stargil Nails Logo
Lade...
); } // Show login form if user is not authenticated and trying to access admin features const needsAuth = !user && (activeTab === "admin-treatments" || activeTab === "admin-bookings" || activeTab === "admin-calendar" || activeTab === "admin-availability" || activeTab === "admin-gallery" || activeTab === "admin-reviews" || activeTab === "profile"); if (needsAuth) { return ; } // Show legal page if legal tab is active if (activeTab === "legal") { return ; } const tabs = [ { id: "profile-landing", label: "Startseite", icon: "🏠", requiresAuth: false }, { id: "booking", label: "Termin buchen", icon: "📅", requiresAuth: false }, { id: "legal", label: "Impressum/Datenschutz", icon: "📋", requiresAuth: false }, { id: "admin-treatments", label: "Behandlungen verwalten", icon: "💅", requiresAuth: true }, { id: "admin-bookings", label: "Buchungen verwalten", icon: "📋", requiresAuth: true }, { id: "admin-calendar", label: "Kalender", icon: "📆", requiresAuth: true }, { id: "admin-availability", label: "Verfügbarkeiten", icon: "⏰", requiresAuth: true }, { id: "admin-gallery", label: "Photo-Wall", icon: "📸", requiresAuth: true }, { id: "admin-reviews", label: "Bewertungen", icon: "⭐", requiresAuth: true }, ...(user ? [{ id: "profile", label: "Profil", icon: "👤", requiresAuth: true }] : []), ] as const; return (
{/* Header */}
setActiveTab("profile-landing")} > Stargil Nails Logo

Stargirlnails Kiel

Professional Nail Design & Care

{/* Hamburger Button für Mobile */} {user && (
Willkommen, {user.username} {user.username} {isOwner && ( Inhaber )}
)}
{/* Desktop Navigation */} {/* Mobile Backdrop */} {isMobileMenuOpen && (
setIsMobileMenuOpen(false)} /> )} {/* Mobile Slide-in Panel */} {/* Main Content */}
{activeTab === "profile-landing" && ( setActiveTab("booking")} /> )} {activeTab === "booking" && (

Buche deine perfekte Nagelbehandlung

Erlebe professionelle Nagelpflege mit unseren Experten. Wähle aus unserem breiten Angebot an Behandlungen und buche noch heute deinen Termin.

)} {activeTab === "admin-treatments" && isOwner && (

Behandlungen verwalten

Füge Behandlungen hinzu, bearbeite und verwalte deine Nagelbehandlungen.

)} {activeTab === "admin-bookings" && isOwner && (

Buchungen verwalten

Sieh dir Kundentermine an und verwalte Buchungen.

)} {activeTab === "admin-calendar" && isOwner && (

Kalender - Bevorstehende Buchungen

Übersichtliche Darstellung aller bevorstehenden Termine im Kalenderformat.

)} {activeTab === "admin-availability" && isOwner && (

Verfügbarkeiten verwalten

Verwalte wiederkehrende Zeiten und Urlaubszeiten.

)} {activeTab === "admin-gallery" && isOwner && (

Photo-Wall verwalten

Lade Fotos hoch und verwalte deine Galerie.

)} {activeTab === "admin-reviews" && isOwner && (

Bewertungen verwalten

Prüfe und verwalte Kundenbewertungen.

)} {activeTab === "profile" && user && (

Benutzerprofil

Verwalte deine Kontoinformationen und Einstellungen.

)}
{/* PWA Installation Prompt for iOS */}
); } export default App;