import { RaRecord } from '../types';
import { UseCanAccessOptions, UseCanAccessResult } from './useCanAccess';
/**
* A hook that calls the authProvider.canAccess() method for a provided resource and action (and optionally a record).
* It redirects to the /access-denied page if the user doesn't have the required permissions.
* It redirects to the /authentication-error page if the authProvider.canAccess throws an error.
*
* The return value updates according to the request state:
*
* - start: { isPending: true }
* - success: { isPending: false }
* - error: { error: [error from provider], isPending: false }
*
* Useful to enable or disable features based on users permissions.
*
* @param {Object} params Any params you want to pass to the authProvider
* @param {string} params.resource The resource to check access for
* @param {string} params.action The action to check access for
* @param {Object} params.record Optional. The record to check access for
*
* @returns Return the react-query result.
*
* @example
* import { useRequireAccess } from 'react-admin';
*
* const PostDetail = () => {
* const { isPending } = useRequireAccess({
* resource: 'posts',
* action: 'read',
* });
* if (isPending) {
* return null;
* }
*
* return ;
* };
*/
export declare const useRequireAccess: = RaRecord, ErrorType extends Error = Error>(params: UseRequireAccessOptions) => {
isError: false;
isPending: true;
isLoading: true;
isLoadingError: false;
isRefetchError: false;
isSuccess: false;
status: "pending";
dataUpdatedAt: number;
errorUpdatedAt: number;
failureCount: number;
failureReason: ErrorType | null;
errorUpdateCount: number;
isFetched: boolean;
isFetchedAfterMount: boolean;
isFetching: boolean;
isInitialLoading: boolean;
isPaused: boolean;
isPlaceholderData: boolean;
isRefetching: boolean;
isStale: boolean;
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>;
fetchStatus: import("@tanstack/query-core").FetchStatus;
} | {
isError: true;
isPending: false;
isLoading: false;
isLoadingError: true;
isRefetchError: false;
isSuccess: false;
status: "error";
dataUpdatedAt: number;
errorUpdatedAt: number;
failureCount: number;
failureReason: ErrorType | null;
errorUpdateCount: number;
isFetched: boolean;
isFetchedAfterMount: boolean;
isFetching: boolean;
isInitialLoading: boolean;
isPaused: boolean;
isPlaceholderData: boolean;
isRefetching: boolean;
isStale: boolean;
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>;
fetchStatus: import("@tanstack/query-core").FetchStatus;
} | {
isError: true;
isPending: false;
isLoading: false;
isLoadingError: false;
isRefetchError: true;
isSuccess: false;
status: "error";
dataUpdatedAt: number;
errorUpdatedAt: number;
failureCount: number;
failureReason: ErrorType | null;
errorUpdateCount: number;
isFetched: boolean;
isFetchedAfterMount: boolean;
isFetching: boolean;
isInitialLoading: boolean;
isPaused: boolean;
isPlaceholderData: boolean;
isRefetching: boolean;
isStale: boolean;
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>;
fetchStatus: import("@tanstack/query-core").FetchStatus;
} | {
isError: false;
isPending: false;
isLoading: false;
isLoadingError: false;
isRefetchError: false;
isSuccess: true;
status: "success";
dataUpdatedAt: number;
errorUpdatedAt: number;
failureCount: number;
failureReason: ErrorType | null;
errorUpdateCount: number;
isFetched: boolean;
isFetchedAfterMount: boolean;
isFetching: boolean;
isInitialLoading: boolean;
isPaused: boolean;
isPlaceholderData: boolean;
isRefetching: boolean;
isStale: boolean;
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>;
fetchStatus: import("@tanstack/query-core").FetchStatus;
};
export type UseRequireAccessOptions = RaRecord, ErrorType extends Error = Error> = UseCanAccessOptions;
export type UseRequireAccessResult = Omit, 'canAccess' | 'data'>;
//# sourceMappingURL=useRequireAccess.d.ts.map