I’m a beginner using Typescript and React. On the UI of the application, there is a defect that does not allow a user to delete their own account when logged in. So like if I was logged in I could delete other accounts created, but not my own. To fix this, in the code shown, I think I need to add a function under “disabled” that checks if the user being selected to delete also belongs to the logged in user. If it does, the disabled should run true. Can someone please help with this and show how to do it?
const deleteAction = {
children: (
<TableMenuItem
data-testid="delete-user-button"
disabled={
!hasAnyPermission(
[
KnownPermissions.IdentityUsersDeleteAllAccounts,
KnownPermissions.IdentityUsersDeleteCurrentAccount,
],
permissions
)
}
onClick={() => handleDeleteUser(user)}
iconId={'delete'}
label={'Delete'}
/>
),
dataTestId: 'delete-user-button',
disabled: !hasAnyPermission(
[
KnownPermissions.IdentityUsersDeleteAllAccounts,
KnownPermissions.IdentityUsersDeleteCurrentAccount,
],
permissions
),
iconId: 'delete',
key: 'delete',
onclick: () => handleDeleteUser(user),
tooltip: 'Delete user',
};
What I have tried:
Can someone please help with this and show how to do it?