import DashboardFirstComponent from "@/components/dashboard/first";
import {parse} from "next-useragent";
import useUser from "@/lib/app/hooks/useUser";

export default function Dashboard() {
    const {user} = useUser();

    const hasPermission = user?.permissions?.includes("view_dashboard_stats")

    if (!hasPermission) return null

    return (
        <DashboardFirstComponent/>
    );
}

export async function getServerSideProps({req, locale}) {
    const {isBot} = parse(req.headers["user-agent"]);
    return {
        props: {
            messages: (await import(`&/locales/${locale}/app.json`)).default,
            title: "Dashboard.dashboard_page",
            isBot,
            locale,
            layout: {name: 'DashboardLayout'}
        },
    };
}
