import React, { useState, useEffect } from "react"; import "./index.less"; import { Redirect, Link } from "react-router-dom"; import _auth from "@netuno/auth-client"; import { PageHeader, Dropdown, Menu, notification } from "antd"; import { DownOutlined, LogoutOutlined, SettingOutlined, } from "@ant-design/icons"; import _service from "@netuno/service-client"; const Main = () => { const [isLogged, setIsLogged] = useState(false); const [dataUser, setDataUser] = useState([]); useEffect(() => { _service({ method: "GET", url: "info", success: (response) => { setDataUser(response.json); setIsLogged(true); }, fail: (e) => { console.log("Service Error", e); notification["error"]({ message: "Informações", description: "Não foi possível carregar as informações do usuário.", }); }, }); }, []); if (!_auth.isLogged()) { return ; } else { const menu = ( Configurações da conta { _auth.logout(); setIsLogged(false); }} > Sair ); return ( e.preventDefault()} > {isLogged && `${dataUser.name} ${dataUser.surname}`}{" "} , ]} /> ); } }; export default Main;