From e2a5b560b1e547be109237d6d34eade87bce1911 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Tue, 7 Oct 2025 17:51:12 -0300 Subject: [PATCH] =?UTF-8?q?views:=20substituir=20CSAT=20pizza=20por=20pizz?= =?UTF-8?q?a=20de=20prioridade=20do=20backlog=20(com=20LabelList,=20toolti?= =?UTF-8?q?p,=20filtros=20de=20empresa=20e=20per=C3=ADodo)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/charts/views-charts.tsx | 77 +++++++++++++++++--------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/src/components/charts/views-charts.tsx b/src/components/charts/views-charts.tsx index 300109f..ce426e7 100644 --- a/src/components/charts/views-charts.tsx +++ b/src/components/charts/views-charts.tsx @@ -17,58 +17,84 @@ import { Skeleton } from "@/components/ui/skeleton" export function ViewsCharts() { return (
- +
) } -function CsatPie() { +function BacklogPriorityPie() { const [companyId, setCompanyId] = usePersistentCompanyFilter("all") + const [timeRange, setTimeRange] = React.useState("30d") const { session, convexUserId } = useAuth() const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID const data = useQuery( - api.reports.csatOverview, + api.reports.backlogOverview, convexUserId - ? ({ tenantId, viewerId: convexUserId as Id<"users">, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) }) + ? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) }) : "skip" - ) as { totalSurveys: number; distribution: { score: number; total: number }[] } | undefined + ) as { priorityCounts: Record } | undefined const companies = useQuery(api.companies.list, convexUserId ? { tenantId, viewerId: convexUserId as Id<"users"> } : "skip") as Array<{ id: Id<"companies">; name: string }> | undefined if (!data) return - const chartData = (data.distribution ?? []).map((d) => ({ score: `Nota ${d.score}`, total: d.total })) - const chartConfig: any = { total: { label: "Respostas" } } + const PRIORITY_LABELS: Record = { LOW: "Baixa", MEDIUM: "Média", HIGH: "Alta", URGENT: "Crítica" } + const keys = ["LOW", "MEDIUM", "HIGH", "URGENT"] + const fills = { + LOW: "var(--chart-1)", + MEDIUM: "var(--chart-2)", + HIGH: "var(--chart-3)", + URGENT: "var(--chart-4)", + } as const + const chartData = keys + .map((k) => ({ name: PRIORITY_LABELS[k] ?? k, value: data.priorityCounts?.[k] ?? 0, fill: fills[k as keyof typeof fills] })) + .filter((d) => d.value > 0) + const chartConfig: any = { value: { label: "Tickets" } } return ( - CSAT - Distribuição - Frequência de respostas por nota + Backlog por prioridade + Distribuição de tickets no período - +
+ + +
{chartData.length === 0 ? (
- Sem respostas no período. + Sem dados no período selecionado.
) : ( - + - } /> - - + } /> + + @@ -132,4 +158,3 @@ function QueuesOpenBar() {
) } -