error pages

This commit is contained in:
Alex Holliday committed 2025-11-24 22:50:33 +00:00
1 parent 1e26fb1e3b
commit 82dbac9ac9
8 files changed
+92 -6

No files matched your search

@@ -11,9 +11,10 @@ import { useEffect, useState } from "react";
import { useAppSelector } from "@/hooks/AppHooks";
import type { ReactNode } from "react";
import { get } from "@/utils/ApiClient";
import { useLocation } from "react-router-dom";
import { useLocation, useNavigate } from "react-router-dom";
export const AuthVerifier = ({ children }: { children: ReactNode }) => {
const location = useLocation();
const navigate = useNavigate();
const isAuthRoute =
["/login", "/register"].includes(location.pathname) ||
location.pathname.startsWith("/recovery") ||
@@ -36,6 +37,11 @@ export const AuthVerifier = ({ children }: { children: ReactNode }) => {
dispatch(setAuthenticated(true));
dispatch(setUser(user));
if (user.teams.length === 0) {
navigate("/no-team");
return;
}
if (
!selectedTeamId ||
!user.teams.find((t) => t.id === selectedTeamId)
@@ -5,11 +5,15 @@ export const ProtectedRoute: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const isAuthenticated = useAppSelector((state) => state.auth.isAuthenticated);
const user = useAppSelector((state) => state.auth.user);
if (!isAuthenticated) {
return <Navigate to="/login" replace />;
}
if (user?.teams.length === 0) {
return <Navigate to="/no-team" replace />;
}
if (!isAuthenticated) {
return null;
}