feat: 国际化修改密码界面

feature/price_manager
Jimmy Liow 1 year ago
parent 63a32f5412
commit 8d3649da9d

@ -0,0 +1,12 @@
{
"CurrentPassword": "Current password",
"NewPassword": "New password",
"ReenterPassword": "Reenter password",
"Validation": {
"Success": "Your password has been successfully updated.",
"Fail": "Failed to change password. Please try again.",
"CurrentPassword": "Please input your password.",
"NewPassword": "Please input your new password.",
"ReenterPassword": "Please reenter your password."
}
}

@ -0,0 +1,12 @@
{
"CurrentPassword": "当前密码",
"NewPassword": "新密码",
"ReenterPassword": "重复输入密码",
"Validation": {
"Success": "密码更新成功",
"Fail": "密码更新失败",
"CurrentPassword": "请输入密码。",
"NewPassword": "请输入新密码。",
"ReenterPassword": "请重复输入密码。"
}
}

@ -51,10 +51,6 @@
"Notice": "通知", "Notice": "通知",
"Report": "质量评分" "Report": "质量评分"
}, },
"Notification": {
"Title": "温馨提示",
"LoginFailed": "密码错误,登陆失败。"
},
"Validation": { "Validation": {
"Title": "温馨提示", "Title": "温馨提示",
"LoginFailed": "密码错误,登陆失败。", "LoginFailed": "密码错误,登陆失败。",

@ -17,7 +17,7 @@ i18n
backend: { backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json', loadPath: '/locales/{{lng}}/{{ns}}.json',
}, },
ns: ['common', 'group', 'vendor'], ns: ['common', 'group', 'vendor', 'account'],
defaultNS: 'common', defaultNS: 'common',
detection: { detection: {
// convertDetectedLanguage: 'Iso15897', // convertDetectedLanguage: 'Iso15897',

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

Loading…
Cancel
Save