import RolePermissionMiddleware from "@/middlewares/RolePermission";
import WithAuthMiddleware from "@/middlewares/WithAuth";
import {parse} from "next-useragent";
import DashboardRoleManagementComponent from "@/components/dashboard/role-management";

const requiredPermissions = ["manage_roles"];
export default function RoleManagement() {
    return (
        <WithAuthMiddleware>
            <RolePermissionMiddleware requiredPermissions={requiredPermissions}>
                <DashboardRoleManagementComponent/>
            </RolePermissionMiddleware>
        </WithAuthMiddleware>
    );
}

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.role_management_page",
            isBot,
        },
    };
}
