Formação do Netuno Maranhão. https://www.linkedin.com/groups/9048260/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

46 lines
1.2 KiB

import React, { useEffect, useState} from 'react';
import { Redirect } from "react-router-dom";
import _auth from '@netuno/auth-client';
import _service from '@netuno/service-client';
import Core from "../../Core";
import { Button, notification } from 'antd';
export default ()=> {
const [loading, setLoading] = useState(false);
const [data, setData] = useState(null);
if (!_auth.isLogged()) {
return <Redirect to="/login" />;
}
useEffect(()=> {
_service({
url: "info",
success: (response) => {
setData(response.json);
},
fail: (e) => {
console.log("Service Error", e);
notification["error"]({
message: 'Informações',
description: 'Não foi possível carregar a informação.',
});
}
});
}, []);
const onLogout = ()=> {
_auth.logout();
setLoading(true);
Core.events.logout();
//window.location = '/login';
}
return (
<div>
<h1>Olá! { data && <h3>{data.name}</h3> }...</h1>
<Button onClick={onLogout} loading={loading}>Sair</Button>
</div>
);
};