|
|
|
@ -1,14 +1,15 @@
|
|
|
|
|
import { useNavigate } from "react-router-dom"
|
|
|
|
|
import { Button, Space, Form, Input, Row, Typography, App } from 'antd'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import useAuthStore from '@/stores/Auth'
|
|
|
|
|
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
|
|
|
|
function ChangePassword() {
|
|
|
|
|
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
const [changeUserPassword] = useAuthStore(
|
|
|
|
|
(state) => [state.changeUserPassword])
|
|
|
|
|
const changeUserPassword = useAuthStore((state) => state.changeUserPassword)
|
|
|
|
|
const { notification } = App.useApp()
|
|
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
|
|
|
|
@ -16,8 +17,8 @@ function ChangePassword() {
|
|
|
|
|
changeUserPassword(values.currentPassword, values.newPassword)
|
|
|
|
|
.then(() => {
|
|
|
|
|
notification.success({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: 'Your password has been successfully updated.',
|
|
|
|
|
message: t('Validation.Title'),
|
|
|
|
|
description: t('account:Validation.Success'),
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
@ -25,8 +26,8 @@ function ChangePassword() {
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: 'Failed to change password. Please try again.',
|
|
|
|
|
message: t('Validation.Title'),
|
|
|
|
|
description: t('account:Validation.Fail'),
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
@ -53,38 +54,38 @@ function ChangePassword() {
|
|
|
|
|
onFinishFailed={onFinishFailed}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
>
|
|
|
|
|
<Form.Item><Title level={2}>Change your password</Title></Form.Item>
|
|
|
|
|
<Form.Item><Title level={2}>{t('ChangePassword')}</Title></Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="Current password"
|
|
|
|
|
label={t('account:CurrentPassword')}
|
|
|
|
|
name="currentPassword"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please input your password!',
|
|
|
|
|
message: t('account:Validation.CurrentPassword'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input.Password />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="New password"
|
|
|
|
|
label={t('account:NewPassword')}
|
|
|
|
|
name="newPassword"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please input your password!',
|
|
|
|
|
message: t('account:Validation.NewPassword'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input.Password />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="Reenter password"
|
|
|
|
|
label={t('account:ReenterPassword')}
|
|
|
|
|
name="reenterPassword"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please reenter your password!',
|
|
|
|
|
message: t('account:Validation.ReenterPassword'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
@ -93,10 +94,10 @@ function ChangePassword() {
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<Space size="middle">
|
|
|
|
|
<Button type="primary" htmlType="submit">
|
|
|
|
|
Save
|
|
|
|
|
{t('Submit')}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button onClick={() => navigate('/reservation/newest')}>
|
|
|
|
|
Cancel
|
|
|
|
|
{t('Cancel')}
|
|
|
|
|
</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
</Form.Item>
|
|
|
|
|