forked from github/plane
c16a5b9b71
* restructure the logic to avoid throwing error if any dat is not found * updated files for previous commit * fix build errors * remove throwing error if userId is undefined * optionally chain display_name property to fix sentry issues * add ooptional check * change issue action logic to increase code maintainability and make sure to send only the updated date while updating the issue * fix issue updation bugs * fix module issues build error * fix runtime errors
62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
// ui
|
|
import { ProfileEmptyState } from "components/ui";
|
|
// image
|
|
import emptyUsers from "public/empty-state/empty_users.svg";
|
|
|
|
type Props = {
|
|
users: {
|
|
avatar: string | null;
|
|
display_name: string | null;
|
|
firstName: string;
|
|
lastName: string;
|
|
count: number;
|
|
id: string;
|
|
}[];
|
|
title: string;
|
|
emptyStateMessage: string;
|
|
workspaceSlug: string;
|
|
};
|
|
|
|
export const AnalyticsLeaderBoard: React.FC<Props> = ({ users, title, emptyStateMessage, workspaceSlug }) => (
|
|
<div className="rounded-[10px] border border-custom-border-200 p-3">
|
|
<h6 className="text-base font-medium">{title}</h6>
|
|
{users.length > 0 ? (
|
|
<div className="mt-3 space-y-3">
|
|
{users.map((user) => (
|
|
<a
|
|
key={user?.display_name ?? "None"}
|
|
href={`/${workspaceSlug}/profile/${user.id}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="flex items-start justify-between gap-4 text-xs"
|
|
>
|
|
<div className="flex items-center gap-2">
|
|
{user && user.avatar && user.avatar !== "" ? (
|
|
<div className="relative h-4 w-4 flex-shrink-0 rounded-full">
|
|
<img
|
|
src={user.avatar}
|
|
className="absolute left-0 top-0 h-full w-full rounded-full object-cover"
|
|
alt={user?.display_name ?? "None"}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<div className="grid h-4 w-4 flex-shrink-0 place-items-center rounded-full bg-gray-700 text-[11px] capitalize text-white">
|
|
{user?.display_name !== "" ? user?.display_name?.[0] : "?"}
|
|
</div>
|
|
)}
|
|
<span className="break-words text-custom-text-200">
|
|
{user?.display_name !== "" ? `${user?.display_name}` : "No assignee"}
|
|
</span>
|
|
</div>
|
|
<span className="flex-shrink-0">{user.count}</span>
|
|
</a>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<div className="px-7 py-4">
|
|
<ProfileEmptyState title="No Data yet" description={emptyStateMessage} image={emptyUsers} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|