Atualiza portal e admin com bloqueio de máquinas desativadas
This commit is contained in:
parent
e5085962e9
commit
630110bf3a
31 changed files with 1756 additions and 244 deletions
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
import { useMemo } from "react"
|
||||
import { useQuery } from "convex/react"
|
||||
import { IconClockHour4, IconMessages, IconTrendingDown, IconTrendingUp } from "@tabler/icons-react"
|
||||
import { IconClockHour4, IconTrendingDown, IconTrendingUp } from "@tabler/icons-react"
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { useAuth } from "@/lib/auth-client"
|
||||
import { DEFAULT_TENANT_ID } from "@/lib/constants"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import {
|
||||
Card,
|
||||
|
|
@ -27,11 +28,6 @@ function formatMinutes(value: number | null) {
|
|||
return `${hours}h ${minutes}min`
|
||||
}
|
||||
|
||||
function formatScore(value: number | null) {
|
||||
if (value === null) return "—"
|
||||
return value.toFixed(2)
|
||||
}
|
||||
|
||||
export function SectionCards() {
|
||||
const { session, convexUserId, isStaff } = useAuth()
|
||||
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
|
|
@ -65,6 +61,29 @@ export function SectionCards() {
|
|||
|
||||
const TrendIcon = trendInfo.icon
|
||||
|
||||
const resolutionInfo = useMemo(() => {
|
||||
if (!dashboard?.resolution) {
|
||||
return {
|
||||
positive: true,
|
||||
badgeLabel: "Sem histórico",
|
||||
rateLabel: "Taxa indisponível",
|
||||
}
|
||||
}
|
||||
const current = dashboard.resolution.resolvedLast7d ?? 0
|
||||
const previous = dashboard.resolution.previousResolved ?? 0
|
||||
const deltaPercentage = dashboard.resolution.deltaPercentage ?? null
|
||||
const positive = deltaPercentage !== null ? deltaPercentage >= 0 : current >= previous
|
||||
const badgeLabel = deltaPercentage !== null
|
||||
? `${deltaPercentage >= 0 ? "+" : ""}${deltaPercentage.toFixed(1)}%`
|
||||
: previous > 0
|
||||
? `${current - previous >= 0 ? "+" : ""}${current - previous}`
|
||||
: "Sem histórico"
|
||||
const rateLabel = dashboard.resolution.rate !== null
|
||||
? `${dashboard.resolution.rate.toFixed(1)}% dos tickets foram resolvidos`
|
||||
: "Taxa indisponível"
|
||||
return { positive, badgeLabel, rateLabel }
|
||||
}, [dashboard])
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-4 px-4 sm:grid-cols-2 xl:grid-cols-4 xl:px-8">
|
||||
<Card className="@container/card border border-border/60 bg-gradient-to-br from-white/90 via-white to-primary/5 p-5 shadow-sm">
|
||||
|
|
@ -150,20 +169,30 @@ export function SectionCards() {
|
|||
|
||||
<Card className="@container/card border border-border/60 bg-gradient-to-br from-white/90 via-white to-primary/5 p-5 shadow-sm">
|
||||
<CardHeader className="gap-3">
|
||||
<CardDescription>CSAT recente</CardDescription>
|
||||
<CardDescription>Tickets resolvidos (7 dias)</CardDescription>
|
||||
<CardTitle className="text-3xl font-semibold tabular-nums">
|
||||
{dashboard ? formatScore(dashboard.csat.averageScore) : <Skeleton className="h-8 w-12" />}
|
||||
{dashboard ? dashboard.resolution.resolvedLast7d : <Skeleton className="h-8 w-12" />}
|
||||
</CardTitle>
|
||||
<CardAction>
|
||||
<Badge variant="outline" className="rounded-full gap-1 px-2 py-1 text-xs">
|
||||
<IconMessages className="size-3.5" />
|
||||
{dashboard ? `${dashboard.csat.totalSurveys} pesquisas` : "—"}
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"rounded-full gap-1 px-2 py-1 text-xs",
|
||||
resolutionInfo.positive ? "text-emerald-600" : "text-amber-600"
|
||||
)}
|
||||
>
|
||||
{resolutionInfo.positive ? (
|
||||
<IconTrendingUp className="size-3.5" />
|
||||
) : (
|
||||
<IconTrendingDown className="size-3.5" />
|
||||
)}
|
||||
{resolutionInfo.badgeLabel}
|
||||
</Badge>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
<CardFooter className="flex-col items-start gap-1 text-sm text-muted-foreground">
|
||||
<span className="text-foreground">Notas de satisfação recebidas nos últimos períodos.</span>
|
||||
<span>Escala de 1 a 5 pontos.</span>
|
||||
<span className="text-foreground">{resolutionInfo.rateLabel}</span>
|
||||
<span>Comparação com os 7 dias anteriores.</span>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue