1
1
import React from 'react' ;
2
2
import { Table , Tooltip , Popconfirm , message , Tag , Popover } from 'antd' ;
3
- import { EyeOutlined , EditOutlined , DeleteOutlined , LockOutlined , DownOutlined } from '@ant-design/icons' ;
3
+ import {
4
+ EyeOutlined ,
5
+ EditOutlined ,
6
+ DeleteOutlined ,
7
+ LockFilled ,
8
+ UnlockOutlined ,
9
+ KeyOutlined ,
10
+ DownOutlined ,
11
+ } from '@ant-design/icons' ;
4
12
5
- import { deleteUser , resetUserPassword } from './Utils.js' ;
13
+ import { deleteUser , resetUserPassword , unlockUserAccount } from './Utils.js' ;
6
14
7
15
const UserManagementTable = ( {
8
16
users,
@@ -25,6 +33,16 @@ const UserManagementTable = ({
25
33
}
26
34
} ;
27
35
36
+ // Unlock user account
37
+ const handleAccountUnlock = async ( { id } ) => {
38
+ try {
39
+ await unlockUserAccount ( { id } ) ;
40
+ message . success ( 'User account unlocked successfully' ) ;
41
+ } catch ( err ) {
42
+ message . error ( 'Failed to unlock user account' ) ;
43
+ }
44
+ } ;
45
+
28
46
// Const handle user deletion - display message and setUsers and filteredUsers
29
47
const handleDeleteUser = async ( { id } ) => {
30
48
try {
@@ -39,12 +57,24 @@ const UserManagementTable = ({
39
57
40
58
// Columns for the table
41
59
const columns = [
60
+ {
61
+ title : '' ,
62
+ key : ( record ) => record . id ,
63
+ width : 1 ,
64
+ render : ( record ) =>
65
+ record . accountLocked &&
66
+ record . accountLocked . isLocked && (
67
+ < Tooltip title = "Account Locked" >
68
+ < LockFilled style = { { color : 'var(--danger)' } } /> { ' ' }
69
+ </ Tooltip >
70
+ ) ,
71
+ } ,
72
+ Table . SELECTION_COLUMN ,
42
73
{
43
74
title : 'First Name' ,
44
75
dataIndex : 'firstName' ,
45
76
key : 'firstName' ,
46
77
} ,
47
-
48
78
{
49
79
title : 'Last Name' ,
50
80
dataIndex : 'lastName' ,
@@ -132,9 +162,35 @@ const UserManagementTable = ({
132
162
cancelText = "No"
133
163
cancelButtonProps = { { type : 'primary' , ghost : true } }
134
164
style = { { width : '500px !important' } } >
135
- < LockOutlined style = { { marginRight : 15 } } />
136
- Reset Password
165
+ < div style = { { marginBottom : '8px' } } >
166
+ < KeyOutlined style = { { marginRight : 7 } } /> Reset Password
167
+ </ div >
137
168
</ Popconfirm >
169
+
170
+ { record . accountLocked && record . accountLocked . isLocked && (
171
+ < Popconfirm
172
+ title = {
173
+ < >
174
+ < div style = { { fontWeight : 'bold' } } > { `Unlock Account` } </ div >
175
+ < div style = { { maxWidth : 460 } } >
176
+ { `Clicking 'Yes' will unlock the user's account and send them a password reset link. Do you want to continue?` }
177
+ </ div >
178
+ </ >
179
+ }
180
+ onConfirm = { ( ) => {
181
+ handleAccountUnlock ( { id : record . id } ) ;
182
+ } }
183
+ okText = "Yes"
184
+ okButtonProps = { { danger : true } }
185
+ cancelText = "No"
186
+ cancelButtonProps = { { type : 'primary' , ghost : true } }
187
+ style = { { width : '500px !important' } } >
188
+ < div >
189
+ < UnlockOutlined style = { { marginRight : 10 } } />
190
+ Unlock Account
191
+ </ div >
192
+ </ Popconfirm >
193
+ ) }
138
194
</ div >
139
195
</ div >
140
196
} >
0 commit comments