teqo-backup/src/lib/notificationContract.ts
Francisco Solla c3f10cce23 feat(C108): sino de notificações — abrir marca tudo como lido, painel limpo, modal central no desktop
openCampaignNotifications (lista + marca em 1 round trip) substitui
listCampaignNotifications + markAllCampaignNotificationsRead; markAllNotificationsRead
extraída (owner-scoped, idempotente, cap 200) com int test; bell vira Dialog
desktop / Drawer mobile (par C94), sem título/rodapé/botões, skeleton de
loading, safe-area, focus-visible, role=alert; readAt sai do contrato do item;
P4-D ledger atualizado (batch sem transação agora no hot path, self-healing).
2026-08-10 02:56:20 -03:00

34 lines
982 B
TypeScript

/** Payload `req.context` flag — domain hooks skip creating notifications when true. */
export const SKIP_CAMPAIGN_NOTIFICATION_CONTEXT_KEY = 'skipCampaignNotification'
/** Opt back into hook-fired notifications inside Vitest (default: skipped). */
export const ENABLE_CAMPAIGN_NOTIFICATION_CONTEXT_KEY = 'enableCampaignNotification'
export const notificationTypes = [
'municipality_update',
'new_supporter',
'activity_attention',
'invite_accepted',
] as const
export type NotificationType = (typeof notificationTypes)[number]
export type NotificationPayload = {
title: string
detail: string
href: string
}
export type NotificationListItem = {
id: number
type: NotificationType
payload: NotificationPayload
createdAt: string
}
export const notificationTypeLabels: Record<NotificationType, string> = {
municipality_update: 'Reporte de campo',
new_supporter: 'Novo apoiador',
activity_attention: 'Atividade',
invite_accepted: 'Convite aceito',
}