import type { NextPage } from 'next';
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import { Main } from '../components/admin/pages/Root/Main'
import { Login } from '../components/admin/pages/login/Login';

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

const Admin: NextPage = () => {
  const dispatch = useAppDispatch();
  const [login, setLogin] = useState<boolean>(false);
  const { token, status_token } = useSelector(selectTokenData);


  function replacer(key:string, value:string) {
    console.log(typeof value);
    if (key === 'token') {
      setLogin(true);
      console.log(value)
    } else {console.log(key)}
  }

 if (status_token === 'completed_token') {
  JSON.stringify(token, replacer);
  console.log(localStorage.getItem("token"), 'token');
}

  return (
        <Login/>
  )
}

export default Admin;
