@voyant-travel/notifications-react 0.111.7
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/LICENSE +201 -0
- package/README.md +30 -0
- package/dist/admin/index.d.ts +70 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +104 -0
- package/dist/admin/notification-deliveries-host.d.ts +7 -0
- package/dist/admin/notification-deliveries-host.d.ts.map +1 -0
- package/dist/admin/notification-deliveries-host.js +92 -0
- package/dist/admin/notification-delivery-detail-dialog.d.ts +8 -0
- package/dist/admin/notification-delivery-detail-dialog.d.ts.map +1 -0
- package/dist/admin/notification-delivery-detail-dialog.js +30 -0
- package/dist/admin/notification-reminder-rule-detail-host.d.ts +12 -0
- package/dist/admin/notification-reminder-rule-detail-host.d.ts.map +1 -0
- package/dist/admin/notification-reminder-rule-detail-host.js +23 -0
- package/dist/admin/notification-reminder-rule-dialog.d.ts +10 -0
- package/dist/admin/notification-reminder-rule-dialog.d.ts.map +1 -0
- package/dist/admin/notification-reminder-rule-dialog.js +122 -0
- package/dist/admin/notification-reminder-rules-host.d.ts +8 -0
- package/dist/admin/notification-reminder-rules-host.d.ts.map +1 -0
- package/dist/admin/notification-reminder-rules-host.js +57 -0
- package/dist/admin/notification-reminder-runs-host.d.ts +7 -0
- package/dist/admin/notification-reminder-runs-host.d.ts.map +1 -0
- package/dist/admin/notification-reminder-runs-host.js +28 -0
- package/dist/admin/notification-settings-host.d.ts +7 -0
- package/dist/admin/notification-settings-host.d.ts.map +1 -0
- package/dist/admin/notification-settings-host.js +11 -0
- package/dist/admin/notification-template-attachments-field.d.ts +10 -0
- package/dist/admin/notification-template-attachments-field.d.ts.map +1 -0
- package/dist/admin/notification-template-attachments-field.js +6 -0
- package/dist/admin/notification-template-authoring-help.d.ts +25 -0
- package/dist/admin/notification-template-authoring-help.d.ts.map +1 -0
- package/dist/admin/notification-template-authoring-help.js +8 -0
- package/dist/admin/notification-template-detail-host.d.ts +11 -0
- package/dist/admin/notification-template-detail-host.d.ts.map +1 -0
- package/dist/admin/notification-template-detail-host.js +159 -0
- package/dist/admin/notification-template-dialog-utils.d.ts +53 -0
- package/dist/admin/notification-template-dialog-utils.d.ts.map +1 -0
- package/dist/admin/notification-template-dialog-utils.js +112 -0
- package/dist/admin/notification-template-dialog.d.ts +10 -0
- package/dist/admin/notification-template-dialog.d.ts.map +1 -0
- package/dist/admin/notification-template-dialog.js +253 -0
- package/dist/admin/notification-template-rendered-preview.d.ts +14 -0
- package/dist/admin/notification-template-rendered-preview.d.ts.map +1 -0
- package/dist/admin/notification-template-rendered-preview.js +6 -0
- package/dist/admin/notification-templates-host.d.ts +9 -0
- package/dist/admin/notification-templates-host.d.ts.map +1 -0
- package/dist/admin/notification-templates-host.js +52 -0
- package/dist/admin/notifications-admin-shared.d.ts +14 -0
- package/dist/admin/notifications-admin-shared.d.ts.map +1 -0
- package/dist/admin/notifications-admin-shared.js +17 -0
- package/dist/admin/pages/notification-reminder-rule-detail-page.d.ts +8 -0
- package/dist/admin/pages/notification-reminder-rule-detail-page.d.ts.map +1 -0
- package/dist/admin/pages/notification-reminder-rule-detail-page.js +10 -0
- package/dist/admin/pages/notification-template-detail-page.d.ts +7 -0
- package/dist/admin/pages/notification-template-detail-page.d.ts.map +1 -0
- package/dist/admin/pages/notification-template-detail-page.js +9 -0
- package/dist/admin/reminders-preview-host.d.ts +7 -0
- package/dist/admin/reminders-preview-host.d.ts.map +1 -0
- package/dist/admin/reminders-preview-host.js +13 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +71 -0
- package/dist/components/notification-settings-form.d.ts +2 -0
- package/dist/components/notification-settings-form.d.ts.map +1 -0
- package/dist/components/notification-settings-form.js +66 -0
- package/dist/components/reminders-preview-list.d.ts +6 -0
- package/dist/components/reminders-preview-list.d.ts.map +1 -0
- package/dist/components/reminders-preview-list.js +19 -0
- package/dist/components/stage-channel-editor-dialog.d.ts +11 -0
- package/dist/components/stage-channel-editor-dialog.d.ts.map +1 -0
- package/dist/components/stage-channel-editor-dialog.js +77 -0
- package/dist/components/stage-channel-list.d.ts +6 -0
- package/dist/components/stage-channel-list.d.ts.map +1 -0
- package/dist/components/stage-channel-list.js +20 -0
- package/dist/components/stage-editor-dialog.d.ts +10 -0
- package/dist/components/stage-editor-dialog.d.ts.map +1 -0
- package/dist/components/stage-editor-dialog.js +104 -0
- package/dist/components/stage-list.d.ts +5 -0
- package/dist/components/stage-list.d.ts.map +1 -0
- package/dist/components/stage-list.js +34 -0
- package/dist/components/template-picker.d.ts +19 -0
- package/dist/components/template-picker.d.ts.map +1 -0
- package/dist/components/template-picker.js +26 -0
- package/dist/components/timezone-combobox.d.ts +9 -0
- package/dist/components/timezone-combobox.d.ts.map +1 -0
- package/dist/components/timezone-combobox.js +67 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/use-notification-deliveries.d.ts +39 -0
- package/dist/hooks/use-notification-deliveries.d.ts.map +1 -0
- package/dist/hooks/use-notification-deliveries.js +12 -0
- package/dist/hooks/use-notification-delivery-mutation.d.ts +32 -0
- package/dist/hooks/use-notification-delivery-mutation.d.ts.map +1 -0
- package/dist/hooks/use-notification-delivery-mutation.js +24 -0
- package/dist/hooks/use-notification-delivery.d.ts +32 -0
- package/dist/hooks/use-notification-delivery.d.ts.map +1 -0
- package/dist/hooks/use-notification-delivery.js +12 -0
- package/dist/hooks/use-notification-reminder-rule-mutation.d.ts +53 -0
- package/dist/hooks/use-notification-reminder-rule-mutation.d.ts.map +1 -0
- package/dist/hooks/use-notification-reminder-rule-mutation.js +31 -0
- package/dist/hooks/use-notification-reminder-rule.d.ts +19 -0
- package/dist/hooks/use-notification-reminder-rule.d.ts.map +1 -0
- package/dist/hooks/use-notification-reminder-rule.js +12 -0
- package/dist/hooks/use-notification-reminder-rules.d.ts +25 -0
- package/dist/hooks/use-notification-reminder-rules.d.ts.map +1 -0
- package/dist/hooks/use-notification-reminder-rules.js +12 -0
- package/dist/hooks/use-notification-reminder-runs.d.ts +56 -0
- package/dist/hooks/use-notification-reminder-runs.d.ts.map +1 -0
- package/dist/hooks/use-notification-reminder-runs.js +12 -0
- package/dist/hooks/use-notification-settings.d.ts +50 -0
- package/dist/hooks/use-notification-settings.d.ts.map +1 -0
- package/dist/hooks/use-notification-settings.js +26 -0
- package/dist/hooks/use-notification-template-authoring.d.ts +5 -0
- package/dist/hooks/use-notification-template-authoring.d.ts.map +1 -0
- package/dist/hooks/use-notification-template-authoring.js +8 -0
- package/dist/hooks/use-notification-template-mutation.d.ts +54 -0
- package/dist/hooks/use-notification-template-mutation.d.ts.map +1 -0
- package/dist/hooks/use-notification-template-mutation.js +31 -0
- package/dist/hooks/use-notification-template-tools.d.ts +80 -0
- package/dist/hooks/use-notification-template-tools.d.ts.map +1 -0
- package/dist/hooks/use-notification-template-tools.js +21 -0
- package/dist/hooks/use-notification-template.d.ts +20 -0
- package/dist/hooks/use-notification-template.d.ts.map +1 -0
- package/dist/hooks/use-notification-template.js +12 -0
- package/dist/hooks/use-notification-templates.d.ts +26 -0
- package/dist/hooks/use-notification-templates.d.ts.map +1 -0
- package/dist/hooks/use-notification-templates.js +12 -0
- package/dist/hooks/use-reminder-rule-stage-mutation.d.ts +93 -0
- package/dist/hooks/use-reminder-rule-stage-mutation.d.ts.map +1 -0
- package/dist/hooks/use-reminder-rule-stage-mutation.js +53 -0
- package/dist/hooks/use-reminder-rule-stages.d.ts +25 -0
- package/dist/hooks/use-reminder-rule-stages.d.ts.map +1 -0
- package/dist/hooks/use-reminder-rule-stages.js +12 -0
- package/dist/hooks/use-reminder-stage-channel-mutation.d.ts +48 -0
- package/dist/hooks/use-reminder-stage-channel-mutation.d.ts.map +1 -0
- package/dist/hooks/use-reminder-stage-channel-mutation.js +42 -0
- package/dist/hooks/use-reminder-stage-channels.d.ts +18 -0
- package/dist/hooks/use-reminder-stage-channels.d.ts.map +1 -0
- package/dist/hooks/use-reminder-stage-channels.js +12 -0
- package/dist/hooks/use-reminders-preview.d.ts +21 -0
- package/dist/hooks/use-reminders-preview.d.ts.map +1 -0
- package/dist/hooks/use-reminders-preview.js +12 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +385 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/messages.d.ts +386 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +26 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro.d.ts +3 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +385 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +72 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +19 -0
- package/dist/query-options.d.ts +1252 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +120 -0
- package/dist/schemas.d.ts +796 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +173 -0
- package/dist/ui.d.ts +9 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +8 -0
- package/package.json +138 -0
- package/src/styles.css +2 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { insertNotificationTemplateSchema, updateNotificationTemplateSchema } from "@voyant-travel/notifications";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateNotificationTemplateInput = z.input<typeof insertNotificationTemplateSchema>;
|
|
4
|
+
export type UpdateNotificationTemplateInput = z.input<typeof updateNotificationTemplateSchema>;
|
|
5
|
+
export declare function useNotificationTemplateMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
name: string;
|
|
10
|
+
channel: "email" | "sms";
|
|
11
|
+
provider: string | null;
|
|
12
|
+
status: "draft" | "active" | "archived";
|
|
13
|
+
subjectTemplate: string | null;
|
|
14
|
+
htmlTemplate: string | null;
|
|
15
|
+
textTemplate: string | null;
|
|
16
|
+
fromAddress: string | null;
|
|
17
|
+
isSystem: boolean;
|
|
18
|
+
metadata: Record<string, unknown> | null;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}, Error, {
|
|
22
|
+
slug: string;
|
|
23
|
+
name: string;
|
|
24
|
+
channel: "email" | "sms";
|
|
25
|
+
provider?: string | null | undefined;
|
|
26
|
+
status?: "draft" | "active" | "archived" | undefined;
|
|
27
|
+
subjectTemplate?: string | null | undefined;
|
|
28
|
+
htmlTemplate?: string | null | undefined;
|
|
29
|
+
textTemplate?: string | null | undefined;
|
|
30
|
+
fromAddress?: string | null | undefined;
|
|
31
|
+
isSystem?: boolean | undefined;
|
|
32
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
33
|
+
}, unknown>;
|
|
34
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
35
|
+
id: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
name: string;
|
|
38
|
+
channel: "email" | "sms";
|
|
39
|
+
provider: string | null;
|
|
40
|
+
status: "draft" | "active" | "archived";
|
|
41
|
+
subjectTemplate: string | null;
|
|
42
|
+
htmlTemplate: string | null;
|
|
43
|
+
textTemplate: string | null;
|
|
44
|
+
fromAddress: string | null;
|
|
45
|
+
isSystem: boolean;
|
|
46
|
+
metadata: Record<string, unknown> | null;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
}, Error, {
|
|
50
|
+
id: string;
|
|
51
|
+
input: UpdateNotificationTemplateInput;
|
|
52
|
+
}, unknown>;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=use-notification-template-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-notification-template-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-template-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAC9F,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAE9F,wBAAgB,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBH,MAAM;eAAS,+BAA+B;;EAgBzF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
5
|
+
import { notificationsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { notificationTemplateSingleResponse } from "../schemas.js";
|
|
7
|
+
export function useNotificationTemplateMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/admin/notifications/templates", notificationTemplateSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.templates() });
|
|
17
|
+
queryClient.setQueryData(notificationsQueryKeys.template(data.id), data);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/admin/notifications/templates/${id}`, notificationTemplateSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.templates() });
|
|
27
|
+
queryClient.setQueryData(notificationsQueryKeys.template(data.id), data);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return { create, update };
|
|
31
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { previewNotificationTemplateSchema, sendNotificationSchema } from "@voyant-travel/notifications";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type PreviewNotificationTemplateInput = z.input<typeof previewNotificationTemplateSchema>;
|
|
4
|
+
export type SendNotificationInput = z.input<typeof sendNotificationSchema>;
|
|
5
|
+
export declare function useNotificationTemplateTools(): {
|
|
6
|
+
preview: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
channel: "email" | "sms";
|
|
8
|
+
provider: string | null;
|
|
9
|
+
fromAddress: string | null;
|
|
10
|
+
subject: string | null;
|
|
11
|
+
html: string | null;
|
|
12
|
+
text: string | null;
|
|
13
|
+
}, Error, {
|
|
14
|
+
channel: "email" | "sms";
|
|
15
|
+
provider?: string | null | undefined;
|
|
16
|
+
subjectTemplate?: string | null | undefined;
|
|
17
|
+
htmlTemplate?: string | null | undefined;
|
|
18
|
+
textTemplate?: string | null | undefined;
|
|
19
|
+
fromAddress?: string | null | undefined;
|
|
20
|
+
data?: Record<string, unknown> | null | undefined;
|
|
21
|
+
}, unknown>;
|
|
22
|
+
testSend: import("@tanstack/react-query").UseMutationResult<{
|
|
23
|
+
id: string;
|
|
24
|
+
templateId: string | null;
|
|
25
|
+
templateSlug: string | null;
|
|
26
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "organization" | "payment_session";
|
|
27
|
+
targetId: string | null;
|
|
28
|
+
personId: string | null;
|
|
29
|
+
organizationId: string | null;
|
|
30
|
+
bookingId: string | null;
|
|
31
|
+
invoiceId: string | null;
|
|
32
|
+
paymentSessionId: string | null;
|
|
33
|
+
channel: "email" | "sms";
|
|
34
|
+
provider: string;
|
|
35
|
+
providerMessageId: string | null;
|
|
36
|
+
status: "pending" | "failed" | "cancelled" | "sent";
|
|
37
|
+
toAddress: string;
|
|
38
|
+
fromAddress: string | null;
|
|
39
|
+
subject: string | null;
|
|
40
|
+
htmlBody: string | null;
|
|
41
|
+
textBody: string | null;
|
|
42
|
+
payloadData: Record<string, unknown> | null;
|
|
43
|
+
metadata: Record<string, unknown> | null;
|
|
44
|
+
errorMessage: string | null;
|
|
45
|
+
scheduledFor: string | null;
|
|
46
|
+
sentAt: string | null;
|
|
47
|
+
failedAt: string | null;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
}, Error, {
|
|
51
|
+
to: string;
|
|
52
|
+
templateId?: string | null | undefined;
|
|
53
|
+
templateSlug?: string | null | undefined;
|
|
54
|
+
channel?: "email" | "sms" | undefined;
|
|
55
|
+
provider?: string | null | undefined;
|
|
56
|
+
from?: string | null | undefined;
|
|
57
|
+
subject?: string | null | undefined;
|
|
58
|
+
html?: string | null | undefined;
|
|
59
|
+
text?: string | null | undefined;
|
|
60
|
+
attachments?: {
|
|
61
|
+
filename: string;
|
|
62
|
+
contentBase64?: string | null | undefined;
|
|
63
|
+
path?: string | null | undefined;
|
|
64
|
+
contentType?: string | null | undefined;
|
|
65
|
+
disposition?: "inline" | "attachment" | null | undefined;
|
|
66
|
+
contentId?: string | null | undefined;
|
|
67
|
+
}[] | null | undefined;
|
|
68
|
+
data?: Record<string, unknown> | null | undefined;
|
|
69
|
+
targetType?: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "organization" | "payment_session" | undefined;
|
|
70
|
+
targetId?: string | null | undefined;
|
|
71
|
+
bookingId?: string | null | undefined;
|
|
72
|
+
invoiceId?: string | null | undefined;
|
|
73
|
+
paymentSessionId?: string | null | undefined;
|
|
74
|
+
personId?: string | null | undefined;
|
|
75
|
+
organizationId?: string | null | undefined;
|
|
76
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
77
|
+
scheduledFor?: string | null | undefined;
|
|
78
|
+
}, unknown>;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=use-notification-template-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-notification-template-tools.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-template-tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iCAAiC,EACjC,sBAAsB,EACvB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAS5B,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAChG,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE1E,wBAAgB,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B3C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
5
|
+
import { notificationDeliverySingleResponse, notificationTemplatePreviewResponse, } from "../schemas.js";
|
|
6
|
+
export function useNotificationTemplateTools() {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
8
|
+
const preview = useMutation({
|
|
9
|
+
mutationFn: async (input) => {
|
|
10
|
+
const { data } = await fetchWithValidation("/v1/admin/notifications/preview", notificationTemplatePreviewResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
11
|
+
return data;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const testSend = useMutation({
|
|
15
|
+
mutationFn: async (input) => {
|
|
16
|
+
const { data } = await fetchWithValidation("/v1/admin/notifications/send", notificationDeliverySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
17
|
+
return data;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return { preview, testSend };
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UseNotificationTemplateOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useNotificationTemplate(id: string, options?: UseNotificationTemplateOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
name: string;
|
|
8
|
+
channel: "email" | "sms";
|
|
9
|
+
provider: string | null;
|
|
10
|
+
status: "draft" | "active" | "archived";
|
|
11
|
+
subjectTemplate: string | null;
|
|
12
|
+
htmlTemplate: string | null;
|
|
13
|
+
textTemplate: string | null;
|
|
14
|
+
fromAddress: string | null;
|
|
15
|
+
isSystem: boolean;
|
|
16
|
+
metadata: Record<string, unknown> | null;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}, Error>;
|
|
20
|
+
//# sourceMappingURL=use-notification-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-notification-template.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-template.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,8BAAmC;;;;;;;;;;;;;;;UAO/F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
4
|
+
import { getNotificationTemplateQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useNotificationTemplate(id, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getNotificationTemplateQueryOptions({ baseUrl, fetcher }, id, options),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NotificationTemplatesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseNotificationTemplatesOptions extends NotificationTemplatesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useNotificationTemplates(options?: UseNotificationTemplatesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
name: string;
|
|
10
|
+
channel: "email" | "sms";
|
|
11
|
+
provider: string | null;
|
|
12
|
+
status: "draft" | "active" | "archived";
|
|
13
|
+
subjectTemplate: string | null;
|
|
14
|
+
htmlTemplate: string | null;
|
|
15
|
+
textTemplate: string | null;
|
|
16
|
+
fromAddress: string | null;
|
|
17
|
+
isSystem: boolean;
|
|
18
|
+
metadata: Record<string, unknown> | null;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}[];
|
|
22
|
+
total: number;
|
|
23
|
+
limit: number;
|
|
24
|
+
offset: number;
|
|
25
|
+
}, Error>;
|
|
26
|
+
//# sourceMappingURL=use-notification-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-notification-templates.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-templates.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAA;AAGxE,MAAM,WAAW,+BAAgC,SAAQ,gCAAgC;IACvF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,+BAAoC;;;;;;;;;;;;;;;;;;;;UAOrF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
4
|
+
import { getNotificationTemplatesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useNotificationTemplates(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
7
|
+
const { enabled = true, ...filters } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getNotificationTemplatesQueryOptions({ baseUrl, fetcher }, filters),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { insertNotificationReminderRuleStageSchema, reorderReminderRuleStagesSchema, updateNotificationReminderRuleStageSchema } from "@voyant-travel/notifications";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateReminderRuleStageInput = z.input<typeof insertNotificationReminderRuleStageSchema>;
|
|
4
|
+
export type UpdateReminderRuleStageInput = z.input<typeof updateNotificationReminderRuleStageSchema>;
|
|
5
|
+
export type ReorderReminderRuleStagesInput = z.input<typeof reorderReminderRuleStagesSchema>;
|
|
6
|
+
export declare function useReminderRuleStageMutation(reminderRuleId: string): {
|
|
7
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
8
|
+
id: string;
|
|
9
|
+
reminderRuleId: string;
|
|
10
|
+
orderIndex: number;
|
|
11
|
+
name: string | null;
|
|
12
|
+
anchor: "due_date" | "booking_created_at" | "departure_date" | "invoice_issued_at" | "last_send_at";
|
|
13
|
+
windowStartDays: number;
|
|
14
|
+
windowEndDays: number;
|
|
15
|
+
cadenceKind: "once" | "every_n_days" | "escalating";
|
|
16
|
+
cadenceEveryDays: number | null;
|
|
17
|
+
cadenceIntervals: {
|
|
18
|
+
repeatEveryDays: number;
|
|
19
|
+
whenDaysUntilDueGT?: number | null | undefined;
|
|
20
|
+
whenDaysUntilDueLT?: number | null | undefined;
|
|
21
|
+
}[] | null;
|
|
22
|
+
maxSendsInStage: number | null;
|
|
23
|
+
respectQuietHours: boolean;
|
|
24
|
+
metadata: Record<string, unknown> | null;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}, Error, {
|
|
28
|
+
orderIndex: unknown;
|
|
29
|
+
anchor: "due_date" | "booking_created_at" | "departure_date" | "invoice_issued_at" | "last_send_at";
|
|
30
|
+
windowStartDays: unknown;
|
|
31
|
+
windowEndDays: unknown;
|
|
32
|
+
cadenceKind: "once" | "every_n_days" | "escalating";
|
|
33
|
+
name?: string | null | undefined;
|
|
34
|
+
cadenceEveryDays?: unknown;
|
|
35
|
+
cadenceIntervals?: {
|
|
36
|
+
repeatEveryDays: unknown;
|
|
37
|
+
whenDaysUntilDueGT?: unknown;
|
|
38
|
+
whenDaysUntilDueLT?: unknown;
|
|
39
|
+
}[] | null | undefined;
|
|
40
|
+
maxSendsInStage?: unknown;
|
|
41
|
+
respectQuietHours?: boolean | undefined;
|
|
42
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
43
|
+
}, unknown>;
|
|
44
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
45
|
+
id: string;
|
|
46
|
+
reminderRuleId: string;
|
|
47
|
+
orderIndex: number;
|
|
48
|
+
name: string | null;
|
|
49
|
+
anchor: "due_date" | "booking_created_at" | "departure_date" | "invoice_issued_at" | "last_send_at";
|
|
50
|
+
windowStartDays: number;
|
|
51
|
+
windowEndDays: number;
|
|
52
|
+
cadenceKind: "once" | "every_n_days" | "escalating";
|
|
53
|
+
cadenceEveryDays: number | null;
|
|
54
|
+
cadenceIntervals: {
|
|
55
|
+
repeatEveryDays: number;
|
|
56
|
+
whenDaysUntilDueGT?: number | null | undefined;
|
|
57
|
+
whenDaysUntilDueLT?: number | null | undefined;
|
|
58
|
+
}[] | null;
|
|
59
|
+
maxSendsInStage: number | null;
|
|
60
|
+
respectQuietHours: boolean;
|
|
61
|
+
metadata: Record<string, unknown> | null;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
}, Error, {
|
|
65
|
+
stageId: string;
|
|
66
|
+
input: UpdateReminderRuleStageInput;
|
|
67
|
+
}, unknown>;
|
|
68
|
+
remove: import("@tanstack/react-query").UseMutationResult<string, Error, string, unknown>;
|
|
69
|
+
reorder: import("@tanstack/react-query").UseMutationResult<{
|
|
70
|
+
id: string;
|
|
71
|
+
reminderRuleId: string;
|
|
72
|
+
orderIndex: number;
|
|
73
|
+
name: string | null;
|
|
74
|
+
anchor: "due_date" | "booking_created_at" | "departure_date" | "invoice_issued_at" | "last_send_at";
|
|
75
|
+
windowStartDays: number;
|
|
76
|
+
windowEndDays: number;
|
|
77
|
+
cadenceKind: "once" | "every_n_days" | "escalating";
|
|
78
|
+
cadenceEveryDays: number | null;
|
|
79
|
+
cadenceIntervals: {
|
|
80
|
+
repeatEveryDays: number;
|
|
81
|
+
whenDaysUntilDueGT?: number | null | undefined;
|
|
82
|
+
whenDaysUntilDueLT?: number | null | undefined;
|
|
83
|
+
}[] | null;
|
|
84
|
+
maxSendsInStage: number | null;
|
|
85
|
+
respectQuietHours: boolean;
|
|
86
|
+
metadata: Record<string, unknown> | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
}[], Error, {
|
|
90
|
+
stageIds: string[];
|
|
91
|
+
}, unknown>;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=use-reminder-rule-stage-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reminder-rule-stage-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reminder-rule-stage-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yCAAyC,EACzC,+BAA+B,EAC/B,yCAAyC,EAC1C,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAA;AACpG,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAA;AACpG,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAE5F,wBAAgB,4BAA4B,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BpD,MAAM;eACR,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CxC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
5
|
+
import { notificationsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { reminderRuleStageSingleResponse, reminderRuleStagesListResponse } from "../schemas.js";
|
|
7
|
+
export function useReminderRuleStageMutation(reminderRuleId) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const base = `/v1/admin/notifications/reminder-rules/${reminderRuleId}/stages`;
|
|
11
|
+
const invalidate = () => queryClient.invalidateQueries({
|
|
12
|
+
queryKey: notificationsQueryKeys.reminderRuleStages(reminderRuleId),
|
|
13
|
+
});
|
|
14
|
+
const create = useMutation({
|
|
15
|
+
mutationFn: async (input) => {
|
|
16
|
+
const { data } = await fetchWithValidation(base, reminderRuleStageSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
17
|
+
return data;
|
|
18
|
+
},
|
|
19
|
+
onSuccess: () => {
|
|
20
|
+
void invalidate();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const update = useMutation({
|
|
24
|
+
mutationFn: async ({ stageId, input, }) => {
|
|
25
|
+
const { data } = await fetchWithValidation(`${base}/${stageId}`, reminderRuleStageSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
26
|
+
return data;
|
|
27
|
+
},
|
|
28
|
+
onSuccess: () => {
|
|
29
|
+
void invalidate();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const remove = useMutation({
|
|
33
|
+
mutationFn: async (stageId) => {
|
|
34
|
+
await fetchWithValidation(`${base}/${stageId}`,
|
|
35
|
+
// 204 → empty body; pass-through using a permissive schema
|
|
36
|
+
reminderRuleStagesListResponse.optional(), { baseUrl, fetcher }, { method: "DELETE" }).catch(() => null);
|
|
37
|
+
return stageId;
|
|
38
|
+
},
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
void invalidate();
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const reorder = useMutation({
|
|
44
|
+
mutationFn: async (input) => {
|
|
45
|
+
const { data } = await fetchWithValidation(`${base}/reorder`, reminderRuleStagesListResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
46
|
+
return data;
|
|
47
|
+
},
|
|
48
|
+
onSuccess: () => {
|
|
49
|
+
void invalidate();
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return { create, update, remove, reorder };
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface UseReminderRuleStagesOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useReminderRuleStages(reminderRuleId: string, options?: UseReminderRuleStagesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
reminderRuleId: string;
|
|
7
|
+
orderIndex: number;
|
|
8
|
+
name: string | null;
|
|
9
|
+
anchor: "due_date" | "booking_created_at" | "departure_date" | "invoice_issued_at" | "last_send_at";
|
|
10
|
+
windowStartDays: number;
|
|
11
|
+
windowEndDays: number;
|
|
12
|
+
cadenceKind: "once" | "every_n_days" | "escalating";
|
|
13
|
+
cadenceEveryDays: number | null;
|
|
14
|
+
cadenceIntervals: {
|
|
15
|
+
repeatEveryDays: number;
|
|
16
|
+
whenDaysUntilDueGT?: number | null | undefined;
|
|
17
|
+
whenDaysUntilDueLT?: number | null | undefined;
|
|
18
|
+
}[] | null;
|
|
19
|
+
maxSendsInStage: number | null;
|
|
20
|
+
respectQuietHours: boolean;
|
|
21
|
+
metadata: Record<string, unknown> | null;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
}[], Error>;
|
|
25
|
+
//# sourceMappingURL=use-reminder-rule-stages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reminder-rule-stages.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reminder-rule-stages.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,4BAAiC;;;;;;;;;;;;;;;;;;;;YAQ3C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
4
|
+
import { getReminderRuleStagesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useReminderRuleStages(reminderRuleId, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getReminderRuleStagesQueryOptions({ baseUrl, fetcher }, reminderRuleId),
|
|
10
|
+
enabled: enabled && Boolean(reminderRuleId),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { insertNotificationReminderStageChannelSchema, updateNotificationReminderStageChannelSchema } from "@voyant-travel/notifications";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateReminderStageChannelInput = z.input<typeof insertNotificationReminderStageChannelSchema>;
|
|
4
|
+
export type UpdateReminderStageChannelInput = z.input<typeof updateNotificationReminderStageChannelSchema>;
|
|
5
|
+
export declare function useReminderStageChannelMutation(reminderRuleId: string, stageId: string): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
stageId: string;
|
|
9
|
+
orderIndex: number;
|
|
10
|
+
channel: "email" | "sms";
|
|
11
|
+
provider: string | null;
|
|
12
|
+
templateId: string | null;
|
|
13
|
+
templateSlug: string | null;
|
|
14
|
+
recipientKind: "primary" | "cc" | "bcc";
|
|
15
|
+
recipientRole: string | null;
|
|
16
|
+
metadata: Record<string, unknown> | null;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}, Error, {
|
|
20
|
+
channel: "email" | "sms";
|
|
21
|
+
orderIndex?: unknown;
|
|
22
|
+
provider?: string | null | undefined;
|
|
23
|
+
templateId?: string | null | undefined;
|
|
24
|
+
templateSlug?: string | null | undefined;
|
|
25
|
+
recipientKind?: "primary" | "cc" | "bcc" | undefined;
|
|
26
|
+
recipientRole?: string | null | undefined;
|
|
27
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
28
|
+
}, unknown>;
|
|
29
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
30
|
+
id: string;
|
|
31
|
+
stageId: string;
|
|
32
|
+
orderIndex: number;
|
|
33
|
+
channel: "email" | "sms";
|
|
34
|
+
provider: string | null;
|
|
35
|
+
templateId: string | null;
|
|
36
|
+
templateSlug: string | null;
|
|
37
|
+
recipientKind: "primary" | "cc" | "bcc";
|
|
38
|
+
recipientRole: string | null;
|
|
39
|
+
metadata: Record<string, unknown> | null;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
}, Error, {
|
|
43
|
+
channelId: string;
|
|
44
|
+
input: UpdateReminderStageChannelInput;
|
|
45
|
+
}, unknown>;
|
|
46
|
+
remove: import("@tanstack/react-query").UseMutationResult<string, Error, string, unknown>;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=use-reminder-stage-channel-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reminder-stage-channel-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reminder-stage-channel-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,4CAA4C,EAC5C,4CAA4C,EAC7C,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,4CAA4C,CACpD,CAAA;AACD,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,4CAA4C,CACpD,CAAA;AAED,wBAAgB,+BAA+B,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA8BtE,MAAM;eACV,+BAA+B;;;EA+B3C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
5
|
+
import { notificationsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { reminderStageChannelSingleResponse } from "../schemas.js";
|
|
7
|
+
export function useReminderStageChannelMutation(reminderRuleId, stageId) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const base = `/v1/admin/notifications/reminder-rules/${reminderRuleId}/stages/${stageId}/channels`;
|
|
11
|
+
const invalidate = () => queryClient.invalidateQueries({
|
|
12
|
+
queryKey: notificationsQueryKeys.reminderStageChannels(stageId),
|
|
13
|
+
});
|
|
14
|
+
const create = useMutation({
|
|
15
|
+
mutationFn: async (input) => {
|
|
16
|
+
const { data } = await fetchWithValidation(base, reminderStageChannelSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
17
|
+
return data;
|
|
18
|
+
},
|
|
19
|
+
onSuccess: () => {
|
|
20
|
+
void invalidate();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const update = useMutation({
|
|
24
|
+
mutationFn: async ({ channelId, input, }) => {
|
|
25
|
+
const { data } = await fetchWithValidation(`${base}/${channelId}`, reminderStageChannelSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
26
|
+
return data;
|
|
27
|
+
},
|
|
28
|
+
onSuccess: () => {
|
|
29
|
+
void invalidate();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const remove = useMutation({
|
|
33
|
+
mutationFn: async (channelId) => {
|
|
34
|
+
await fetchWithValidation(`${base}/${channelId}`, reminderStageChannelSingleResponse.optional(), { baseUrl, fetcher }, { method: "DELETE" }).catch(() => null);
|
|
35
|
+
return channelId;
|
|
36
|
+
},
|
|
37
|
+
onSuccess: () => {
|
|
38
|
+
void invalidate();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return { create, update, remove };
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface UseReminderStageChannelsOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useReminderStageChannels(reminderRuleId: string, stageId: string, options?: UseReminderStageChannelsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
stageId: string;
|
|
7
|
+
orderIndex: number;
|
|
8
|
+
channel: "email" | "sms";
|
|
9
|
+
provider: string | null;
|
|
10
|
+
templateId: string | null;
|
|
11
|
+
templateSlug: string | null;
|
|
12
|
+
recipientKind: "primary" | "cc" | "bcc";
|
|
13
|
+
recipientRole: string | null;
|
|
14
|
+
metadata: Record<string, unknown> | null;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
}[], Error>;
|
|
18
|
+
//# sourceMappingURL=use-reminder-stage-channels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reminder-stage-channels.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reminder-stage-channels.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,+BAAoC;;;;;;;;;;;;;YAQ9C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
4
|
+
import { getReminderStageChannelsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useReminderStageChannels(reminderRuleId, stageId, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getReminderStageChannelsQueryOptions({ baseUrl, fetcher }, reminderRuleId, stageId),
|
|
10
|
+
enabled: enabled && Boolean(reminderRuleId) && Boolean(stageId),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RemindersPreviewFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseRemindersPreviewOptions extends RemindersPreviewFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useRemindersPreview(options?: UseRemindersPreviewOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
ruleId: string;
|
|
7
|
+
ruleName: string;
|
|
8
|
+
ruleSlug: string;
|
|
9
|
+
targetType: string;
|
|
10
|
+
targetId: string;
|
|
11
|
+
bookingId: string | null;
|
|
12
|
+
stageId: string;
|
|
13
|
+
stageName: string | null;
|
|
14
|
+
stageOrderIndex: number;
|
|
15
|
+
anchor: string;
|
|
16
|
+
anchorDate: string;
|
|
17
|
+
scheduledAt: string;
|
|
18
|
+
sendCountAtFire: number;
|
|
19
|
+
reasoning: string;
|
|
20
|
+
}[], Error>;
|
|
21
|
+
//# sourceMappingURL=use-reminders-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reminders-preview.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reminders-preview.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;;;YAO3E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantNotificationsContext } from "../provider.js";
|
|
4
|
+
import { getRemindersPreviewQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRemindersPreview(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantNotificationsContext();
|
|
7
|
+
const { enabled = true, ...filters } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getRemindersPreviewQueryOptions({ baseUrl, fetcher }, filters),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|