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 | 11x 11x 11x 11x 601x 594x 594x 594x 594x 594x | 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;
}
|