text: /* eslint-disable react/jsx-props-no-spreading */
  /* eslint-disable react/require-default-props */
  import React, { useState, useEffect } from 'react';
  import PropTypes from 'prop-types';
  
  import { Route, Redirect } from 'react-router-dom';
  
  import AuthLayout from '../pages/_layouts/auth';
  import DefaultLayout from '../pages/_layouts/default';
  
  export default function RouteWrapper({
    component: Component,
    isPrivate = false,
    ...rest
  }) {
    const [signed, setSigned] = useState(!!localStorage.getItem('user'));
  
    if (!signed && isPrivate) {
      return <Redirect to="/" />;
    }
  
    if (signed && !isPrivate) {
      return <Redirect to="/usuarios" />;
    }
  
    const Layout = signed ? DefaultLayout : AuthLayout;
  
    return (
      <Route
        {...rest}
        render={(props) => (
          <Layout>
            <Component {...props} />
          </Layout>
        )}
      />
    );
  }
  
  RouteWrapper.propTypes = {
    isPrivate: PropTypes.bool,
    component: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
  };
  