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.
 
 
 
 

86 lines
2.0 KiB

import { Modal, Button, Checkbox, Form, Input } from 'antd';
import _service from '@netuno/service-client';
function LoginModal({isLoginModalOpen, setIsLoginModalOpen}) {
const handleLoginOk = () => {
setIsLoginModalOpen(false);
};
const handleLoginCancel = () => {
setIsLoginModalOpen(false);
};
const onFinish = values => {
console.log('Success:', values);
_service({
url: "/services/_auth",
method: "POST",
data: {...values, jwt: true },
success: (response) => {
if (response.json) {
console.log("Service Response", response.json);
localStorage.setItem('access_token', response.json.access_token);
}
},
fail: (e) => {
console.log("Service Error", e);
}
});
};
const onFinishFailed = errorInfo => {
console.log('Failed:', errorInfo);
};
return (
<>
<Modal
title="Fazer login"
closable={{ 'aria-label': 'Custom Close Button' }}
open={isLoginModalOpen}
onOk={handleLoginOk}
onCancel={handleLoginCancel}
okButtonProps={{ style: { display: 'none' } }}
>
<Form
name="basic"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
style={{ maxWidth: 600 }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
>
<Form.Item
label="Username"
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
>
<Input />
</Form.Item>
<Form.Item
label="Password"
name="password"
rules={[{ required: true, message: 'Please input your password!' }]}
>
<Input.Password />
</Form.Item>
<Form.Item label={null}>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</Modal>
</>
);
}
export default LoginModal;