Merge branch 'main' of github.com:hainatravel/GHHub
commit
5b5698e644
@ -0,0 +1,105 @@
|
||||
import { Button, Space, 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 [form] = Form.useForm();
|
||||
|
||||
const onFinish = (values) => {
|
||||
authStore.changeUserPassword(values.currentPassword, values.newPassword)
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: `Notification`,
|
||||
description: 'Your password has been successfully updated.',
|
||||
placement: 'top',
|
||||
duration: 4,
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
notification.error({
|
||||
message: `Notification`,
|
||||
description: 'Failed to change password. Please try again.',
|
||||
placement: 'top',
|
||||
duration: 4,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const onFinishFailed = (errorInfo) => {
|
||||
console.log('Failed:', errorInfo);
|
||||
// form.resetFields();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Row justify="center" align="middle" style={{ minHeight: 500 }}>
|
||||
<Form
|
||||
name="basic"
|
||||
form={form}
|
||||
layout="vertical"
|
||||
size="large"
|
||||
style={{
|
||||
maxWidth: 600,
|
||||
}}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item><Title level={2}>Change your password</Title></Form.Item>
|
||||
<Form.Item
|
||||
label="Current password"
|
||||
name="currentPassword"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input your password!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="New password"
|
||||
name="newPassword"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input your password!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Reenter password"
|
||||
name="reenterPassword"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please reenter your password!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space size="middle">
|
||||
<Button type="primary" htmlType="submit">
|
||||
Save
|
||||
</Button>
|
||||
<Button htmlType="submit">
|
||||
Cancel
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ChangePassword;
|
@ -0,0 +1,23 @@
|
||||
import { Descriptions, Col, Row } from 'antd';
|
||||
import { useStore } from '@/stores/StoreContext.js';
|
||||
|
||||
function Profile() {
|
||||
|
||||
const { authStore } = useStore();
|
||||
const { login } = authStore;
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col span={12} offset={6}>
|
||||
<Descriptions title="User Profile" layout="vertical" column={2}>
|
||||
<Descriptions.Item label="Username">{login.username}</Descriptions.Item>
|
||||
<Descriptions.Item label="Telephone">{login.telephone}</Descriptions.Item>
|
||||
<Descriptions.Item label="Email address">{login.emailAddress}</Descriptions.Item>
|
||||
<Descriptions.Item label="Company">{login.travelAgencyName}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export default Profile;
|
Loading…
Reference in New Issue