import { Route, Redirect } from 'react-router-dom';
import { useSelector } from 'react-redux';

import { IPrivateProps} from '../../../../typescript/components/Routes/interfaces';
import { getToken } from '../../../../redux/authorization/selector'

function PrivateRoute({ children, ...routeProps }: IPrivateProps) {
  const token = useSelector(getToken)
  return (
    <Route {...routeProps}>
      {token ? children : <Redirect to="/z/" />}
    </Route>
  );
}



export default PrivateRoute
