@burdenoff/microfe-notification 2026.830.2 → 2026.1013.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendNotification.js","names":[],"sources":["../../src/hooks/useSendNotification.ts"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n TriggerNotificationMutation,\n TriggerNotificationWithTemplateMutation,\n TriggerBatchNotificationsMutation,\n} from '../generated/global-operations';\n\n// =============================================================================\n// Type Definitions (aligned with backend GraphQL schema)\n// =============================================================================\n\nexport type NotificationChannelType =\n 'DISCORD' | 'EMAIL' | 'PUSH' | 'SLACK' | 'SMS' | 'TEAMS' | 'TELEGRAM' | 'WEBHOOK' | 'WHATSAPP';\n\nexport type NotificationTypeEnum = 'ALERT' | 'MARKETING' | 'SYSTEM' | 'TRANSACTIONAL';\n\nexport type NotificationPriorityEnum = 'HIGH' | 'LOW' | 'MEDIUM' | 'URGENT';\n\nexport type NotificationStatusEnum =\n | 'CANCELLED'\n | 'DELIVERED'\n | 'DRAFT'\n | 'EXPIRED'\n | 'FAILED'\n | 'PENDING'\n | 'READ'\n | 'SCHEDULED'\n | 'SENT'\n | 'TRIGGERED';\n\nexport type NotificationDeliveryStatusEnum =\n | 'BOUNCED'\n | 'CLICKED'\n | 'COMPLAINED'\n | 'DELIVERED'\n | 'DELIVERING'\n | 'FAILED'\n | 'OPENED'\n | 'PENDING'\n | 'PROCESSING'\n | 'QUEUED'\n | 'RETRYING'\n | 'SENT'\n | 'UNSUBSCRIBED';\n\nexport type TriggerStatusEnum = 'CANCELLED' | 'FAILED' | 'PENDING' | 'TRIGGERED';\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface CreateNotificationInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n appName?: string;\n body: string;\n channel: NotificationChannelType;\n data?: Record<string, unknown>;\n expiresAt?: string;\n htmlBody?: string;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n metadata?: Record<string, unknown>;\n priority?: NotificationPriorityEnum;\n recipient: RecipientInput;\n redirectUrl?: string;\n subject?: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n topicId?: string;\n type?: NotificationTypeEnum;\n}\n\nexport interface TriggerNotificationInput {\n notificationId?: string;\n notification?: CreateNotificationInput;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n}\n\nexport interface TemplateNotificationResult {\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n notifications: TriggerNotificationResult[];\n}\n\nexport interface TriggerWithTemplateInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n expiresAt?: string;\n redirectUrl?: string;\n priority?: NotificationPriorityEnum;\n /** Single recipient (use this OR recipients, not both) */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery (use this OR recipient, not both) */\n recipients?: RecipientInput[];\n templateSlug: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n topicId?: string;\n variables: Record<string, unknown>;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerBatchInput {\n notificationIds?: string[];\n notifications?: CreateNotificationInput[];\n priority?: NotificationPriorityEnum;\n delayBetweenBatches?: number;\n batchSize?: number;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerNotificationResult {\n id: string;\n status: NotificationStatusEnum;\n deliveryStatus?: NotificationDeliveryStatusEnum;\n triggerStatus: TriggerStatusEnum;\n sentAt?: string;\n title: string;\n message: string;\n}\n\nexport interface BatchNotificationResult {\n batchId: string;\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n successCount: number;\n failureCount: number;\n results: Record<string, unknown>;\n}\n\n// =============================================================================\n\n/**\n * Hook to send notifications\n * Provides methods for triggering single, batch, and template-based notifications\n */\nexport function useSendNotification() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [isLoading, _setIsLoading] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [lastResult, setLastResult] = useState<\n TriggerNotificationResult | BatchNotificationResult | TemplateNotificationResult | null\n >(null);\n\n // Get global client — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n /**\n * Send a single notification.\n * @throws the underlying GraphQL/network error after setting the hook's `error` state, so callers can inspect it (e.g. detect gateway FORBIDDEN via `isPermissionError`).\n */\n const sendNotification = useCallback(\n async (input: TriggerNotificationInput): Promise<TriggerNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationMutation>({\n mutation: NotificationOps.TriggerNotificationDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotification ?? null;\n if (!raw) return null;\n const notification: TriggerNotificationResult = {\n id: raw.id,\n status: raw.status as unknown as NotificationStatusEnum,\n deliveryStatus: (raw.deliveryStatus ?? undefined) as\n NotificationDeliveryStatusEnum | undefined,\n triggerStatus: raw.triggerStatus as unknown as TriggerStatusEnum,\n sentAt: raw.sentAt ?? undefined,\n title: raw.title,\n message: raw.message,\n };\n setLastResult(notification);\n return notification;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send notification';\n console.error('[useSendNotification] Failed to send notification:', err);\n setError(message);\n // Re-throw so the caller's catch block can inspect the raw error (e.g.,\n // detect gateway FORBIDDEN via isPermissionError) — matches the\n // useNotificationTemplates pattern.\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notification using a template. Supports single recipient (recipient) or bulk delivery (recipients).\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendWithTemplate = useCallback(\n async (input: TriggerWithTemplateInput): Promise<TemplateNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationWithTemplateMutation>({\n mutation: NotificationOps.TriggerNotificationWithTemplateDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotificationWithTemplate ?? null;\n if (!raw) return null;\n const templateResult: TemplateNotificationResult = {\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n notifications: raw.notifications.map((n) => ({\n id: n.id,\n status: n.status as unknown as NotificationStatusEnum,\n deliveryStatus: undefined,\n triggerStatus: 'TRIGGERED' as TriggerStatusEnum,\n sentAt: n.sentAt ?? undefined,\n title: n.title,\n message: n.message,\n })),\n };\n setLastResult(templateResult);\n return templateResult;\n } catch (err: unknown) {\n const message =\n err instanceof Error ? err.message : 'Failed to send notification with template';\n console.error('[useSendNotification] Failed to send notification with template:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notifications to multiple recipients.\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendBatch = useCallback(\n async (input: TriggerBatchInput): Promise<BatchNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerBatchNotificationsMutation>({\n mutation: NotificationOps.TriggerBatchNotificationsDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerBatchNotifications ?? null;\n if (!raw) return null;\n const batchResult: BatchNotificationResult = {\n batchId: raw.batchId,\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n successCount: raw.totalTriggered,\n failureCount: raw.totalFailed,\n results: raw.results,\n };\n setLastResult(batchResult);\n return batchResult;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send batch notifications';\n console.error('[useSendNotification] Failed to send batch notifications:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Helper: Send a simple notification to one recipient\n * Simplified interface for common use case\n */\n const sendSimple = useCallback(\n async (params: {\n recipient: RecipientInput;\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<TriggerNotificationResult | null> => {\n return sendNotification({\n notification: {\n body: params.body,\n channel: params.channel,\n recipient: params.recipient,\n subject: params.subject,\n type: params.type || 'TRANSACTIONAL',\n priority: params.priority || 'MEDIUM',\n },\n platform: params.channel,\n });\n },\n [sendNotification]\n );\n\n /**\n * Helper: Send to multiple recipients with same message\n */\n const sendToMultiple = useCallback(\n async (params: {\n recipients: RecipientInput[];\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<BatchNotificationResult | null> => {\n const notifications: CreateNotificationInput[] = params.recipients.map((recipient) => ({\n body: params.body,\n channel: params.channel,\n recipient,\n subject: params.subject,\n type: params.type || 'MARKETING',\n priority: params.priority || 'MEDIUM',\n }));\n\n return sendBatch({ notifications });\n },\n [sendBatch]\n );\n\n /**\n * Clear error state\n */\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n /**\n * Clear last result\n */\n const clearResult = useCallback(() => {\n setLastResult(null);\n }, []);\n\n return {\n // State\n isLoading,\n isSending,\n error,\n lastResult,\n\n // Core methods\n sendNotification,\n sendWithTemplate,\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,UAAU,EAAO,YAAY;IAC9B;GACD,UAAU,EAAO;GAClB,CAAC,EAEJ,CAAC,EAAiB,CACnB;EAwDC,gBAnDqB,EACrB,OAAO,MAiBE,EAAU,EAAE,eAT8B,EAAO,WAAW,KAAK,OAAe;GACrF,MAAM,EAAO;GACb,SAAS,EAAO;GAChB;GACA,SAAS,EAAO;GAChB,MAAM,EAAO,QAAQ;GACrB,UAAU,EAAO,YAAY;GAC9B,EAAE,EAE+B,CAAC,EAErC,CAAC,EAAU,CACZ;EAiCC,YA5BiB,QAAkB;AACnC,KAAS,KAAK;KACb,EAAE,CAAC;EA2BJ,aAtBkB,QAAkB;AACpC,KAAc,KAAK;KAClB,EAAE,CAAC;EAqBL"}
|
|
1
|
+
{"version":3,"file":"useSendNotification.js","names":[],"sources":["../../src/hooks/useSendNotification.ts"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n TriggerNotificationMutation,\n TriggerNotificationWithTemplateMutation,\n TriggerBatchNotificationsMutation,\n} from '../generated/global-operations';\n\n// =============================================================================\n// Type Definitions (aligned with backend GraphQL schema)\n// =============================================================================\n\nexport type NotificationChannelType =\n | 'DISCORD'\n | 'EMAIL'\n | 'PUSH'\n | 'SLACK'\n | 'SMS'\n | 'TEAMS'\n | 'TELEGRAM'\n | 'WEBHOOK'\n | 'WHATSAPP';\n\nexport type NotificationTypeEnum = 'ALERT' | 'MARKETING' | 'SYSTEM' | 'TRANSACTIONAL';\n\nexport type NotificationPriorityEnum = 'HIGH' | 'LOW' | 'MEDIUM' | 'URGENT';\n\nexport type NotificationStatusEnum =\n | 'CANCELLED'\n | 'DELIVERED'\n | 'DRAFT'\n | 'EXPIRED'\n | 'FAILED'\n | 'PENDING'\n | 'READ'\n | 'SCHEDULED'\n | 'SENT'\n | 'TRIGGERED';\n\nexport type NotificationDeliveryStatusEnum =\n | 'BOUNCED'\n | 'CLICKED'\n | 'COMPLAINED'\n | 'DELIVERED'\n | 'DELIVERING'\n | 'FAILED'\n | 'OPENED'\n | 'PENDING'\n | 'PROCESSING'\n | 'QUEUED'\n | 'RETRYING'\n | 'SENT'\n | 'UNSUBSCRIBED';\n\nexport type TriggerStatusEnum = 'CANCELLED' | 'FAILED' | 'PENDING' | 'TRIGGERED';\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface CreateNotificationInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n appName?: string;\n body: string;\n channel: NotificationChannelType;\n data?: Record<string, unknown>;\n expiresAt?: string;\n htmlBody?: string;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n metadata?: Record<string, unknown>;\n priority?: NotificationPriorityEnum;\n recipient: RecipientInput;\n redirectUrl?: string;\n subject?: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n topicId?: string;\n type?: NotificationTypeEnum;\n}\n\nexport interface TriggerNotificationInput {\n notificationId?: string;\n notification?: CreateNotificationInput;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n}\n\nexport interface TemplateNotificationResult {\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n notifications: TriggerNotificationResult[];\n}\n\nexport interface TriggerWithTemplateInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n expiresAt?: string;\n redirectUrl?: string;\n priority?: NotificationPriorityEnum;\n /** Single recipient (use this OR recipients, not both) */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery (use this OR recipient, not both) */\n recipients?: RecipientInput[];\n templateSlug: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n topicId?: string;\n variables: Record<string, unknown>;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerBatchInput {\n notificationIds?: string[];\n notifications?: CreateNotificationInput[];\n priority?: NotificationPriorityEnum;\n delayBetweenBatches?: number;\n batchSize?: number;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerNotificationResult {\n id: string;\n status: NotificationStatusEnum;\n deliveryStatus?: NotificationDeliveryStatusEnum;\n triggerStatus: TriggerStatusEnum;\n sentAt?: string;\n title: string;\n message: string;\n}\n\nexport interface BatchNotificationResult {\n batchId: string;\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n successCount: number;\n failureCount: number;\n results: Record<string, unknown>;\n}\n\n// =============================================================================\n\n/**\n * Hook to send notifications\n * Provides methods for triggering single, batch, and template-based notifications\n */\nexport function useSendNotification() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [isLoading, _setIsLoading] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [lastResult, setLastResult] = useState<\n TriggerNotificationResult | BatchNotificationResult | TemplateNotificationResult | null\n >(null);\n\n // Get global client — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n /**\n * Send a single notification.\n * @throws the underlying GraphQL/network error after setting the hook's `error` state, so callers can inspect it (e.g. detect gateway FORBIDDEN via `isPermissionError`).\n */\n const sendNotification = useCallback(\n async (input: TriggerNotificationInput): Promise<TriggerNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationMutation>({\n mutation: NotificationOps.TriggerNotificationDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotification ?? null;\n if (!raw) return null;\n const notification: TriggerNotificationResult = {\n id: raw.id,\n status: raw.status as unknown as NotificationStatusEnum,\n deliveryStatus: (raw.deliveryStatus ?? undefined) as\n | NotificationDeliveryStatusEnum\n | undefined,\n triggerStatus: raw.triggerStatus as unknown as TriggerStatusEnum,\n sentAt: raw.sentAt ?? undefined,\n title: raw.title,\n message: raw.message,\n };\n setLastResult(notification);\n return notification;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send notification';\n console.error('[useSendNotification] Failed to send notification:', err);\n setError(message);\n // Re-throw so the caller's catch block can inspect the raw error (e.g.,\n // detect gateway FORBIDDEN via isPermissionError) — matches the\n // useNotificationTemplates pattern.\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notification using a template. Supports single recipient (recipient) or bulk delivery (recipients).\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendWithTemplate = useCallback(\n async (input: TriggerWithTemplateInput): Promise<TemplateNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationWithTemplateMutation>({\n mutation: NotificationOps.TriggerNotificationWithTemplateDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotificationWithTemplate ?? null;\n if (!raw) return null;\n const templateResult: TemplateNotificationResult = {\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n notifications: raw.notifications.map((n) => ({\n id: n.id,\n status: n.status as unknown as NotificationStatusEnum,\n deliveryStatus: undefined,\n triggerStatus: 'TRIGGERED' as TriggerStatusEnum,\n sentAt: n.sentAt ?? undefined,\n title: n.title,\n message: n.message,\n })),\n };\n setLastResult(templateResult);\n return templateResult;\n } catch (err: unknown) {\n const message =\n err instanceof Error ? err.message : 'Failed to send notification with template';\n console.error('[useSendNotification] Failed to send notification with template:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notifications to multiple recipients.\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendBatch = useCallback(\n async (input: TriggerBatchInput): Promise<BatchNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerBatchNotificationsMutation>({\n mutation: NotificationOps.TriggerBatchNotificationsDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerBatchNotifications ?? null;\n if (!raw) return null;\n const batchResult: BatchNotificationResult = {\n batchId: raw.batchId,\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n successCount: raw.totalTriggered,\n failureCount: raw.totalFailed,\n results: raw.results,\n };\n setLastResult(batchResult);\n return batchResult;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send batch notifications';\n console.error('[useSendNotification] Failed to send batch notifications:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Helper: Send a simple notification to one recipient\n * Simplified interface for common use case\n */\n const sendSimple = useCallback(\n async (params: {\n recipient: RecipientInput;\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<TriggerNotificationResult | null> => {\n return sendNotification({\n notification: {\n body: params.body,\n channel: params.channel,\n recipient: params.recipient,\n subject: params.subject,\n type: params.type || 'TRANSACTIONAL',\n priority: params.priority || 'MEDIUM',\n },\n platform: params.channel,\n });\n },\n [sendNotification]\n );\n\n /**\n * Helper: Send to multiple recipients with same message\n */\n const sendToMultiple = useCallback(\n async (params: {\n recipients: RecipientInput[];\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<BatchNotificationResult | null> => {\n const notifications: CreateNotificationInput[] = params.recipients.map((recipient) => ({\n body: params.body,\n channel: params.channel,\n recipient,\n subject: params.subject,\n type: params.type || 'MARKETING',\n priority: params.priority || 'MEDIUM',\n }));\n\n return sendBatch({ notifications });\n },\n [sendBatch]\n );\n\n /**\n * Clear error state\n */\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n /**\n * Clear last result\n */\n const clearResult = useCallback(() => {\n setLastResult(null);\n }, []);\n\n return {\n // State\n isLoading,\n isSending,\n error,\n lastResult,\n\n // Core methods\n sendNotification,\n sendWithTemplate,\n sendBatch,\n\n // Helper methods\n sendSimple,\n sendToMultiple,\n\n // Utilities\n clearError,\n clearResult,\n };\n}\n"],"mappings":";;;;;AAiMA,SAAgB,IAAsB;CACpC,IAAM,EAAE,cAAW,qBAAkB,GAAiB,EAChD,CAAC,GAAW,KAAiB,EAAS,GAAM,EAC5C,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAY,KAAiB,EAElC,KAAK,EAGD,IAAY,QACT,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,EACrF,CAAC,GAAe,EAAU,CAAC,EAMxB,IAAmB,EACvB,OAAO,MAA+E;AAEpF,EADA,EAAa,GAAK,EAClB,EAAS,KAAK;AAEd,MAAI;GAOF,IAAM,KALS,MADA,GAAW,CACE,OAAoC;IAC9D,UAAU;IACV,WAAW,EAAE,UAAO;IACrB,CAAC,EAEiB,MAAM,uBAAuB;AAChD,OAAI,CAAC,EAAK,QAAO;GACjB,IAAM,IAA0C;IAC9C,IAAI,EAAI;IACR,QAAQ,EAAI;IACZ,gBAAiB,EAAI,kBAAkB,KAAA;IAGvC,eAAe,EAAI;IACnB,QAAQ,EAAI,UAAU,KAAA;IACtB,OAAO,EAAI;IACX,SAAS,EAAI;IACd;AAED,UADA,EAAc,EAAa,EACpB;WACA,GAAc;GACrB,IAAM,IAAU,aAAe,QAAQ,EAAI,UAAU;AAMrD,SALA,Q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Q,EAAI,UAAU;AAGrD,SAFA,QAAQ,MAAM,6DAA6D,EAAI,EAC/E,EAAS,EAAQ,EACX;YACE;AACR,KAAa,GAAM;;IAGvB,CAAC,EAAU,CACZ;AAsED,QAAO;EAEL;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA,YA7EiB,EACjB,OAAO,MAQE,EAAiB;GACtB,cAAc;IACZ,MAAM,EAAO;IACb,SAAS,EAAO;IAChB,WAAW,EAAO;IAClB,SAAS,EAAO;IAChB,MAAM,EAAO,QAAQ;IACrB,UAAU,EAAO,YAAY;IAC9B;GACD,UAAU,EAAO;GAClB,CAAC,EAEJ,CAAC,EAAiB,CACnB;EAwDC,gBAnDqB,EACrB,OAAO,MAiBE,EAAU,EAAE,eAT8B,EAAO,WAAW,KAAK,OAAe;GACrF,MAAM,EAAO;GACb,SAAS,EAAO;GAChB;GACA,SAAS,EAAO;GAChB,MAAM,EAAO,QAAQ;GACrB,UAAU,EAAO,YAAY;GAC9B,EAAE,EAE+B,CAAC,EAErC,CAAC,EAAU,CACZ;EAiCC,YA5BiB,QAAkB;AACnC,KAAS,KAAK;KACb,EAAE,CAAC;EA2BJ,aAtBkB,QAAkB;AACpC,KAAc,KAAK;KAClB,EAAE,CAAC;EAqBL"}
|
|
@@ -10,12 +10,13 @@ import { useMemo as c } from "react";
|
|
|
10
10
|
import { usePermissions as l } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
11
11
|
import { BellRing as u, CheckCheck as d, Search as f } from "lucide-react";
|
|
12
12
|
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
13
|
+
import { PushOptInToggle as g } from "@burdenoff/fe-libs/chrome";
|
|
14
|
+
import { AuroraBackground as _, Button as v, EmphasisPanel as y, GlassCard as b, GradientText as x, IllustratedEmptyState as S, PagePurpose as C } from "@burdenoff/fe-libs/ui";
|
|
14
15
|
//#region src/pages/NotificationCenterPage.tsx
|
|
15
|
-
var
|
|
16
|
+
var w = {
|
|
16
17
|
archived: !1,
|
|
17
18
|
channel: "IN_APP"
|
|
18
|
-
},
|
|
19
|
+
}, T = { channel: "IN_APP" }, E = [
|
|
19
20
|
{
|
|
20
21
|
value: "SYSTEM",
|
|
21
22
|
labelKey: "notifications.typeSystem",
|
|
@@ -36,7 +37,7 @@ var C = {
|
|
|
36
37
|
labelKey: "notifications.typeMarketing",
|
|
37
38
|
label: "Marketing"
|
|
38
39
|
}
|
|
39
|
-
],
|
|
40
|
+
], D = [
|
|
40
41
|
{
|
|
41
42
|
value: "URGENT",
|
|
42
43
|
labelKey: "notifications.priorityUrgent",
|
|
@@ -58,55 +59,56 @@ var C = {
|
|
|
58
59
|
label: "Low"
|
|
59
60
|
}
|
|
60
61
|
];
|
|
61
|
-
function
|
|
62
|
-
let
|
|
63
|
-
baseFilter:
|
|
64
|
-
unreadFilter:
|
|
65
|
-
}), { topics:
|
|
66
|
-
return
|
|
62
|
+
function O() {
|
|
63
|
+
let O = r(), { hasPermission: k, isLoading: A } = l(), { currentUser: j } = e(), { notifications: M, unreadCount: N, notificationFilter: P, markAsRead: F, markAllAsRead: I, archiveNotification: L, recordAction: R, updateFilter: z, resetFilter: B } = t({
|
|
64
|
+
baseFilter: w,
|
|
65
|
+
unreadFilter: T
|
|
66
|
+
}), { topics: V } = n({ isActive: !0 }), H = c(() => i(M, P), [M, P]), U = c(() => a(H, O), [H, O]);
|
|
67
|
+
return A ? /* @__PURE__ */ m("div", {
|
|
67
68
|
className: "flex h-64 items-center justify-center",
|
|
68
69
|
children: /* @__PURE__ */ m("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
69
|
-
}) : !
|
|
70
|
+
}) : !k(s.NOTIFICATION_LIST) && !j?.id ? /* @__PURE__ */ m("div", {
|
|
70
71
|
className: "p-8 text-center text-text-secondary",
|
|
71
|
-
children:
|
|
72
|
+
children: O("notifications.noPermissionView", "You don't have permission to view notifications.")
|
|
72
73
|
}) : /* @__PURE__ */ h("div", {
|
|
73
74
|
className: "space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200",
|
|
74
75
|
children: [
|
|
75
|
-
/* @__PURE__ */ m(
|
|
76
|
+
/* @__PURE__ */ m(C, {
|
|
76
77
|
icon: /* @__PURE__ */ m(u, { size: 16 }),
|
|
77
|
-
children:
|
|
78
|
+
children: O("notifications.centerPurpose", "Your in-app inbox. Everything the platform needs you to see — task assignments, mentions, alerts and system updates — lands here. Filter by type, priority or topic, mark items as read, and archive what you no longer need.")
|
|
78
79
|
}),
|
|
79
80
|
/* @__PURE__ */ h("div", {
|
|
80
81
|
className: "relative overflow-hidden rounded-2xl",
|
|
81
|
-
children: [/* @__PURE__ */ m(
|
|
82
|
+
children: [/* @__PURE__ */ m(_, { intensity: "subtle" }), /* @__PURE__ */ h(y, {
|
|
82
83
|
"data-tour": "notification-center-header",
|
|
83
84
|
className: "flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",
|
|
84
85
|
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("h1", {
|
|
85
86
|
className: "text-xl sm:text-2xl font-bold text-primary",
|
|
86
|
-
children: /* @__PURE__ */ m(
|
|
87
|
+
children: /* @__PURE__ */ m(x, { children: O("notifications.centerTitle", "Notification Center") })
|
|
87
88
|
}), /* @__PURE__ */ m("p", {
|
|
88
89
|
className: "text-sm text-secondary mt-1",
|
|
89
|
-
children:
|
|
90
|
-
|
|
90
|
+
children: N > 0 ? /* @__PURE__ */ h(p, { children: [
|
|
91
|
+
O("notifications.youHave", "You have"),
|
|
91
92
|
" ",
|
|
92
93
|
/* @__PURE__ */ h("span", {
|
|
93
94
|
className: "inline-flex items-center gap-1.5 font-semibold text-primary",
|
|
94
95
|
"data-tour": "notification-center-unread-count",
|
|
95
|
-
children: [/* @__PURE__ */ m("span", { className: "inline-block h-2 w-2 rounded-full bg-accent-primary motion-safe:animate-vc-glow-pulse" }),
|
|
96
|
+
children: [/* @__PURE__ */ m("span", { className: "inline-block h-2 w-2 rounded-full bg-accent-primary motion-safe:animate-vc-glow-pulse" }), N]
|
|
96
97
|
}),
|
|
97
98
|
" ",
|
|
98
|
-
|
|
99
|
-
] }) :
|
|
100
|
-
})] }),
|
|
99
|
+
O(N === 1 ? "notifications.unreadNotification" : "notifications.unreadNotifications", N === 1 ? "unread notification" : "unread notifications")
|
|
100
|
+
] }) : O("notifications.allCaughtUp", "All caught up!")
|
|
101
|
+
})] }), N > 0 && /* @__PURE__ */ h(v, {
|
|
101
102
|
"data-tour": "notification-center-mark-all-read",
|
|
102
103
|
variant: "outline",
|
|
103
|
-
onClick:
|
|
104
|
+
onClick: I,
|
|
104
105
|
className: "gap-2",
|
|
105
|
-
children: [/* @__PURE__ */ m(d, { size: 16 }),
|
|
106
|
+
children: [/* @__PURE__ */ m(d, { size: 16 }), O("notifications.markAllAsRead", "Mark All as Read")]
|
|
106
107
|
})]
|
|
107
108
|
})]
|
|
108
109
|
}),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ m(g, {}),
|
|
111
|
+
/* @__PURE__ */ h(b, {
|
|
110
112
|
treatment: "plain",
|
|
111
113
|
"data-tour": "notification-center-filters",
|
|
112
114
|
className: "flex flex-col gap-3 border-border-seam p-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-4 sm:p-4",
|
|
@@ -119,78 +121,78 @@ function D() {
|
|
|
119
121
|
}), /* @__PURE__ */ m("input", {
|
|
120
122
|
"data-tour": "notification-center-search",
|
|
121
123
|
type: "text",
|
|
122
|
-
placeholder:
|
|
123
|
-
value:
|
|
124
|
-
onChange: (e) =>
|
|
124
|
+
placeholder: O("notifications.searchPlaceholder", "Search notifications..."),
|
|
125
|
+
value: P.search,
|
|
126
|
+
onChange: (e) => z({ search: e.target.value }),
|
|
125
127
|
className: "w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150"
|
|
126
128
|
})]
|
|
127
129
|
}),
|
|
128
130
|
/* @__PURE__ */ h("select", {
|
|
129
|
-
value:
|
|
130
|
-
onChange: (e) =>
|
|
131
|
+
value: P.type,
|
|
132
|
+
onChange: (e) => z({ type: e.target.value }),
|
|
131
133
|
className: "px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150",
|
|
132
134
|
children: [/* @__PURE__ */ m("option", {
|
|
133
135
|
value: "ALL",
|
|
134
|
-
children:
|
|
135
|
-
}),
|
|
136
|
+
children: O("notifications.allTypes", "All Types")
|
|
137
|
+
}), E.map((e) => /* @__PURE__ */ m("option", {
|
|
136
138
|
value: e.value,
|
|
137
|
-
children:
|
|
139
|
+
children: O(e.labelKey, e.label)
|
|
138
140
|
}, e.value))]
|
|
139
141
|
}),
|
|
140
142
|
/* @__PURE__ */ h("select", {
|
|
141
|
-
value:
|
|
142
|
-
onChange: (e) =>
|
|
143
|
+
value: P.priority,
|
|
144
|
+
onChange: (e) => z({ priority: e.target.value }),
|
|
143
145
|
className: "px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150",
|
|
144
146
|
children: [/* @__PURE__ */ m("option", {
|
|
145
147
|
value: "ALL",
|
|
146
|
-
children:
|
|
147
|
-
}),
|
|
148
|
+
children: O("notifications.allPriorities", "All Priorities")
|
|
149
|
+
}), D.map((e) => /* @__PURE__ */ m("option", {
|
|
148
150
|
value: e.value,
|
|
149
|
-
children:
|
|
151
|
+
children: O(e.labelKey, e.label)
|
|
150
152
|
}, e.value))]
|
|
151
153
|
}),
|
|
152
154
|
/* @__PURE__ */ h("select", {
|
|
153
|
-
value:
|
|
154
|
-
onChange: (e) =>
|
|
155
|
+
value: P.topicId || "",
|
|
156
|
+
onChange: (e) => z({ topicId: e.target.value || void 0 }),
|
|
155
157
|
className: "px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150",
|
|
156
158
|
children: [/* @__PURE__ */ m("option", {
|
|
157
159
|
value: "",
|
|
158
|
-
children:
|
|
159
|
-
}),
|
|
160
|
+
children: O("notifications.allTopics", "All Topics")
|
|
161
|
+
}), V.map((e) => /* @__PURE__ */ m("option", {
|
|
160
162
|
value: e.id,
|
|
161
163
|
children: e.name
|
|
162
164
|
}, e.id))]
|
|
163
165
|
}),
|
|
164
166
|
/* @__PURE__ */ h("select", {
|
|
165
|
-
value:
|
|
166
|
-
onChange: (e) =>
|
|
167
|
+
value: P.isRead === null ? "ALL" : P.isRead ? "READ" : "UNREAD",
|
|
168
|
+
onChange: (e) => z({ isRead: e.target.value === "ALL" ? null : e.target.value === "READ" }),
|
|
167
169
|
className: "px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150",
|
|
168
170
|
children: [
|
|
169
171
|
/* @__PURE__ */ m("option", {
|
|
170
172
|
value: "ALL",
|
|
171
|
-
children:
|
|
173
|
+
children: O("notifications.filterAll", "All")
|
|
172
174
|
}),
|
|
173
175
|
/* @__PURE__ */ m("option", {
|
|
174
176
|
value: "UNREAD",
|
|
175
|
-
children:
|
|
177
|
+
children: O("notifications.filterUnread", "Unread")
|
|
176
178
|
}),
|
|
177
179
|
/* @__PURE__ */ m("option", {
|
|
178
180
|
value: "READ",
|
|
179
|
-
children:
|
|
181
|
+
children: O("notifications.filterRead", "Read")
|
|
180
182
|
})
|
|
181
183
|
]
|
|
182
184
|
}),
|
|
183
|
-
(
|
|
184
|
-
onClick:
|
|
185
|
+
(P.search || P.type !== "ALL" || P.priority !== "ALL" || P.isRead !== null || !!P.topicId) && /* @__PURE__ */ m("button", {
|
|
186
|
+
onClick: B,
|
|
185
187
|
className: "px-3 py-2 text-sm text-tertiary hover:text-primary transition-colors duration-150",
|
|
186
|
-
children:
|
|
188
|
+
children: O("notifications.resetFilters", "Reset")
|
|
187
189
|
})
|
|
188
190
|
]
|
|
189
191
|
}),
|
|
190
192
|
/* @__PURE__ */ m("div", {
|
|
191
193
|
"data-tour": "notification-center-list",
|
|
192
194
|
className: "space-y-6",
|
|
193
|
-
children:
|
|
195
|
+
children: H.length > 0 ? Object.entries(U).map(([e, t]) => /* @__PURE__ */ h("div", {
|
|
194
196
|
className: "animate-in fade-in slide-in-from-bottom-2 duration-200",
|
|
195
197
|
children: [/* @__PURE__ */ m("h2", {
|
|
196
198
|
className: "text-sm font-semibold text-tertiary mb-3",
|
|
@@ -199,18 +201,18 @@ function D() {
|
|
|
199
201
|
className: "space-y-2",
|
|
200
202
|
children: t.map((e) => /* @__PURE__ */ m(o, {
|
|
201
203
|
notification: e,
|
|
202
|
-
onMarkAsRead:
|
|
203
|
-
onArchive:
|
|
204
|
-
onAction:
|
|
204
|
+
onMarkAsRead: F,
|
|
205
|
+
onArchive: L,
|
|
206
|
+
onAction: R,
|
|
205
207
|
analyticsSource: "center"
|
|
206
208
|
}, e.id))
|
|
207
209
|
})]
|
|
208
210
|
}, e)) : /* @__PURE__ */ m("div", {
|
|
209
211
|
className: "animate-in fade-in duration-200",
|
|
210
|
-
children: /* @__PURE__ */ m(
|
|
211
|
-
illustration:
|
|
212
|
-
title:
|
|
213
|
-
description:
|
|
212
|
+
children: /* @__PURE__ */ m(S, {
|
|
213
|
+
illustration: M.length === 0 ? "empty-notifications" : "empty-search",
|
|
214
|
+
title: O("notifications.noNotificationsFound", "No notifications found"),
|
|
215
|
+
description: M.length === 0 ? O("notifications.noNotificationsYet", "You don't have any notifications yet. We'll notify you when something important happens.") : O("notifications.adjustFilters", "Try adjusting your filters to see more notifications.")
|
|
214
216
|
})
|
|
215
217
|
})
|
|
216
218
|
})
|
|
@@ -218,6 +220,6 @@ function D() {
|
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
//#endregion
|
|
221
|
-
export {
|
|
223
|
+
export { O as NotificationCenterPage };
|
|
222
224
|
|
|
223
225
|
//# sourceMappingURL=NotificationCenterPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationCenterPage.js","names":[],"sources":["../../src/pages/NotificationCenterPage.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Search, CheckCheck, BellRing } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n AuroraBackground,\n Button,\n EmphasisPanel,\n GlassCard,\n GradientText,\n IllustratedEmptyState,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotifications, useNotificationTopics } from '../hooks';\nimport { NotificationCard } from '../components/NotificationCard';\nimport { filterNotifications, groupNotificationsByDate } from '../utils';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationPriority, NotificationType } from '../types';\n\nconst CENTER_FILTER = { archived: false, channel: 'IN_APP' as const };\nconst CENTER_UNREAD_FILTER = { channel: 'IN_APP' };\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alert' },\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\nconst PRIORITY_OPTIONS: Array<{ value: NotificationPriority; labelKey: string; label: string }> = [\n { value: 'URGENT', labelKey: 'notifications.priorityUrgent', label: 'Urgent' },\n { value: 'HIGH', labelKey: 'notifications.priorityHigh', label: 'High' },\n { value: 'NORMAL', labelKey: 'notifications.priorityNormal', label: 'Normal' },\n { value: 'LOW', labelKey: 'notifications.priorityLow', label: 'Low' },\n];\n\n/**\n * Notification Center Page\n *\n * Main page for viewing and managing in-app notifications\n */\nexport function NotificationCenterPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const {\n notifications,\n unreadCount,\n notificationFilter,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n updateFilter,\n resetFilter,\n } = useNotifications({ baseFilter: CENTER_FILTER, unreadFilter: CENTER_UNREAD_FILTER });\n const { topics } = useNotificationTopics({ isActive: true });\n\n // Filter and group notifications\n const filteredNotifications = useMemo(\n () => filterNotifications(notifications, notificationFilter),\n [notifications, notificationFilter]\n );\n const groupedNotifications = useMemo(\n () => groupNotificationsByDate(filteredNotifications, tr),\n [filteredNotifications, tr]\n );\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr('notifications.noPermissionView', \"You don't have permission to view notifications.\")}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200\">\n <PagePurpose icon={<BellRing size={16} />}>\n {tr(\n 'notifications.centerPurpose',\n 'Your in-app inbox. Everything the platform needs you to see — task assignments, mentions, alerts and system updates — lands here. Filter by type, priority or topic, mark items as read, and archive what you no longer need.'\n )}\n </PagePurpose>\n\n {/* Header — the page's single emphasis zone (unread summary + the one CTA).\n Wrapped in a relative overflow-hidden container so the AuroraBackground\n can sit behind it (at -z-10) without ever moving content. This is the\n MFE's single aurora hero. */}\n <div className=\"relative overflow-hidden rounded-2xl\">\n <AuroraBackground intensity=\"subtle\" />\n <EmphasisPanel\n data-tour=\"notification-center-header\"\n className=\"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6\"\n >\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n <GradientText>{tr('notifications.centerTitle', 'Notification Center')}</GradientText>\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {unreadCount > 0 ? (\n <>\n {tr('notifications.youHave', 'You have')}{' '}\n <span\n className=\"inline-flex items-center gap-1.5 font-semibold text-primary\"\n data-tour=\"notification-center-unread-count\"\n >\n <span className=\"inline-block h-2 w-2 rounded-full bg-accent-primary motion-safe:animate-vc-glow-pulse\" />\n {unreadCount}\n </span>{' '}\n {tr(\n unreadCount === 1\n ? 'notifications.unreadNotification'\n : 'notifications.unreadNotifications',\n unreadCount === 1 ? 'unread notification' : 'unread notifications'\n )}\n </>\n ) : (\n tr('notifications.allCaughtUp', 'All caught up!')\n )}\n </p>\n </div>\n\n {unreadCount > 0 && (\n <Button\n data-tour=\"notification-center-mark-all-read\"\n variant=\"outline\"\n onClick={markAllAsRead}\n className=\"gap-2\"\n >\n <CheckCheck size={16} />\n {tr('notifications.markAllAsRead', 'Mark All as Read')}\n </Button>\n )}\n </EmphasisPanel>\n </div>\n\n {/* Filters */}\n <GlassCard\n treatment=\"plain\"\n data-tour=\"notification-center-filters\"\n className=\"flex flex-col gap-3 border-border-seam p-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-4 sm:p-4\"\n >\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n data-tour=\"notification-center-search\"\n type=\"text\"\n placeholder={tr('notifications.searchPlaceholder', 'Search notifications...')}\n value={notificationFilter.search}\n onChange={(e) => updateFilter({ search: e.target.value })}\n className=\"w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n />\n </div>\n\n {/* Type filter */}\n <select\n value={notificationFilter.type}\n onChange={(e) => updateFilter({ type: e.target.value as NotificationType | 'ALL' })}\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.allTypes', 'All Types')}</option>\n {TYPE_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {tr(option.labelKey, option.label)}\n </option>\n ))}\n </select>\n\n {/* Priority filter */}\n <select\n value={notificationFilter.priority}\n onChange={(e) =>\n updateFilter({ priority: e.target.value as NotificationPriority | 'ALL' })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.allPriorities', 'All Priorities')}</option>\n {PRIORITY_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {tr(option.labelKey, option.label)}\n </option>\n ))}\n </select>\n\n <select\n value={notificationFilter.topicId || ''}\n onChange={(e) => updateFilter({ topicId: e.target.value || undefined })}\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"\">{tr('notifications.allTopics', 'All Topics')}</option>\n {topics.map((topic) => (\n <option key={topic.id} value={topic.id}>\n {topic.name}\n </option>\n ))}\n </select>\n\n {/* Read/Unread filter */}\n <select\n value={\n notificationFilter.isRead === null\n ? 'ALL'\n : notificationFilter.isRead\n ? 'READ'\n : 'UNREAD'\n }\n onChange={(e) =>\n updateFilter({\n isRead: e.target.value === 'ALL' ? null : e.target.value === 'READ',\n })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.filterAll', 'All')}</option>\n <option value=\"UNREAD\">{tr('notifications.filterUnread', 'Unread')}</option>\n <option value=\"READ\">{tr('notifications.filterRead', 'Read')}</option>\n </select>\n\n {/* Reset filters */}\n {(notificationFilter.search ||\n notificationFilter.type !== 'ALL' ||\n notificationFilter.priority !== 'ALL' ||\n notificationFilter.isRead !== null ||\n Boolean(notificationFilter.topicId)) && (\n <button\n onClick={resetFilter}\n className=\"px-3 py-2 text-sm text-tertiary hover:text-primary transition-colors duration-150\"\n >\n {tr('notifications.resetFilters', 'Reset')}\n </button>\n )}\n </GlassCard>\n\n {/* Notifications list */}\n <div data-tour=\"notification-center-list\" className=\"space-y-6\">\n {filteredNotifications.length > 0 ? (\n Object.entries(groupedNotifications).map(([group, groupNotifications]) => (\n <div key={group} className=\"animate-in fade-in slide-in-from-bottom-2 duration-200\">\n <h2 className=\"text-sm font-semibold text-tertiary mb-3\">{group}</h2>\n <div className=\"space-y-2\">\n {groupNotifications.map((notification) => (\n <NotificationCard\n key={notification.id}\n notification={notification}\n onMarkAsRead={markAsRead}\n onArchive={archiveNotification}\n onAction={recordAction}\n analyticsSource=\"center\"\n />\n ))}\n </div>\n </div>\n ))\n ) : (\n <div className=\"animate-in fade-in duration-200\">\n <IllustratedEmptyState\n illustration={notifications.length === 0 ? 'empty-notifications' : 'empty-search'}\n title={tr('notifications.noNotificationsFound', 'No notifications found')}\n description={\n notifications.length === 0\n ? tr(\n 'notifications.noNotificationsYet',\n \"You don't have any notifications yet. We'll notify you when something important happens.\"\n )\n : tr(\n 'notifications.adjustFilters',\n 'Try adjusting your filters to see more notifications.'\n )\n }\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAM,IAAgB;CAAE,UAAU;CAAO,SAAS;CAAmB,EAC/D,IAAuB,EAAE,SAAS,UAAU,EAC5C,IAAoF;CACxF;EAAE,OAAO;EAAU,UAAU;EAA4B,OAAO;EAAU;CAC1E;EAAE,OAAO;EAAS,UAAU;EAA2B,OAAO;EAAS;CACvE;EAAE,OAAO;EAAiB,UAAU;EAAmC,OAAO;EAAiB;CAC/F;EAAE,OAAO;EAAa,UAAU;EAA+B,OAAO;EAAa;CACpF,EACK,IAA4F;CAChG;EAAE,OAAO;EAAU,UAAU;EAAgC,OAAO;EAAU;CAC9E;EAAE,OAAO;EAAQ,UAAU;EAA8B,OAAO;EAAQ;CACxE;EAAE,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D,kBAAC,OAAD;KAAiB,WAAU;eAA3B,CACE,kBAAC,MAAD;MAAI,WAAU;gBAA4C;MAAW,CAAA,EACrE,kBAAC,OAAD;MAAK,WAAU;gBACZ,EAAmB,KAAK,MACvB,kBAAC,GAAD;OAEgB;OACd,cAAc;OACd,WAAW;OACX,UAAU;OACV,iBAAgB;OAChB,EANK,EAAa,GAMlB,CACF;MACE,CAAA,CACF;OAdI,EAcJ,CACN,GAEF,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,GAAD;MACE,cAAc,EAAc,WAAW,IAAI,wBAAwB;MACnE,OAAO,EAAG,sCAAsC,yBAAyB;MACzE,aACE,EAAc,WAAW,IACrB,EACE,oCACA,2FACD,GACD,EACE,+BACA,wDACD;MAEP,CAAA;KACE,CAAA;IAEJ,CAAA;GACF"}
|
|
1
|
+
{"version":3,"file":"NotificationCenterPage.js","names":[],"sources":["../../src/pages/NotificationCenterPage.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Search, CheckCheck, BellRing } from 'lucide-react';\nimport { PushOptInToggle } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n AuroraBackground,\n Button,\n EmphasisPanel,\n GlassCard,\n GradientText,\n IllustratedEmptyState,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotifications, useNotificationTopics } from '../hooks';\nimport { NotificationCard } from '../components/NotificationCard';\nimport { filterNotifications, groupNotificationsByDate } from '../utils';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationPriority, NotificationType } from '../types';\n\nconst CENTER_FILTER = { archived: false, channel: 'IN_APP' as const };\nconst CENTER_UNREAD_FILTER = { channel: 'IN_APP' };\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alert' },\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\nconst PRIORITY_OPTIONS: Array<{ value: NotificationPriority; labelKey: string; label: string }> = [\n { value: 'URGENT', labelKey: 'notifications.priorityUrgent', label: 'Urgent' },\n { value: 'HIGH', labelKey: 'notifications.priorityHigh', label: 'High' },\n { value: 'NORMAL', labelKey: 'notifications.priorityNormal', label: 'Normal' },\n { value: 'LOW', labelKey: 'notifications.priorityLow', label: 'Low' },\n];\n\n/**\n * Notification Center Page\n *\n * Main page for viewing and managing in-app notifications\n */\nexport function NotificationCenterPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const {\n notifications,\n unreadCount,\n notificationFilter,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n updateFilter,\n resetFilter,\n } = useNotifications({ baseFilter: CENTER_FILTER, unreadFilter: CENTER_UNREAD_FILTER });\n const { topics } = useNotificationTopics({ isActive: true });\n\n // Filter and group notifications\n const filteredNotifications = useMemo(\n () => filterNotifications(notifications, notificationFilter),\n [notifications, notificationFilter]\n );\n const groupedNotifications = useMemo(\n () => groupNotificationsByDate(filteredNotifications, tr),\n [filteredNotifications, tr]\n );\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr('notifications.noPermissionView', \"You don't have permission to view notifications.\")}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200\">\n <PagePurpose icon={<BellRing size={16} />}>\n {tr(\n 'notifications.centerPurpose',\n 'Your in-app inbox. Everything the platform needs you to see — task assignments, mentions, alerts and system updates — lands here. Filter by type, priority or topic, mark items as read, and archive what you no longer need.'\n )}\n </PagePurpose>\n\n {/* Header — the page's single emphasis zone (unread summary + the one CTA).\n Wrapped in a relative overflow-hidden container so the AuroraBackground\n can sit behind it (at -z-10) without ever moving content. This is the\n MFE's single aurora hero. */}\n <div className=\"relative overflow-hidden rounded-2xl\">\n <AuroraBackground intensity=\"subtle\" />\n <EmphasisPanel\n data-tour=\"notification-center-header\"\n className=\"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6\"\n >\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n <GradientText>{tr('notifications.centerTitle', 'Notification Center')}</GradientText>\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {unreadCount > 0 ? (\n <>\n {tr('notifications.youHave', 'You have')}{' '}\n <span\n className=\"inline-flex items-center gap-1.5 font-semibold text-primary\"\n data-tour=\"notification-center-unread-count\"\n >\n <span className=\"inline-block h-2 w-2 rounded-full bg-accent-primary motion-safe:animate-vc-glow-pulse\" />\n {unreadCount}\n </span>{' '}\n {tr(\n unreadCount === 1\n ? 'notifications.unreadNotification'\n : 'notifications.unreadNotifications',\n unreadCount === 1 ? 'unread notification' : 'unread notifications'\n )}\n </>\n ) : (\n tr('notifications.allCaughtUp', 'All caught up!')\n )}\n </p>\n </div>\n\n {unreadCount > 0 && (\n <Button\n data-tour=\"notification-center-mark-all-read\"\n variant=\"outline\"\n onClick={markAllAsRead}\n className=\"gap-2\"\n >\n <CheckCheck size={16} />\n {tr('notifications.markAllAsRead', 'Mark All as Read')}\n </Button>\n )}\n </EmphasisPanel>\n </div>\n\n {/* Push opt-in — renders nothing when the surface has no push support\n (web without a service worker, or a shell that never registered a\n controller), so no wrapper card here to avoid an empty box in that\n case. Placed here too since this page, not just the bell dropdown,\n can be the first notification surface a user reaches. */}\n <PushOptInToggle />\n\n {/* Filters */}\n <GlassCard\n treatment=\"plain\"\n data-tour=\"notification-center-filters\"\n className=\"flex flex-col gap-3 border-border-seam p-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-4 sm:p-4\"\n >\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n data-tour=\"notification-center-search\"\n type=\"text\"\n placeholder={tr('notifications.searchPlaceholder', 'Search notifications...')}\n value={notificationFilter.search}\n onChange={(e) => updateFilter({ search: e.target.value })}\n className=\"w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n />\n </div>\n\n {/* Type filter */}\n <select\n value={notificationFilter.type}\n onChange={(e) => updateFilter({ type: e.target.value as NotificationType | 'ALL' })}\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.allTypes', 'All Types')}</option>\n {TYPE_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {tr(option.labelKey, option.label)}\n </option>\n ))}\n </select>\n\n {/* Priority filter */}\n <select\n value={notificationFilter.priority}\n onChange={(e) =>\n updateFilter({ priority: e.target.value as NotificationPriority | 'ALL' })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.allPriorities', 'All Priorities')}</option>\n {PRIORITY_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {tr(option.labelKey, option.label)}\n </option>\n ))}\n </select>\n\n <select\n value={notificationFilter.topicId || ''}\n onChange={(e) => updateFilter({ topicId: e.target.value || undefined })}\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"\">{tr('notifications.allTopics', 'All Topics')}</option>\n {topics.map((topic) => (\n <option key={topic.id} value={topic.id}>\n {topic.name}\n </option>\n ))}\n </select>\n\n {/* Read/Unread filter */}\n <select\n value={\n notificationFilter.isRead === null\n ? 'ALL'\n : notificationFilter.isRead\n ? 'READ'\n : 'UNREAD'\n }\n onChange={(e) =>\n updateFilter({\n isRead: e.target.value === 'ALL' ? null : e.target.value === 'READ',\n })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n >\n <option value=\"ALL\">{tr('notifications.filterAll', 'All')}</option>\n <option value=\"UNREAD\">{tr('notifications.filterUnread', 'Unread')}</option>\n <option value=\"READ\">{tr('notifications.filterRead', 'Read')}</option>\n </select>\n\n {/* Reset filters */}\n {(notificationFilter.search ||\n notificationFilter.type !== 'ALL' ||\n notificationFilter.priority !== 'ALL' ||\n notificationFilter.isRead !== null ||\n Boolean(notificationFilter.topicId)) && (\n <button\n onClick={resetFilter}\n className=\"px-3 py-2 text-sm text-tertiary hover:text-primary transition-colors duration-150\"\n >\n {tr('notifications.resetFilters', 'Reset')}\n </button>\n )}\n </GlassCard>\n\n {/* Notifications list */}\n <div data-tour=\"notification-center-list\" className=\"space-y-6\">\n {filteredNotifications.length > 0 ? (\n Object.entries(groupedNotifications).map(([group, groupNotifications]) => (\n <div key={group} className=\"animate-in fade-in slide-in-from-bottom-2 duration-200\">\n <h2 className=\"text-sm font-semibold text-tertiary mb-3\">{group}</h2>\n <div className=\"space-y-2\">\n {groupNotifications.map((notification) => (\n <NotificationCard\n key={notification.id}\n notification={notification}\n onMarkAsRead={markAsRead}\n onArchive={archiveNotification}\n onAction={recordAction}\n analyticsSource=\"center\"\n />\n ))}\n </div>\n </div>\n ))\n ) : (\n <div className=\"animate-in fade-in duration-200\">\n <IllustratedEmptyState\n illustration={notifications.length === 0 ? 'empty-notifications' : 'empty-search'}\n title={tr('notifications.noNotificationsFound', 'No notifications found')}\n description={\n notifications.length === 0\n ? tr(\n 'notifications.noNotificationsYet',\n \"You don't have any notifications yet. We'll notify you when something important happens.\"\n )\n : tr(\n 'notifications.adjustFilters',\n 'Try adjusting your filters to see more notifications.'\n )\n }\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAM,IAAgB;CAAE,UAAU;CAAO,SAAS;CAAmB,EAC/D,IAAuB,EAAE,SAAS,UAAU,EAC5C,IAAoF;CACxF;EAAE,OAAO;EAAU,UAAU;EAA4B,OAAO;EAAU;CAC1E;EAAE,OAAO;EAAS,UAAU;EAA2B,OAAO;EAAS;CACvE;EAAE,OAAO;EAAiB,UAAU;EAAmC,OAAO;EAAiB;CAC/F;EAAE,OAAO;EAAa,UAAU;EAA+B,OAAO;EAAa;CACpF,EACK,IAA4F;CAChG;EAAE,OAAO;EAAU,UAAU;EAAgC,OAAO;EAAU;CAC9E;EAAE,OAAO;EAAQ,UAAU;EAA8B,OAAO;EAAQ;CACxE;EAAE,OAAO;EAAU,UAAU;EAAgC,OAAO;EAAU;CAC9E;EAAE,OAAO;EAAO,UAAU;EAA6B,OAAO;EAAO;CACtE;AAOD,SAAgB,IAAyB;CACvC,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,mBAAgB,GAAiB,EACnC,EACJ,kBACA,gBACA,uBACA,eACA,kBACA,wBACA,iBACA,iBACA,mBACE,EAAiB;EAAE,YAAY;EAAe,cAAc;EAAsB,CAAC,EACjF,EAAE,cAAW,EAAsB,EAAE,UAAU,IAAM,CAAC,EAGtD,IAAwB,QACtB,EAAoB,GAAe,EAAmB,EAC5D,CAAC,GAAe,EAAmB,CACpC,EACK,IAAuB,QACrB,EAAyB,GAAuB,EAAG,EACzD,CAAC,GAAuB,EAAG,CAC5B;AAkBD,QAhBI,IAEA,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD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 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-notification",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1013.1",
|
|
4
4
|
"description": "Notification microfrontend for multi-channel notification management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@apollo/client": "^4.0.9",
|
|
52
|
-
"@burdenoff/fe-libs": "2026.
|
|
52
|
+
"@burdenoff/fe-libs": "2026.1012.2",
|
|
53
53
|
"@types/lodash-es": "^4.17.12",
|
|
54
54
|
"graphql": "^16.12.0",
|
|
55
55
|
"graphql-ws": "^6.0.6",
|