import { Modal, Form, Input, Button } from 'antd';
|
|
|
|
import _service from '@netuno/service-client';
|
|
|
|
function CadastrarMedicosModal({isCadastrarMedicosModalOpen, setIsCadastrarMedicosModalOpen}) {
|
|
const handleCadastrarMedicosOk = () => {
|
|
setIsCadastrarMedicosModalOpen(false);
|
|
};
|
|
const handleCadastrarMedicosCancel = () => {
|
|
setIsCadastrarMedicosModalOpen(false);
|
|
};
|
|
|
|
const onFinish = values => {
|
|
console.log('Values:', values);
|
|
_service({
|
|
url: "/services/medicos",
|
|
method: "POST",
|
|
data: {...values, especialidades: [], convenios: [] },
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
|
|
},
|
|
success: (response) => {
|
|
if (response.json) {
|
|
console.log("Service Response", response.json);
|
|
}
|
|
},
|
|
fail: (e) => {
|
|
console.log("Service Error", e);
|
|
}
|
|
});
|
|
};
|
|
|
|
const onFinishFailed = errorInfo => {
|
|
console.log('Failed:', errorInfo);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
|
|
<Modal
|
|
title="Cadastrar novo médico"
|
|
closable={{ 'aria-label': 'Custom Close Button' }}
|
|
open={isCadastrarMedicosModalOpen}
|
|
onOk={handleCadastrarMedicosOk}
|
|
onCancel={handleCadastrarMedicosCancel}
|
|
okButtonProps={{ style: { display: 'none' } }}
|
|
>
|
|
|
|
<Form
|
|
name="basic"
|
|
labelCol={{ span: 8 }}
|
|
wrapperCol={{ span: 16 }}
|
|
style={{ maxWidth: 600 }}
|
|
initialValues={{ remember: true }}
|
|
onFinish={onFinish}
|
|
onFinishFailed={onFinishFailed}
|
|
autoComplete="off"
|
|
>
|
|
|
|
<Form.Item
|
|
label="Nome"
|
|
name="nome"
|
|
rules={[{ required: true, message: 'Escreva o nome' }]}
|
|
>
|
|
<Input />
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
label="CRM"
|
|
name="crm"
|
|
rules={[{ required: true, message: 'Escreva o CRM' }]}
|
|
>
|
|
<Input.Password />
|
|
</Form.Item>
|
|
|
|
<Form.Item label={null}>
|
|
<Button type="primary" htmlType="submit">
|
|
Submit
|
|
</Button>
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</Modal>
|
|
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default CadastrarMedicosModal;
|