mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 18:29:15 +03:00
fix: user search to ilike op
This commit is contained in:
parent
4091e68be0
commit
0fc37a713a
@ -27,21 +27,23 @@ const UserItem: React.FC<UserItemPropsType> = ({ user, onEdit, onDelete }) => {
|
|||||||
userStore: { me },
|
userStore: { me },
|
||||||
} = useRootStore();
|
} = useRootStore();
|
||||||
|
|
||||||
/**
|
const isDisabledActions = (() => {
|
||||||
* The user with role TEACHER can edit users with only STUDENT role
|
/**
|
||||||
*/
|
* Disable editing when rendering on account item
|
||||||
const isDisabledActions = () => {
|
*/
|
||||||
|
if (me !== null && me.id === user.id) return true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable editing based on user roles
|
||||||
|
*/
|
||||||
if (helpres.userContainRoles(user.roles, [UserRoleEnum.ADMIN, UserRoleEnum.TEACHER]) && me !== null) {
|
if (helpres.userContainRoles(user.roles, [UserRoleEnum.ADMIN, UserRoleEnum.TEACHER]) && me !== null) {
|
||||||
/**
|
|
||||||
* Disable editing
|
|
||||||
*/
|
|
||||||
if (me.isTeacher || me.isStudent) {
|
if (me.isTeacher || me.isStudent) {
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
})();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box borderWidth='1px' borderRadius='lg' w='full' p='3'>
|
<Box borderWidth='1px' borderRadius='lg' w='full' p='3'>
|
||||||
@ -60,7 +62,7 @@ const UserItem: React.FC<UserItemPropsType> = ({ user, onEdit, onDelete }) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
<Box>
|
<Box>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={isDisabledActions()}
|
disabled={isDisabledActions}
|
||||||
onClick={() => onEdit(user)}
|
onClick={() => onEdit(user)}
|
||||||
aria-label='Edit'
|
aria-label='Edit'
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
@ -68,7 +70,7 @@ const UserItem: React.FC<UserItemPropsType> = ({ user, onEdit, onDelete }) => {
|
|||||||
icon={<EditIcon />}
|
icon={<EditIcon />}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={isDisabledActions()}
|
disabled={isDisabledActions}
|
||||||
onClick={() => onDelete(user)}
|
onClick={() => onDelete(user)}
|
||||||
colorScheme='red'
|
colorScheme='red'
|
||||||
aria-label='Delete'
|
aria-label='Delete'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user