({
children,
fallback,
shouldFallback,
}: ProtectedPageProps)
| 17 | }).toString()}`; |
| 18 | |
| 19 | function ProtectedPage({ |
| 20 | children, |
| 21 | fallback, |
| 22 | shouldFallback, |
| 23 | }: ProtectedPageProps): ReactElement { |
| 24 | const router = useRouter(); |
| 25 | const { tokenRefreshed, user } = useContext(AuthContext); |
| 26 | |
| 27 | useEffect(() => { |
| 28 | if (tokenRefreshed && !user) { |
| 29 | router.replace(getOnboardingRedirect(router.asPath || '/')); |
| 30 | } |
| 31 | // @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM |
| 32 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 33 | }, [router, tokenRefreshed, user]); |
| 34 | |
| 35 | return <>{shouldFallback ? fallback : children}</>; |
| 36 | } |
| 37 | |
| 38 | export default ProtectedPage; |
nothing calls this directly
no test coverage detected