diff --git a/src/hooks/useFetchEntity.tsx b/src/hooks/useFetchEntity.tsx index 7431177..0efdfeb 100644 --- a/src/hooks/useFetchEntity.tsx +++ b/src/hooks/useFetchEntity.tsx @@ -37,7 +37,7 @@ export const useFetchEntity = ( () => isFetchRequired( exploreMode !== EXPLORE_MODE.CS_FETCH_CS_FILTERING, - Boolean(token), + Boolean(token), // TODO(cc), note a fetch is required if the token is true, but is unable to re-fetch on logout when token is undefined! Page is required to reload! Boolean(catalogState), Boolean(entityResponse) ), diff --git a/src/providers/googleSignInAuthentication/hooks/useGoogleSignInService.ts b/src/providers/googleSignInAuthentication/hooks/useGoogleSignInService.ts index ad048df..e71a597 100644 --- a/src/providers/googleSignInAuthentication/hooks/useGoogleSignInService.ts +++ b/src/providers/googleSignInAuthentication/hooks/useGoogleSignInService.ts @@ -1,4 +1,4 @@ -import Router from "next/router"; +import { useRouter } from "next/router"; import { useCallback } from "react"; import { useProviders } from "../../../hooks/authentication/providers/useProviders"; import { Service } from "../../authentication/auth/types"; @@ -8,6 +8,7 @@ import { service } from "../service/service"; export const useGoogleSignInService = (reducer: SessionReducer): Service => { const { findProvider } = useProviders(); + const { basePath } = useRouter(); const { authenticationReducer: { authenticationDispatch }, authReducer: { authDispatch }, @@ -36,10 +37,16 @@ export const useGoogleSignInService = (reducer: SessionReducer): Service => { credentialsDispatch, tokenDispatch, }); - if (!options?.callbackUrl) return; - Router.push(options?.callbackUrl).catch((e) => console.error(e)); + // Request page reload, ensuring that the entity detail page is re-initialized with the correct state and associated data. + location.href = options?.callbackUrl || basePath; }, - [authDispatch, authenticationDispatch, credentialsDispatch, tokenDispatch] + [ + authDispatch, + authenticationDispatch, + basePath, + credentialsDispatch, + tokenDispatch, + ] ); return { requestLogin: onLogin, requestLogout: onLogout };