|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { Outlet, Link, useHref, useNavigate, NavLink } from "react-router-dom";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { observer } from "mobx-react";
|
|
|
|
|
import { toJS } from "mobx";
|
|
|
|
|
import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge, Typography, Modal, Input, Button, App as AntApp } from "antd";
|
|
|
|
@ -25,13 +25,15 @@ const items = [
|
|
|
|
|
type: "divider",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: <Link to="/login">Logout</Link>,
|
|
|
|
|
label: <Link to="/login?out">Logout</Link>,
|
|
|
|
|
key: "3",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
|
const { authStore, noticeStore } = useStore();
|
|
|
|
|
const { notification } = AntApp.useApp();
|
|
|
|
|
const login = toJS(authStore.login);
|
|
|
|
|
const { noticeUnRead } = noticeStore;
|
|
|
|
|
const href = useHref();
|
|
|
|
@ -45,6 +47,30 @@ function App() {
|
|
|
|
|
}
|
|
|
|
|
}, [href]);
|
|
|
|
|
|
|
|
|
|
const onSubmit = () => {
|
|
|
|
|
authStore.valdateUserPassword(login.username, password)
|
|
|
|
|
.then(() => {
|
|
|
|
|
authStore.fetchUserDetail()
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: 'Failed to get user information.',
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
setPassword('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const splitPath = href.split("/");
|
|
|
|
|
let defaultPath = "reservation";
|
|
|
|
|
|
|
|
|
@ -70,18 +96,18 @@ function App() {
|
|
|
|
|
closable={false}
|
|
|
|
|
maskClosable={false}
|
|
|
|
|
footer={null}
|
|
|
|
|
open={false}
|
|
|
|
|
// open={isModalOpen} onOk={handleOk} onCancel={handleCancel}
|
|
|
|
|
open={login.timeout}
|
|
|
|
|
>
|
|
|
|
|
<Title level={4}>Login timeout</Title>
|
|
|
|
|
<Title level={3}>Login timeout</Title>
|
|
|
|
|
<span>Please input your password</span>
|
|
|
|
|
<Space direction="horizontal">
|
|
|
|
|
<Input.Password addonBefore={login.username} />
|
|
|
|
|
<Input.Password value={password}
|
|
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
|
|
|
onPressEnter={() => onSubmit()}
|
|
|
|
|
addonBefore={login.username} />
|
|
|
|
|
<Button
|
|
|
|
|
style={{
|
|
|
|
|
width: 80,
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => setPasswordVisible((prevState) => !prevState)}
|
|
|
|
|
></Button></Space>
|
|
|
|
|
onClick={() => onSubmit()}
|
|
|
|
|
>Submit</Button></Space>
|
|
|
|
|
|
|
|
|
|
</Modal>
|
|
|
|
|
<Layout
|
|
|
|
@ -123,7 +149,9 @@ function App() {
|
|
|
|
|
<Dropdown
|
|
|
|
|
menu={{
|
|
|
|
|
items,
|
|
|
|
|
}}>
|
|
|
|
|
}}
|
|
|
|
|
trigger={['click']}
|
|
|
|
|
>
|
|
|
|
|
<a onClick={e => e.preventDefault()}>
|
|
|
|
|
<Space>
|
|
|
|
|
{authStore.login.username}
|
|
|
|
|