auth working in webpage

This commit is contained in:
José Salazar
2025-11-28 13:59:29 -05:00
parent 4cbb3c429a
commit 7a1da8c0d4
6 changed files with 531 additions and 458 deletions

View File

@@ -0,0 +1,25 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useAuth } from '@/hooks/useAuth';
import { Loader2 } from 'lucide-react';
export default function ProtectedRoute({ children }) {
const { user, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100">
<div className="text-center">
<Loader2 className="w-12 h-12 text-[#0A39DF] animate-spin mx-auto mb-4" />
<p className="text-slate-600 font-medium">Loading...</p>
</div>
</div>
);
}
if (!user) {
return <Navigate to="/login" replace />;
}
return children;
}

View File

@@ -0,0 +1,25 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useAuth } from '@/hooks/useAuth';
import { Loader2 } from 'lucide-react';
export default function PublicRoute({ children }) {
const { user, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100">
<div className="text-center">
<Loader2 className="w-12 h-12 text-[#0A39DF] animate-spin mx-auto mb-4" />
<p className="text-slate-600 font-medium">Loading...</p>
</div>
</div>
);
}
if (user) {
return <Navigate to="/" replace />;
}
return children;
}