- Add AuthContext to manage user authentication state and token storage. - Create hooks for login, registration, and logout functionalities. - Implement dashboard layout with authentication check and loading state. - Enhance dashboard page with channel management features including create, edit, and delete channels. - Integrate API calls for channel operations and current broadcast retrieval. - Add stream URL resolution via server-side API route to handle redirects. - Update TV page to utilize new hooks for channel and broadcast management. - Refactor components for better organization and user experience. - Update application metadata for improved branding.
29 lines
730 B
TypeScript
29 lines
730 B
TypeScript
"use client";
|
|
|
|
import { useEffect, type ReactNode } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useAuthContext } from "@/context/auth-context";
|
|
|
|
export default function DashboardLayout({ children }: { children: ReactNode }) {
|
|
const { token, isLoaded } = useAuthContext();
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (isLoaded && !token) {
|
|
router.push("/login");
|
|
}
|
|
}, [isLoaded, token, router]);
|
|
|
|
if (!isLoaded) {
|
|
return (
|
|
<div className="flex flex-1 items-center justify-center">
|
|
<div className="h-5 w-5 animate-spin rounded-full border-2 border-zinc-700 border-t-zinc-300" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!token) return null;
|
|
|
|
return <>{children}</>;
|
|
}
|