"use client";

import {StaffRoles} from "@/constants";
import {useMe} from "@/hooks";

export default function RoleGuard({
  roles,
  children,
}: {
  roles: StaffRoles[];
  children: React.ReactNode;
}) {
  const {data, isLoading} = useMe();

  if (isLoading) return null; // یا Skeleton

  if (!data) return null;

  const userRole = data.data.role.toUpperCase() as StaffRoles;
  console.log(!roles.includes(userRole));
  if (!roles.includes(userRole)) return null;

  return <>{children}</>;
}
