import type { NextPage } from 'next';
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/router'
import { useSelector } from 'react-redux';
import { Main } from './main'
import { Login } from './login';

import { selectTokenData } from '../../redux/login/selectors';

const Index: NextPage = () => {
  const router = useRouter();
  const { token, status_token } = useSelector(selectTokenData);
  const [login, setLogin] = useState(false);

  useEffect(() => {
   // token.length ? router.push('/admin/main'): router.push('/admin/login')
   console.log(status_token, 'token');
   setLogin(true);

  });

  return (
       <>
       {
          login ? <Main/>: <Login/>
       }
       </>
  )
}

export default Index;
