import {useUser} from "../utils/users/UseUser.ts";
import {Outlet, useNavigate} from "react-router-dom";
import React, {useEffect} from "react";

export function DashboardLayout() {
    const { user } = useUser();
    const navigate = useNavigate();

    useEffect(() => {
        if (!user) {
            navigate("/login/")
        }
    }, [navigate, user]);

    if (!user){
        return null;
    }

    return (
        <>
            <div className="header">
                <h1 className="logo">Pro-Fi</h1>
            </div>
            <div className="content">
                <Outlet />
            </div>
        </>
    );
}