import { useFetchData } from '@/hooks/useFetchData';

export const useRolePage = (
  defaultRolePagesQuery: any = {},
  defaultPagesQuery: any = {},
  defaultRolesQuery: any = {},
) => {
  // Fetch role pages and page data from backend
  const {
    data: rolePagesData,
    fetchData: refetchRolePages,
    reqQuery: rolePagesQuery,
  } = useFetchData('rolePages/findMany', 'post', defaultRolePagesQuery);
  const {
    data: pageData,
    fetchData: refetchPages,
    reqQuery: pageQuery,
  } = useFetchData('page/findMany', 'post', defaultPagesQuery);
  const {
    data: rolesData,
    fetchData: refetchRoles,
    reqQuery: rolesQuery,
  } = useFetchData('role/findMany', 'post', defaultRolesQuery);
  return {
    rolePagesData,
    refetchRolePages,
    rolePagesQuery,
    pageData,
    refetchPages,
    pageQuery,
    rolesData,
    refetchRoles,
    rolesQuery,
  };
};
