From 45a6f9923ddb2135f8e04733b98a26e7401889b7 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Sun, 31 Jan 2021 19:07:06 +0100 Subject: [PATCH] sort the role list alfabaticlly (#346) --- src/clients/ClientDetails.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/clients/ClientDetails.tsx b/src/clients/ClientDetails.tsx index e4e158970a..4d145de82f 100644 --- a/src/clients/ClientDetails.tsx +++ b/src/clients/ClientDetails.tsx @@ -110,7 +110,19 @@ export const ClientDetails = () => { const [client, setClient] = useState(); const loader = async () => { - return await adminClient.clients.listRoles({ id }); + const roles = await adminClient.clients.listRoles({ id }); + return roles.sort((r1, r2) => { + const r1Name = r1.name?.toUpperCase(); + const r2Name = r2.name?.toUpperCase(); + if (r1Name! < r2Name!) { + return -1; + } + if (r1Name! > r2Name!) { + return 1; + } + + return 0; + }); }; const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({