增加修改密码界面
parent
4182133790
commit
9e8869acd2
@ -0,0 +1,126 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button, Checkbox, Form, Input, Row, Typography, App } from 'antd';
|
||||
import { useStore } from '@/stores/StoreContext.js';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
function ChangePassword() {
|
||||
|
||||
const { authStore } = useStore();
|
||||
const { notification } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const onFinish = (values) => {
|
||||
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 }}>
|
||||
<Title level={3}>Change your password</Title>
|
||||
<Form
|
||||
name="basic"
|
||||
labelCol={{
|
||||
span: 8,
|
||||
}}
|
||||
wrapperCol={{
|
||||
span: 16,
|
||||
}}
|
||||
style={{
|
||||
maxWidth: 600,
|
||||
}}
|
||||
initialValues={{
|
||||
remember: true,
|
||||
}}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item
|
||||
label="Current password"
|
||||
name="username"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input your username!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="New password"
|
||||
name="password"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input your password!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Reenter password"
|
||||
name="password"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input your password!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
wrapperCol={{
|
||||
offset: 8,
|
||||
span: 16,
|
||||
}}
|
||||
>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Save
|
||||
</Button>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
wrapperCol={{
|
||||
offset: 8,
|
||||
span: 16,
|
||||
}}
|
||||
>
|
||||
<Button htmlType="submit">
|
||||
Cancel
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export default ChangePassword;
|
Loading…
Reference in New Issue