feat: add getLayout to return type of withAuthorization (#82)

This commit is contained in:
Krzysztof Żuraw 2022-10-13 09:22:49 +02:00 committed by GitHub
parent e11b8f956b
commit d7ccde30ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,10 @@ const defaultProps: Props = {
unmounted: <p>Loading</p>,
};
type WithAuthorizationHOC<P> = React.FunctionComponent<P> & {
getLayout?: (page: React.ReactElement) => React.ReactNode;
};
/**
* Most likely, views from your app will be only accessibly inside Dashboard iframe.
* This HOC can be used to handle all checks, with default messages included.
@ -38,7 +42,7 @@ export const withAuthorization =
(props: Props = defaultProps) =>
<BaseProps extends React.ComponentProps<NextPage>>(
BaseComponent: React.FunctionComponent<BaseProps>
) => {
): WithAuthorizationHOC<BaseProps> => {
const { dashboardTokenInvalid, noDashboardToken, notIframe, unmounted } = {
...defaultProps,
...props,
@ -67,5 +71,5 @@ export const withAuthorization =
return <BaseComponent {...innerProps} />;
}
return AuthorizedPage;
return AuthorizedPage as WithAuthorizationHOC<BaseProps>;
};