feat: The Other Dude v9.0.1 — full-featured email system
ci: add GitHub Pages deployment workflow for docs site Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
31
frontend/src/components/alerts/AlertBadge.tsx
Normal file
31
frontend/src/components/alerts/AlertBadge.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* AlertBadge — renders a red badge with active alert count.
|
||||
* Polls every 30 seconds. Returns null if count is 0.
|
||||
*/
|
||||
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { alertsApi } from '@/lib/alertsApi'
|
||||
import { useAuth } from '@/lib/auth'
|
||||
|
||||
export function AlertBadge() {
|
||||
const { user } = useAuth()
|
||||
const tenantId = user?.tenant_id
|
||||
|
||||
const { data } = useQuery({
|
||||
queryKey: ['alert-active-count', tenantId],
|
||||
queryFn: () => alertsApi.getActiveAlertCount(tenantId!),
|
||||
enabled: !!tenantId,
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
|
||||
if (!data?.count) return null
|
||||
|
||||
return (
|
||||
<span
|
||||
className="bg-error text-text-primary text-xs font-medium rounded-full px-1.5 py-0.5 leading-none min-w-[1.25rem] text-center"
|
||||
title={`${data.count} active alert${data.count === 1 ? '' : 's'}`}
|
||||
>
|
||||
{data.count > 99 ? '99+' : data.count}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user