mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
- Expanded installation options in README to include SurfSense Cloud as a new method. - Updated UserRead schema to include pages_limit and pages_used fields. - Added AnnouncementBanner component to the dashboard layout for improved user notifications. - Refactored DashboardPage to utilize useUser hook for user state management. - Integrated page usage display in AppSidebar to show user-specific page limits and usage. - Removed deprecated apiClient code and replaced it with hooks for better API interaction.
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { Loader2 } from "lucide-react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useEffect, useState } from "react";
|
|
import { AnnouncementBanner } from "@/components/announcement-banner";
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
|
|
interface DashboardLayoutProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default function DashboardLayout({ children }: DashboardLayoutProps) {
|
|
const router = useRouter();
|
|
const [isCheckingAuth, setIsCheckingAuth] = useState(true);
|
|
|
|
useEffect(() => {
|
|
// Check if user is authenticated
|
|
const token = localStorage.getItem("surfsense_bearer_token");
|
|
if (!token) {
|
|
router.push("/login");
|
|
return;
|
|
}
|
|
setIsCheckingAuth(false);
|
|
}, [router]);
|
|
|
|
// Show loading screen while checking authentication
|
|
if (isCheckingAuth) {
|
|
return (
|
|
<div className="flex flex-col items-center justify-center min-h-screen space-y-4">
|
|
<Card className="w-[350px] bg-background/60 backdrop-blur-sm">
|
|
<CardHeader className="pb-2">
|
|
<CardTitle className="text-xl font-medium">Loading Dashboard</CardTitle>
|
|
<CardDescription>Checking authentication...</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="flex justify-center py-6">
|
|
<Loader2 className="h-12 w-12 text-primary animate-spin" />
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<AnnouncementBanner />
|
|
{children}
|
|
</>
|
|
);
|
|
}
|