|
|
|
@ -1,27 +1,75 @@ |
|
|
|
import { useState, useEffect, useRef } from "react"; |
|
|
|
import React, { useState, useEffect, useImperativeHandle } from "react"; |
|
|
|
|
|
|
|
import MyButton from "../../components/MyButton"; |
|
|
|
import { Table } from 'antd'; |
|
|
|
|
|
|
|
import _service from '@netuno/service-client'; |
|
|
|
|
|
|
|
import "./index.less"; |
|
|
|
|
|
|
|
function DashboardContainer() { |
|
|
|
const [counter, setCounter] = useState(0); |
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
title: 'UID', |
|
|
|
dataIndex: 'uid', |
|
|
|
key: 'uid', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'Nome', |
|
|
|
dataIndex: 'nome', |
|
|
|
key: 'nome', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'CPF', |
|
|
|
dataIndex: 'CPF', |
|
|
|
key: 'CPF', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'RG', |
|
|
|
dataIndex: 'RG', |
|
|
|
key: 'RG', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'Data de Nascimento', |
|
|
|
dataIndex: 'data de nascimento', |
|
|
|
key: 'data de nascimento', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'Endereço', |
|
|
|
dataIndex: 'endereço', |
|
|
|
key: 'endereço', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'Telefone', |
|
|
|
dataIndex: 'telefone', |
|
|
|
key: 'telefone', |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
const refButton = useRef(); |
|
|
|
function DashboardContainer() { |
|
|
|
const [pacientes, setPacientes] = useState([]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
$(refButton.current).fadeOut(250).fadeIn(250); |
|
|
|
}, [counter]); |
|
|
|
carregarPacientes(); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const onClick = () => { |
|
|
|
setCounter(counter + 1); |
|
|
|
const carregarPacientes = () => { |
|
|
|
setPacientes([]); |
|
|
|
_service({ |
|
|
|
url: "/services/pacientes", |
|
|
|
success: (response) => { |
|
|
|
setPacientes(response.json); |
|
|
|
}, |
|
|
|
fail: (e) => { |
|
|
|
console.error("Serviço de pacientes falhou.", e); |
|
|
|
message.error("Serviço de pacientes falhou.", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className="my-dashboard"> |
|
|
|
<div ref={refButton} className="my-dashboard__button"> |
|
|
|
<MyButton text={`ReactJS ⚡ Ant.Design 👉 Click me! ${counter}`} onClick={onClick} /> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
|
|
|
|
<Table dataSource={pacientes} columns={columns} /> |
|
|
|
|
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|
|