@burdenoff/microfe-notification 2026.1129.1 → 2026.1129.3
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.
- package/dist/NotificationRoutes.js +73 -72
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/generated/global-operations.d.ts +4 -0
- package/dist/generated/global-operations.js +4 -0
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +3 -0
- package/dist/hooks/useSendNotification.d.ts +1 -1
- package/dist/hooks/useSendNotification.js.map +1 -1
- package/dist/translations/en.d.ts +179 -0
- package/dist/v2/InboxPage.js +113 -97
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.d.ts +9 -4
- package/dist/v2/NotificationDetailPanel.js +66 -51
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/admin/ChoiceSelect.d.ts +9 -0
- package/dist/v2/admin/ChoiceSelect.js +24 -0
- package/dist/v2/admin/ChoiceSelect.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.d.ts +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +207 -0
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -0
- package/dist/v2/admin/InsertDetail.d.ts +6 -0
- package/dist/v2/admin/InsertDetail.js +77 -0
- package/dist/v2/admin/InsertDetail.js.map +1 -0
- package/dist/v2/admin/TemplateEditor.d.ts +6 -0
- package/dist/v2/admin/TemplateEditor.js +92 -0
- package/dist/v2/admin/TemplateEditor.js.map +1 -0
- package/dist/v2/admin/TemplateFields.d.ts +9 -0
- package/dist/v2/admin/TemplateFields.js +130 -0
- package/dist/v2/admin/TemplateFields.js.map +1 -0
- package/dist/v2/admin/TemplatePage.d.ts +1 -0
- package/dist/v2/admin/TemplatePage.js +62 -0
- package/dist/v2/admin/TemplatePage.js.map +1 -0
- package/dist/v2/admin/TemplatePreview.d.ts +8 -0
- package/dist/v2/admin/TemplatePreview.js +112 -0
- package/dist/v2/admin/TemplatePreview.js.map +1 -0
- package/dist/v2/admin/TemplatesPage.d.ts +1 -0
- package/dist/v2/admin/TemplatesPage.js +173 -0
- package/dist/v2/admin/TemplatesPage.js.map +1 -0
- package/dist/v2/admin/TopicDialog.d.ts +11 -0
- package/dist/v2/admin/TopicDialog.js +113 -0
- package/dist/v2/admin/TopicDialog.js.map +1 -0
- package/dist/v2/admin/TopicsPage.d.ts +1 -0
- package/dist/v2/admin/TopicsPage.js +152 -0
- package/dist/v2/admin/TopicsPage.js.map +1 -0
- package/dist/v2/admin/templateText.d.ts +35 -0
- package/dist/v2/admin/templateText.js +114 -0
- package/dist/v2/admin/templateText.js.map +1 -0
- package/dist/v2/admin/useTemplateDraft.d.ts +32 -0
- package/dist/v2/admin/useTemplateDraft.js +117 -0
- package/dist/v2/admin/useTemplateDraft.js.map +1 -0
- package/dist/v2/admin/words.d.ts +15 -0
- package/dist/v2/admin/words.js +67 -0
- package/dist/v2/admin/words.js.map +1 -0
- package/dist/v2/send/MessageTab.d.ts +4 -0
- package/dist/v2/send/MessageTab.js +152 -0
- package/dist/v2/send/MessageTab.js.map +1 -0
- package/dist/v2/send/PeopleTab.d.ts +4 -0
- package/dist/v2/send/PeopleTab.js +156 -0
- package/dist/v2/send/PeopleTab.js.map +1 -0
- package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
- package/dist/v2/send/SendNotificationDialog.js +98 -0
- package/dist/v2/send/SendNotificationDialog.js.map +1 -0
- package/dist/v2/send/SendRedirect.d.ts +1 -0
- package/dist/v2/send/SendRedirect.js +20 -0
- package/dist/v2/send/SendRedirect.js.map +1 -0
- package/dist/v2/send/WhenTab.d.ts +4 -0
- package/dist/v2/send/WhenTab.js +64 -0
- package/dist/v2/send/WhenTab.js.map +1 -0
- package/dist/v2/send/sendModel.d.ts +47 -0
- package/dist/v2/send/sendModel.js +90 -0
- package/dist/v2/send/sendModel.js.map +1 -0
- package/dist/v2/send/useSendDraft.d.ts +24 -0
- package/dist/v2/send/useSendDraft.js +120 -0
- package/dist/v2/send/useSendDraft.js.map +1 -0
- package/package.json +1 -1
|
@@ -55,6 +55,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
|
|
|
55
55
|
name: string;
|
|
56
56
|
description: string | null;
|
|
57
57
|
type: import('../generated/global-types').NotificationType;
|
|
58
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
58
59
|
locale: string;
|
|
59
60
|
subject: string | null;
|
|
60
61
|
bodyTemplate: string;
|
|
@@ -73,6 +74,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
|
|
|
73
74
|
name: string;
|
|
74
75
|
description: string | null;
|
|
75
76
|
type: import('../generated/global-types').NotificationType;
|
|
77
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
76
78
|
locale: string;
|
|
77
79
|
subject: string | null;
|
|
78
80
|
bodyTemplate: string;
|
|
@@ -113,6 +115,7 @@ export declare function useNotificationTemplate(slug: string | undefined, locale
|
|
|
113
115
|
name: string;
|
|
114
116
|
description: string | null;
|
|
115
117
|
type: import('../generated/global-types').NotificationType;
|
|
118
|
+
channel: import('../generated/global-types').NotificationChannel;
|
|
116
119
|
locale: string;
|
|
117
120
|
subject: string | null;
|
|
118
121
|
bodyTemplate: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NotificationChannelType = 'DISCORD' | 'EMAIL' | 'PUSH' | 'SLACK' | 'SMS' | 'TEAMS' | 'TELEGRAM' | 'WEBHOOK' | 'WHATSAPP';
|
|
1
|
+
export type NotificationChannelType = 'DISCORD' | 'EMAIL' | 'IN_APP' | 'PUSH' | 'SLACK' | 'SMS' | 'TEAMS' | 'TELEGRAM' | 'WEBHOOK' | 'WHATSAPP';
|
|
2
2
|
export type NotificationTypeEnum = 'ALERT' | 'MARKETING' | 'SYSTEM' | 'TRANSACTIONAL';
|
|
3
3
|
export type NotificationPriorityEnum = 'HIGH' | 'LOW' | 'MEDIUM' | 'URGENT';
|
|
4
4
|
export type NotificationStatusEnum = 'CANCELLED' | 'DELIVERED' | 'DRAFT' | 'EXPIRED' | 'FAILED' | 'PENDING' | 'READ' | 'SCHEDULED' | 'SENT' | 'TRIGGERED';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendNotification.js","names":["NotificationOps.TriggerNotificationDocument","NotificationOps.TriggerNotificationWithTemplateDocument","NotificationOps.TriggerBatchNotificationsDocument","useSendNotification","useNotification","isLoading","_setIsLoading","useState","isSending","setIsSending","error","setError","lastResult","setLastResult","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","sendNotification","raw","TriggerNotificationDocument","notification","err","message","sendWithTemplate","TriggerNotificationWithTemplateDocument","templateResult","n","sendBatch","TriggerBatchNotificationsDocument","batchResult","params","notifications"],"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,\n sendBatch,\n\n // Helper methods\n sendSimple,\n sendToMultiple,\n\n // Utilities\n clearError,\n clearResult,\n };\n}\n"],"mappings":";;;;;AAyLA,SAAgBG,IAAsB;CACpC,IAAM,EAAE,cAAW,qBAAkBC,EAAgB,GAC/C,CAACC,GAAWC,KAAiBC,EAAS,EAAK,GAC3C,CAACC,GAAWC,KAAgBF,EAAS,EAAK,GAC1C,CAACG,GAAOC,KAAYJ,EAAwB,IAAI,GAChD,CAACK,GAAYC,KAAiBN,EAElC,IAAI,GAGAO,IAAYC,QACTC,EAA4BC,KAAiB,KAAA,GAAWC,KAAa,KAAA,CAAS,GACpF,CAACD,GAAeC,CAAS,CAAC,GAMvBC,IAAmBJ,EACvB,OAAO,MAA+E;EAEpF,AADAN,EAAa,EAAI,GACjBE,EAAS,IAAI;EAEb,IAAI;GAOF,IAAMS,KAAM,MANGN,EACM,CAAA,CAAO,OAAoC;IAC9D,UAAUd;IACV,WAAW,EAAE,SAAM;GACrB,CAAC,EAAA,CAEkB,MAAM,uBAAuB;GAChD,IAAI,CAACoB,GAAK,OAAO;GACjB,IAAME,IAA0C;IAC9C,IAAIF,EAAI;IACR,QAAQA,EAAI;IACZ,gBAAiBA,EAAI,kBAAkB,KAAA;IAEvC,eAAeA,EAAI;IACnB,QAAQA,EAAI,UAAU,KAAA;IACtB,OAAOA,EAAI;IACX,SAASA,EAAI;GACf;GAEA,OADAP,EAAcS,CAAY,GACnBA;EACT,SAASC,GAAc;GACrB,IAAMC,IAAUD,a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IACpB,aAAaA,EAAI;IACjB,cAAcA,EAAI;IAClB,cAAcA,EAAI;IAClB,SAASA,EAAI;GACf;GAEA,OADAP,EAAckB,CAAW,GAClBA;EACT,SAASR,GAAc;GACrB,IAAMC,IAAUD,aAAe,QAAQA,EAAI,UAAU;GAGrD,MAFA,QAAQ,MAAM,6DAA6DA,CAAG,GAC9EZ,EAASa,CAAO,GACVD;EACR,UAAU;GACR,EAAa,EAAK;EACpB;CACF,GACA,CAACT,CAAS,CACZ;CAsEA,OAAO;EAEL;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA,YA7EiBC,EACjB,OAAO,MAQEI,EAAiB;GACtB,cAAc;IACZ,MAAMa,EAAO;IACb,SAASA,EAAO;IAChB,WAAWA,EAAO;IAClB,SAASA,EAAO;IAChB,MAAMA,EAAO,QAAQ;IACrB,UAAUA,EAAO,YAAY;GAC/B;GACA,UAAUA,EAAO;EACnB,CAAC,GAEH,CAACb,CAAgB,CAwDjB;EACA,gBAnDqBJ,EACrB,OAAO,MAOwC;GAC7C,IAAMkB,IAA2CD,EAAO,WAAW,KAAK,OAAe;IACrF,MAAMA,EAAO;IACb,SAASA,EAAO;IAChB;IACA,SAASA,EAAO;IAChB,MAAMA,EAAO,QAAQ;IACrB,UAAUA,EAAO,YAAY;GAC/B,EAAE;GAEF,OAAOH,EAAU,EAAE,iBAAc,CAAC;EACpC,GACA,CAACA,CAAS,CA+BV;EAGA,YA5BiBd,QAAkB;GACnC,EAAS,IAAI;EACf,GAAG,CAAC,CA0BF;EACA,aAtBkBA,QAAkB;GACpC,EAAc,IAAI;EACpB,GAAG,CAAC,CAoBF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useSendNotification.js","names":["NotificationOps.TriggerNotificationDocument","NotificationOps.TriggerNotificationWithTemplateDocument","NotificationOps.TriggerBatchNotificationsDocument","useSendNotification","useNotification","isLoading","_setIsLoading","useState","isSending","setIsSending","error","setError","lastResult","setLastResult","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","sendNotification","raw","TriggerNotificationDocument","notification","err","message","sendWithTemplate","TriggerNotificationWithTemplateDocument","templateResult","n","sendBatch","TriggerBatchNotificationsDocument","batchResult","params","notifications"],"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 | 'IN_APP'\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 | 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 // Hel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AEL;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA,YA7EiBC,EACjB,OAAO,MAQEI,EAAiB;GACtB,cAAc;IACZ,MAAMa,EAAO;IACb,SAASA,EAAO;IAChB,WAAWA,EAAO;IAClB,SAASA,EAAO;IAChB,MAAMA,EAAO,QAAQ;IACrB,UAAUA,EAAO,YAAY;GAC/B;GACA,UAAUA,EAAO;EACnB,CAAC,GAEH,CAACb,CAAgB,CAwDjB;EACA,gBAnDqBJ,EACrB,OAAO,MAOwC;GAC7C,IAAMkB,IAA2CD,EAAO,WAAW,KAAK,OAAe;IACrF,MAAMA,EAAO;IACb,SAASA,EAAO;IAChB;IACA,SAASA,EAAO;IAChB,MAAMA,EAAO,QAAQ;IACrB,UAAUA,EAAO,YAAY;GAC/B,EAAE;GAEF,OAAOH,EAAU,EAAE,iBAAc,CAAC;EACpC,GACA,CAACA,CAAS,CA+BV;EAGA,YA5BiBd,QAAkB;GACnC,EAAS,IAAI;EACf,GAAG,CAAC,CA0BF;EACA,aAtBkBA,QAAkB;GACpC,EAAc,IAAI;EACpB,GAAG,CAAC,CAoBF;CACF;AACF"}
|
|
@@ -470,6 +470,22 @@ export declare const enTranslations: {
|
|
|
470
470
|
v3: {
|
|
471
471
|
actionsFor: string;
|
|
472
472
|
archive: string;
|
|
473
|
+
cancel: string;
|
|
474
|
+
channel: {
|
|
475
|
+
email: string;
|
|
476
|
+
inApp: string;
|
|
477
|
+
other: string;
|
|
478
|
+
push: string;
|
|
479
|
+
slack: string;
|
|
480
|
+
sms: string;
|
|
481
|
+
whatsapp: string;
|
|
482
|
+
};
|
|
483
|
+
delivery: {
|
|
484
|
+
delivered: string;
|
|
485
|
+
failed: string;
|
|
486
|
+
sent: string;
|
|
487
|
+
waiting: string;
|
|
488
|
+
};
|
|
473
489
|
empty: {
|
|
474
490
|
actionBody: string;
|
|
475
491
|
actionTitle: string;
|
|
@@ -497,12 +513,36 @@ export declare const enTranslations: {
|
|
|
497
513
|
sent: string;
|
|
498
514
|
unsubscribed: string;
|
|
499
515
|
};
|
|
516
|
+
kind: {
|
|
517
|
+
activity: string;
|
|
518
|
+
alerts: string;
|
|
519
|
+
news: string;
|
|
520
|
+
other: string;
|
|
521
|
+
updates: string;
|
|
522
|
+
};
|
|
523
|
+
log: {
|
|
524
|
+
any: string;
|
|
525
|
+
delivered: string;
|
|
526
|
+
emptyBody: string;
|
|
527
|
+
emptyTitle: string;
|
|
528
|
+
failed: string;
|
|
529
|
+
inApp: string;
|
|
530
|
+
line: string;
|
|
531
|
+
noneTitle: string;
|
|
532
|
+
purpose: string;
|
|
533
|
+
show: string;
|
|
534
|
+
title: string;
|
|
535
|
+
waiting: string;
|
|
536
|
+
waitingShort: string;
|
|
537
|
+
};
|
|
500
538
|
markAll: string;
|
|
501
539
|
markedAll: string;
|
|
502
540
|
markRead: string;
|
|
503
541
|
markUnread: string;
|
|
504
542
|
more: string;
|
|
505
543
|
needsYou: string;
|
|
544
|
+
off: string;
|
|
545
|
+
on: string;
|
|
506
546
|
panel: {
|
|
507
547
|
close: string;
|
|
508
548
|
loading: string;
|
|
@@ -527,12 +567,130 @@ export declare const enTranslations: {
|
|
|
527
567
|
restore: string;
|
|
528
568
|
search: string;
|
|
529
569
|
settings: string;
|
|
570
|
+
send: {
|
|
571
|
+
add: string;
|
|
572
|
+
added: string;
|
|
573
|
+
blank: string;
|
|
574
|
+
chosenMany: string;
|
|
575
|
+
chosenNone: string;
|
|
576
|
+
chosenOne: string;
|
|
577
|
+
day: string;
|
|
578
|
+
details: string;
|
|
579
|
+
detailsHelp: string;
|
|
580
|
+
failed: string;
|
|
581
|
+
failedWhy: string;
|
|
582
|
+
find: string;
|
|
583
|
+
findPlaceholder: string;
|
|
584
|
+
later: string;
|
|
585
|
+
messagePlaceholder: string;
|
|
586
|
+
needChannel: string;
|
|
587
|
+
needDetails: string;
|
|
588
|
+
needFuture: string;
|
|
589
|
+
needMessage: string;
|
|
590
|
+
needPeople: string;
|
|
591
|
+
needTitle: string;
|
|
592
|
+
needTopic: string;
|
|
593
|
+
needWhen: string;
|
|
594
|
+
noPermission: string;
|
|
595
|
+
noTopic: string;
|
|
596
|
+
nobody: string;
|
|
597
|
+
noneSent: string;
|
|
598
|
+
now: string;
|
|
599
|
+
nowHelp: string;
|
|
600
|
+
purpose: string;
|
|
601
|
+
remove: string;
|
|
602
|
+
schedule: string;
|
|
603
|
+
scheduled: string;
|
|
604
|
+
searchFailed: string;
|
|
605
|
+
send: string;
|
|
606
|
+
sentMany: string;
|
|
607
|
+
sentOne: string;
|
|
608
|
+
someSent: string;
|
|
609
|
+
startFrom: string;
|
|
610
|
+
tabMessage: string;
|
|
611
|
+
tabPeople: string;
|
|
612
|
+
tabWhen: string;
|
|
613
|
+
time: string;
|
|
614
|
+
title: string;
|
|
615
|
+
titlePlaceholder: string;
|
|
616
|
+
toMany: string;
|
|
617
|
+
toNobody: string;
|
|
618
|
+
toOne: string;
|
|
619
|
+
topic: string;
|
|
620
|
+
topicHelp: string;
|
|
621
|
+
topicOptional: string;
|
|
622
|
+
when: string;
|
|
623
|
+
zone: string;
|
|
624
|
+
};
|
|
530
625
|
tab: {
|
|
531
626
|
action: string;
|
|
532
627
|
all: string;
|
|
533
628
|
archived: string;
|
|
534
629
|
unread: string;
|
|
535
630
|
};
|
|
631
|
+
template: {
|
|
632
|
+
anotherDetail: string;
|
|
633
|
+
channel: string;
|
|
634
|
+
channelFixed: string;
|
|
635
|
+
create: string;
|
|
636
|
+
created: string;
|
|
637
|
+
detailName: string;
|
|
638
|
+
detailPlaceholder: string;
|
|
639
|
+
detailsHelp: string;
|
|
640
|
+
form: string;
|
|
641
|
+
htmlKept: string;
|
|
642
|
+
insert: string;
|
|
643
|
+
kind: string;
|
|
644
|
+
loading: string;
|
|
645
|
+
message: string;
|
|
646
|
+
messagePlaceholder: string;
|
|
647
|
+
missingBody: string;
|
|
648
|
+
missingTitle: string;
|
|
649
|
+
name: string;
|
|
650
|
+
namePlaceholder: string;
|
|
651
|
+
new: string;
|
|
652
|
+
newDetail: string;
|
|
653
|
+
newDetailHelp: string;
|
|
654
|
+
newPurpose: string;
|
|
655
|
+
now: string;
|
|
656
|
+
preview: string;
|
|
657
|
+
previewFrom: string;
|
|
658
|
+
previewMessage: string;
|
|
659
|
+
previewTitle: string;
|
|
660
|
+
previewWith: string;
|
|
661
|
+
productFallback: string;
|
|
662
|
+
purpose: string;
|
|
663
|
+
save: string;
|
|
664
|
+
saved: string;
|
|
665
|
+
title: string;
|
|
666
|
+
titlePlaceholder: string;
|
|
667
|
+
what: string;
|
|
668
|
+
};
|
|
669
|
+
templates: {
|
|
670
|
+
actionsFor: string;
|
|
671
|
+
channel: string;
|
|
672
|
+
delete: string;
|
|
673
|
+
deleteBody: string;
|
|
674
|
+
deleted: string;
|
|
675
|
+
deleteFailed: string;
|
|
676
|
+
deleteTitle: string;
|
|
677
|
+
edited: string;
|
|
678
|
+
emptyBody: string;
|
|
679
|
+
emptyTitle: string;
|
|
680
|
+
kind: string;
|
|
681
|
+
new: string;
|
|
682
|
+
noMatch: string;
|
|
683
|
+
purpose: string;
|
|
684
|
+
saveFailed: string;
|
|
685
|
+
search: string;
|
|
686
|
+
status: string;
|
|
687
|
+
template: string;
|
|
688
|
+
title: string;
|
|
689
|
+
turnedOff: string;
|
|
690
|
+
turnedOn: string;
|
|
691
|
+
turnOff: string;
|
|
692
|
+
turnOn: string;
|
|
693
|
+
};
|
|
536
694
|
thing: {
|
|
537
695
|
affectedRuns: string;
|
|
538
696
|
attempt: string;
|
|
@@ -544,6 +702,27 @@ export declare const enTranslations: {
|
|
|
544
702
|
timeline: string;
|
|
545
703
|
title: string;
|
|
546
704
|
today: string;
|
|
705
|
+
topics: {
|
|
706
|
+
about: string;
|
|
707
|
+
create: string;
|
|
708
|
+
created: string;
|
|
709
|
+
deleteBody: string;
|
|
710
|
+
deleteTitle: string;
|
|
711
|
+
dialogHelp: string;
|
|
712
|
+
edit: string;
|
|
713
|
+
editTitle: string;
|
|
714
|
+
emptyBody: string;
|
|
715
|
+
emptyTitle: string;
|
|
716
|
+
namePlaceholder: string;
|
|
717
|
+
new: string;
|
|
718
|
+
people: string;
|
|
719
|
+
purpose: string;
|
|
720
|
+
saved: string;
|
|
721
|
+
title: string;
|
|
722
|
+
topic: string;
|
|
723
|
+
turnedOff: string;
|
|
724
|
+
turnedOn: string;
|
|
725
|
+
};
|
|
547
726
|
unread: string;
|
|
548
727
|
yesterday: string;
|
|
549
728
|
};
|
package/dist/v2/InboxPage.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { useNotifications as e } from "../hooks/useNotifications.js";
|
|
2
2
|
import { useTr as t } from "../shared/hooks/useTr.js";
|
|
3
3
|
import { useNotificationPaths as n } from "../navigation-v2/paths.js";
|
|
4
|
-
import {
|
|
5
|
-
import { INBOX_TABS as
|
|
6
|
-
import { InboxRows as
|
|
7
|
-
import { NotificationDetailPanel as
|
|
8
|
-
import { useMarkUnread as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
4
|
+
import { holdsAdminToolPermission as r, useAdminTools as i } from "../navigation-v2/useAdminTools.js";
|
|
5
|
+
import { INBOX_TABS as a, isUnread as o, needsAction as s, readInboxTab as c } from "./model/inbox.js";
|
|
6
|
+
import { InboxRows as l } from "./InboxRows.js";
|
|
7
|
+
import { NotificationDetailPanel as u } from "./NotificationDetailPanel.js";
|
|
8
|
+
import { useMarkUnread as d } from "./useNotificationDetail.js";
|
|
9
|
+
import { SendNotificationDialog as f } from "./send/SendNotificationDialog.js";
|
|
10
|
+
import { SEND_PARAM as p } from "./send/sendModel.js";
|
|
11
|
+
import { useMemo as m } from "react";
|
|
12
|
+
import { usePermissions as h } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
13
|
+
import { CheckCheck as g, Search as _ } from "lucide-react";
|
|
14
|
+
import { Navigate as v, useNavigate as y, useSearchParams as b } from "react-router";
|
|
15
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
16
|
+
import { PageHeader as C } from "@burdenoff/fe-libs/chrome";
|
|
17
|
+
import { Button as w, EmptyState as T, Input as E, LoadError as D, PageTabs as O, useNotify as k } from "@burdenoff/fe-libs/ui";
|
|
15
18
|
// src/v2/InboxPage.tsx
|
|
16
|
-
var
|
|
19
|
+
var A = {
|
|
17
20
|
all: {
|
|
18
21
|
archived: !1,
|
|
19
22
|
channel: "IN_APP"
|
|
@@ -31,145 +34,158 @@ var E = {
|
|
|
31
34
|
archived: !0,
|
|
32
35
|
channel: "IN_APP"
|
|
33
36
|
}
|
|
34
|
-
},
|
|
35
|
-
function
|
|
37
|
+
}, j = { channel: "IN_APP" };
|
|
38
|
+
function M(e, t) {
|
|
36
39
|
return e === "send" ? t.send : e === "templates" ? t.templates : e === "topics" ? t.topics : e === "history" ? t.deliveryLog : null;
|
|
37
40
|
}
|
|
38
|
-
function
|
|
39
|
-
let e = n(), [t] =
|
|
40
|
-
return r ? /* @__PURE__ */
|
|
41
|
+
function N() {
|
|
42
|
+
let e = n(), [t] = b(), r = M(t.get("tab"), e);
|
|
43
|
+
return r ? /* @__PURE__ */ x(v, {
|
|
41
44
|
to: r,
|
|
42
45
|
replace: !0
|
|
43
|
-
}) : /* @__PURE__ */
|
|
46
|
+
}) : /* @__PURE__ */ x(P, {});
|
|
44
47
|
}
|
|
45
|
-
function
|
|
46
|
-
let
|
|
47
|
-
baseFilter:
|
|
48
|
-
unreadFilter:
|
|
49
|
-
}),
|
|
50
|
-
let t = new URLSearchParams(
|
|
51
|
-
e ? t.set("open", e) : t.delete("open"),
|
|
52
|
-
},
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
function P() {
|
|
49
|
+
let v = t(), T = y(), M = k(), N = n(), { tools: P } = i(), { hasPermission: I, isLoading: L } = h(), [R, z] = b(), B = R.get("send") === "1" && !L && r("send", I), V = c(R.get("tab")), H = R.get("open"), U = e({
|
|
50
|
+
baseFilter: A[V],
|
|
51
|
+
unreadFilter: j
|
|
52
|
+
}), W = d(), G = m(() => V === "action" ? U.notifications.filter(s) : U.notifications, [U.notifications, V]), K = U.notificationFilter.search ?? "", q = (e) => {
|
|
53
|
+
let t = new URLSearchParams(R);
|
|
54
|
+
e ? t.set("open", e) : t.delete("open"), z(t);
|
|
55
|
+
}, J = (e) => {
|
|
56
|
+
let t = new URLSearchParams(R);
|
|
57
|
+
e ? t.set(p, "1") : t.delete(p), z(t);
|
|
58
|
+
}, Y = async () => {
|
|
59
|
+
let e = U.allNotifications.filter(o).map((e) => e.id), t = e.length >= U.unreadCount;
|
|
60
|
+
await U.markAllAsRead(), M({
|
|
61
|
+
title: v("notifications.v3.markedAll", "Marked {{count}} as read", { count: U.unreadCount || e.length }),
|
|
56
62
|
tone: "success",
|
|
57
63
|
undo: t && e.length > 0 ? async () => {
|
|
58
|
-
await
|
|
64
|
+
await W(e), await U.refetch();
|
|
59
65
|
} : void 0
|
|
60
66
|
});
|
|
61
|
-
},
|
|
62
|
-
all:
|
|
63
|
-
unread:
|
|
64
|
-
action:
|
|
65
|
-
archived:
|
|
67
|
+
}, X = {
|
|
68
|
+
all: v("notifications.v3.tab.all", "All"),
|
|
69
|
+
unread: v("notifications.v3.tab.unread", "Unread"),
|
|
70
|
+
action: v("notifications.v3.tab.action", "Needs action"),
|
|
71
|
+
archived: v("notifications.v3.tab.archived", "Archived")
|
|
66
72
|
};
|
|
67
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ S("div", {
|
|
68
74
|
"data-account-pages-v2": "notifications",
|
|
69
75
|
className: "flex w-full min-w-0 flex-col",
|
|
70
76
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ x(C, {
|
|
72
78
|
variant: "compact",
|
|
73
|
-
title:
|
|
74
|
-
description:
|
|
75
|
-
primary: /* @__PURE__ */
|
|
79
|
+
title: v("notifications.v3.title", "Notifications"),
|
|
80
|
+
description: v("notifications.v3.purpose", "Everything that needs you, and everything you were told."),
|
|
81
|
+
primary: /* @__PURE__ */ S(w, {
|
|
76
82
|
variant: "outline",
|
|
77
|
-
disabled:
|
|
78
|
-
onClick: () => void
|
|
83
|
+
disabled: U.unreadCount === 0,
|
|
84
|
+
onClick: () => void Y(),
|
|
79
85
|
"data-testid": "inbox-mark-all",
|
|
80
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ x(g, { "aria-hidden": "true" }), v("notifications.v3.markAll", "Mark all as read")]
|
|
81
87
|
}),
|
|
82
88
|
settings: {
|
|
83
|
-
label:
|
|
84
|
-
onClick: () =>
|
|
89
|
+
label: v("notifications.v3.settings", "Notification settings"),
|
|
90
|
+
onClick: () => T(N.preferences)
|
|
85
91
|
},
|
|
86
|
-
more:
|
|
92
|
+
more: P.map((e) => e.id === "send" ? {
|
|
93
|
+
id: e.id,
|
|
94
|
+
label: v("notifications.v3.send.title", "Send a notification"),
|
|
95
|
+
onSelect: () => J(!0)
|
|
96
|
+
} : {
|
|
87
97
|
id: e.id,
|
|
88
98
|
label: e.label,
|
|
89
|
-
onSelect: () =>
|
|
90
|
-
})
|
|
99
|
+
onSelect: () => T(e.href)
|
|
100
|
+
})
|
|
91
101
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
ariaLabel:
|
|
94
|
-
activeId:
|
|
95
|
-
tabs:
|
|
102
|
+
/* @__PURE__ */ x(O, {
|
|
103
|
+
ariaLabel: v("notifications.v3.title", "Notifications"),
|
|
104
|
+
activeId: V,
|
|
105
|
+
tabs: a.map((e) => ({
|
|
96
106
|
id: e,
|
|
97
|
-
label:
|
|
107
|
+
label: X[e],
|
|
98
108
|
href: `?tab=${e}`,
|
|
99
|
-
badge: e === "unread" &&
|
|
109
|
+
badge: e === "unread" && U.unreadCount > 0 ? U.unreadCount : void 0
|
|
100
110
|
}))
|
|
101
111
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ S("div", {
|
|
103
113
|
className: "mt-4 flex flex-col gap-3",
|
|
104
114
|
children: [
|
|
105
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ S("label", {
|
|
106
116
|
className: "relative block max-w-md",
|
|
107
117
|
children: [
|
|
108
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ x("span", {
|
|
109
119
|
className: "sr-only",
|
|
110
|
-
children:
|
|
120
|
+
children: v("notifications.v3.search", "Search notifications")
|
|
111
121
|
}),
|
|
112
|
-
/* @__PURE__ */ _
|
|
122
|
+
/* @__PURE__ */ x(_, {
|
|
113
123
|
className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
|
|
114
124
|
"aria-hidden": "true"
|
|
115
125
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ x(E, {
|
|
117
127
|
type: "search",
|
|
118
128
|
className: "pl-9",
|
|
119
|
-
value:
|
|
120
|
-
placeholder:
|
|
121
|
-
onChange: (e) =>
|
|
129
|
+
value: K,
|
|
130
|
+
placeholder: v("notifications.v3.search", "Search notifications"),
|
|
131
|
+
onChange: (e) => U.updateFilter({ search: e.target.value }),
|
|
122
132
|
"data-testid": "inbox-search"
|
|
123
133
|
})
|
|
124
134
|
]
|
|
125
135
|
}),
|
|
126
|
-
|
|
127
|
-
what:
|
|
128
|
-
error:
|
|
129
|
-
onRetry: () => void
|
|
130
|
-
}) : !
|
|
131
|
-
tab:
|
|
132
|
-
searching: !!
|
|
133
|
-
}) : /* @__PURE__ */
|
|
134
|
-
notifications:
|
|
135
|
-
loading:
|
|
136
|
+
U.error && G.length === 0 ? /* @__PURE__ */ x(D, {
|
|
137
|
+
what: v("notifications.v3.title", "Notifications"),
|
|
138
|
+
error: U.error,
|
|
139
|
+
onRetry: () => void U.refetch()
|
|
140
|
+
}) : !U.isLoading && G.length === 0 ? /* @__PURE__ */ x(F, {
|
|
141
|
+
tab: V,
|
|
142
|
+
searching: !!K.trim()
|
|
143
|
+
}) : /* @__PURE__ */ x(l, {
|
|
144
|
+
notifications: G,
|
|
145
|
+
loading: U.isLoading && G.length === 0,
|
|
136
146
|
onOpen: (e) => {
|
|
137
|
-
|
|
138
|
-
let t =
|
|
139
|
-
t &&
|
|
147
|
+
q(e);
|
|
148
|
+
let t = G.find((t) => t.id === e);
|
|
149
|
+
t && o(t) && U.markAsRead(e);
|
|
140
150
|
},
|
|
141
|
-
onMarkRead: (e) => void
|
|
142
|
-
onMarkUnread: (e) => void
|
|
143
|
-
onArchive: (e) => void
|
|
144
|
-
onRestore: (e) => void
|
|
151
|
+
onMarkRead: (e) => void U.markAsRead(e),
|
|
152
|
+
onMarkUnread: (e) => void W([e]).then(() => U.refetch()),
|
|
153
|
+
onArchive: (e) => void U.archiveNotification(e),
|
|
154
|
+
onRestore: (e) => void U.unarchiveNotification(e)
|
|
145
155
|
}),
|
|
146
|
-
|
|
156
|
+
U.hasMore ? /* @__PURE__ */ x("div", {
|
|
147
157
|
className: "flex justify-center",
|
|
148
|
-
children: /* @__PURE__ */
|
|
158
|
+
children: /* @__PURE__ */ x(w, {
|
|
149
159
|
variant: "ghost",
|
|
150
|
-
busy:
|
|
151
|
-
onClick: () => void
|
|
160
|
+
busy: U.isLoadingMore,
|
|
161
|
+
onClick: () => void U.loadMore(),
|
|
152
162
|
"data-testid": "inbox-more",
|
|
153
|
-
children:
|
|
163
|
+
children: v("notifications.v3.more", "Show more")
|
|
154
164
|
})
|
|
155
165
|
}) : null
|
|
156
166
|
]
|
|
157
167
|
}),
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
id:
|
|
160
|
-
onClose: () =>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
/* @__PURE__ */ x(u, {
|
|
169
|
+
id: H,
|
|
170
|
+
onClose: () => q(null),
|
|
171
|
+
inboxActions: {
|
|
172
|
+
markUnread: (e) => void W([e]).then(() => U.refetch()),
|
|
173
|
+
archive: (e) => {
|
|
174
|
+
U.archiveNotification(e), q(null);
|
|
175
|
+
},
|
|
176
|
+
restore: (e) => void U.unarchiveNotification(e)
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
/* @__PURE__ */ x(f, {
|
|
180
|
+
open: B,
|
|
181
|
+
onClose: () => J(!1)
|
|
166
182
|
})
|
|
167
183
|
]
|
|
168
184
|
});
|
|
169
185
|
}
|
|
170
|
-
function
|
|
186
|
+
function F({ tab: e, searching: n }) {
|
|
171
187
|
let r = t();
|
|
172
|
-
if (n) return /* @__PURE__ */
|
|
188
|
+
if (n) return /* @__PURE__ */ x(T, {
|
|
173
189
|
kind: "no-results",
|
|
174
190
|
title: r("notifications.v3.empty.searchTitle", "No notifications match"),
|
|
175
191
|
description: r("notifications.v3.empty.searchBody", "Try other words.")
|
|
@@ -180,12 +196,12 @@ function j({ tab: e, searching: n }) {
|
|
|
180
196
|
action: [r("notifications.v3.empty.actionTitle", "Nothing waiting for you"), r("notifications.v3.empty.actionBody", "Approvals and requests show up here.")],
|
|
181
197
|
archived: [r("notifications.v3.empty.archivedTitle", "Nothing archived"), r("notifications.v3.empty.archivedBody", "Archive a notification to keep it out of the way. It stays here.")]
|
|
182
198
|
}[e];
|
|
183
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ x(T, {
|
|
184
200
|
kind: e === "archived" ? "first-use" : "all-done",
|
|
185
201
|
title: i,
|
|
186
202
|
description: a
|
|
187
203
|
});
|
|
188
204
|
}
|
|
189
|
-
export {
|
|
205
|
+
export { N as InboxPage };
|
|
190
206
|
|
|
191
207
|
//# sourceMappingURL=InboxPage.js.map
|