2023-05-15 05:52:06 +00:00
|
|
|
type Props = {
|
|
|
|
users: {
|
|
|
|
avatar: string | null;
|
2023-05-16 09:41:40 +00:00
|
|
|
email: string | null;
|
2023-05-16 05:11:37 +00:00
|
|
|
firstName: string;
|
|
|
|
lastName: string;
|
2023-05-15 05:52:06 +00:00
|
|
|
count: number;
|
|
|
|
}[];
|
|
|
|
title: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AnalyticsLeaderboard: React.FC<Props> = ({ users, title }) => (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="p-3 border border-custom-border-200 rounded-[10px]">
|
2023-05-15 05:52:06 +00:00
|
|
|
<h6 className="text-base font-medium">{title}</h6>
|
2023-05-17 07:55:58 +00:00
|
|
|
{users.length > 0 ? (
|
|
|
|
<div className="mt-3 space-y-3">
|
|
|
|
{users.map((user) => (
|
|
|
|
<div
|
|
|
|
key={user.email ?? "None"}
|
|
|
|
className="flex items-start justify-between gap-4 text-xs"
|
|
|
|
>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
{user && user.avatar && user.avatar !== "" ? (
|
2023-06-06 20:26:21 +00:00
|
|
|
<div className="relative rounded-full h-4 w-4 flex-shrink-0">
|
|
|
|
<img
|
2023-05-17 07:55:58 +00:00
|
|
|
src={user.avatar}
|
2023-06-06 20:26:21 +00:00
|
|
|
className="absolute top-0 left-0 h-full w-full object-cover rounded-full"
|
2023-05-17 07:55:58 +00:00
|
|
|
alt={user.email ?? "None"}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="grid place-items-center flex-shrink-0 rounded-full bg-gray-700 text-[11px] capitalize text-white h-4 w-4">
|
|
|
|
{user.firstName !== "" ? user.firstName[0] : "?"}
|
|
|
|
</div>
|
|
|
|
)}
|
2023-07-10 07:17:00 +00:00
|
|
|
<span className="break-words text-custom-text-200">
|
2023-05-17 07:55:58 +00:00
|
|
|
{user.firstName !== "" ? `${user.firstName} ${user.lastName}` : "No assignee"}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span className="flex-shrink-0">{user.count}</span>
|
2023-05-15 05:52:06 +00:00
|
|
|
</div>
|
2023-05-17 07:55:58 +00:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
) : (
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="text-custom-text-200 text-center text-sm py-8">No matching data found.</div>
|
2023-05-17 07:55:58 +00:00
|
|
|
)}
|
2023-05-15 05:52:06 +00:00
|
|
|
</div>
|
|
|
|
);
|