824191ce81
- Add manifest.json with PWA configuration - Add viewport settings for iOS (viewport-fit: cover) - Add meta tags for iOS Safari (apple-mobile-web-app-capable) - Add mobile CSS optimizations: * iOS Safe Area support * Minimum 44x44px touch targets * Disable zoom on input focus * Remove scrollbars on mobile * Disable hover effects on touch devices * Standalone mode styles - Add InstallPrompt component for Add to Home Screen - Add SVG icon (needs PNG conversion)
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import { useEffect, useState } from "react"
|
|
import { useRouter, usePathname } from "next/navigation"
|
|
import { useAuth } from "@/lib/auth"
|
|
import { Loader2 } from "lucide-react"
|
|
import { Sidebar } from "@/components/layout/Sidebar"
|
|
import { InstallPrompt } from "@/components/ui/install-prompt"
|
|
|
|
export default function DashboardLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
const router = useRouter()
|
|
const pathname = usePathname()
|
|
const { token, isHydrated } = useAuth()
|
|
const [checked, setChecked] = useState(false)
|
|
|
|
useEffect(() => {
|
|
if (!isHydrated) return
|
|
|
|
if (!token) {
|
|
router.push("/login")
|
|
} else {
|
|
setChecked(true)
|
|
}
|
|
}, [isHydrated, token, router])
|
|
|
|
if (!isHydrated || !checked) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-background">
|
|
<Loader2 className="w-8 h-8 animate-spin text-primary" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!token) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<div className="flex min-h-screen bg-background">
|
|
<Sidebar />
|
|
<main className="flex-1 min-h-screen">
|
|
<div className="p-8 h-full">
|
|
{children}
|
|
</div>
|
|
</main>
|
|
<InstallPrompt />
|
|
</div>
|
|
)
|
|
}
|