login page

This commit is contained in:
naiba
2024-11-02 22:34:43 +08:00
parent d945ca97c1
commit 017e6cfdcf
32 changed files with 2236 additions and 170 deletions

16
src/routes/protect.tsx Normal file
View File

@@ -0,0 +1,16 @@
import { Navigate } from "react-router-dom";
import { useAuth } from "@/hooks/useAuth";
export const ProtectedRoute = ({ children }: {
children: React.ReactNode;
}) => {
const { profile } = useAuth();
if (!profile && window.location.pathname !== "/dashboard/login") {
return <Navigate to="/dashboard/login" />;
}
return children;
};
export default ProtectedRoute;