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