13 lines
331 B
TypeScript
13 lines
331 B
TypeScript
import { PropsWithChildren } from 'react';
|
|
import { Navigate } from 'react-router-dom';
|
|
|
|
export default function AuthWrapper(props: PropsWithChildren) {
|
|
|
|
if (!localStorage.getItem('token')) {
|
|
console.log('No token found, redirecting to login');
|
|
return <Navigate to={'/login'} />
|
|
}
|
|
|
|
return <div>{props.children}</div>;
|
|
}
|