2023-07-28 08:09:42 +00:00
|
|
|
// ui
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IUserProfileData, IUserStateDistribution } from "@plane/types";
|
|
|
|
import { ProfileEmptyState, PieGraph } from "@/components/ui";
|
2023-08-09 10:15:20 +00:00
|
|
|
// image
|
2024-03-19 14:38:35 +00:00
|
|
|
import { STATE_GROUPS } from "@/constants/state";
|
2024-06-11 09:09:52 +00:00
|
|
|
import stateGraph from "@/public/empty-state/state_graph.svg";
|
2023-07-28 08:09:42 +00:00
|
|
|
// types
|
|
|
|
// constants
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
stateDistribution: IUserStateDistribution[];
|
|
|
|
userProfile: IUserProfileData | undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ProfileStateDistribution: React.FC<Props> = ({ stateDistribution, userProfile }) => {
|
|
|
|
if (!userProfile) return null;
|
|
|
|
|
|
|
|
return (
|
2023-08-18 14:48:03 +00:00
|
|
|
<div className="flex flex-col space-y-2">
|
2024-03-06 08:54:36 +00:00
|
|
|
<h3 className="text-lg font-medium">Issues by state</h3>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex-grow rounded border border-custom-border-100 p-7">
|
2023-08-09 10:15:20 +00:00
|
|
|
{userProfile.state_distribution.length > 0 ? (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="grid grid-cols-1 gap-x-6 md:grid-cols-2">
|
2023-08-09 10:15:20 +00:00
|
|
|
<div>
|
|
|
|
<PieGraph
|
|
|
|
data={
|
|
|
|
userProfile.state_distribution.map((group) => ({
|
|
|
|
id: group.state_group,
|
|
|
|
label: group.state_group,
|
|
|
|
value: group.state_count,
|
2024-04-16 15:05:37 +00:00
|
|
|
color: STATE_GROUPS[group.state_group]?.color ?? "rgb(var(--color-primary-100))",
|
2023-08-09 10:15:20 +00:00
|
|
|
})) ?? []
|
|
|
|
}
|
|
|
|
height="250px"
|
|
|
|
innerRadius={0.6}
|
|
|
|
cornerRadius={5}
|
|
|
|
padAngle={2}
|
|
|
|
enableArcLabels
|
|
|
|
arcLabelsTextColor="#000000"
|
|
|
|
enableArcLinkLabels={false}
|
|
|
|
activeInnerRadiusOffset={5}
|
2024-04-16 15:05:37 +00:00
|
|
|
colors={(datum) => datum?.data?.color}
|
2023-08-09 10:15:20 +00:00
|
|
|
tooltip={(datum) => (
|
|
|
|
<div className="flex items-center gap-2 rounded-md border border-custom-border-200 bg-custom-background-90 p-2 text-xs">
|
2023-12-10 10:18:10 +00:00
|
|
|
<span className="capitalize text-custom-text-200">{datum.datum.label} issues:</span>{" "}
|
2023-08-09 10:15:20 +00:00
|
|
|
{datum.datum.value}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
margin={{
|
|
|
|
top: 32,
|
|
|
|
right: 0,
|
|
|
|
bottom: 32,
|
|
|
|
left: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center">
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="w-full space-y-4">
|
2023-08-09 10:15:20 +00:00
|
|
|
{stateDistribution.map((group) => (
|
2023-11-08 15:01:46 +00:00
|
|
|
<div key={group.state_group} className="flex items-center justify-between gap-2 text-xs">
|
2023-08-09 10:15:20 +00:00
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
<div
|
|
|
|
className="h-2.5 w-2.5 rounded-sm"
|
|
|
|
style={{
|
2024-04-16 15:05:37 +00:00
|
|
|
backgroundColor: STATE_GROUPS[group.state_group]?.color ?? "rgb(var(--color-primary-100))",
|
2023-08-09 10:15:20 +00:00
|
|
|
}}
|
|
|
|
/>
|
2024-03-06 08:54:36 +00:00
|
|
|
<div className="whitespace-nowrap">{STATE_GROUPS[group.state_group].label}</div>
|
2023-08-09 10:15:20 +00:00
|
|
|
</div>
|
|
|
|
<div>{group.state_count}</div>
|
2023-07-28 08:09:42 +00:00
|
|
|
</div>
|
2023-08-09 10:15:20 +00:00
|
|
|
))}
|
|
|
|
</div>
|
2023-07-28 08:09:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-09 10:15:20 +00:00
|
|
|
) : (
|
|
|
|
<ProfileEmptyState
|
|
|
|
title="No Data yet"
|
|
|
|
description="Create issues to view the them by states in the graph for better analysis."
|
|
|
|
image={stateGraph}
|
|
|
|
/>
|
|
|
|
)}
|
2023-07-28 08:09:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|