From 50bba57481af09cd886b1f805faf42ad08743805 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Thu, 2 Apr 2020 13:16:20 -0600 Subject: [PATCH] Users list fixes (#7) * Updated dependencies * Imported changes from old repo for users reconnect * Added add group buttons * Removed console logs * partial fix for total user issue * Added sort to users list Co-authored-by: Benjamin Perez Co-authored-by: Daniel Valdivia --- portal-ui/src/screens/Console/Users/Users.tsx | 5 +++-- portal-ui/src/utils/sortFunctions.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 portal-ui/src/utils/sortFunctions.ts diff --git a/portal-ui/src/screens/Console/Users/Users.tsx b/portal-ui/src/screens/Console/Users/Users.tsx index bf95be19a..c9752b809 100644 --- a/portal-ui/src/screens/Console/Users/Users.tsx +++ b/portal-ui/src/screens/Console/Users/Users.tsx @@ -32,6 +32,7 @@ import { } from "@material-ui/core"; import Typography from "@material-ui/core/Typography"; import { User, UsersList } from "./types"; +import { usersSort } from '../../../utils/sortFunctions'; import { MinTablePaginationActions } from "../../../common/MinTablePaginationActions"; import AddUser from "./AddUser"; import DeleteUser from "./DeleteUser"; @@ -135,8 +136,8 @@ class Users extends React.Component { .then((res: UsersList) => { this.setState({ loading: false, - records: res.users, - totalRecords: res.total_users, + records: res.users.sort(usersSort), + totalRecords: res.users.length, error: "" }); // if we get 0 results, and page > 0 , go down 1 page diff --git a/portal-ui/src/utils/sortFunctions.ts b/portal-ui/src/utils/sortFunctions.ts new file mode 100644 index 000000000..29c75f704 --- /dev/null +++ b/portal-ui/src/utils/sortFunctions.ts @@ -0,0 +1,15 @@ +interface sortInterface { + accessKey: string; +} + +export const usersSort = (a: sortInterface, b: sortInterface) => { + if (a.accessKey > b.accessKey) { + return 1; + } + if (a.accessKey < b.accessKey) { + return -1; + } + // a must be equal to b + return 0; +}; +