Refina métricas de tempo e filtros de alertas

This commit is contained in:
Esdras Renan 2025-10-07 23:10:16 -03:00
parent ef25cbe799
commit b880aa3ea6
3 changed files with 36 additions and 22 deletions

View file

@ -17,10 +17,12 @@ export function AdminAlertsManager() {
const [range, setRange] = useState<string>("30d")
const { session, convexUserId } = useAuth()
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
const now = new Date()
const days = range === "7d" ? 7 : range === "30d" ? 30 : range === "90d" ? 90 : null
const end = now.getTime()
const start = days ? end - days * 24 * 60 * 60 * 1000 : undefined
const { start, end } = useMemo(() => {
const daysLocal = range === "7d" ? 7 : range === "30d" ? 30 : range === "90d" ? 90 : null
const endLocal = Date.now()
const startLocal = daysLocal ? endLocal - daysLocal * 24 * 60 * 60 * 1000 : undefined
return { start: startLocal, end: endLocal }
}, [range])
const alertsRaw = useQuery(
api.alerts.list,