Availability based on permissions

This commit is contained in:
cdricms
2025-02-19 16:16:47 +01:00
parent 446813315d
commit 2011ae93b6
26 changed files with 1071 additions and 794 deletions

View File

@@ -0,0 +1,17 @@
import getMe from "@/lib/getMe";
import { Role } from "@/types/types";
import { getCookie } from "cookies-next";
import { useEffect, useState } from "react";
export default function useRoles() {
const [roles, setRoles] = useState<Role[] | null>(null);
const cookie = getCookie("auth_token");
useEffect(() => {
if (cookie)
getMe(cookie?.toString()).then((me) => {
setRoles(me?.data?.roles ?? null);
});
}, []);
return roles;
}