@drawbridge/components 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/form-subdomain-missions.js +54 -47
- package/dist/bridge/form-subdomain-missions.mjs +54 -47
- package/dist/bridge/template-layout.js +1 -1
- package/dist/bridge/template-layout.mjs +1 -1
- package/dist/bridge/template-modal.js +1 -1
- package/dist/bridge/template-modal.mjs +1 -1
- package/dist/dashboard/form-organization-campaign-agreement.js +2 -2
- package/dist/dashboard/form-organization-campaign-agreement.mjs +2 -2
- package/dist/dashboard/form-organization-workflow.js +548 -54
- package/dist/dashboard/form-organization-workflow.mjs +539 -54
- package/dist/dashboard/form-otc.js +7 -4
- package/dist/dashboard/form-otc.mjs +8 -5
- package/dist/dashboard/input-editor.js +56 -12
- package/dist/dashboard/input-editor.mjs +53 -11
- package/dist/dashboard/order-sections.js +23 -12
- package/dist/dashboard/order-sections.mjs +23 -12
- package/dist/dashboard/steps.js +5 -0
- package/dist/dashboard/steps.mjs +5 -0
- package/dist/dashboard/template-socket.js +6 -0
- package/dist/dashboard/template-socket.mjs +6 -0
- package/dist/input-code.js +2 -8
- package/dist/input-code.mjs +2 -8
- package/package.json +3 -3
- package/types/bridge/form-subdomain-missions.d.ts +1 -1
- package/types/dashboard/form-organization-workflow.d.ts +44 -0
- package/types/dashboard/input-editor.d.ts +9 -1
- package/types/dashboard/steps.d.ts +2 -0
- package/types/input-code.d.ts +0 -2
|
@@ -28,11 +28,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var form_organization_workflow_exports = {};
|
|
29
29
|
__export(form_organization_workflow_exports, {
|
|
30
30
|
FormOrganizationWorkflowEdit: () => FormOrganizationWorkflowEdit,
|
|
31
|
+
RESPONSE: () => RESPONSE,
|
|
31
32
|
SAMPLE: () => SAMPLE,
|
|
32
33
|
TextPreview: () => TextPreview,
|
|
33
34
|
firstEntryOnly: () => firstEntryOnly,
|
|
35
|
+
issueRow: () => issueRow,
|
|
36
|
+
memberOptions: () => memberOptions,
|
|
37
|
+
partToStart: () => partToStart,
|
|
34
38
|
pickedCopy: () => pickedCopy,
|
|
39
|
+
plainHtml: () => plainHtml,
|
|
35
40
|
prefillRow: () => prefillRow,
|
|
41
|
+
responseParts: () => responseParts,
|
|
42
|
+
responseSave: () => responseSave,
|
|
43
|
+
responseStart: () => responseStart,
|
|
44
|
+
stepAfterPart: () => stepAfterPart,
|
|
36
45
|
stepReason: () => stepReason,
|
|
37
46
|
stepRow: () => stepRow,
|
|
38
47
|
stepVariables: () => stepVariables,
|
|
@@ -46,6 +55,7 @@ var import_link = __toESM(require("./link"));
|
|
|
46
55
|
var import_react = require("react");
|
|
47
56
|
var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
|
|
48
57
|
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
58
|
+
var import_html = require("@drawbridge/drawbridge-utils/html");
|
|
49
59
|
var import_form = require("../shared/lib/form");
|
|
50
60
|
var import_react_query = require("@tanstack/react-query");
|
|
51
61
|
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
@@ -58,6 +68,7 @@ var import_input_url = __toESM(require("../shared/input-url"));
|
|
|
58
68
|
var import_input_resource = __toESM(require("./input-resource"));
|
|
59
69
|
var import_input_combobox = __toESM(require("./input-combobox"));
|
|
60
70
|
var import_form_notification = require("./form-notification");
|
|
71
|
+
var import_input_editor = __toESM(require("./input-editor"));
|
|
61
72
|
var import_input_array = require("./input-array");
|
|
62
73
|
var import_badge = __toESM(require("../shared/badge"));
|
|
63
74
|
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
@@ -73,9 +84,10 @@ const emailSteps = ["step.email.send"];
|
|
|
73
84
|
const teamSteps = ["step.email.notify"];
|
|
74
85
|
const messageSteps = [...emailSteps, "step.sms.send"];
|
|
75
86
|
const renderedSteps = [...emailSteps, ...teamSteps];
|
|
87
|
+
const RESPONSE = "step.response.send";
|
|
76
88
|
const firstEntryOnly = ({ campaign, event, type }) => {
|
|
77
89
|
var _a, _b;
|
|
78
|
-
if (event !== "lead.insert" || !type || emailSteps.includes(type)) return false;
|
|
90
|
+
if (event !== "lead.insert" || !type || emailSteps.includes(type) || type === RESPONSE) return false;
|
|
79
91
|
if (type === "step.sms.send") return (((_a = campaign == null ? void 0 : campaign.form) == null ? void 0 : _a.submissionLeadPrimaryKey) ?? ((_b = campaign == null ? void 0 : campaign.settings) == null ? void 0 : _b.submissionLeadPrimaryKey)) !== "phone";
|
|
80
92
|
return true;
|
|
81
93
|
};
|
|
@@ -98,20 +110,23 @@ const memberParams = {
|
|
|
98
110
|
createdAt: -1
|
|
99
111
|
}
|
|
100
112
|
};
|
|
113
|
+
const memberOptions = (organization) => ({
|
|
114
|
+
queryKey: ["organization-members", organization, "options"],
|
|
115
|
+
queryFn: async () => {
|
|
116
|
+
const { result } = await (0, import_fetch.request)({
|
|
117
|
+
endpoint: "/organization/" + organization + "/members",
|
|
118
|
+
// limit / skip / sort are required by the route's query validation.
|
|
119
|
+
params: memberParams
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
},
|
|
123
|
+
staleTime: Infinity
|
|
124
|
+
});
|
|
101
125
|
const useOrganizationMembers = (organization) => {
|
|
102
126
|
var _a;
|
|
103
127
|
const members = (0, import_react_query.useQuery)({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const { result } = await (0, import_fetch.request)({
|
|
107
|
-
endpoint: "/organization/" + organization + "/members",
|
|
108
|
-
// limit / skip / sort are required by the route's query validation.
|
|
109
|
-
params: memberParams
|
|
110
|
-
});
|
|
111
|
-
return result;
|
|
112
|
-
},
|
|
113
|
-
enabled: Boolean(organization),
|
|
114
|
-
staleTime: Infinity
|
|
128
|
+
...memberOptions(organization),
|
|
129
|
+
enabled: Boolean(organization)
|
|
115
130
|
});
|
|
116
131
|
return {
|
|
117
132
|
items: ((_a = members.data) == null ? void 0 : _a.items) || [],
|
|
@@ -153,8 +168,108 @@ const stepReason = ({ entry, saved = [], type }) => {
|
|
|
153
168
|
var _a, _b;
|
|
154
169
|
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;
|
|
155
170
|
};
|
|
171
|
+
const responseStart = (number) => ({
|
|
172
|
+
email: {
|
|
173
|
+
enabled: true,
|
|
174
|
+
message: import_drawbridge_utils.constants.campaign.confirmation.message,
|
|
175
|
+
score: null,
|
|
176
|
+
subject: import_drawbridge_utils.constants.campaign.confirmation.subject,
|
|
177
|
+
text: import_drawbridge_utils.constants.campaign.confirmation.text
|
|
178
|
+
},
|
|
179
|
+
sms: {
|
|
180
|
+
enabled: number === "verified",
|
|
181
|
+
message: import_drawbridge_utils.constants.campaign.confirmation.sms.giveaway
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const responseParts = ({ autoResponse, campaign, organization, settings }) => {
|
|
185
|
+
var _a, _b;
|
|
186
|
+
const { fields, number } = autoResponse || {};
|
|
187
|
+
const base = "/organizations/" + organization;
|
|
188
|
+
const addField = {
|
|
189
|
+
href: base + "/campaigns/" + campaign + "/form",
|
|
190
|
+
text: "Add field"
|
|
191
|
+
};
|
|
192
|
+
const numberTask = () => {
|
|
193
|
+
if (number === "verified") return null;
|
|
194
|
+
if (number === "error") return {
|
|
195
|
+
button: {
|
|
196
|
+
href: base + "/settings",
|
|
197
|
+
text: "View number"
|
|
198
|
+
},
|
|
199
|
+
message: "Your SMS number wasn't approved.",
|
|
200
|
+
type: "error"
|
|
201
|
+
};
|
|
202
|
+
if (number) return {
|
|
203
|
+
message: "Your SMS number is waiting for approval.",
|
|
204
|
+
type: "warning"
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
button: {
|
|
208
|
+
href: base + "/settings",
|
|
209
|
+
text: "Get a number"
|
|
210
|
+
},
|
|
211
|
+
message: "Texts need an SMS number."
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
const emailCan = Boolean(fields == null ? void 0 : fields.email);
|
|
215
|
+
const smsCan = Boolean(fields == null ? void 0 : fields.phone) && number === "verified";
|
|
216
|
+
return {
|
|
217
|
+
can: emailCan || smsCan,
|
|
218
|
+
email: {
|
|
219
|
+
can: emailCan,
|
|
220
|
+
hidden: !(fields == null ? void 0 : fields.email),
|
|
221
|
+
on: emailCan && ((_a = settings == null ? void 0 : settings.email) == null ? void 0 : _a.enabled) === true,
|
|
222
|
+
task: (fields == null ? void 0 : fields.email) ? null : {
|
|
223
|
+
button: addField,
|
|
224
|
+
message: "Emails need an Email field on the form."
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
sms: {
|
|
228
|
+
can: smsCan,
|
|
229
|
+
hidden: !(fields == null ? void 0 : fields.phone),
|
|
230
|
+
on: smsCan && ((_b = settings == null ? void 0 : settings.sms) == null ? void 0 : _b.enabled) === true,
|
|
231
|
+
task: (fields == null ? void 0 : fields.phone) ? numberTask() : {
|
|
232
|
+
button: addField,
|
|
233
|
+
message: "Texts need a Phone field on the form."
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const stepAfterPart = ({ enabled, next, other }) => next || enabled !== false && other === true;
|
|
239
|
+
const partToStart = (parts) => {
|
|
240
|
+
if (parts.email.on || parts.sms.on) return null;
|
|
241
|
+
return parts.email.can ? "email" : "sms";
|
|
242
|
+
};
|
|
243
|
+
const issueRow = ({ issue, steps = [] }) => (issue == null ? void 0 : issue.step) ? steps.findIndex((step) => (step == null ? void 0 : step.type) === issue.step || (step == null ? void 0 : step.type) === RESPONSE && messageSteps.includes(issue.step)) : -1;
|
|
244
|
+
const scoreHolds = ({ message, score, subject }) => Boolean(score) && score.subject === subject && score.message === message;
|
|
245
|
+
const responseSave = ({ email, sms }) => ({
|
|
246
|
+
email: {
|
|
247
|
+
enabled: email.enabled,
|
|
248
|
+
message: email.message,
|
|
249
|
+
...scoreHolds(email) && {
|
|
250
|
+
score: email.score
|
|
251
|
+
},
|
|
252
|
+
subject: email.subject,
|
|
253
|
+
...email.text && {
|
|
254
|
+
text: email.text
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
sms: {
|
|
258
|
+
enabled: sms.enabled,
|
|
259
|
+
message: sms.message
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const plainHtml = (text, variables) => String(text || "").split("\n").map((line) => {
|
|
263
|
+
const marked = line.match(/^\[(.+)\]$/);
|
|
264
|
+
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + (0, import_html.escapeHtml)(marked[1]) + '"></span>' : (0, import_input_editor.plainLine)(line, variables)) + "</p>";
|
|
265
|
+
}).join("");
|
|
266
|
+
const taggedScore = (settings) => (settings == null ? void 0 : settings.score) ? {
|
|
267
|
+
...settings.score,
|
|
268
|
+
message: (settings == null ? void 0 : settings.message) || "",
|
|
269
|
+
subject: (settings == null ? void 0 : settings.subject) || ""
|
|
270
|
+
} : null;
|
|
156
271
|
const stepRow = (step = {}, members = []) => {
|
|
157
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
272
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
158
273
|
return {
|
|
159
274
|
connectionId: step.connectionId || "",
|
|
160
275
|
discount: ((_a = step.settings) == null ? void 0 : _a.discount) || null,
|
|
@@ -167,28 +282,32 @@ const stepRow = (step = {}, members = []) => {
|
|
|
167
282
|
// render as an unlabelled chip nobody could identify.
|
|
168
283
|
members: (((_b = step.settings) == null ? void 0 : _b.members) || []).map((id) => members.find((member) => (member == null ? void 0 : member.id) === id)).filter(Boolean),
|
|
169
284
|
message: ((_c = step.settings) == null ? void 0 : _c.message) || "",
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
285
|
+
score: taggedScore(step.settings),
|
|
286
|
+
// @story workflows/auto-response
|
|
287
|
+
// Its two parts; null on every other row, so every row holds the same keys.
|
|
288
|
+
settings: step.type === RESPONSE ? {
|
|
289
|
+
email: {
|
|
290
|
+
enabled: ((_e = (_d = step.settings) == null ? void 0 : _d.email) == null ? void 0 : _e.enabled) === true,
|
|
291
|
+
message: ((_g = (_f = step.settings) == null ? void 0 : _f.email) == null ? void 0 : _g.message) || "",
|
|
292
|
+
score: taggedScore((_h = step.settings) == null ? void 0 : _h.email),
|
|
293
|
+
subject: ((_j = (_i = step.settings) == null ? void 0 : _i.email) == null ? void 0 : _j.subject) || "",
|
|
294
|
+
text: ((_l = (_k = step.settings) == null ? void 0 : _k.email) == null ? void 0 : _l.text) || ""
|
|
295
|
+
},
|
|
296
|
+
sms: {
|
|
297
|
+
enabled: ((_n = (_m = step.settings) == null ? void 0 : _m.sms) == null ? void 0 : _n.enabled) === true,
|
|
298
|
+
message: ((_p = (_o = step.settings) == null ? void 0 : _o.sms) == null ? void 0 : _p.message) || ""
|
|
299
|
+
}
|
|
182
300
|
} : null,
|
|
183
301
|
slug: step.slug || "",
|
|
184
|
-
subject: ((
|
|
302
|
+
subject: ((_q = step.settings) == null ? void 0 : _q.subject) || "",
|
|
185
303
|
// The editor writes this only when the merchant touches it, so without a
|
|
186
304
|
// seed an untouched save dropped the plain rendering of the message.
|
|
187
|
-
text: ((
|
|
305
|
+
text: ((_r = step.settings) == null ? void 0 : _r.text) || "",
|
|
188
306
|
type: step.type || "",
|
|
189
|
-
url: ((
|
|
307
|
+
url: ((_s = step.settings) == null ? void 0 : _s.url) || ""
|
|
190
308
|
};
|
|
191
309
|
};
|
|
310
|
+
const hasWords = (value) => Boolean(String(value || "").replace(/<[^>]*>/g, "").trim());
|
|
192
311
|
const workflowSchema = import_yup.default.object({
|
|
193
312
|
steps: import_yup.default.array().of(
|
|
194
313
|
import_yup.default.object({
|
|
@@ -206,11 +325,9 @@ const workflowSchema = import_yup.default.object({
|
|
|
206
325
|
return schema;
|
|
207
326
|
}),
|
|
208
327
|
// @story workflows/edit
|
|
209
|
-
// The editor writes an empty message as "<p></p>", which a plain
|
|
210
|
-
// required() accepts: a message needs words, not only markup.
|
|
211
328
|
message: import_yup.default.string().test("words", "Message is required", function(value) {
|
|
212
329
|
var _a;
|
|
213
|
-
return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) ||
|
|
330
|
+
return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) || hasWords(value);
|
|
214
331
|
}).when("type", ([type], schema) => {
|
|
215
332
|
if (type === "step.sms.send") {
|
|
216
333
|
return schema.required("Message is required").max(1500).label("Message");
|
|
@@ -220,6 +337,28 @@ const workflowSchema = import_yup.default.object({
|
|
|
220
337
|
}
|
|
221
338
|
return schema;
|
|
222
339
|
}),
|
|
340
|
+
// @story workflows/auto-response
|
|
341
|
+
// A part's fields are required only while that part is on, with the
|
|
342
|
+
// limits the step declares in utils, so the api never refuses a save
|
|
343
|
+
// the form allowed.
|
|
344
|
+
settings: import_yup.default.object().nullable().when("type", ([type], schema) => type === RESPONSE ? schema.shape({
|
|
345
|
+
email: import_yup.default.object({
|
|
346
|
+
message: import_yup.default.string().when("enabled", {
|
|
347
|
+
is: true,
|
|
348
|
+
then: (part) => part.test("words", "Message is required", hasWords).max(2e3).label("Message")
|
|
349
|
+
}),
|
|
350
|
+
subject: import_yup.default.string().when("enabled", {
|
|
351
|
+
is: true,
|
|
352
|
+
then: (part) => part.required("Subject is required").max(150).label("Subject")
|
|
353
|
+
})
|
|
354
|
+
}),
|
|
355
|
+
sms: import_yup.default.object({
|
|
356
|
+
message: import_yup.default.string().when("enabled", {
|
|
357
|
+
is: true,
|
|
358
|
+
then: (part) => part.required("Message is required").max(1500).label("Message")
|
|
359
|
+
})
|
|
360
|
+
})
|
|
361
|
+
}) : schema),
|
|
223
362
|
// No minimum. The organization owner is always a recipient, so a
|
|
224
363
|
// step with no members chosen is complete — requiring one here
|
|
225
364
|
// made the step unsaveable for a solo merchant, who has no
|
|
@@ -385,14 +524,340 @@ const StepPreview = ({ campaign, control, image, name, organization, type }) =>
|
|
|
385
524
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No preview available" })
|
|
386
525
|
] });
|
|
387
526
|
};
|
|
527
|
+
const LeadEmailNote = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
528
|
+
"p",
|
|
529
|
+
{
|
|
530
|
+
...{
|
|
531
|
+
className: "text-sm text-gray-dark"
|
|
532
|
+
},
|
|
533
|
+
children: "Drawbridge adds the entrant's order and missions under your message. You can't edit or remove them."
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
const RESPONSE_STATES = [
|
|
537
|
+
{
|
|
538
|
+
key: "Email",
|
|
539
|
+
value: "email"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
key: "Text",
|
|
543
|
+
value: "sms"
|
|
544
|
+
}
|
|
545
|
+
];
|
|
546
|
+
const ResponseText = ({ className, id, text, variables }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
547
|
+
"div",
|
|
548
|
+
{
|
|
549
|
+
...{
|
|
550
|
+
className,
|
|
551
|
+
id
|
|
552
|
+
},
|
|
553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
554
|
+
import_input_editor.EditorView,
|
|
555
|
+
{
|
|
556
|
+
...{
|
|
557
|
+
value: plainHtml(text, variables)
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
const ResponseStepCard = ({
|
|
564
|
+
card,
|
|
565
|
+
children,
|
|
566
|
+
control,
|
|
567
|
+
disabled,
|
|
568
|
+
formState,
|
|
569
|
+
off,
|
|
570
|
+
onChecking,
|
|
571
|
+
response: {
|
|
572
|
+
autoResponse,
|
|
573
|
+
campaign,
|
|
574
|
+
enabled,
|
|
575
|
+
event,
|
|
576
|
+
id,
|
|
577
|
+
index,
|
|
578
|
+
organization,
|
|
579
|
+
settings,
|
|
580
|
+
title,
|
|
581
|
+
variables
|
|
582
|
+
},
|
|
583
|
+
setValue
|
|
584
|
+
}) => {
|
|
585
|
+
var _a, _b, _c, _d, _e;
|
|
586
|
+
const [picked, setPicked] = (0, import_react.useState)("email");
|
|
587
|
+
const name = `steps.${index}`;
|
|
588
|
+
const parts = responseParts({ autoResponse, campaign, organization, settings });
|
|
589
|
+
const shown = parts.email.hidden ? "sms" : parts.sms.hidden ? "email" : picked;
|
|
590
|
+
const placeholders = autoResponse == null ? void 0 : autoResponse.placeholders;
|
|
591
|
+
const preview = useEmailPreview({
|
|
592
|
+
campaign,
|
|
593
|
+
event: parts.email.hidden ? null : event,
|
|
594
|
+
message: (_a = settings == null ? void 0 : settings.email) == null ? void 0 : _a.message,
|
|
595
|
+
organization,
|
|
596
|
+
subject: (_b = settings == null ? void 0 : settings.email) == null ? void 0 : _b.subject,
|
|
597
|
+
text: (_c = settings == null ? void 0 : settings.email) == null ? void 0 : _c.text
|
|
598
|
+
});
|
|
599
|
+
const brand = (0, import_sms.smsBrandLine)(title, (_d = settings == null ? void 0 : settings.sms) == null ? void 0 : _d.message);
|
|
600
|
+
const partSwitch = ({ label, message, other, part }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
601
|
+
import_form.Controller,
|
|
602
|
+
{
|
|
603
|
+
...{
|
|
604
|
+
control,
|
|
605
|
+
name: name + ".settings." + part + ".enabled",
|
|
606
|
+
render: ({ field: { onChange, value } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
607
|
+
import_input_group.default,
|
|
608
|
+
{
|
|
609
|
+
...{
|
|
610
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
611
|
+
import_input_switch.default,
|
|
612
|
+
{
|
|
613
|
+
...{
|
|
614
|
+
"aria-label": label,
|
|
615
|
+
disabled: disabled || !parts[part].can,
|
|
616
|
+
onChange: (next) => {
|
|
617
|
+
var _a2;
|
|
618
|
+
onChange(next);
|
|
619
|
+
setValue(name + ".enabled", stepAfterPart({ enabled, next, other: (_a2 = settings == null ? void 0 : settings[other]) == null ? void 0 : _a2.enabled }));
|
|
620
|
+
setPicked(part);
|
|
621
|
+
},
|
|
622
|
+
value: parts[part].can && value === true
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
),
|
|
626
|
+
label,
|
|
627
|
+
message
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
)
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
635
|
+
import_card_section.default,
|
|
636
|
+
{
|
|
637
|
+
...{
|
|
638
|
+
...card,
|
|
639
|
+
columns: 2
|
|
640
|
+
},
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
643
|
+
"div",
|
|
644
|
+
{
|
|
645
|
+
...{
|
|
646
|
+
className: "space-y-6" + (off ? " opacity-50" : "")
|
|
647
|
+
},
|
|
648
|
+
children: [
|
|
649
|
+
children,
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
651
|
+
"div",
|
|
652
|
+
{
|
|
653
|
+
...{
|
|
654
|
+
className: "pt-6 border-t border-gray space-y-6"
|
|
655
|
+
},
|
|
656
|
+
children: [
|
|
657
|
+
partSwitch({ label: "Email", other: "sms", part: "email" }),
|
|
658
|
+
parts.email.task && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card_task.default, { ...parts.email.task }),
|
|
659
|
+
!parts.email.hidden && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
661
|
+
"div",
|
|
662
|
+
{
|
|
663
|
+
...{
|
|
664
|
+
className: "space-y-3" + (parts.email.on ? "" : " opacity-50")
|
|
665
|
+
},
|
|
666
|
+
children: [
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
668
|
+
import_form_notification.FormNotification,
|
|
669
|
+
{
|
|
670
|
+
...{
|
|
671
|
+
control,
|
|
672
|
+
disabled: disabled || !parts.email.on,
|
|
673
|
+
formState,
|
|
674
|
+
onChecking,
|
|
675
|
+
setValue,
|
|
676
|
+
values: {
|
|
677
|
+
id,
|
|
678
|
+
name: name + ".settings.email",
|
|
679
|
+
organization,
|
|
680
|
+
variables
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
),
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LeadEmailNote, {})
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
690
|
+
import_input_group.default,
|
|
691
|
+
{
|
|
692
|
+
...{
|
|
693
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
694
|
+
ResponseText,
|
|
695
|
+
{
|
|
696
|
+
...{
|
|
697
|
+
className: "w-full border border-inherit rounded px-3 py-2 disabled",
|
|
698
|
+
text: preview == null ? void 0 : preview.text,
|
|
699
|
+
variables
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
),
|
|
703
|
+
label: "Plain-text version"
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
)
|
|
707
|
+
] })
|
|
708
|
+
]
|
|
709
|
+
}
|
|
710
|
+
),
|
|
711
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
712
|
+
"div",
|
|
713
|
+
{
|
|
714
|
+
...{
|
|
715
|
+
className: "mt-10 pt-10 border-t border-gray-dark space-y-6"
|
|
716
|
+
},
|
|
717
|
+
children: [
|
|
718
|
+
partSwitch({
|
|
719
|
+
label: "Text",
|
|
720
|
+
// The line goes with the part's fields when the form lacks the field.
|
|
721
|
+
message: !parts.sms.hidden && "Sends to entrants who agree to texts. Each text costs 2 actions, and a long text costs more.",
|
|
722
|
+
other: "email",
|
|
723
|
+
part: "sms"
|
|
724
|
+
}),
|
|
725
|
+
parts.sms.task && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card_task.default, { ...parts.sms.task }),
|
|
726
|
+
!parts.sms.hidden && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
727
|
+
import_form.Controller,
|
|
728
|
+
{
|
|
729
|
+
...{
|
|
730
|
+
control,
|
|
731
|
+
name: name + ".settings.sms.message",
|
|
732
|
+
render: ({ field: { onChange, value } }) => {
|
|
733
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
735
|
+
"div",
|
|
736
|
+
{
|
|
737
|
+
...{
|
|
738
|
+
className: parts.sms.on ? "" : "opacity-50"
|
|
739
|
+
},
|
|
740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
741
|
+
import_input_group.default,
|
|
742
|
+
{
|
|
743
|
+
...{
|
|
744
|
+
error: (_f = (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.settings) == null ? void 0 : _d2.sms) == null ? void 0 : _e2.message) == null ? void 0 : _f.message,
|
|
745
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
746
|
+
import_input_editor.default,
|
|
747
|
+
{
|
|
748
|
+
...{
|
|
749
|
+
disabled: disabled || !parts.sms.on,
|
|
750
|
+
...(placeholders == null ? void 0 : placeholders.missions) && {
|
|
751
|
+
locked: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResponseText, { ...{ text: "[" + placeholders.missions + "]" } })
|
|
752
|
+
},
|
|
753
|
+
onChange: ({ text }) => onChange(text),
|
|
754
|
+
plain: true,
|
|
755
|
+
value: value || "",
|
|
756
|
+
variables
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
),
|
|
760
|
+
label: "Message"
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
)
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
)
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
)
|
|
773
|
+
]
|
|
774
|
+
}
|
|
775
|
+
),
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
777
|
+
"div",
|
|
778
|
+
{
|
|
779
|
+
...{
|
|
780
|
+
className: off || !parts[shown].on ? "opacity-50" : ""
|
|
781
|
+
},
|
|
782
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
783
|
+
import_preview.default,
|
|
784
|
+
{
|
|
785
|
+
...{
|
|
786
|
+
...!parts.email.hidden && !parts.sms.hidden && {
|
|
787
|
+
states: {
|
|
788
|
+
onChange: setPicked,
|
|
789
|
+
options: RESPONSE_STATES,
|
|
790
|
+
value: shown
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
children: shown === "email" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
795
|
+
"iframe",
|
|
796
|
+
{
|
|
797
|
+
...{
|
|
798
|
+
className: "block w-full h-full border-0 bg-white",
|
|
799
|
+
srcDoc: (preview == null ? void 0 : preview.html) || "",
|
|
800
|
+
title: "Auto response"
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextPreview, { children: [
|
|
804
|
+
brand && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: brand }),
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
806
|
+
ResponseText,
|
|
807
|
+
{
|
|
808
|
+
...{
|
|
809
|
+
text: (_e = settings == null ? void 0 : settings.sms) == null ? void 0 : _e.message,
|
|
810
|
+
variables
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
),
|
|
814
|
+
(placeholders == null ? void 0 : placeholders.missions) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
815
|
+
ResponseText,
|
|
816
|
+
{
|
|
817
|
+
...{
|
|
818
|
+
className: "mt-2",
|
|
819
|
+
text: "[" + placeholders.missions + "]"
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
),
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2", children: "Reply STOP to opt out" })
|
|
824
|
+
] })
|
|
825
|
+
}
|
|
826
|
+
)
|
|
827
|
+
}
|
|
828
|
+
)
|
|
829
|
+
]
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
};
|
|
388
833
|
const StepCard = ({
|
|
389
834
|
children,
|
|
390
835
|
control,
|
|
836
|
+
disabled,
|
|
391
837
|
email,
|
|
838
|
+
formState,
|
|
392
839
|
off,
|
|
840
|
+
onChecking,
|
|
393
841
|
preview,
|
|
842
|
+
response,
|
|
843
|
+
setValue,
|
|
394
844
|
...card
|
|
395
|
-
}) =>
|
|
845
|
+
}) => response ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
846
|
+
ResponseStepCard,
|
|
847
|
+
{
|
|
848
|
+
...{
|
|
849
|
+
card,
|
|
850
|
+
control,
|
|
851
|
+
disabled,
|
|
852
|
+
formState,
|
|
853
|
+
off,
|
|
854
|
+
onChecking,
|
|
855
|
+
response,
|
|
856
|
+
setValue
|
|
857
|
+
},
|
|
858
|
+
children
|
|
859
|
+
}
|
|
860
|
+
) : email ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
396
861
|
EmailStepCard,
|
|
397
862
|
{
|
|
398
863
|
...{
|
|
@@ -439,7 +904,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
439
904
|
onSuccess,
|
|
440
905
|
values
|
|
441
906
|
}) => {
|
|
442
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
907
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
443
908
|
const event = (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event;
|
|
444
909
|
const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization);
|
|
445
910
|
const queryClient = (0, import_react_query.useQueryClient)();
|
|
@@ -481,7 +946,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
481
946
|
control,
|
|
482
947
|
name: "steps"
|
|
483
948
|
});
|
|
484
|
-
const issueIndex = (
|
|
949
|
+
const issueIndex = issueRow({ issue: values == null ? void 0 : values.issue, steps: watchedSteps || [] });
|
|
485
950
|
const getAvailableVariables = (index) => stepVariables(catalog, watchedSteps, index);
|
|
486
951
|
const loading = membersLoading || commerceConnection.isLoading;
|
|
487
952
|
const prefilled = (0, import_react.useRef)(false);
|
|
@@ -615,13 +1080,14 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
615
1080
|
}) => {
|
|
616
1081
|
try {
|
|
617
1082
|
const body = {
|
|
618
|
-
steps: steps.map(({ connectionId, discount, enabled, members, message, score, slug, subject, text, type, url }, index) => {
|
|
619
|
-
const settings = {};
|
|
1083
|
+
steps: steps.map(({ connectionId, discount, enabled, members, message, score, settings: parts, slug, subject, text, type, url }, index) => {
|
|
1084
|
+
const settings = type === RESPONSE ? responseSave(parts) : {};
|
|
1085
|
+
if (type === RESPONSE && parts.email.score && !settings.email.score) setValue("steps." + index + ".settings.email.score", null);
|
|
620
1086
|
if (type === "step.webhook.send") settings.url = url;
|
|
621
1087
|
if (emailSteps.includes(type)) settings.subject = subject;
|
|
622
1088
|
if (messageSteps.includes(type)) settings.message = message;
|
|
623
1089
|
if (emailSteps.includes(type)) {
|
|
624
|
-
if (
|
|
1090
|
+
if (scoreHolds({ message, score, subject })) settings.score = score;
|
|
625
1091
|
else if (score) setValue("steps." + index + ".score", null);
|
|
626
1092
|
if (text) settings.text = text;
|
|
627
1093
|
}
|
|
@@ -702,7 +1168,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
702
1168
|
import_input_group.default,
|
|
703
1169
|
{
|
|
704
1170
|
...{
|
|
705
|
-
error: (
|
|
1171
|
+
error: (_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.steps) == null ? void 0 : _h.message,
|
|
706
1172
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
707
1173
|
import_input_array.InputArraySortable,
|
|
708
1174
|
{
|
|
@@ -723,6 +1189,12 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
723
1189
|
children: ({ field, handle, index, remove }) => {
|
|
724
1190
|
var _a2;
|
|
725
1191
|
const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
|
|
1192
|
+
const parts = step.type === RESPONSE && responseParts({
|
|
1193
|
+
autoResponse: values == null ? void 0 : values.autoResponse,
|
|
1194
|
+
campaign: values == null ? void 0 : values.campaign,
|
|
1195
|
+
organization: values == null ? void 0 : values.organization,
|
|
1196
|
+
settings: step.settings
|
|
1197
|
+
});
|
|
726
1198
|
return (
|
|
727
1199
|
// @story workflows/edit
|
|
728
1200
|
// EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
|
|
@@ -734,6 +1206,23 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
734
1206
|
{
|
|
735
1207
|
...{
|
|
736
1208
|
control,
|
|
1209
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
|
|
1210
|
+
formState,
|
|
1211
|
+
onChecking,
|
|
1212
|
+
setValue,
|
|
1213
|
+
// @story workflows/auto-response
|
|
1214
|
+
response: step.type === RESPONSE && {
|
|
1215
|
+
autoResponse: values == null ? void 0 : values.autoResponse,
|
|
1216
|
+
campaign: values == null ? void 0 : values.campaign,
|
|
1217
|
+
enabled: step.enabled,
|
|
1218
|
+
event,
|
|
1219
|
+
id: field.id,
|
|
1220
|
+
index,
|
|
1221
|
+
organization: values == null ? void 0 : values.organization,
|
|
1222
|
+
settings: step.settings,
|
|
1223
|
+
title: organizationData == null ? void 0 : organizationData.title,
|
|
1224
|
+
variables: getAvailableVariables(index)
|
|
1225
|
+
},
|
|
737
1226
|
// @story workflows/send-email
|
|
738
1227
|
// A Send email step shows its email beside its form.
|
|
739
1228
|
off: step.enabled === false,
|
|
@@ -785,10 +1274,13 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
785
1274
|
{
|
|
786
1275
|
...{
|
|
787
1276
|
"aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
|
|
788
|
-
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
|
|
789
|
-
onChange
|
|
1277
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || parts && !parts.can,
|
|
1278
|
+
onChange: (next) => {
|
|
1279
|
+
onChange(next);
|
|
1280
|
+
if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
|
|
1281
|
+
},
|
|
790
1282
|
small: true,
|
|
791
|
-
value: value !== false
|
|
1283
|
+
value: value !== false && (!parts || parts.can)
|
|
792
1284
|
}
|
|
793
1285
|
}
|
|
794
1286
|
);
|
|
@@ -818,7 +1310,8 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
818
1310
|
{
|
|
819
1311
|
...{
|
|
820
1312
|
// A step switched off is greyed; its settings are kept.
|
|
821
|
-
|
|
1313
|
+
// Auto response's whole card greys, its parts as well.
|
|
1314
|
+
className: "space-y-3" + (step.enabled === false && !parts ? " opacity-50" : "")
|
|
822
1315
|
},
|
|
823
1316
|
children: [
|
|
824
1317
|
issueIndex === index && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -847,9 +1340,11 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
847
1340
|
{
|
|
848
1341
|
...{
|
|
849
1342
|
onChange: (val) => {
|
|
1343
|
+
var _a4;
|
|
850
1344
|
const [type] = val.split("::");
|
|
851
1345
|
const option = getStepOptions(index).find((o) => o.value === val);
|
|
852
1346
|
const copy = pickedCopy({ row: getValues(`steps.${index}`), type });
|
|
1347
|
+
setValue(`steps.${index}.settings`, type === RESPONSE ? responseStart((_a4 = values == null ? void 0 : values.autoResponse) == null ? void 0 : _a4.number) : null);
|
|
853
1348
|
onChange(type);
|
|
854
1349
|
setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
|
|
855
1350
|
setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
|
|
@@ -980,15 +1475,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
980
1475
|
}
|
|
981
1476
|
}
|
|
982
1477
|
),
|
|
983
|
-
event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
984
|
-
"p",
|
|
985
|
-
{
|
|
986
|
-
...{
|
|
987
|
-
className: "text-sm text-gray-dark"
|
|
988
|
-
},
|
|
989
|
-
children: "Drawbridge adds the entrant's order and missions under your message. You can't edit or remove them."
|
|
990
|
-
}
|
|
991
|
-
),
|
|
1478
|
+
event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LeadEmailNote, {}),
|
|
992
1479
|
step.type === "step.sms.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
993
1480
|
import_form.Controller,
|
|
994
1481
|
{
|
|
@@ -1075,9 +1562,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1075
1562
|
// QA read "Issue a discount code", built the one-step workflow that
|
|
1076
1563
|
// describes, and reported the codes as never arriving.
|
|
1077
1564
|
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
1078
|
-
"Creates the code and saves it to the lead. To send it,
|
|
1079
|
-
"{{shopifyDiscountCode}}",
|
|
1080
|
-
" in the message.",
|
|
1565
|
+
"Creates the code and saves it to the lead. To send it, keep this step before Auto response and add Shopify Discount Code to its message.",
|
|
1081
1566
|
commerceDomain ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
1082
1567
|
" ",
|
|
1083
1568
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
|
|
@@ -1123,11 +1608,20 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1123
1608
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1124
1609
|
0 && (module.exports = {
|
|
1125
1610
|
FormOrganizationWorkflowEdit,
|
|
1611
|
+
RESPONSE,
|
|
1126
1612
|
SAMPLE,
|
|
1127
1613
|
TextPreview,
|
|
1128
1614
|
firstEntryOnly,
|
|
1615
|
+
issueRow,
|
|
1616
|
+
memberOptions,
|
|
1617
|
+
partToStart,
|
|
1129
1618
|
pickedCopy,
|
|
1619
|
+
plainHtml,
|
|
1130
1620
|
prefillRow,
|
|
1621
|
+
responseParts,
|
|
1622
|
+
responseSave,
|
|
1623
|
+
responseStart,
|
|
1624
|
+
stepAfterPart,
|
|
1131
1625
|
stepReason,
|
|
1132
1626
|
stepRow,
|
|
1133
1627
|
stepVariables,
|