Skip to content
Prev Previous commit
Next Next commit
sorting users
  • Loading branch information
gabe-lyons authored and hsheth2 committed Jun 25, 2021
commit f1c723163d086e45a9b7a596b19d80d6a38b69ce
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Avatar, Tooltip } from 'antd';
import { UserUsageCounts } from '../../../../types.generated';

Expand All @@ -7,9 +7,11 @@ export type Props = {
};

export default function UsageFacepile({ users }: Props) {
const sortedUsers = useMemo(() => users?.slice().sort((a, b) => (b?.count || 0) - (a?.count || 0)), [users]);

return (
<Avatar.Group maxCount={2}>
{users?.map((user) => (
{sortedUsers?.map((user) => (
<Tooltip title={user?.userEmail}>
<Avatar>{user?.userEmail?.charAt(0).toUpperCase()}</Avatar>
</Tooltip>
Expand Down