Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 8x 8x 8x 8x 316x 311x 311x 311x 311x 311x | import { useAuthContext } from "features/auth/AuthProvider"; import { useUser } from "features/userQueries/useUsers"; import { useRouter } from "next/router"; import { loginRoute } from "routes"; export default function useCurrentUser() { const authState = useAuthContext().authState; const userQuery = useUser(authState.userId ?? undefined); const router = useRouter(); Iif (!authState.userId) { console.error("No user id available to get current user."); Iif (typeof window !== "undefined") router.push(loginRoute); } return userQuery; } |