"use client"; import { useTranslations } from "next-intl"; import { useEffect, useState } from "react"; import { useGlobalLoadingEffect } from "@/hooks/use-global-loading"; import { getBearerToken, redirectToLogin } from "@/lib/auth-utils"; interface DashboardLayoutProps { children: React.ReactNode; } export default function DashboardLayout({ children }: DashboardLayoutProps) { const t = useTranslations("dashboard"); const [isCheckingAuth, setIsCheckingAuth] = useState(true); // Use the global loading screen - spinner animation won't reset useGlobalLoadingEffect(isCheckingAuth, t("checking_auth"), "default"); useEffect(() => { // Check if user is authenticated const token = getBearerToken(); if (!token) { // Save current path and redirect to login redirectToLogin(); return; } setIsCheckingAuth(false); }, []); // Return null while loading - the global provider handles the loading UI if (isCheckingAuth) { return null; } return (