import React from 'react' import { Route, RouteProps, Redirect } from 'react-router-dom'; import { useAuth } from './auth-context'; export const PrivateRoute: React.FC = ({component: Component, children, ...rest}) => { const { isAuthenticated } = useAuth(); return { if(isAuthenticated) { if(Component) { return ; } else if(children) { return <>{children}; } } else { return ; } }} /> }; export const AuthRoute: React.FC = ({ component: Component, children, ...rest}) => { const { isAuthenticated } = useAuth(); return { if(isAuthenticated) { let state = props.location.state as any; let from = '/my-account.html'; if (typeof state == 'object' && 'from' in state){ from = state.from; } return ; } else { if(Component) { return ; } else if(children) { return <>{children}; } } }} /> };