import { useState } from "react";
import { Link, useLocation } from "wouter";
import { useTranslation } from "react-i18next";
import {
LayoutDashboard, Building2, BarChart3, CreditCard,
HelpCircle, LogOut, Stethoscope, Menu, X, Shield,
} from "lucide-react";
import { useAuth } from "@/_core/hooks/useAuth";
import { cn } from "@/lib/utils";
function LanguageSwitcher({ className = "" }: { className?: string }) {
const { i18n } = useTranslation();
const current = i18n.resolvedLanguage ?? i18n.language ?? "fr";
const change = (lng: "fr" | "en") => i18n.changeLanguage(lng);
return (
);
}
export default function Layout({ children }: { children: React.ReactNode }) {
const { t } = useTranslation();
const [location] = useLocation();
const { user, logout } = useAuth();
const [mobileOpen, setMobileOpen] = useState(false);
const NAV = [
{ href: "/dashboard", label: t("nav.dashboard"), icon: LayoutDashboard },
{ href: "/dashboard/clinics", label: t("nav.clinics"), icon: Building2 },
{ href: "/dashboard/analytics", label: t("nav.analytics"), icon: BarChart3 },
{ href: "/dashboard/subscription", label: t("nav.subscription"), icon: CreditCard },
{ href: "/help", label: t("nav.help"), icon: HelpCircle },
...(user?.role === "admin"
? [{ href: "/admin", label: "Admin", icon: Shield }]
: []),
];
const isActive = (href: string) =>
href === "/dashboard"
? location === "/dashboard"
: location === href || location.startsWith(href + "/");
return (
{/* ─── Sidebar (desktop) ──────────────────────────────────────────── */}
{/* ─── Main column ───────────────────────────────────────────────── */}
{/* Top bar (mobile) */}
{/* Mobile drawer */}
{mobileOpen && (
);
}