diff --git a/packages/web/lib/logout.ts b/packages/web/lib/logout.ts index 689c81f5a..058cb6aca 100644 --- a/packages/web/lib/logout.ts +++ b/packages/web/lib/logout.ts @@ -2,8 +2,10 @@ import { useQueryClient } from '@tanstack/react-query' import { deinitAnalytics } from './analytics' import { logoutMutation } from './networking/mutations/logoutMutation' import { useCallback } from 'react' +import { useRouter } from 'next/router' export const useLogout = () => { + const router = useRouter() const queryClient = useQueryClient() const logout = useCallback(async () => { await logoutMutation() @@ -14,10 +16,11 @@ export const useLogout = () => { } deinitAnalytics() queryClient.clear() - window.location.href = '/login' - } catch { - // TODO: display an error message instead - window.location.href = '/' + console.log('cleared the query client') + router.push('/login') + } catch (err) { + console.log('error on logout: ', err) + router.push('/') } }, []) return { logout }