2023-05-11 12:08:46 +00:00
|
|
|
// icons
|
2023-10-16 14:57:22 +00:00
|
|
|
import { Triangle } from "lucide-react";
|
2023-05-11 12:08:46 +00:00
|
|
|
// types
|
2023-09-11 06:15:28 +00:00
|
|
|
import { IDefaultAnalyticsResponse, TStateGroups } from "types";
|
2023-05-11 12:08:46 +00:00
|
|
|
// constants
|
|
|
|
import { STATE_GROUP_COLORS } from "constants/state";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
defaultAnalytics: IDefaultAnalyticsResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AnalyticsDemand: React.FC<Props> = ({ defaultAnalytics }) => (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="space-y-3 rounded-[10px] border border-custom-border-200 p-3">
|
2023-05-11 12:08:46 +00:00
|
|
|
<h5 className="text-xs text-red-500">DEMAND</h5>
|
|
|
|
<div>
|
2023-07-10 07:17:00 +00:00
|
|
|
<h4 className="text-custom-text-100 text-base font-medium">Total open tasks</h4>
|
2023-05-11 12:08:46 +00:00
|
|
|
<h3 className="mt-1 text-xl font-semibold">{defaultAnalytics.open_issues}</h3>
|
|
|
|
</div>
|
|
|
|
<div className="space-y-6">
|
2023-05-15 05:52:06 +00:00
|
|
|
{defaultAnalytics?.open_issues_classified.map((group) => {
|
2023-05-11 12:08:46 +00:00
|
|
|
const percentage = ((group.state_count / defaultAnalytics.total_issues) * 100).toFixed(0);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div key={group.state_group} className="space-y-2">
|
|
|
|
<div className="flex items-center justify-between gap-2 text-xs">
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
<span
|
|
|
|
className="h-2 w-2 rounded-full"
|
|
|
|
style={{
|
2023-09-11 06:15:28 +00:00
|
|
|
backgroundColor: STATE_GROUP_COLORS[group.state_group as TStateGroups],
|
2023-05-11 12:08:46 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<h6 className="capitalize">{group.state_group}</h6>
|
2023-07-10 07:17:00 +00:00
|
|
|
<span className="ml-1 rounded-3xl bg-custom-background-80 px-2 py-0.5 text-[0.65rem] text-custom-text-200">
|
2023-05-11 12:08:46 +00:00
|
|
|
{group.state_count}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="text-custom-text-200">{percentage}%</p>
|
2023-05-11 12:08:46 +00:00
|
|
|
</div>
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="bar relative h-1 w-full rounded bg-custom-background-80">
|
2023-05-11 12:08:46 +00:00
|
|
|
<div
|
|
|
|
className="absolute top-0 left-0 h-1 rounded duration-300"
|
|
|
|
style={{
|
|
|
|
width: `${percentage}%`,
|
2023-09-11 06:15:28 +00:00
|
|
|
backgroundColor: STATE_GROUP_COLORS[group.state_group as TStateGroups],
|
2023-05-11 12:08:46 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="!mt-6 flex w-min items-center gap-2 whitespace-nowrap rounded-md border border-custom-border-200 bg-custom-background-80 p-2 text-xs">
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="flex items-center gap-1 text-custom-text-200">
|
2023-10-16 14:57:22 +00:00
|
|
|
<Triangle className="h-4 w-4" />
|
2023-11-28 17:00:07 +00:00
|
|
|
<span>Estimate demand:</span>
|
2023-05-11 12:08:46 +00:00
|
|
|
</p>
|
|
|
|
<p className="font-medium">
|
|
|
|
{defaultAnalytics.open_estimate_sum}/{defaultAnalytics.total_estimate_sum}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|