import React, { ComponentType, JSX } from "react";
import type { User } from "../../types/index.js";
/**
* Options to customize the withPageAuthRequired higher order component.
*/
export interface WithPageAuthRequiredOptions {
/**
* ```js
* withPageAuthRequired(Profile, {
* returnTo: '/profile'
* });
* ```
*
* Add a path to return the user to after login.
*/
returnTo?: string;
/**
* ```js
* withPageAuthRequired(Profile, {
* onRedirecting: () =>
Redirecting...
* });
* ```
*
* Render a message to show that the user is being redirected.
*/
onRedirecting?: () => JSX.Element;
/**
* ```js
* withPageAuthRequired(Profile, {
* onError: error => Error: {error.message}
* });
* ```
*
* Render a fallback in case of error fetching the user from the profile API route.
*/
onError?: (error: Error) => JSX.Element;
}
export interface UserProps {
user: User;
}
/**
* ```js
* const MyProtectedPage = withPageAuthRequired(MyPage);
* ```
*
* When you wrap your pages in this higher order component and an anonymous user visits your page,
* they will be redirected to the login page and then returned to the page they were redirected from (after login).
*/
export type WithPageAuthRequired = (Component: ComponentType
, options?: WithPageAuthRequiredOptions) => React.FC
;
export declare const withPageAuthRequired: WithPageAuthRequired;