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
46 lines
1.2 KiB
3 years ago
|
import React, { useState } from "react";
|
||
|
import { Form, Input, Button, Alert } from "antd";
|
||
|
import UserService from "../service/UserService";
|
||
|
import { useHistory } from "react-router-dom";
|
||
|
|
||
|
export default function LoginPage() {
|
||
|
const [error, setError] = useState();
|
||
|
const history = useHistory();
|
||
|
|
||
|
const onSubmit = ({ email, password }) => {
|
||
|
UserService.login(email, password)
|
||
|
.then(() => history.push("/profile"))
|
||
|
.catch((err) => {
|
||
|
setError(err);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const layout = {
|
||
|
labelCol: { span: 8 },
|
||
|
wrapperCol: { span: 4 },
|
||
|
};
|
||
|
const tailLayout = {
|
||
|
wrapperCol: { offset: 8, span: 4 },
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
3 years ago
|
{error && <Alert message={"Login faild:" + error} type="error" />}
|
||
3 years ago
|
<br />
|
||
|
<Form onFinish={onSubmit} {...layout}>
|
||
|
<Form.Item label="Email" name="email">
|
||
|
<Input type="email"></Input>
|
||
|
</Form.Item>
|
||
|
<Form.Item label="Password" name="password">
|
||
|
<Input type="password"></Input>
|
||
|
</Form.Item>
|
||
|
<Form.Item {...tailLayout}>
|
||
|
<Button type="primary" htmlType="submit">
|
||
|
Submit
|
||
|
</Button>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
</>
|
||
|
);
|
||
|
}
|