import React, { useState, useEffect } from "react";
import _service from '@netuno/service-client';

import { Layout, Menu } from 'antd';

import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link
} from "react-router-dom";

import Home from './pages/Home';
import Login from './pages/Login';
import Register from './pages/Register';
import Main from './pages/Main';

import logo from './logo.svg';
import './App.less';

const { Header, Footer, Content } = Layout;

export default () => {
  const [ data, setData ] = useState([]);
  useEffect(()=> {
    _service({
        url: "pessoas",
        success: (response) => {
            setData(response.json);
        },
        fail: (e) => {
            console.log("Service Error", e);
        }
    });
  }, []);

  return (
    <Router>
      <Layout>
        <Header>
          <Menu mode="horizontal" theme="dark">
            <Menu.Item><Link to="/">Home</Link></Menu.Item>
            <Menu.Item><Link to="/login">Login</Link></Menu.Item>
            <Menu.Item><Link to="/register">Register</Link></Menu.Item>
          </Menu>
        </Header>
        <Content>
          <Switch>
            <Route path="/login">
              <Login/>
            </Route>
            <Route path="/register">
              <Register/>
            </Route>
            <Route path="/main">
              <Main/>
            </Route>
            <Route path="/">
              <Home/>
            </Route>
          </Switch>
        </Content>
        <Footer>
          <h2>Plataforma Social</h2>
          Desenvolvimento de demonstração.
        </Footer>
      </Layout>
    </Router>
  );
};
