feat: add getLayout to return type of withAuthorization (#82)
This commit is contained in:
parent
e11b8f956b
commit
d7ccde30ee
1 changed files with 6 additions and 2 deletions
|
@ -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>;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue