Files
revenue-fe/src/auth/RequireAuth.tsx
wayanrivan ea1a678a25 update
2026-07-02 15:20:41 +07:00

20 lines
506 B
TypeScript

import { Navigate, Outlet, useLocation } from 'react-router-dom';
import { ScreenLoader } from '@/components/loaders';
import { useAuthContext } from './useAuthContext';
const RequireAuth = () => {
const { auth, loading } = useAuthContext();
const location = useLocation();
// console.log('RequireAuth render: loading =', loading, ' auth =', auth);
if (loading) {
return <ScreenLoader />;
}
return auth ? <Outlet /> : <Navigate to="/auth/login" replace />;
};
export { RequireAuth };