|
|
|
@ -1,20 +1,44 @@
|
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
|
|
import { Button, Checkbox, Form, Input, Row, App } from 'antd';
|
|
|
|
|
import { useStore } from '@/stores/StoreContext.js';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Login() {
|
|
|
|
|
const { authStore } = useStore();
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const { notification } = App.useApp();
|
|
|
|
|
|
|
|
|
|
const onFinish = (values) => {
|
|
|
|
|
console.log('Success:', values);
|
|
|
|
|
authStore.valdateUserPassword(values.username, values.password);
|
|
|
|
|
authStore.valdateUserPassword(values.username, values.password)
|
|
|
|
|
.then((userId) => {
|
|
|
|
|
authStore.fetchUserDetail(userId)
|
|
|
|
|
.then((user) => {
|
|
|
|
|
// navigate(-1) is equivalent to hitting the back button.
|
|
|
|
|
navigate("/reservation/newest");
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onFinishFailed = (errorInfo) => {
|
|
|
|
|
console.log('Failed:', errorInfo);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Row justify="center" align="middle" style={{ minHeight: 500 }}>
|
|
|
|
|
<Form
|
|
|
|
@ -47,7 +71,6 @@ function Login() {
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="Password"
|
|
|
|
|
name="password"
|
|
|
|
@ -60,7 +83,6 @@ function Login() {
|
|
|
|
|
>
|
|
|
|
|
<Input.Password />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="remember"
|
|
|
|
|
valuePropName="checked"
|
|
|
|
@ -71,7 +93,6 @@ function Login() {
|
|
|
|
|
>
|
|
|
|
|
<Checkbox>Remember me</Checkbox>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
wrapperCol={{
|
|
|
|
|
offset: 8,
|
|
|
|
|