@@ -110,17 +110,14 @@ const UserTable = ({ users }: { users: User[] }) => {
110
110
111
111
const ActionUserTable = ( {
112
112
users,
113
- onSelect,
114
113
actionText,
115
- actionButtonText ,
114
+ drawActionComponent
116
115
} : {
117
116
users : User [ ]
118
- onSelect : ( user : User ) => void
119
117
actionText : string
120
- actionButtonText : string
118
+ drawActionComponent : ( user : User ) => any
121
119
} ) => {
122
120
const { t } = useTranslation ( )
123
-
124
121
if ( ! users || users . length === 0 ) return null
125
122
126
123
return (
@@ -180,15 +177,8 @@ const ActionUserTable = ({
180
177
< Typography variant = "h6" > { user . primaryEmail } </ Typography >
181
178
</ TableCell >
182
179
< TableCell >
183
- < Button
184
- variant = "outlined"
185
- onClick = { ( ) => {
186
- onSelect ( user )
187
- } }
188
- >
189
- { actionButtonText }
190
- </ Button >
191
- </ TableCell >
180
+ { drawActionComponent ( user ) }
181
+ </ TableCell >
192
182
</ TableRow >
193
183
) ) }
194
184
</ TableBody >
@@ -221,13 +211,10 @@ const UserSearch = () => {
221
211
}
222
212
//a component which allows users to be searched in order to perform some kind of action with the user
223
213
export const ActionUserSearch = ( {
224
- onSelect,
225
214
actionText,
226
- actionButtonText,
227
- } : {
228
- onSelect : ( user : User ) => void
215
+ drawActionComponent } : {
229
216
actionText : string
230
- actionButtonText : string
217
+ drawActionComponent : ( user : User ) => any
231
218
} ) => {
232
219
const [ search , setSearch ] = useState ( '' )
233
220
const { users, isLoading, refetch } = useUserSearch ( search )
@@ -246,7 +233,7 @@ export const ActionUserSearch = ({
246
233
{ search . length > 2 && search . length < 5 && < div > { t ( 'admin:typeMore' ) } </ div > }
247
234
248
235
{ isLoading && < div > Loading...</ div > }
249
- { users && < ActionUserTable users = { users } onSelect = { onSelect } actionText = { actionText } actionButtonText = { actionButtonText } /> }
236
+ { users && < ActionUserTable users = { users } actionText = { actionText } drawActionComponent = { drawActionComponent } /> }
250
237
</ Box >
251
238
)
252
239
}
0 commit comments