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

export const usePageManagement = (
  defaultPageListQuery: any = {},
  defaultResourceListQuery: any = {},
  defaultPageResourceAssociationQuery: any = {},
) => {
  const {
    data: pageListData,
    fetchData: refetchPageList,
    reqQuery: pageListRequestQuery,
  } = useFetchData('page/findMany', 'post', defaultPageListQuery);

  const {
    data: availableResourcesData,
    fetchData: refetchAvailableResources,
    reqQuery: resourceListRequestQuery,
  } = useFetchData('resource/findMany', 'post', defaultResourceListQuery);

  const {
    data: pageResourceAssociationsData,
    fetchData: refetchPageResourceAssociations,
    reqQuery: pageResourceAssociationRequestQuery,
  } = useFetchData(
    'pageResource/findMany',
    'post',
    defaultPageResourceAssociationQuery,
  );
  return {
    pageListData,
    refetchPageList,
    pageListRequestQuery,
    availableResourcesData,
    refetchAvailableResources,
    resourceListRequestQuery,
    pageResourceAssociationsData,
    refetchPageResourceAssociations,
    pageResourceAssociationRequestQuery,
  };
};
