diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/(overview)/components/policy-status-chart.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/(overview)/components/policy-status-chart.tsx
index 205af251fb..ca063c0d07 100644
--- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/(overview)/components/policy-status-chart.tsx
+++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/(overview)/components/policy-status-chart.tsx
@@ -4,262 +4,262 @@ import * as React from "react";
import { Pie, PieChart, Label, Tooltip, ResponsiveContainer } from "recharts";
import {
- Card,
- CardContent,
- CardHeader,
- CardFooter,
- CardTitle,
+ Card,
+ CardContent,
+ CardHeader,
+ CardFooter,
+ CardTitle,
} from "@comp/ui/card";
import {
- type ChartConfig,
- ChartContainer,
- ChartTooltip,
- ChartTooltipContent,
+ type ChartConfig,
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
} from "@comp/ui/chart";
import { useI18n } from "@/locales/client";
import { Badge } from "@comp/ui/badge";
import {
- PieChart as PieChartIcon,
- BarChart as ChartIcon,
- Info,
+ PieChart as PieChartIcon,
+ BarChart as ChartIcon,
+ Info,
} from "lucide-react";
interface PolicyOverviewData {
- totalPolicies: number;
- publishedPolicies: number;
- draftPolicies: number;
- archivedPolicies: number;
- needsReviewPolicies: number;
+ totalPolicies: number;
+ publishedPolicies: number;
+ draftPolicies: number;
+ archivedPolicies: number;
+ needsReviewPolicies: number;
}
interface PolicyStatusChartProps {
- data?: PolicyOverviewData | null;
+ data?: PolicyOverviewData | null;
}
const CHART_COLORS = {
- published: "hsl(var(--chart-positive))", // green
- draft: "hsl(var(--chart-neutral))", // yellow
- archived: "hsl(var(--chart-warning))", // gray
- needs_review: "hsl(var(--chart-destructive))", // red
+ published: "hsl(var(--chart-positive))", // green
+ draft: "hsl(var(--chart-neutral))", // yellow
+ archived: "hsl(var(--chart-warning))", // gray
+ needs_review: "hsl(var(--chart-destructive))", // red
};
// Custom tooltip component for the pie chart
const StatusTooltip = ({ active, payload }: any) => {
- if (active && payload && payload.length) {
- const data = payload[0].payload;
- return (
-
-
{data.name}
-
- Count: {data.value}
-
-
- );
- }
- return null;
+ if (active && payload && payload.length) {
+ const data = payload[0].payload;
+ return (
+
+
{data.name}
+
+ Count: {data.value}
+
+
+ );
+ }
+ return null;
};
export function PolicyStatusChart({ data }: PolicyStatusChartProps) {
- const t = useI18n();
+ const t = useI18n();
- if (!data) {
- return (
-
-
-
-
-
-
- {t("policies.dashboard.policy_status") || "Policy Status"}
-
-
-
- {t("common.status.overview")}
-
-
-
-
-
-
-
-
-
- No policy data available
-
-
-
-
-
-
-
- );
- }
+ if (!data) {
+ return (
+
+
+
+
+
+
+ {t("policies.dashboard.policy_status") || "Policy Status"}
+
+
+
+ {t("policies.dashboard.policy_status")}
+
+
+
+
+
+
+
+
+
+ No policy data available
+
+
+
+
+
+
+
+ );
+ }
- const chartData = React.useMemo(() => {
- const items = [
- {
- name: t("policies.status.published"),
- value: data.publishedPolicies,
- fill: CHART_COLORS.published,
- },
- {
- name: t("policies.status.draft"),
- value: data.draftPolicies,
- fill: CHART_COLORS.draft,
- },
- {
- name: t("policies.status.archived"),
- value: data.archivedPolicies,
- fill: CHART_COLORS.archived,
- },
- {
- name: t("policies.status.needs_review"),
- value: data.needsReviewPolicies,
- fill: CHART_COLORS.needs_review,
- },
- ];
+ const chartData = React.useMemo(() => {
+ const items = [
+ {
+ name: t("policies.status.published"),
+ value: data.publishedPolicies,
+ fill: CHART_COLORS.published,
+ },
+ {
+ name: t("policies.status.draft"),
+ value: data.draftPolicies,
+ fill: CHART_COLORS.draft,
+ },
+ {
+ name: t("policies.status.archived"),
+ value: data.archivedPolicies,
+ fill: CHART_COLORS.archived,
+ },
+ {
+ name: t("policies.status.needs_review"),
+ value: data.needsReviewPolicies,
+ fill: CHART_COLORS.needs_review,
+ },
+ ];
- return items.filter((item) => item.value);
- }, [data, t]);
+ return items.filter((item) => item.value);
+ }, [data, t]);
- const chartConfig = {
- value: {
- label: "Count",
- },
- } satisfies ChartConfig;
+ const chartConfig = {
+ value: {
+ label: "Count",
+ },
+ } satisfies ChartConfig;
- // Calculate most common status
- const mostCommonStatus = React.useMemo(() => {
- if (!chartData.length) return null;
- return chartData.reduce((prev, current) =>
- prev.value > current.value ? prev : current,
- );
- }, [chartData]);
+ // Calculate most common status
+ const mostCommonStatus = React.useMemo(() => {
+ if (!chartData.length) return null;
+ return chartData.reduce((prev, current) =>
+ prev.value > current.value ? prev : current,
+ );
+ }, [chartData]);
- return (
-
-
-
-
-
-
- {t("policies.dashboard.policy_status") || "Policy Status"}
-
-
- {data.totalPolicies > 0 && mostCommonStatus && (
-
- Most: {mostCommonStatus.name}
-
- )}
-
+ return (
+
+
+
+
+
+
+ {t("policies.dashboard.policy_status") || "Policy Status"}
+
+
+ {data.totalPolicies > 0 && mostCommonStatus && (
+
+ Most: {mostCommonStatus.name}
+
+ )}
+
-
-
-
-
-
- } />
-
-
-
-
-
-
-
- {chartData.map((entry) => (
-
-
-
- {entry.name}
-
- ({entry.value})
-
-
-
- ))}
-
-
-
- );
+
+
+
+
+
+ } />
+
+
+
+
+
+
+
+ {chartData.map((entry) => (
+
+
+
+ {entry.name}
+
+ ({entry.value})
+
+
+
+ ))}
+
+
+
+ );
}