@drawbridge/components 0.1.13 → 0.1.14
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/components/styles.css +364 -2
- package/dist/advertisement.js +3 -1
- package/dist/advertisement.mjs +3 -1
- package/dist/bridge/advertisements.js +2 -0
- package/dist/bridge/advertisements.mjs +2 -0
- package/dist/bridge/countdown.js +2 -1
- package/dist/bridge/countdown.mjs +2 -1
- package/dist/bridge/form-subdomain-embed.js +18 -20
- package/dist/bridge/form-subdomain-embed.mjs +18 -20
- package/dist/bridge/form-subdomain-header.js +24 -1
- package/dist/bridge/form-subdomain-header.mjs +24 -1
- package/dist/bridge/form-subdomain-missions.js +538 -0
- package/dist/bridge/form-subdomain-missions.mjs +502 -0
- package/dist/bridge/form-subdomain.js +530 -220
- package/dist/bridge/form-subdomain.mjs +533 -222
- package/dist/bridge/lib/entry.js +59 -0
- package/dist/bridge/lib/entry.mjs +29 -0
- package/dist/bridge/lib/location.js +38 -0
- package/dist/bridge/lib/location.mjs +13 -0
- package/dist/bridge/lib/order.js +71 -0
- package/dist/bridge/lib/order.mjs +44 -0
- package/dist/bridge/lib/url.js +9 -0
- package/dist/bridge/lib/url.mjs +7 -0
- package/dist/bridge/share-button.js +5 -3
- package/dist/bridge/share-button.mjs +5 -3
- package/dist/bridge/subdomain-content.js +7 -6
- package/dist/bridge/subdomain-content.mjs +7 -6
- package/dist/bridge/template-layout.js +59 -21
- package/dist/bridge/template-layout.mjs +59 -21
- package/dist/bridge/template-modal.js +42 -76
- package/dist/bridge/template-modal.mjs +39 -73
- package/dist/bridge/template-preview.js +208 -0
- package/dist/bridge/template-preview.mjs +173 -0
- package/dist/bridge/template-subdomain-gallery.js +6 -2
- package/dist/bridge/template-subdomain-gallery.mjs +6 -2
- package/dist/bridge/template-subdomain-link.js +6 -1
- package/dist/bridge/template-subdomain-link.mjs +6 -1
- package/dist/bridge/template-subdomain.js +20 -15
- package/dist/bridge/template-subdomain.mjs +20 -15
- package/dist/dashboard/accordion.js +74 -39
- package/dist/dashboard/accordion.mjs +74 -39
- package/dist/dashboard/avatar.js +109 -3
- package/dist/dashboard/avatar.mjs +106 -4
- package/dist/dashboard/buttons-subscription.js +384 -0
- package/dist/dashboard/buttons-subscription.mjs +349 -0
- package/dist/dashboard/card-campaign-switch.js +265 -0
- package/dist/dashboard/card-campaign-switch.mjs +231 -0
- package/dist/dashboard/card-order.js +28 -11
- package/dist/dashboard/card-order.mjs +28 -11
- package/dist/dashboard/card-section.js +26 -2
- package/dist/dashboard/card-section.mjs +26 -2
- package/dist/dashboard/card-tile.js +6 -7
- package/dist/dashboard/card-tile.mjs +6 -7
- package/dist/dashboard/connection-workflows.js +196 -0
- package/dist/dashboard/connection-workflows.mjs +162 -0
- package/dist/dashboard/device.js +95 -0
- package/dist/dashboard/device.mjs +72 -0
- package/dist/dashboard/form-admin-campaign.js +19 -50
- package/dist/dashboard/form-admin-campaign.mjs +20 -51
- package/dist/dashboard/form-ai.js +9 -6
- package/dist/dashboard/form-ai.mjs +9 -6
- package/dist/dashboard/form-auth.js +35 -25
- package/dist/dashboard/form-auth.mjs +36 -26
- package/dist/dashboard/form-file.js +10 -1
- package/dist/dashboard/form-file.mjs +10 -1
- package/dist/dashboard/form-filters-analytics.js +14 -1
- package/dist/dashboard/form-filters-analytics.mjs +15 -2
- package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
- package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
- package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
- package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
- package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
- package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
- package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
- package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
- package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
- package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
- package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-link.js +7 -1
- package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
- package/dist/dashboard/form-organization-campaign-mission.js +291 -0
- package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
- package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
- package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-page.js +20 -11
- package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
- package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
- package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-section.js +223 -0
- package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
- package/dist/dashboard/form-organization-campaign.js +114 -469
- package/dist/dashboard/form-organization-campaign.mjs +113 -467
- package/dist/dashboard/form-organization-export.js +4 -7
- package/dist/dashboard/form-organization-export.mjs +4 -7
- package/dist/dashboard/form-organization-identity.js +46 -51
- package/dist/dashboard/form-organization-identity.mjs +46 -51
- package/dist/dashboard/form-organization-workflow.js +518 -686
- package/dist/dashboard/form-organization-workflow.mjs +517 -682
- package/dist/dashboard/form-organization.js +82 -110
- package/dist/dashboard/form-organization.mjs +81 -109
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-payment-methods.js +20 -9
- package/dist/dashboard/form-payment-methods.mjs +20 -9
- package/dist/dashboard/form-stripe.js +30 -0
- package/dist/dashboard/form-stripe.mjs +26 -0
- package/dist/dashboard/input-array.js +4 -2
- package/dist/dashboard/input-array.mjs +4 -2
- package/dist/dashboard/input-combobox.js +7 -3
- package/dist/dashboard/input-combobox.mjs +7 -3
- package/dist/dashboard/input-date.js +7 -0
- package/dist/dashboard/input-date.mjs +7 -0
- package/dist/dashboard/input-fields.js +80 -20
- package/dist/dashboard/input-fields.mjs +80 -20
- package/dist/dashboard/input-file.js +21 -1
- package/dist/dashboard/input-file.mjs +21 -1
- package/dist/dashboard/input-font.js +10 -1
- package/dist/dashboard/input-font.mjs +10 -1
- package/dist/dashboard/lib/item-list.js +57 -0
- package/dist/dashboard/lib/item-list.mjs +33 -0
- package/dist/dashboard/lib/menu.js +50 -0
- package/dist/dashboard/lib/menu.mjs +26 -0
- package/dist/dashboard/locked.js +82 -0
- package/dist/dashboard/locked.mjs +53 -0
- package/dist/dashboard/menu.js +72 -19
- package/dist/dashboard/menu.mjs +72 -19
- package/dist/dashboard/note-ai.js +69 -0
- package/dist/dashboard/note-ai.mjs +36 -0
- package/dist/dashboard/preview.js +419 -0
- package/dist/dashboard/preview.mjs +384 -0
- package/dist/dashboard/steps.js +39 -13
- package/dist/dashboard/steps.mjs +37 -12
- package/dist/dashboard/table-contacts.js +136 -0
- package/dist/dashboard/table-contacts.mjs +103 -0
- package/dist/dashboard/template-not-found.js +4 -2
- package/dist/dashboard/template-not-found.mjs +4 -2
- package/dist/dashboard/template-socket.js +20 -7
- package/dist/dashboard/template-socket.mjs +20 -7
- package/dist/icons/desktop.js +46 -0
- package/dist/icons/desktop.mjs +27 -0
- package/dist/icons/phone.js +46 -0
- package/dist/icons/phone.mjs +27 -0
- package/dist/icons/puzzle-piece.js +46 -0
- package/dist/icons/puzzle-piece.mjs +27 -0
- package/dist/icons/tablet.js +46 -0
- package/dist/icons/tablet.mjs +27 -0
- package/dist/icons/users.js +46 -0
- package/dist/icons/users.mjs +27 -0
- package/dist/input-checkbox.js +1 -0
- package/dist/input-checkbox.mjs +1 -0
- package/dist/input-code.js +101 -0
- package/dist/input-code.mjs +78 -0
- package/dist/input-text.js +2 -1
- package/dist/input-text.mjs +2 -1
- package/dist/shared/input-checkbox-list.js +0 -1
- package/dist/shared/input-checkbox-list.mjs +0 -1
- package/dist/shared/input-switch.js +6 -1
- package/dist/shared/input-switch.mjs +6 -1
- package/dist/shared/lib/campaign.js +117 -0
- package/dist/shared/lib/campaign.mjs +91 -0
- package/dist/shared/lib/helpers.js +14 -2
- package/dist/shared/lib/helpers.mjs +13 -2
- package/package.json +133 -13
- package/types/bridge/form-subdomain-header.d.ts +2 -0
- package/types/bridge/form-subdomain-missions.d.ts +36 -0
- package/types/bridge/form-subdomain.d.ts +23 -1
- package/types/bridge/lib/entry.d.ts +26 -0
- package/types/bridge/lib/location.d.ts +13 -0
- package/types/bridge/lib/order.d.ts +30 -0
- package/types/bridge/lib/url.d.ts +19 -0
- package/types/bridge/template-modal.d.ts +1 -1
- package/types/bridge/template-preview.d.ts +10 -0
- package/types/bridge/template-subdomain-link.d.ts +2 -0
- package/types/dashboard/accordion.d.ts +2 -0
- package/types/dashboard/avatar.d.ts +18 -2
- package/types/dashboard/buttons-subscription.d.ts +22 -0
- package/types/dashboard/card-campaign-switch.d.ts +32 -0
- package/types/dashboard/card-order.d.ts +11 -0
- package/types/dashboard/card-section.d.ts +2 -0
- package/types/dashboard/connection-workflows.d.ts +33 -0
- package/types/dashboard/device.d.ts +12 -0
- package/types/dashboard/form-admin-campaign.d.ts +3 -2
- package/types/dashboard/form-ai.d.ts +2 -2
- package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
- package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
- package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
- package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
- package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
- package/types/dashboard/form-organization-campaign.d.ts +27 -17
- package/types/dashboard/form-organization-identity.d.ts +2 -0
- package/types/dashboard/form-organization-workflow.d.ts +43 -47
- package/types/dashboard/form-organization.d.ts +7 -2
- package/types/dashboard/form-stripe.d.ts +3 -0
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-date.d.ts +2 -0
- package/types/dashboard/input-fields.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +4 -0
- package/types/dashboard/lib/item-list.d.ts +14 -0
- package/types/dashboard/lib/menu.d.ts +17 -0
- package/types/dashboard/locked.d.ts +10 -0
- package/types/dashboard/menu.d.ts +10 -2
- package/types/dashboard/note-ai.d.ts +15 -0
- package/types/dashboard/preview.d.ts +33 -0
- package/types/dashboard/steps.d.ts +19 -4
- package/types/dashboard/table-cell-title.d.ts +2 -2
- package/types/dashboard/table-contacts.d.ts +2 -0
- package/types/icons/desktop.d.ts +5 -0
- package/types/icons/phone.d.ts +5 -0
- package/types/icons/puzzle-piece.d.ts +5 -0
- package/types/icons/tablet.d.ts +5 -0
- package/types/icons/users.d.ts +5 -0
- package/types/input-code.d.ts +23 -0
- package/types/shared/input-switch.d.ts +2 -0
- package/types/shared/lib/campaign.d.ts +35 -0
- package/types/shared/lib/helpers.d.ts +3 -0
- package/dist/dashboard/card-integration.js +0 -187
- package/dist/dashboard/card-integration.mjs +0 -158
- package/dist/dashboard/iframe.js +0 -159
- package/dist/dashboard/iframe.mjs +0 -130
- package/types/dashboard/card-integration.d.ts +0 -24
- package/types/dashboard/iframe.d.ts +0 -18
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Image from "next/image";
|
|
3
3
|
import Link from "./link.mjs";
|
|
4
|
-
import { Fragment, useCallback, useState } from "react";
|
|
4
|
+
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
6
6
|
import { useForm, useWatch, Controller } from "../shared/lib/form.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
8
|
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
9
9
|
import Form from "../shared/form.mjs";
|
|
10
10
|
import Fieldset from "../shared/fieldset.mjs";
|
|
11
11
|
import InputGroup from "../input-group.mjs";
|
|
12
12
|
import Error from "../shared/error.mjs";
|
|
13
|
-
import InputText from "../input-text.mjs";
|
|
14
13
|
import InputTextarea from "../input-textarea.mjs";
|
|
15
14
|
import InputUrl from "../shared/input-url.mjs";
|
|
16
15
|
import InputResource from "./input-resource.mjs";
|
|
@@ -18,13 +17,16 @@ import InputCombobox from "./input-combobox.mjs";
|
|
|
18
17
|
import { FormNotification } from "./form-notification.mjs";
|
|
19
18
|
import { InputArrayButton, InputArrayControl, InputArraySortable } from "./input-array.mjs";
|
|
20
19
|
import Badge from "../shared/badge.mjs";
|
|
20
|
+
import CardSection from "./card-section.mjs";
|
|
21
|
+
import Accordion from "./accordion.mjs";
|
|
22
|
+
import Preview from "./preview.mjs";
|
|
21
23
|
import CardTask from "./card-task.mjs";
|
|
22
24
|
import { LoaderDynamic } from "../shared/loader.mjs";
|
|
23
25
|
import { smsNumberActive } from "./lib/sms.mjs";
|
|
24
26
|
import Trash from "../icons/trash.mjs";
|
|
25
27
|
import Button from "../shared/button.mjs";
|
|
26
|
-
const emailSteps = ["step.email.send"
|
|
27
|
-
const teamSteps = ["step.email.notify"
|
|
28
|
+
const emailSteps = ["step.email.send"];
|
|
29
|
+
const teamSteps = ["step.email.notify"];
|
|
28
30
|
const messageSteps = [...emailSteps, "step.sms.send"];
|
|
29
31
|
const defaultScore = {
|
|
30
32
|
rules: [
|
|
@@ -43,16 +45,8 @@ const stepPrefills = {
|
|
|
43
45
|
subject: "Thanks for entering",
|
|
44
46
|
text: "Thanks for entering. We have your entry and will be in touch."
|
|
45
47
|
},
|
|
46
|
-
// Nothing to prefill
|
|
47
|
-
|
|
48
|
-
// and the drawer creates the workflow without it.
|
|
49
|
-
"step.email.notify": {},
|
|
50
|
-
"step.email.digest": {
|
|
51
|
-
message: "You had {{count}} new entries.",
|
|
52
|
-
score: defaultScore,
|
|
53
|
-
subject: "Your entries",
|
|
54
|
-
text: "You had {{count}} new entries."
|
|
55
|
-
}
|
|
48
|
+
// Nothing to prefill: the step writes its own copy.
|
|
49
|
+
"step.email.notify": {}
|
|
56
50
|
};
|
|
57
51
|
const memberParams = {
|
|
58
52
|
filters: {
|
|
@@ -90,188 +84,27 @@ const memberLabel = (member) => {
|
|
|
90
84
|
var _a, _b, _c;
|
|
91
85
|
return [(_a = member == null ? void 0 : member.user) == null ? void 0 : _a.firstName, (_b = member == null ? void 0 : member.user) == null ? void 0 : _b.lastName].filter(Boolean).join(" ") || (member == null ? void 0 : member.email) || ((_c = member == null ? void 0 : member.user) == null ? void 0 : _c.email) || "Member";
|
|
92
86
|
};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
87
|
+
const stepVariables = (entry, steps = [], index = 0) => [
|
|
88
|
+
...(entry == null ? void 0 : entry.variables) || [],
|
|
89
|
+
...steps.slice(0, index).flatMap((step) => {
|
|
90
|
+
var _a;
|
|
91
|
+
return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((option) => option.value === (step == null ? void 0 : step.type))) == null ? void 0 : _a.returns) || [];
|
|
92
|
+
})
|
|
93
|
+
];
|
|
94
|
+
const prefillRow = ({ entry, step, steps = [] }) => {
|
|
95
|
+
if (!step || steps.some((row) => (row == null ? void 0 : row.type) === step)) return null;
|
|
96
|
+
const option = ((entry == null ? void 0 : entry.steps) || []).find((each) => each.value === step);
|
|
97
|
+
if (!option || option.ownerOnly || option.disabled) return null;
|
|
98
|
+
return stepRow({
|
|
99
|
+
connectionId: option.connectionId,
|
|
100
|
+
settings: stepPrefills[step] || {},
|
|
101
|
+
slug: option.slug,
|
|
102
|
+
type: step
|
|
104
103
|
});
|
|
105
|
-
const catalogList = catalog.data || [];
|
|
106
|
-
const triggerGroups = catalogList.filter((item) => item.type !== "schedule" || item.trigger === current).reduce((groups, item) => {
|
|
107
|
-
const model = item.type === "schedule" ? "schedule" : item.trigger.split(".")[0];
|
|
108
|
-
if (!groups[model]) groups[model] = [];
|
|
109
|
-
groups[model].push(item);
|
|
110
|
-
return groups;
|
|
111
|
-
}, {});
|
|
112
|
-
const triggerOptions = [
|
|
113
|
-
{ key: "Select a trigger", value: "" },
|
|
114
|
-
...Object.entries(triggerGroups).sort(([a], [b]) => a.localeCompare(b)).flatMap(([model, items]) => [
|
|
115
|
-
{ key: model.charAt(0).toUpperCase() + model.slice(1), header: true },
|
|
116
|
-
...items.sort((a, b) => a.title.localeCompare(b.title)).map((item) => ({
|
|
117
|
-
image: item.image,
|
|
118
|
-
key: item.title,
|
|
119
|
-
value: item.trigger
|
|
120
|
-
}))
|
|
121
|
-
])
|
|
122
|
-
];
|
|
123
|
-
return { catalog, catalogList, triggerOptions };
|
|
124
104
|
};
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...{
|
|
129
|
-
control,
|
|
130
|
-
name: "triggerEvent",
|
|
131
|
-
render: ({ field: { value, onChange } }) => {
|
|
132
|
-
var _a, _b;
|
|
133
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
-
InputGroup,
|
|
135
|
-
{
|
|
136
|
-
...{
|
|
137
|
-
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.triggerEvent) == null ? void 0 : _b.message,
|
|
138
|
-
input: /* @__PURE__ */ jsx(
|
|
139
|
-
InputCombobox,
|
|
140
|
-
{
|
|
141
|
-
...{
|
|
142
|
-
onChange: (val) => {
|
|
143
|
-
onChange(val);
|
|
144
|
-
const entry = catalogList.find((item) => item.trigger === val);
|
|
145
|
-
if (entry) {
|
|
146
|
-
const currentTitle = getValues("title");
|
|
147
|
-
const catalogTitles = catalogList.map((item) => item.title);
|
|
148
|
-
if (!currentTitle || catalogTitles.includes(currentTitle)) {
|
|
149
|
-
setValue("title", entry.title);
|
|
150
|
-
}
|
|
151
|
-
;
|
|
152
|
-
}
|
|
153
|
-
;
|
|
154
|
-
},
|
|
155
|
-
options: triggerOptions,
|
|
156
|
-
value: value || ""
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
),
|
|
160
|
-
label: "Trigger"
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
const WorkflowTitleField = ({ control, formState }) => /* @__PURE__ */ jsx(
|
|
169
|
-
Controller,
|
|
170
|
-
{
|
|
171
|
-
...{
|
|
172
|
-
control,
|
|
173
|
-
name: "title",
|
|
174
|
-
render: ({ field: { value, onChange } }) => {
|
|
175
|
-
var _a, _b;
|
|
176
|
-
return /* @__PURE__ */ jsx(
|
|
177
|
-
InputGroup,
|
|
178
|
-
{
|
|
179
|
-
...{
|
|
180
|
-
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.title) == null ? void 0 : _b.message,
|
|
181
|
-
input: /* @__PURE__ */ jsx(
|
|
182
|
-
InputText,
|
|
183
|
-
{
|
|
184
|
-
...{
|
|
185
|
-
onChange,
|
|
186
|
-
placeholder: "Workflow name",
|
|
187
|
-
value: value || ""
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
label: "Title"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
const campaignFilterId = (campaign) => (campaign == null ? void 0 : campaign.id) || campaign || null;
|
|
200
|
-
const campaignFilterIds = (filters) => (Array.isArray(filters == null ? void 0 : filters.campaigns) ? filters.campaigns : [filters == null ? void 0 : filters.campaign]).map(campaignFilterId).filter(Boolean);
|
|
201
|
-
const filterRows = (ids, docs) => ids.map((id) => docs.find((doc) => (doc == null ? void 0 : doc.id) === id) || { id });
|
|
202
|
-
const filterSeed = (seeds, id) => (seeds || []).find((doc) => (doc == null ? void 0 : doc.id) === id);
|
|
203
|
-
const filterMissing = (error) => {
|
|
204
|
-
if ((error == null ? void 0 : error.status) === 404) return { result: null };
|
|
205
|
-
throw error;
|
|
206
|
-
};
|
|
207
|
-
const WorkflowFilterField = ({
|
|
208
|
-
collection,
|
|
209
|
-
control,
|
|
210
|
-
label,
|
|
211
|
-
message,
|
|
212
|
-
model,
|
|
213
|
-
multiple = false,
|
|
214
|
-
name,
|
|
215
|
-
organization,
|
|
216
|
-
resource,
|
|
217
|
-
seeds
|
|
218
|
-
}) => {
|
|
219
|
-
const queryClient = useQueryClient();
|
|
220
|
-
const value = useWatch({
|
|
221
|
-
control,
|
|
222
|
-
name
|
|
223
|
-
});
|
|
224
|
-
const ids = multiple ? value || [] : [value].filter(Boolean);
|
|
225
|
-
const docs = useQueries({
|
|
226
|
-
queries: ids.map((id) => ({
|
|
227
|
-
queryKey: ["workflow-filter", model, organization, id],
|
|
228
|
-
queryFn: async () => {
|
|
229
|
-
const { result } = await request({
|
|
230
|
-
endpoint: "/organization/" + organization + "/" + resource + "/" + id
|
|
231
|
-
}).catch(filterMissing);
|
|
232
|
-
return result;
|
|
233
|
-
},
|
|
234
|
-
initialData: () => filterSeed(seeds, id),
|
|
235
|
-
staleTime: Infinity
|
|
236
|
-
}))
|
|
237
|
-
}).map((query) => query.data);
|
|
238
|
-
const seed = (doc) => (doc == null ? void 0 : doc.id) && queryClient.setQueryData(["workflow-filter", model, organization, doc.id], doc);
|
|
239
|
-
return /* @__PURE__ */ jsx(
|
|
240
|
-
Controller,
|
|
241
|
-
{
|
|
242
|
-
...{
|
|
243
|
-
control,
|
|
244
|
-
name,
|
|
245
|
-
render: ({ field: { onChange } }) => /* @__PURE__ */ jsx(
|
|
246
|
-
InputGroup,
|
|
247
|
-
{
|
|
248
|
-
...{
|
|
249
|
-
input: /* @__PURE__ */ jsx(
|
|
250
|
-
InputResource,
|
|
251
|
-
{
|
|
252
|
-
...{
|
|
253
|
-
endpoint: "/organization/" + organization + "/" + collection,
|
|
254
|
-
model,
|
|
255
|
-
multiple,
|
|
256
|
-
onChange: multiple ? (picked) => {
|
|
257
|
-
picked.forEach(seed);
|
|
258
|
-
onChange(picked.map((doc) => doc == null ? void 0 : doc.id).filter(Boolean));
|
|
259
|
-
} : (doc) => {
|
|
260
|
-
seed(doc);
|
|
261
|
-
onChange((doc == null ? void 0 : doc.id) || null);
|
|
262
|
-
},
|
|
263
|
-
value: multiple ? filterRows(ids, docs) : docs[0] || null
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
label,
|
|
268
|
-
message
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
);
|
|
105
|
+
const stepReason = ({ entry, saved = [], type }) => {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((step) => (step == null ? void 0 : step.value) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _a.reason) || ((_b = saved.find((step) => (step == null ? void 0 : step.type) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _b.reason) || null;
|
|
275
108
|
};
|
|
276
109
|
const stepRow = (step = {}, members = []) => {
|
|
277
110
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
@@ -306,119 +139,7 @@ const stepRow = (step = {}, members = []) => {
|
|
|
306
139
|
url: ((_i = step.settings) == null ? void 0 : _i.url) || ""
|
|
307
140
|
};
|
|
308
141
|
};
|
|
309
|
-
const FormOrganizationWorkflow = ({
|
|
310
|
-
disabled,
|
|
311
|
-
onClose,
|
|
312
|
-
onError,
|
|
313
|
-
onSuccess,
|
|
314
|
-
values
|
|
315
|
-
}) => {
|
|
316
|
-
const { catalog, catalogList, triggerOptions } = useWorkflowCatalog(values == null ? void 0 : values.organization, values == null ? void 0 : values.triggerEvent);
|
|
317
|
-
const { control, formState, getValues, handleSubmit, setValue } = useForm({
|
|
318
|
-
defaultValues: {
|
|
319
|
-
title: "",
|
|
320
|
-
triggerEvent: (values == null ? void 0 : values.triggerEvent) || ""
|
|
321
|
-
},
|
|
322
|
-
resolver: resolver(
|
|
323
|
-
yup.object({
|
|
324
|
-
title: yup.string().required().max(100).label("Title"),
|
|
325
|
-
triggerEvent: yup.string().label("Trigger").required("A trigger is required")
|
|
326
|
-
})
|
|
327
|
-
)
|
|
328
|
-
});
|
|
329
|
-
const watchedTrigger = useWatch({
|
|
330
|
-
control,
|
|
331
|
-
name: "triggerEvent"
|
|
332
|
-
});
|
|
333
|
-
const onSubmit = async ({ title, triggerEvent }) => {
|
|
334
|
-
const prefill = stepPrefills[values == null ? void 0 : values.step];
|
|
335
|
-
const prefilledSteps = prefill ? [{
|
|
336
|
-
settings: { ...prefill },
|
|
337
|
-
type: values.step
|
|
338
|
-
}] : [];
|
|
339
|
-
try {
|
|
340
|
-
const response = await request({
|
|
341
|
-
body: {
|
|
342
|
-
steps: prefilledSteps,
|
|
343
|
-
title,
|
|
344
|
-
trigger: {
|
|
345
|
-
event: triggerEvent,
|
|
346
|
-
filters: {
|
|
347
|
-
// Both blank, meaning every campaign and every segment. The
|
|
348
|
-
// create drawer asks for a trigger and a title only; narrowing
|
|
349
|
-
// is done on the workflow page afterwards.
|
|
350
|
-
campaigns: [],
|
|
351
|
-
segment: null
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/workflow",
|
|
356
|
-
method: "POST"
|
|
357
|
-
});
|
|
358
|
-
onSuccess(response);
|
|
359
|
-
onClose == null ? void 0 : onClose();
|
|
360
|
-
} catch (error) {
|
|
361
|
-
onError(error);
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
if (catalog.isLoading) {
|
|
365
|
-
return /* @__PURE__ */ jsx(LoaderDynamic, {});
|
|
366
|
-
}
|
|
367
|
-
return /* @__PURE__ */ jsx(
|
|
368
|
-
Form,
|
|
369
|
-
{
|
|
370
|
-
...{
|
|
371
|
-
className: "relative w-full",
|
|
372
|
-
onSubmit: handleSubmit(onSubmit)
|
|
373
|
-
},
|
|
374
|
-
children: /* @__PURE__ */ jsxs(
|
|
375
|
-
Fieldset,
|
|
376
|
-
{
|
|
377
|
-
...{
|
|
378
|
-
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
379
|
-
},
|
|
380
|
-
children: [
|
|
381
|
-
/* @__PURE__ */ jsx(
|
|
382
|
-
WorkflowTriggerField,
|
|
383
|
-
{
|
|
384
|
-
...{
|
|
385
|
-
control,
|
|
386
|
-
formState,
|
|
387
|
-
catalogList,
|
|
388
|
-
triggerOptions,
|
|
389
|
-
getValues,
|
|
390
|
-
setValue
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
),
|
|
394
|
-
watchedTrigger && /* @__PURE__ */ jsx(
|
|
395
|
-
WorkflowTitleField,
|
|
396
|
-
{
|
|
397
|
-
...{
|
|
398
|
-
control,
|
|
399
|
-
formState
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
),
|
|
403
|
-
/* @__PURE__ */ jsx(
|
|
404
|
-
Button,
|
|
405
|
-
{
|
|
406
|
-
...{
|
|
407
|
-
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
408
|
-
type: "submit"
|
|
409
|
-
},
|
|
410
|
-
children: "Create workflow"
|
|
411
|
-
}
|
|
412
|
-
)
|
|
413
|
-
]
|
|
414
|
-
}
|
|
415
|
-
)
|
|
416
|
-
}
|
|
417
|
-
);
|
|
418
|
-
};
|
|
419
142
|
const workflowSchema = yup.object({
|
|
420
|
-
title: yup.string().required().max(100).label("Title"),
|
|
421
|
-
triggerEvent: yup.string().label("Trigger").required("A trigger is required"),
|
|
422
143
|
steps: yup.array().of(
|
|
423
144
|
yup.object({
|
|
424
145
|
type: yup.string().label("Step").required("A step is required"),
|
|
@@ -434,7 +155,13 @@ const workflowSchema = yup.object({
|
|
|
434
155
|
}
|
|
435
156
|
return schema;
|
|
436
157
|
}),
|
|
437
|
-
|
|
158
|
+
// @story workflows/edit
|
|
159
|
+
// The editor writes an empty message as "<p></p>", which a plain
|
|
160
|
+
// required() accepts: a message needs words, not only markup.
|
|
161
|
+
message: yup.string().test("words", "Message is required", function(value) {
|
|
162
|
+
var _a;
|
|
163
|
+
return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) || Boolean(String(value || "").replace(/<[^>]*>/g, "").trim());
|
|
164
|
+
}).when("type", ([type], schema) => {
|
|
438
165
|
if (type === "step.sms.send") {
|
|
439
166
|
return schema.required("Message is required").max(1500).label("Message");
|
|
440
167
|
}
|
|
@@ -458,21 +185,157 @@ const workflowSchema = yup.object({
|
|
|
458
185
|
})
|
|
459
186
|
)
|
|
460
187
|
});
|
|
188
|
+
const samples = [
|
|
189
|
+
{
|
|
190
|
+
key: "New lead",
|
|
191
|
+
value: "lead"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: "Verified their email",
|
|
195
|
+
value: "verified"
|
|
196
|
+
}
|
|
197
|
+
];
|
|
198
|
+
const useEmailPreview = ({ campaign, event, message, organization, sample, subject, text }) => {
|
|
199
|
+
const asked = JSON.stringify({ message, sample, subject, text });
|
|
200
|
+
const [settled, setSettled] = useState(asked);
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
const timer = setTimeout(() => setSettled(asked), 400);
|
|
203
|
+
return () => clearTimeout(timer);
|
|
204
|
+
}, [asked]);
|
|
205
|
+
const preview = useQuery({
|
|
206
|
+
enabled: Boolean(organization && campaign && event),
|
|
207
|
+
placeholderData: keepPreviousData,
|
|
208
|
+
queryFn: async () => {
|
|
209
|
+
const { result } = await request({
|
|
210
|
+
body: JSON.parse(settled),
|
|
211
|
+
endpoint: "/organization/" + organization + "/campaign/" + campaign + "/workflow/" + event + "/preview",
|
|
212
|
+
method: "POST"
|
|
213
|
+
});
|
|
214
|
+
return result;
|
|
215
|
+
},
|
|
216
|
+
queryKey: ["workflow-email-preview", organization, campaign, event, settled]
|
|
217
|
+
});
|
|
218
|
+
return preview.data;
|
|
219
|
+
};
|
|
220
|
+
const EmailStepCard = ({
|
|
221
|
+
card,
|
|
222
|
+
children,
|
|
223
|
+
control,
|
|
224
|
+
email: {
|
|
225
|
+
campaign,
|
|
226
|
+
event,
|
|
227
|
+
name,
|
|
228
|
+
organization
|
|
229
|
+
}
|
|
230
|
+
}) => {
|
|
231
|
+
const [sample, setSample] = useState(samples[0].value);
|
|
232
|
+
const [subject, message, text] = useWatch({
|
|
233
|
+
control,
|
|
234
|
+
name: [name + ".subject", name + ".message", name + ".text"]
|
|
235
|
+
});
|
|
236
|
+
const preview = useEmailPreview({ campaign, event, message, organization, sample, subject, text });
|
|
237
|
+
return /* @__PURE__ */ jsxs(
|
|
238
|
+
CardSection,
|
|
239
|
+
{
|
|
240
|
+
...{
|
|
241
|
+
...card,
|
|
242
|
+
columns: 2
|
|
243
|
+
},
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsxs(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
...{
|
|
249
|
+
className: "space-y-6"
|
|
250
|
+
},
|
|
251
|
+
children: [
|
|
252
|
+
children,
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
Accordion,
|
|
255
|
+
{
|
|
256
|
+
...{
|
|
257
|
+
className: "pt-6 border-t border-gray",
|
|
258
|
+
classNamePanel: "mt-6",
|
|
259
|
+
title: "Plain-text version"
|
|
260
|
+
},
|
|
261
|
+
children: /* @__PURE__ */ jsx(
|
|
262
|
+
"pre",
|
|
263
|
+
{
|
|
264
|
+
...{
|
|
265
|
+
className: "p-4 rounded border border-gray bg-white text-sm whitespace-pre-wrap wrap-anywhere"
|
|
266
|
+
},
|
|
267
|
+
children: preview == null ? void 0 : preview.text
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
/* @__PURE__ */ jsx(
|
|
276
|
+
Preview,
|
|
277
|
+
{
|
|
278
|
+
...{
|
|
279
|
+
states: {
|
|
280
|
+
onChange: setSample,
|
|
281
|
+
options: samples,
|
|
282
|
+
value: sample
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
children: /* @__PURE__ */ jsx(
|
|
286
|
+
"iframe",
|
|
287
|
+
{
|
|
288
|
+
...{
|
|
289
|
+
// The rendered email, as a mail app shows it.
|
|
290
|
+
className: "block w-full h-full border-0 bg-white",
|
|
291
|
+
srcDoc: (preview == null ? void 0 : preview.html) || "",
|
|
292
|
+
title: "Send email"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
const StepCard = ({
|
|
303
|
+
children,
|
|
304
|
+
control,
|
|
305
|
+
email,
|
|
306
|
+
...card
|
|
307
|
+
}) => email ? /* @__PURE__ */ jsx(
|
|
308
|
+
EmailStepCard,
|
|
309
|
+
{
|
|
310
|
+
...{
|
|
311
|
+
card,
|
|
312
|
+
control,
|
|
313
|
+
email
|
|
314
|
+
},
|
|
315
|
+
children
|
|
316
|
+
}
|
|
317
|
+
) : /* @__PURE__ */ jsx(
|
|
318
|
+
CardSection,
|
|
319
|
+
{
|
|
320
|
+
...card,
|
|
321
|
+
children
|
|
322
|
+
}
|
|
323
|
+
);
|
|
461
324
|
const FormOrganizationWorkflowEdit = ({
|
|
325
|
+
catalog,
|
|
462
326
|
disabled,
|
|
463
|
-
onClose,
|
|
464
327
|
onError,
|
|
465
328
|
onSuccess,
|
|
466
329
|
values
|
|
467
330
|
}) => {
|
|
468
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
469
|
-
const
|
|
331
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
332
|
+
const event = (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event;
|
|
470
333
|
const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization);
|
|
471
334
|
const queryClient = useQueryClient();
|
|
472
335
|
const organizationData = queryClient.getQueryData(["organization", values == null ? void 0 : values.organization]);
|
|
473
336
|
const ownerEmail = organizationData.owner.email;
|
|
474
337
|
const smsActive = smsNumberActive(organizationData);
|
|
475
|
-
const commerceConnectionId = ((_b =
|
|
338
|
+
const commerceConnectionId = ((_b = ((catalog == null ? void 0 : catalog.steps) || []).find(
|
|
476
339
|
(s) => s.value === "step.commerce.customer.insert" || s.value === "step.commerce.code.issue"
|
|
477
340
|
)) == null ? void 0 : _b.connectionId) || null;
|
|
478
341
|
const commerceConnection = useQuery({
|
|
@@ -498,38 +361,29 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
498
361
|
);
|
|
499
362
|
const { control, formState, getValues, handleSubmit, setValue } = useForm({
|
|
500
363
|
values: {
|
|
501
|
-
steps: defaultSteps
|
|
502
|
-
filterCampaigns: campaignFilterIds((_g = values == null ? void 0 : values.trigger) == null ? void 0 : _g.filters),
|
|
503
|
-
// Stored and returned as a plain id — extend.workflow() $lookup-hydrates
|
|
504
|
-
// only the campaign — but read through the same reducer, so the field
|
|
505
|
-
// stays right if the segment is ever hydrated too.
|
|
506
|
-
filterSegment: campaignFilterId((_i = (_h = values == null ? void 0 : values.trigger) == null ? void 0 : _h.filters) == null ? void 0 : _i.segment),
|
|
507
|
-
title: (values == null ? void 0 : values.title) || "",
|
|
508
|
-
triggerEvent: ((_j = values == null ? void 0 : values.trigger) == null ? void 0 : _j.event) || ""
|
|
364
|
+
steps: defaultSteps
|
|
509
365
|
},
|
|
510
366
|
resolver: resolver(workflowSchema)
|
|
511
367
|
});
|
|
512
|
-
const watchedTrigger = useWatch({
|
|
513
|
-
control,
|
|
514
|
-
name: "triggerEvent"
|
|
515
|
-
});
|
|
516
368
|
const watchedSteps = useWatch({
|
|
517
369
|
control,
|
|
518
370
|
name: "steps"
|
|
519
371
|
});
|
|
520
|
-
const issueIndex = ((
|
|
521
|
-
const
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
372
|
+
const issueIndex = ((_g = values == null ? void 0 : values.issue) == null ? void 0 : _g.step) ? (watchedSteps || []).findIndex((step) => (step == null ? void 0 : step.type) === values.issue.step) : -1;
|
|
373
|
+
const getAvailableVariables = (index) => stepVariables(catalog, watchedSteps, index);
|
|
374
|
+
const loading = membersLoading || commerceConnection.isLoading;
|
|
375
|
+
const prefilled = useRef(false);
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
if (loading || disabled || prefilled.current) return;
|
|
378
|
+
prefilled.current = true;
|
|
379
|
+
const row = prefillRow({ entry: catalog, step: values == null ? void 0 : values.step, steps: getValues("steps") });
|
|
380
|
+
if (row) setValue("steps", [...getValues("steps"), row], { shouldDirty: true });
|
|
381
|
+
}, [catalog, disabled, getValues, loading, setValue, values == null ? void 0 : values.step]);
|
|
528
382
|
const getStepOptions = (index) => {
|
|
529
383
|
const usedTypes = watchedSteps.map((s, i) => i !== index ? s.type : null).filter(Boolean);
|
|
530
384
|
return [
|
|
531
385
|
{ key: "Select a step", value: "" },
|
|
532
|
-
...((
|
|
386
|
+
...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).filter((step) => {
|
|
533
387
|
var _a2;
|
|
534
388
|
return !step.ownerOnly || step.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
|
|
535
389
|
}).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => ({
|
|
@@ -546,7 +400,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
546
400
|
// connectionless and sendgrid is gone — but the rule is about any
|
|
547
401
|
// two entries sharing a type, so it stays.
|
|
548
402
|
value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
|
|
549
|
-
...step.disabled ? {
|
|
403
|
+
...step.disabled && !step.reason ? {
|
|
550
404
|
badge: {
|
|
551
405
|
text: "Enable connection"
|
|
552
406
|
},
|
|
@@ -554,8 +408,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
554
408
|
element: Link,
|
|
555
409
|
key: step == null ? void 0 : step.key,
|
|
556
410
|
props: {
|
|
557
|
-
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
|
|
558
|
-
onClick: onClose
|
|
411
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
|
|
559
412
|
}
|
|
560
413
|
} : {},
|
|
561
414
|
// The same link-shaped option, greyed: it cannot be picked, and
|
|
@@ -570,14 +423,29 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
570
423
|
key: step == null ? void 0 : step.key,
|
|
571
424
|
props: {
|
|
572
425
|
"aria-disabled": true,
|
|
573
|
-
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
|
|
574
|
-
|
|
426
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
|
|
427
|
+
}
|
|
428
|
+
} : {},
|
|
429
|
+
// @story workflows/edit
|
|
430
|
+
// A step the form cannot feed: greyed with its reason, and a
|
|
431
|
+
// click opens the campaign's Form page, where the field is added.
|
|
432
|
+
...step.reason ? {
|
|
433
|
+
badge: {
|
|
434
|
+
text: step.reason
|
|
435
|
+
},
|
|
436
|
+
className: "opacity-50",
|
|
437
|
+
disabled: false,
|
|
438
|
+
element: Link,
|
|
439
|
+
key: step == null ? void 0 : step.key,
|
|
440
|
+
props: {
|
|
441
|
+
"aria-disabled": true,
|
|
442
|
+
href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
|
|
575
443
|
}
|
|
576
444
|
} : {}
|
|
577
445
|
}))
|
|
578
446
|
];
|
|
579
447
|
};
|
|
580
|
-
const lockedStep = (index) => ((
|
|
448
|
+
const lockedStep = (index) => ((catalog == null ? void 0 : catalog.steps) || []).some((s) => {
|
|
581
449
|
var _a2;
|
|
582
450
|
return s.ownerOnly && s.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
|
|
583
451
|
});
|
|
@@ -591,7 +459,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
591
459
|
return match ? match.value : "";
|
|
592
460
|
};
|
|
593
461
|
const getStepConnection = (field) => {
|
|
594
|
-
const steps = (
|
|
462
|
+
const steps = (catalog == null ? void 0 : catalog.steps) || [];
|
|
595
463
|
const def = field.connectionId && steps.find((s) => s.connectionId === field.connectionId) || field.slug && steps.find((s) => s.slug === field.slug && s.value === field.type) || steps.find((s) => s.value === field.type);
|
|
596
464
|
if (!def) return null;
|
|
597
465
|
const connected = Boolean(def.connectionId);
|
|
@@ -604,6 +472,19 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
604
472
|
};
|
|
605
473
|
};
|
|
606
474
|
const renderStepBadge = (field) => {
|
|
475
|
+
const reason = stepReason({ entry: catalog, saved: values == null ? void 0 : values.steps, type: field == null ? void 0 : field.type });
|
|
476
|
+
if (reason) {
|
|
477
|
+
return /* @__PURE__ */ jsx(
|
|
478
|
+
Badge,
|
|
479
|
+
{
|
|
480
|
+
...{
|
|
481
|
+
size: "small",
|
|
482
|
+
type: "error"
|
|
483
|
+
},
|
|
484
|
+
children: reason
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
}
|
|
607
488
|
const conn = getStepConnection(field);
|
|
608
489
|
if (!conn) return null;
|
|
609
490
|
return /* @__PURE__ */ jsx(
|
|
@@ -618,11 +499,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
618
499
|
);
|
|
619
500
|
};
|
|
620
501
|
const onSubmit = async ({
|
|
621
|
-
steps
|
|
622
|
-
filterCampaigns,
|
|
623
|
-
filterSegment,
|
|
624
|
-
title,
|
|
625
|
-
triggerEvent
|
|
502
|
+
steps
|
|
626
503
|
}) => {
|
|
627
504
|
try {
|
|
628
505
|
const body = {
|
|
@@ -638,7 +515,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
638
515
|
}
|
|
639
516
|
if (teamSteps.includes(type)) settings.members = (members || []).map((member) => member == null ? void 0 : member.id).filter(Boolean);
|
|
640
517
|
if (type === "step.commerce.code.issue") settings.discount = discount;
|
|
641
|
-
const catalogSteps = (
|
|
518
|
+
const catalogSteps = (catalog == null ? void 0 : catalog.steps) || [];
|
|
642
519
|
const catalogStep = connectionId && catalogSteps.find((s) => s.connectionId === connectionId) || slug && catalogSteps.find((s) => s.slug === slug && s.value === type) || catalogSteps.find((s) => s.value === type);
|
|
643
520
|
const resolvedConnectionId = (catalogStep == null ? void 0 : catalogStep.connectionId) || connectionId || null;
|
|
644
521
|
const resolvedSlug = (catalogStep == null ? void 0 : catalogStep.slug) || slug || null;
|
|
@@ -648,19 +525,11 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
648
525
|
settings,
|
|
649
526
|
type
|
|
650
527
|
};
|
|
651
|
-
})
|
|
652
|
-
title,
|
|
653
|
-
trigger: {
|
|
654
|
-
event: triggerEvent,
|
|
655
|
-
filters: {
|
|
656
|
-
campaigns: filterCampaigns || [],
|
|
657
|
-
segment: filterSegment || null
|
|
658
|
-
}
|
|
659
|
-
}
|
|
528
|
+
})
|
|
660
529
|
};
|
|
661
530
|
const response = await request({
|
|
662
531
|
body,
|
|
663
|
-
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/
|
|
532
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/workflow/" + event,
|
|
664
533
|
method: "PUT"
|
|
665
534
|
});
|
|
666
535
|
onSuccess(response);
|
|
@@ -668,7 +537,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
668
537
|
onError(error);
|
|
669
538
|
}
|
|
670
539
|
};
|
|
671
|
-
if (
|
|
540
|
+
if (loading) {
|
|
672
541
|
return /* @__PURE__ */ jsx(LoaderDynamic, {});
|
|
673
542
|
}
|
|
674
543
|
return /* @__PURE__ */ jsx(
|
|
@@ -695,65 +564,32 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
695
564
|
}
|
|
696
565
|
}
|
|
697
566
|
),
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
|
|
700
|
-
{
|
|
701
|
-
...{
|
|
702
|
-
control,
|
|
703
|
-
formState,
|
|
704
|
-
catalogList,
|
|
705
|
-
triggerOptions,
|
|
706
|
-
getValues,
|
|
707
|
-
setValue
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
),
|
|
711
|
-
watchedTrigger && /* @__PURE__ */ jsx(
|
|
712
|
-
WorkflowTitleField,
|
|
567
|
+
/* @__PURE__ */ jsxs(
|
|
568
|
+
CardSection,
|
|
713
569
|
{
|
|
714
570
|
...{
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
name: "filterCampaigns",
|
|
731
|
-
organization: values == null ? void 0 : values.organization,
|
|
732
|
-
resource: "campaign",
|
|
733
|
-
seeds: (_m = (_l = values == null ? void 0 : values.trigger) == null ? void 0 : _l.filters) == null ? void 0 : _m.campaigns
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
),
|
|
737
|
-
watchedTrigger === "segment.contact.add" && /* @__PURE__ */ jsx(
|
|
738
|
-
WorkflowFilterField,
|
|
739
|
-
{
|
|
740
|
-
...{
|
|
741
|
-
collection: "segments",
|
|
742
|
-
control,
|
|
743
|
-
label: "Segment",
|
|
744
|
-
message: "Only trigger when a contact joins a specific segment. Leaving blank will trigger for all segments.",
|
|
745
|
-
model: "segment",
|
|
746
|
-
name: "filterSegment",
|
|
747
|
-
organization: values == null ? void 0 : values.organization,
|
|
748
|
-
resource: "segment"
|
|
749
|
-
}
|
|
571
|
+
"data-trigger": true,
|
|
572
|
+
title: "Trigger"
|
|
573
|
+
},
|
|
574
|
+
children: [
|
|
575
|
+
/* @__PURE__ */ jsx("p", { children: values == null ? void 0 : values.title }),
|
|
576
|
+
(values == null ? void 0 : values.description) && /* @__PURE__ */ jsx(
|
|
577
|
+
"p",
|
|
578
|
+
{
|
|
579
|
+
...{
|
|
580
|
+
className: "text-sm text-gray-dark"
|
|
581
|
+
},
|
|
582
|
+
children: values.description
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
]
|
|
750
586
|
}
|
|
751
587
|
),
|
|
752
588
|
/* @__PURE__ */ jsx(
|
|
753
589
|
InputGroup,
|
|
754
590
|
{
|
|
755
591
|
...{
|
|
756
|
-
error: (
|
|
592
|
+
error: (_i = (_h = formState == null ? void 0 : formState.errors) == null ? void 0 : _h.steps) == null ? void 0 : _i.message,
|
|
757
593
|
input: /* @__PURE__ */ jsx(
|
|
758
594
|
InputArraySortable,
|
|
759
595
|
{
|
|
@@ -765,7 +601,6 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
765
601
|
InputArrayButton,
|
|
766
602
|
{
|
|
767
603
|
...{
|
|
768
|
-
disabled: !watchedTrigger,
|
|
769
604
|
onClick: () => append(stepRow()),
|
|
770
605
|
text: "Add step"
|
|
771
606
|
}
|
|
@@ -774,318 +609,321 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
774
609
|
},
|
|
775
610
|
children: ({ field, handle, index, remove }) => {
|
|
776
611
|
const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
|
|
777
|
-
return
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
612
|
+
return (
|
|
613
|
+
// @story workflows/edit
|
|
614
|
+
// EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
|
|
615
|
+
// edited in place: the drag handle left of Step N, as every
|
|
616
|
+
// sortable list has it, then its connection badge and Remove
|
|
617
|
+
// in the card's head, its fields in the body.
|
|
618
|
+
/* @__PURE__ */ jsx(
|
|
619
|
+
StepCard,
|
|
620
|
+
{
|
|
621
|
+
...{
|
|
622
|
+
control,
|
|
623
|
+
// @story workflows/send-email
|
|
624
|
+
// A Send email step shows its email beside its form.
|
|
625
|
+
email: emailSteps.includes(step.type) && {
|
|
626
|
+
campaign: values == null ? void 0 : values.campaign,
|
|
627
|
+
event,
|
|
628
|
+
name: `steps.${index}`,
|
|
629
|
+
organization: values == null ? void 0 : values.organization
|
|
630
|
+
},
|
|
631
|
+
cta: /* @__PURE__ */ jsxs(
|
|
632
|
+
"span",
|
|
633
|
+
{
|
|
634
|
+
...{
|
|
635
|
+
className: "flex items-center gap-2"
|
|
636
|
+
},
|
|
637
|
+
children: [
|
|
638
|
+
renderStepBadge(step),
|
|
639
|
+
!lockedStep(index) && /* @__PURE__ */ jsx(
|
|
640
|
+
InputArrayControl,
|
|
641
|
+
{
|
|
642
|
+
...{
|
|
643
|
+
onClick: () => remove(index),
|
|
644
|
+
icon: Trash
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
"remove"
|
|
648
|
+
)
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
),
|
|
652
|
+
"data-step": index + 1,
|
|
653
|
+
title: /* @__PURE__ */ jsxs(
|
|
654
|
+
"span",
|
|
655
|
+
{
|
|
656
|
+
...{
|
|
657
|
+
className: "flex items-center gap-2"
|
|
658
|
+
},
|
|
659
|
+
children: [
|
|
660
|
+
handle,
|
|
661
|
+
"Step " + (index + 1)
|
|
662
|
+
]
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
},
|
|
666
|
+
children: /* @__PURE__ */ jsxs(
|
|
785
667
|
"div",
|
|
786
668
|
{
|
|
787
669
|
...{
|
|
788
|
-
className: "
|
|
670
|
+
className: "space-y-3"
|
|
789
671
|
},
|
|
790
672
|
children: [
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
|
|
673
|
+
issueIndex === index && /* @__PURE__ */ jsx(
|
|
674
|
+
Error,
|
|
793
675
|
{
|
|
794
676
|
...{
|
|
795
|
-
|
|
796
|
-
}
|
|
797
|
-
children: [
|
|
798
|
-
handle,
|
|
799
|
-
/* @__PURE__ */ jsxs(
|
|
800
|
-
"span",
|
|
801
|
-
{
|
|
802
|
-
...{
|
|
803
|
-
className: "text-sm font-medium"
|
|
804
|
-
},
|
|
805
|
-
children: [
|
|
806
|
-
"Step ",
|
|
807
|
-
index + 1
|
|
808
|
-
]
|
|
809
|
-
}
|
|
810
|
-
)
|
|
811
|
-
]
|
|
677
|
+
error: values.issue.message
|
|
678
|
+
}
|
|
812
679
|
}
|
|
813
680
|
),
|
|
814
|
-
/* @__PURE__ */
|
|
815
|
-
|
|
681
|
+
/* @__PURE__ */ jsx(
|
|
682
|
+
Controller,
|
|
816
683
|
{
|
|
817
684
|
...{
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
{
|
|
825
|
-
...{
|
|
826
|
-
onClick: () => remove(index),
|
|
827
|
-
icon: Trash
|
|
828
|
-
}
|
|
829
|
-
},
|
|
830
|
-
"remove"
|
|
831
|
-
)
|
|
832
|
-
]
|
|
833
|
-
}
|
|
834
|
-
)
|
|
835
|
-
]
|
|
836
|
-
}
|
|
837
|
-
),
|
|
838
|
-
issueIndex === index && /* @__PURE__ */ jsx(
|
|
839
|
-
Error,
|
|
840
|
-
{
|
|
841
|
-
...{
|
|
842
|
-
error: values.issue.message
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
),
|
|
846
|
-
/* @__PURE__ */ jsx(
|
|
847
|
-
Controller,
|
|
848
|
-
{
|
|
849
|
-
...{
|
|
850
|
-
control,
|
|
851
|
-
name: `steps.${index}.type`,
|
|
852
|
-
render: ({ field: { onChange } }) => {
|
|
853
|
-
var _a2, _b2, _c2, _d2;
|
|
854
|
-
return /* @__PURE__ */ jsx(
|
|
855
|
-
InputGroup,
|
|
856
|
-
{
|
|
857
|
-
...{
|
|
858
|
-
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
|
|
859
|
-
input: /* @__PURE__ */ jsx(
|
|
860
|
-
InputCombobox,
|
|
685
|
+
control,
|
|
686
|
+
name: `steps.${index}.type`,
|
|
687
|
+
render: ({ field: { onChange } }) => {
|
|
688
|
+
var _a2, _b2, _c2, _d2;
|
|
689
|
+
return /* @__PURE__ */ jsx(
|
|
690
|
+
InputGroup,
|
|
861
691
|
{
|
|
862
692
|
...{
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
693
|
+
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
|
|
694
|
+
input: /* @__PURE__ */ jsx(
|
|
695
|
+
InputCombobox,
|
|
696
|
+
{
|
|
697
|
+
...{
|
|
698
|
+
onChange: (val) => {
|
|
699
|
+
const [type] = val.split("::");
|
|
700
|
+
const option = getStepOptions(index).find((o) => o.value === val);
|
|
701
|
+
onChange(type);
|
|
702
|
+
setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
|
|
703
|
+
setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
|
|
704
|
+
},
|
|
705
|
+
disabled: lockedStep(index),
|
|
706
|
+
options: getStepOptions(index),
|
|
707
|
+
// Resolved from the WHOLE ROW, not from this path: the
|
|
708
|
+
// option value carries a connection the type alone cannot
|
|
709
|
+
// name.
|
|
710
|
+
value: getStepValue(step, index)
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
),
|
|
714
|
+
label: "Step"
|
|
876
715
|
}
|
|
877
716
|
}
|
|
878
|
-
)
|
|
879
|
-
label: "Step"
|
|
717
|
+
);
|
|
880
718
|
}
|
|
881
719
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
var _a2, _b2, _c2, _d2;
|
|
895
|
-
return /* @__PURE__ */ jsx(
|
|
896
|
-
InputGroup,
|
|
897
|
-
{
|
|
898
|
-
...{
|
|
899
|
-
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
|
|
900
|
-
input: /* @__PURE__ */ jsx(
|
|
901
|
-
InputUrl,
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
step.type === "step.webhook.send" && /* @__PURE__ */ jsx(
|
|
723
|
+
Controller,
|
|
724
|
+
{
|
|
725
|
+
...{
|
|
726
|
+
control,
|
|
727
|
+
name: `steps.${index}.url`,
|
|
728
|
+
render: ({ field: { value, onChange } }) => {
|
|
729
|
+
var _a2, _b2, _c2, _d2;
|
|
730
|
+
return /* @__PURE__ */ jsx(
|
|
731
|
+
InputGroup,
|
|
902
732
|
{
|
|
903
733
|
...{
|
|
904
|
-
|
|
905
|
-
|
|
734
|
+
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
|
|
735
|
+
input: /* @__PURE__ */ jsx(
|
|
736
|
+
InputUrl,
|
|
737
|
+
{
|
|
738
|
+
...{
|
|
739
|
+
onChange,
|
|
740
|
+
value: value || ""
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
),
|
|
744
|
+
label: "Webhook URL"
|
|
906
745
|
}
|
|
907
746
|
}
|
|
908
|
-
)
|
|
909
|
-
label: "Webhook URL"
|
|
747
|
+
);
|
|
910
748
|
}
|
|
911
749
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
var _a2, _b2, _c2, _d2;
|
|
926
|
-
return /* @__PURE__ */ jsx(
|
|
927
|
-
InputGroup,
|
|
928
|
-
{
|
|
929
|
-
...{
|
|
930
|
-
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
|
|
931
|
-
input: /* @__PURE__ */ jsx(
|
|
932
|
-
InputResource,
|
|
750
|
+
}
|
|
751
|
+
),
|
|
752
|
+
teamSteps.includes(step.type) && lockedStep(index) && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "Recipients are chosen by the organization owner." }),
|
|
753
|
+
teamSteps.includes(step.type) && !lockedStep(index) && /* @__PURE__ */ jsx(
|
|
754
|
+
Controller,
|
|
755
|
+
{
|
|
756
|
+
...{
|
|
757
|
+
control,
|
|
758
|
+
name: `steps.${index}.members`,
|
|
759
|
+
render: ({ field: { value, onChange } }) => {
|
|
760
|
+
var _a2, _b2, _c2, _d2;
|
|
761
|
+
return /* @__PURE__ */ jsx(
|
|
762
|
+
InputGroup,
|
|
933
763
|
{
|
|
934
764
|
...{
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
765
|
+
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
|
|
766
|
+
input: /* @__PURE__ */ jsx(
|
|
767
|
+
InputResource,
|
|
768
|
+
{
|
|
769
|
+
...{
|
|
770
|
+
empty: "No members to add",
|
|
771
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/members",
|
|
772
|
+
// The owner is a chip like the others, only it cannot be
|
|
773
|
+
// removed: they are always a recipient and it is resolved
|
|
774
|
+
// in sync. Shaped like a member so `render` labels it the
|
|
775
|
+
// same way.
|
|
776
|
+
fixed: [{ email: ownerEmail }],
|
|
777
|
+
model: "member",
|
|
778
|
+
multiple: true,
|
|
779
|
+
onChange,
|
|
780
|
+
params: memberParams,
|
|
781
|
+
render: memberLabel,
|
|
782
|
+
// The row shows the name ( memberLabel ), so the search has
|
|
783
|
+
// to hit the name too. The members endpoint joins `user`
|
|
784
|
+
// before its search stage, so the nested keys resolve.
|
|
785
|
+
// Email stays for invitees who have not registered yet.
|
|
786
|
+
// ponytail: a full "First Last" query matches neither key;
|
|
787
|
+
// a $concat'd name on the API side if that comes up.
|
|
788
|
+
searchKeys: ["email", "user.firstName", "user.lastName"],
|
|
789
|
+
value: value || []
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
label: "Recipients"
|
|
955
794
|
}
|
|
956
795
|
}
|
|
957
|
-
)
|
|
958
|
-
label: "Recipients"
|
|
796
|
+
);
|
|
959
797
|
}
|
|
960
798
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
var _a2, _b2, _c2, _d2;
|
|
994
|
-
return /* @__PURE__ */ jsx(
|
|
995
|
-
InputGroup,
|
|
996
|
-
{
|
|
997
|
-
...{
|
|
998
|
-
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
|
|
999
|
-
input: /* @__PURE__ */ jsx(
|
|
1000
|
-
InputTextarea,
|
|
799
|
+
}
|
|
800
|
+
),
|
|
801
|
+
emailSteps.includes(step.type) && /* @__PURE__ */ jsx(
|
|
802
|
+
FormNotification,
|
|
803
|
+
{
|
|
804
|
+
...{
|
|
805
|
+
control,
|
|
806
|
+
// As the Fieldset above: the Message editor is a
|
|
807
|
+
// contenteditable, which a disabled fieldset never reaches.
|
|
808
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
|
|
809
|
+
formState,
|
|
810
|
+
onChecking,
|
|
811
|
+
setValue,
|
|
812
|
+
values: {
|
|
813
|
+
id: field.id,
|
|
814
|
+
name: `steps.${index}`,
|
|
815
|
+
organization: values == null ? void 0 : values.organization,
|
|
816
|
+
variables: getAvailableVariables(index)
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
step.type === "step.sms.send" && /* @__PURE__ */ jsx(
|
|
822
|
+
Controller,
|
|
823
|
+
{
|
|
824
|
+
...{
|
|
825
|
+
control,
|
|
826
|
+
name: `steps.${index}.message`,
|
|
827
|
+
render: ({ field: { value, onChange } }) => {
|
|
828
|
+
var _a2, _b2, _c2, _d2;
|
|
829
|
+
return /* @__PURE__ */ jsx(
|
|
830
|
+
InputGroup,
|
|
1001
831
|
{
|
|
1002
832
|
...{
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
833
|
+
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
|
|
834
|
+
input: /* @__PURE__ */ jsx(
|
|
835
|
+
InputTextarea,
|
|
836
|
+
{
|
|
837
|
+
...{
|
|
838
|
+
onChange,
|
|
839
|
+
rows: 3,
|
|
840
|
+
value: value || ""
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
),
|
|
844
|
+
label: "Message"
|
|
1006
845
|
}
|
|
1007
846
|
}
|
|
1008
|
-
)
|
|
1009
|
-
label: "Message"
|
|
847
|
+
);
|
|
1010
848
|
}
|
|
1011
849
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
var _a2, _b2, _c2, _d2;
|
|
1025
|
-
return /* @__PURE__ */ jsx(
|
|
1026
|
-
InputGroup,
|
|
1027
|
-
{
|
|
1028
|
-
...{
|
|
1029
|
-
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
|
|
1030
|
-
input: /* @__PURE__ */ jsx(
|
|
1031
|
-
InputResource,
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
step.type === "step.commerce.code.issue" && /* @__PURE__ */ jsx(
|
|
853
|
+
Controller,
|
|
854
|
+
{
|
|
855
|
+
...{
|
|
856
|
+
control,
|
|
857
|
+
name: `steps.${index}.discount`,
|
|
858
|
+
render: ({ field: { value, onChange } }) => {
|
|
859
|
+
var _a2, _b2, _c2, _d2;
|
|
860
|
+
return /* @__PURE__ */ jsx(
|
|
861
|
+
InputGroup,
|
|
1032
862
|
{
|
|
1033
863
|
...{
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
inline
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
864
|
+
error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
|
|
865
|
+
input: /* @__PURE__ */ jsx(
|
|
866
|
+
InputResource,
|
|
867
|
+
{
|
|
868
|
+
...{
|
|
869
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + commerceConnectionId + "/hook/browse.promotions",
|
|
870
|
+
model: "discount",
|
|
871
|
+
onChange,
|
|
872
|
+
// A DISCOUNT THE STORE CANNOT BACK IS SHOWN AND EXPLAINED, never
|
|
873
|
+
// filtered out. The merchant can see it in Shopify admin, so a row
|
|
874
|
+
// missing here with no reason reads as our bug rather than their
|
|
875
|
+
// setting — and the reason names the fix.
|
|
876
|
+
render: (item) => /* @__PURE__ */ jsxs("div", { children: [
|
|
877
|
+
/* @__PURE__ */ jsx("span", { className: (item == null ? void 0 : item.blocked) ? "text-gray-dark" : void 0, children: item == null ? void 0 : item.title }),
|
|
878
|
+
((item == null ? void 0 : item.blocked) || (item == null ? void 0 : item.warning)) && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-dark", children: item.blocked || item.warning })
|
|
879
|
+
] }),
|
|
880
|
+
renderButton: ({ button, item }) => (
|
|
881
|
+
// The list's small inline Add, unless the list says otherwise.
|
|
882
|
+
/* @__PURE__ */ jsx(
|
|
883
|
+
Button,
|
|
884
|
+
{
|
|
885
|
+
...{
|
|
886
|
+
inline: true,
|
|
887
|
+
size: "small",
|
|
888
|
+
...button.props,
|
|
889
|
+
disabled: Boolean(item == null ? void 0 : item.blocked),
|
|
890
|
+
title: (item == null ? void 0 : item.blocked) || void 0
|
|
891
|
+
},
|
|
892
|
+
children: button.text
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
),
|
|
896
|
+
value: value || null
|
|
1058
897
|
}
|
|
1059
|
-
|
|
898
|
+
}
|
|
1060
899
|
),
|
|
1061
|
-
|
|
900
|
+
label: "Discount",
|
|
901
|
+
// "Issue" means MINT, not send — this step creates the code and saves
|
|
902
|
+
// it to the lead, and nothing reaches them until a later email step
|
|
903
|
+
// names the variable. Said here because the step picker says nothing:
|
|
904
|
+
// QA read "Issue a discount code", built the one-step workflow that
|
|
905
|
+
// describes, and reported the codes as never arriving.
|
|
906
|
+
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
907
|
+
"Creates the code and saves it to the lead. To send it, add an email step after this one with ",
|
|
908
|
+
"{{shopifyDiscountCode}}",
|
|
909
|
+
" in the message.",
|
|
910
|
+
commerceDomain ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
911
|
+
" ",
|
|
912
|
+
/* @__PURE__ */ jsx("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
|
|
913
|
+
] }) : null
|
|
914
|
+
] })
|
|
1062
915
|
}
|
|
1063
916
|
}
|
|
1064
|
-
)
|
|
1065
|
-
label: "Discount",
|
|
1066
|
-
// "Issue" means MINT, not send — this step creates the code and saves
|
|
1067
|
-
// it to the lead, and nothing reaches them until a later email step
|
|
1068
|
-
// names the variable. Said here because the step picker says nothing:
|
|
1069
|
-
// QA read "Issue a discount code", built the one-step workflow that
|
|
1070
|
-
// describes, and reported the codes as never arriving.
|
|
1071
|
-
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1072
|
-
"Creates the code and saves it to the lead. To send it, add an email step after this one with ",
|
|
1073
|
-
"{{shopifyDiscountCode}}",
|
|
1074
|
-
" in the message.",
|
|
1075
|
-
commerceDomain ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1076
|
-
" ",
|
|
1077
|
-
/* @__PURE__ */ jsx("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
|
|
1078
|
-
] }) : null
|
|
1079
|
-
] })
|
|
917
|
+
);
|
|
1080
918
|
}
|
|
1081
919
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
920
|
+
}
|
|
921
|
+
)
|
|
922
|
+
]
|
|
1085
923
|
}
|
|
1086
924
|
)
|
|
1087
|
-
|
|
1088
|
-
|
|
925
|
+
}
|
|
926
|
+
)
|
|
1089
927
|
);
|
|
1090
928
|
}
|
|
1091
929
|
}
|
|
@@ -1112,13 +950,10 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1112
950
|
);
|
|
1113
951
|
};
|
|
1114
952
|
export {
|
|
1115
|
-
FormOrganizationWorkflow,
|
|
1116
953
|
FormOrganizationWorkflowEdit,
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
filterMissing,
|
|
1120
|
-
filterRows,
|
|
1121
|
-
filterSeed,
|
|
954
|
+
prefillRow,
|
|
955
|
+
stepReason,
|
|
1122
956
|
stepRow,
|
|
957
|
+
stepVariables,
|
|
1123
958
|
workflowSchema
|
|
1124
959
|
};
|