feat(client): add update password
This commit is contained in:
parent
8f3fde623f
commit
1eadd834e3
@ -70,7 +70,7 @@ export default function Header({ title, additionalContent }: HeaderProps) {
|
|||||||
closeDrawer={closeEditDrawer}
|
closeDrawer={closeEditDrawer}
|
||||||
type="edit"
|
type="edit"
|
||||||
>
|
>
|
||||||
{user?.id && <UserEdit userId={user?.id} />}
|
{user?.id && <UserEdit closeDrawer={closeEditDrawer} userId={user?.id} />}
|
||||||
</ContentDrawer>
|
</ContentDrawer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { UserService } from '@/services/userService';
|
import { UserService } from '@/services/userService';
|
||||||
import { useUserSelector } from '@/store/userStore';
|
import { useUserSelector } from '@/store/userStore';
|
||||||
import { User, UserUpdate } from '@/types/user';
|
import { UserUpdate } from '@/types/user';
|
||||||
import { LoadingOutlined } from '@ant-design/icons';
|
import { LoadingOutlined } from '@ant-design/icons';
|
||||||
import { Button, Form, Input, Select, Spin } from 'antd';
|
import { Button, Form, Input, message, Select, Spin } from 'antd';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
@ -10,17 +10,19 @@ const { Option } = Select;
|
|||||||
|
|
||||||
interface UserEditProps {
|
interface UserEditProps {
|
||||||
userId?: number;
|
userId?: number;
|
||||||
|
closeDrawer: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UserEdit({ userId }: UserEditProps) {
|
export default function UserEdit({ userId, closeDrawer }: UserEditProps) {
|
||||||
const currentUser = useUserSelector();
|
const currentUser = useUserSelector();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [user, setUser] = useState<User>({
|
const [user, setUser] = useState<UserUpdate>({
|
||||||
id: 0,
|
id: 0,
|
||||||
name: '',
|
name: '',
|
||||||
login: '',
|
login: '',
|
||||||
email: '',
|
email: '',
|
||||||
|
password: '',
|
||||||
bindTenantId: '',
|
bindTenantId: '',
|
||||||
role: 'VIEWER',
|
role: 'VIEWER',
|
||||||
meta: {},
|
meta: {},
|
||||||
@ -53,10 +55,13 @@ export default function UserEdit({ userId }: UserEditProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Object.keys(updatedUser).length > 0) {
|
if (Object.keys(updatedUser).length > 0) {
|
||||||
|
console.log('updateUser', userId, updatedUser);
|
||||||
await UserService.updateUser(userId!, updatedUser);
|
await UserService.updateUser(userId!, updatedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
message.info(t('editAccountMessage'), 4);
|
||||||
|
closeDrawer();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -49,6 +49,7 @@ i18n
|
|||||||
createdAt: 'Created',
|
createdAt: 'Created',
|
||||||
saving: 'Saving...',
|
saving: 'Saving...',
|
||||||
createdAccountMessage: 'User successfully created!',
|
createdAccountMessage: 'User successfully created!',
|
||||||
|
editAccountMessage: 'User successfully updated!',
|
||||||
you: '(You)',
|
you: '(You)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -91,6 +92,7 @@ i18n
|
|||||||
createdAt: 'Создано',
|
createdAt: 'Создано',
|
||||||
saving: 'Сохранение...',
|
saving: 'Сохранение...',
|
||||||
createdAccountMessage: 'Пользователь успешно создан!',
|
createdAccountMessage: 'Пользователь успешно создан!',
|
||||||
|
editAccountMessage: 'Пользователь успешно обновлен!',
|
||||||
you: '(Вы)',
|
you: '(Вы)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -123,6 +123,15 @@ export default function AccountsPage() {
|
|||||||
title: t('createdAt'),
|
title: t('createdAt'),
|
||||||
dataIndex: 'createdAt',
|
dataIndex: 'createdAt',
|
||||||
key: 'createdAt',
|
key: 'createdAt',
|
||||||
|
render: (text) => (
|
||||||
|
<div>
|
||||||
|
{new Date(text).toLocaleString('ru', {
|
||||||
|
year: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('status'),
|
title: t('status'),
|
||||||
@ -191,7 +200,7 @@ export default function AccountsPage() {
|
|||||||
closeDrawer={closeEditDrawer}
|
closeDrawer={closeEditDrawer}
|
||||||
type="edit"
|
type="edit"
|
||||||
>
|
>
|
||||||
<UserEdit userId={activeAccount?.id} />
|
<UserEdit userId={activeAccount?.id} closeDrawer={closeEditDrawer} />
|
||||||
</ContentDrawer>
|
</ContentDrawer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Form, Input, Button, Typography } from 'antd';
|
import { Form, Input, Button, Typography, message } from 'antd';
|
||||||
import {
|
import {
|
||||||
EyeInvisibleOutlined,
|
EyeInvisibleOutlined,
|
||||||
EyeTwoTone,
|
EyeTwoTone,
|
||||||
@ -45,7 +45,11 @@ export default function LoginPage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form name="login" onFinish={onFinish} layout="vertical">
|
<Form
|
||||||
|
name="login"
|
||||||
|
onFinish={onFinish}
|
||||||
|
layout="vertical"
|
||||||
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="login"
|
name="login"
|
||||||
rules={[{ required: true, message: 'Введите login' }]}
|
rules={[{ required: true, message: 'Введите login' }]}
|
||||||
|
Loading…
Reference in New Issue
Block a user