fix: languages config, update-password

This commit is contained in:
jialin
2024-06-25 11:50:55 +08:00
parent bd6b3dcbe3
commit 9edce7116e
21 changed files with 435 additions and 128 deletions
+58 -23
View File
@@ -1,21 +1,29 @@
import FormButtons from '@/components/form-buttons';
import SealInput from '@/components/seal-form/seal-input';
import { PasswordReg } from '@/config';
import { INPUT_WIDTH } from '@/constants';
import { updatePassword } from '@/pages/login/apis';
import { PageContainer } from '@ant-design/pro-components';
import { Form } from 'antd';
import { useIntl } from '@umijs/max';
import { Form, message } from 'antd';
import { StrictMode } from 'react';
interface ProfileProps {
name: string;
password: string;
originalPassword: string;
email: string;
username?: string;
new_password: string;
current_password: string;
}
const Profile: React.FC = () => {
const [form] = Form.useForm();
const intl = useIntl();
const handleOnFinish = (values: any) => {
console.log('handleOnFinish', values);
const newpasswordValue = Form.useWatch('new_password', form);
const handleOnFinish = async (values: any) => {
try {
await updatePassword(values);
message.success(intl.formatMessage({ id: 'common.message.success' }));
} catch (error) {}
};
const handleOnFinishFailed = (errorInfo: any) => {
@@ -30,7 +38,7 @@ const Profile: React.FC = () => {
<PageContainer
ghost
header={{
title: 'Profile'
title: intl.formatMessage({ id: 'users.form.updatepassword' })
}}
extra={[]}
>
@@ -41,33 +49,60 @@ const Profile: React.FC = () => {
onFinish={handleOnFinish}
onFinishFailed={handleOnFinishFailed}
>
<Form.Item<ProfileProps> name="name" rules={[{ required: true }]}>
{/* <Form.Item<ProfileProps>
name="username"
rules={[
{
required: true,
message: intl.formatMessage(
{ id: 'common.form.rule.input' },
{
name: intl.formatMessage({ id: 'common.form.username' })
}
)
}
]}
>
<SealInput.Input
label="Name"
label={intl.formatMessage({ id: 'common.form.username' })}
required
style={{ width: INPUT_WIDTH.default }}
></SealInput.Input>
</Form.Item>
<Form.Item<ProfileProps> name="email" rules={[{ required: true }]}>
<SealInput.Input
label="Email"
required
style={{ width: INPUT_WIDTH.default }}
></SealInput.Input>
</Form.Item>
</Form.Item> */}
<Form.Item<ProfileProps>
name="originalPassword"
rules={[{ required: true }]}
name="current_password"
rules={[
{
required: true,
message: intl.formatMessage(
{ id: 'common.form.rule.input' },
{
name: intl.formatMessage({
id: 'users.form.currentpassword'
})
}
)
}
]}
>
<SealInput.Password
label="Original Password"
label={intl.formatMessage({ id: 'users.form.currentpassword' })}
required
style={{ width: INPUT_WIDTH.default }}
></SealInput.Password>
</Form.Item>
<Form.Item<ProfileProps> name="password" rules={[{ required: true }]}>
<Form.Item<ProfileProps>
name="new_password"
rules={[
{
required: true,
pattern: PasswordReg,
message: intl.formatMessage({ id: 'users.form.rule.password' })
}
]}
>
<SealInput.Password
label="Password"
label={intl.formatMessage({ id: 'users.form.newpassword' })}
required
style={{ width: INPUT_WIDTH.default }}
></SealInput.Password>