Skip to content

Commit

Permalink
sort user roles on edit modal (#2211)
Browse files Browse the repository at this point in the history
  • Loading branch information
djnunez-aot authored May 8, 2024
1 parent b687913 commit 8971d70
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions epictrack-web/src/components/user/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ const UserList = () => {
try {
const userResult = await UserService.getUsers();
if (userResult.status === 200) {
const sortedResults = (userResult.data as User[]).sort((a, b) => {
const aValue = a.group?.level ?? -0;
const bValue = b.group?.level ?? -0;
return bValue - aValue;
});
setUsers(sortedResults as never);
setUsers(userResult.data as never);
}
} catch (error) {
console.error("User List: ", error);
Expand Down Expand Up @@ -101,7 +96,9 @@ const UserList = () => {
menuPosition="fixed"
getOptionValue={(opt) => opt.id}
getOptionLabel={(opt) => opt.display_name}
options={groups.filter((p) => currentUserGroup.level >= p.level)}
options={groups
.filter((p) => currentUserGroup.level >= p.level)
.sort((a, b) => b.level - a.level)}
required={true}
// menuPortalTarget={document.body}
onChange={(newVal) => setSelectedGroup(newVal)}
Expand Down Expand Up @@ -171,7 +168,7 @@ const UserList = () => {
initialState={{
sorting: [
{
id: "group.level",
id: "name",
desc: false,
},
],
Expand Down

0 comments on commit 8971d70

Please sign in to comment.