@@ -4,7 +4,7 @@ import gql from 'graphql-tag';
44import Router from 'next/router' ;
55import cookie from 'cookie' ;
66import { Account , Query } from '@graphql-model' ;
7- import { NextDocumentContext } from 'next/document' ;
7+ import { DocumentProps , NextDocumentContext } from 'next/document' ;
88
99interface LoggedInUserResponse {
1010 readonly loggedInUser : Pick < Account , 'id' | 'firstName' | 'lastName' > ;
@@ -49,7 +49,7 @@ export interface WithAuthAdminProps extends LoggedInUserResponse {
4949 readonly logout : ( client : ApolloClient < any > ) => ( ) => Promise < void > ;
5050}
5151
52- export const withAuthAdmin = ( BaseComponent : React . ComponentType < WithAuthAdminProps > ) => {
52+ export const withAuthAdmin = ( BaseComponent : React . ComponentType < WithAuthAdminProps > & { getInitialProps ? ( ctx : NextDocumentContext ) : DocumentProps } ) => {
5353 return class extends React . Component < LoggedInUserResponse > {
5454 handleOnLogout = ( apolloClient : ApolloClient < any > ) => async ( ) => {
5555 document . cookie = cookie . serialize ( 'token' , '' , {
@@ -65,8 +65,8 @@ export const withAuthAdmin = (BaseComponent: React.ComponentType<WithAuthAdminPr
6565 // If not signed in, send them somewhere more useful
6666 await redirect ( '/login' , context ) ;
6767 }
68-
69- return { loggedInUser} ;
68+ const props = BaseComponent . getInitialProps ? await BaseComponent . getInitialProps ( context ) : { } ;
69+ return { ... props , loggedInUser} ;
7070 }
7171
7272 render ( ) {
0 commit comments