@drawbridge/components 0.1.15 → 0.1.17
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 +43 -34
- package/dist/bridge/form-subdomain-missions.mjs +43 -34
- package/dist/bridge/lib/url.js +3 -3
- package/dist/bridge/lib/url.mjs +3 -3
- package/dist/bridge/share-button.js +12 -2
- package/dist/bridge/share-button.mjs +12 -2
- package/dist/bridge/template-layout.js +1 -1
- package/dist/bridge/template-layout.mjs +1 -1
- package/dist/dashboard/answer-rows.js +77 -0
- package/dist/dashboard/answer-rows.mjs +41 -0
- package/dist/dashboard/card-order.js +186 -243
- package/dist/dashboard/card-order.mjs +186 -243
- 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-campaign-field-list.js +8 -49
- package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
- package/dist/dashboard/form-organization-workflow.js +588 -157
- package/dist/dashboard/form-organization-workflow.mjs +578 -157
- package/dist/dashboard/form-otc.js +7 -4
- package/dist/dashboard/form-otc.mjs +8 -5
- package/dist/dashboard/input-editor.js +46 -10
- package/dist/dashboard/input-editor.mjs +44 -9
- package/dist/dashboard/item-row.js +92 -0
- package/dist/dashboard/item-row.mjs +63 -0
- package/dist/dashboard/lib/sms.js +3 -0
- package/dist/dashboard/lib/sms.mjs +2 -0
- package/dist/dashboard/order-sections.js +231 -0
- package/dist/dashboard/order-sections.mjs +196 -0
- package/dist/dashboard/preview.js +29 -2
- package/dist/dashboard/preview.mjs +28 -2
- 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/dist/shared/lib/helpers.js +7 -0
- package/dist/shared/lib/helpers.mjs +7 -0
- package/package.json +19 -4
- package/types/bridge/lib/url.d.ts +5 -4
- package/types/dashboard/answer-rows.d.ts +30 -0
- package/types/dashboard/card-order.d.ts +16 -14
- package/types/dashboard/form-organization-workflow.d.ts +46 -0
- package/types/dashboard/input-editor.d.ts +7 -1
- package/types/dashboard/item-row.d.ts +25 -0
- package/types/dashboard/order-sections.d.ts +36 -0
- package/types/dashboard/steps.d.ts +2 -0
- package/types/input-code.d.ts +0 -2
- package/types/shared/lib/helpers.d.ts +1 -1
|
@@ -2,7 +2,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import Image from "next/image";
|
|
3
3
|
import Link from "./link.mjs";
|
|
4
4
|
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { constants } from "@drawbridge/drawbridge-utils";
|
|
5
6
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
7
|
+
import { escapeHtml } from "@drawbridge/drawbridge-utils/html";
|
|
6
8
|
import { useForm, useWatch, Controller } from "../shared/lib/form.mjs";
|
|
7
9
|
import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
10
|
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
@@ -15,37 +17,34 @@ import InputUrl from "../shared/input-url.mjs";
|
|
|
15
17
|
import InputResource from "./input-resource.mjs";
|
|
16
18
|
import InputCombobox from "./input-combobox.mjs";
|
|
17
19
|
import { FormNotification } from "./form-notification.mjs";
|
|
20
|
+
import InputEditor, { EditorView } from "./input-editor.mjs";
|
|
18
21
|
import { InputArrayButton, InputArrayControl, InputArraySortable } from "./input-array.mjs";
|
|
19
22
|
import Badge from "../shared/badge.mjs";
|
|
20
23
|
import InputSwitch from "../shared/input-switch.mjs";
|
|
21
|
-
import Tooltip from "../shared/tooltip.mjs";
|
|
22
24
|
import CardSection from "./card-section.mjs";
|
|
23
25
|
import Accordion from "./accordion.mjs";
|
|
24
26
|
import Preview from "./preview.mjs";
|
|
25
27
|
import CardTask from "./card-task.mjs";
|
|
26
28
|
import { LoaderDynamic } from "../shared/loader.mjs";
|
|
27
|
-
import { smsNumberActive } from "./lib/sms.mjs";
|
|
29
|
+
import { smsBrandLine, smsNumberActive } from "./lib/sms.mjs";
|
|
28
30
|
import Trash from "../icons/trash.mjs";
|
|
29
31
|
import Button from "../shared/button.mjs";
|
|
30
32
|
const emailSteps = ["step.email.send"];
|
|
31
33
|
const teamSteps = ["step.email.notify"];
|
|
32
34
|
const messageSteps = [...emailSteps, "step.sms.send"];
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
threshold: 5,
|
|
41
|
-
total: 0.5
|
|
35
|
+
const renderedSteps = [...emailSteps, ...teamSteps];
|
|
36
|
+
const RESPONSE = "step.response.send";
|
|
37
|
+
const firstEntryOnly = ({ campaign, event, type }) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
if (event !== "lead.insert" || !type || emailSteps.includes(type) || type === RESPONSE) return false;
|
|
40
|
+
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";
|
|
41
|
+
return true;
|
|
42
42
|
};
|
|
43
43
|
const stepPrefills = {
|
|
44
44
|
"step.email.send": {
|
|
45
|
-
message:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
text: "Thanks for entering. We have your entry and will be in touch."
|
|
45
|
+
message: constants.campaign.confirmation.message,
|
|
46
|
+
subject: constants.campaign.confirmation.subject,
|
|
47
|
+
text: constants.campaign.confirmation.text
|
|
49
48
|
},
|
|
50
49
|
// Nothing to prefill: the step writes its own copy.
|
|
51
50
|
"step.email.notify": {}
|
|
@@ -104,16 +103,120 @@ const prefillRow = ({ entry, step, steps = [] }) => {
|
|
|
104
103
|
type: step
|
|
105
104
|
});
|
|
106
105
|
};
|
|
106
|
+
const pickedCopy = ({ row, type }) => {
|
|
107
|
+
const previous = stepPrefills[row == null ? void 0 : row.type];
|
|
108
|
+
const untouched = !!(previous == null ? void 0 : previous.subject) && (row == null ? void 0 : row.subject) === previous.subject && (row == null ? void 0 : row.message) === previous.message;
|
|
109
|
+
const { message = "", subject = "", text = "" } = stepPrefills[type] || {};
|
|
110
|
+
if (!untouched && ((row == null ? void 0 : row.subject) || (row == null ? void 0 : row.message))) return null;
|
|
111
|
+
return subject || untouched ? { message, subject, text } : null;
|
|
112
|
+
};
|
|
107
113
|
const stepReason = ({ entry, saved = [], type }) => {
|
|
108
114
|
var _a, _b;
|
|
109
115
|
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;
|
|
110
116
|
};
|
|
117
|
+
const responseStart = (number) => ({
|
|
118
|
+
email: {
|
|
119
|
+
enabled: true,
|
|
120
|
+
message: constants.campaign.confirmation.message,
|
|
121
|
+
score: null,
|
|
122
|
+
subject: constants.campaign.confirmation.subject,
|
|
123
|
+
text: constants.campaign.confirmation.text
|
|
124
|
+
},
|
|
125
|
+
sms: {
|
|
126
|
+
enabled: number === "verified",
|
|
127
|
+
message: constants.campaign.confirmation.sms.giveaway
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const responseParts = ({ autoResponse, campaign, organization, settings }) => {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
const { fields, number } = autoResponse || {};
|
|
133
|
+
const base = "/organizations/" + organization;
|
|
134
|
+
const addField = {
|
|
135
|
+
href: base + "/campaigns/" + campaign + "/form",
|
|
136
|
+
text: "Add field"
|
|
137
|
+
};
|
|
138
|
+
const numberTask = () => {
|
|
139
|
+
if (number === "verified") return null;
|
|
140
|
+
if (number === "error") return {
|
|
141
|
+
button: {
|
|
142
|
+
href: base + "/settings",
|
|
143
|
+
text: "View number"
|
|
144
|
+
},
|
|
145
|
+
message: "Your SMS number wasn't approved.",
|
|
146
|
+
type: "error"
|
|
147
|
+
};
|
|
148
|
+
if (number) return {
|
|
149
|
+
message: "Your SMS number is waiting for approval.",
|
|
150
|
+
type: "warning"
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
button: {
|
|
154
|
+
href: base + "/settings",
|
|
155
|
+
text: "Get a number"
|
|
156
|
+
},
|
|
157
|
+
message: "Texts need an SMS number."
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
const emailCan = Boolean(fields == null ? void 0 : fields.email);
|
|
161
|
+
const smsCan = Boolean(fields == null ? void 0 : fields.phone) && number === "verified";
|
|
162
|
+
return {
|
|
163
|
+
can: emailCan || smsCan,
|
|
164
|
+
email: {
|
|
165
|
+
can: emailCan,
|
|
166
|
+
hidden: !(fields == null ? void 0 : fields.email),
|
|
167
|
+
on: emailCan && ((_a = settings == null ? void 0 : settings.email) == null ? void 0 : _a.enabled) === true,
|
|
168
|
+
task: (fields == null ? void 0 : fields.email) ? null : {
|
|
169
|
+
button: addField,
|
|
170
|
+
message: "Emails need an Email field on the form."
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
sms: {
|
|
174
|
+
can: smsCan,
|
|
175
|
+
hidden: !(fields == null ? void 0 : fields.phone),
|
|
176
|
+
on: smsCan && ((_b = settings == null ? void 0 : settings.sms) == null ? void 0 : _b.enabled) === true,
|
|
177
|
+
task: (fields == null ? void 0 : fields.phone) ? numberTask() : {
|
|
178
|
+
button: addField,
|
|
179
|
+
message: "Texts need a Phone field on the form."
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
const stepAfterPart = ({ enabled, next, other }) => next || enabled !== false && other === true;
|
|
185
|
+
const partToStart = (parts) => {
|
|
186
|
+
if (parts.email.on || parts.sms.on) return null;
|
|
187
|
+
return parts.email.can ? "email" : "sms";
|
|
188
|
+
};
|
|
189
|
+
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;
|
|
190
|
+
const scoreHolds = ({ message, score, subject }) => Boolean(score) && score.subject === subject && score.message === message;
|
|
191
|
+
const responseSave = ({ email, sms }) => ({
|
|
192
|
+
email: {
|
|
193
|
+
enabled: email.enabled,
|
|
194
|
+
message: email.message,
|
|
195
|
+
...scoreHolds(email) && {
|
|
196
|
+
score: email.score
|
|
197
|
+
},
|
|
198
|
+
subject: email.subject,
|
|
199
|
+
...email.text && {
|
|
200
|
+
text: email.text
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
sms: {
|
|
204
|
+
enabled: sms.enabled,
|
|
205
|
+
message: sms.message
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const plainHtml = (text) => String(text || "").split("\n").map((line) => {
|
|
209
|
+
const marked = line.match(/^\[(.+)\]$/);
|
|
210
|
+
return "<p>" + (marked ? '<span data-variable="placeholder" key="placeholder" label="' + escapeHtml(marked[1]) + '"></span>' : escapeHtml(line)) + "</p>";
|
|
211
|
+
}).join("");
|
|
212
|
+
const taggedScore = (settings) => (settings == null ? void 0 : settings.score) ? {
|
|
213
|
+
...settings.score,
|
|
214
|
+
message: (settings == null ? void 0 : settings.message) || "",
|
|
215
|
+
subject: (settings == null ? void 0 : settings.subject) || ""
|
|
216
|
+
} : null;
|
|
111
217
|
const stepRow = (step = {}, members = []) => {
|
|
112
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
218
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
113
219
|
return {
|
|
114
|
-
// @story workflows/entry-confirmation
|
|
115
|
-
// The System email: no remove and no switch ( the api keeps it on ).
|
|
116
|
-
confirmation: Boolean(step.confirmation),
|
|
117
220
|
connectionId: step.connectionId || "",
|
|
118
221
|
discount: ((_a = step.settings) == null ? void 0 : _a.discount) || null,
|
|
119
222
|
// @story workflows/step-switch
|
|
@@ -125,28 +228,32 @@ const stepRow = (step = {}, members = []) => {
|
|
|
125
228
|
// render as an unlabelled chip nobody could identify.
|
|
126
229
|
members: (((_b = step.settings) == null ? void 0 : _b.members) || []).map((id) => members.find((member) => (member == null ? void 0 : member.id) === id)).filter(Boolean),
|
|
127
230
|
message: ((_c = step.settings) == null ? void 0 : _c.message) || "",
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
231
|
+
score: taggedScore(step.settings),
|
|
232
|
+
// @story workflows/auto-response
|
|
233
|
+
// Its two parts; null on every other row, so every row holds the same keys.
|
|
234
|
+
settings: step.type === RESPONSE ? {
|
|
235
|
+
email: {
|
|
236
|
+
enabled: ((_e = (_d = step.settings) == null ? void 0 : _d.email) == null ? void 0 : _e.enabled) === true,
|
|
237
|
+
message: ((_g = (_f = step.settings) == null ? void 0 : _f.email) == null ? void 0 : _g.message) || "",
|
|
238
|
+
score: taggedScore((_h = step.settings) == null ? void 0 : _h.email),
|
|
239
|
+
subject: ((_j = (_i = step.settings) == null ? void 0 : _i.email) == null ? void 0 : _j.subject) || "",
|
|
240
|
+
text: ((_l = (_k = step.settings) == null ? void 0 : _k.email) == null ? void 0 : _l.text) || ""
|
|
241
|
+
},
|
|
242
|
+
sms: {
|
|
243
|
+
enabled: ((_n = (_m = step.settings) == null ? void 0 : _m.sms) == null ? void 0 : _n.enabled) === true,
|
|
244
|
+
message: ((_p = (_o = step.settings) == null ? void 0 : _o.sms) == null ? void 0 : _p.message) || ""
|
|
245
|
+
}
|
|
140
246
|
} : null,
|
|
141
247
|
slug: step.slug || "",
|
|
142
|
-
subject: ((
|
|
248
|
+
subject: ((_q = step.settings) == null ? void 0 : _q.subject) || "",
|
|
143
249
|
// The editor writes this only when the merchant touches it, so without a
|
|
144
250
|
// seed an untouched save dropped the plain rendering of the message.
|
|
145
|
-
text: ((
|
|
251
|
+
text: ((_r = step.settings) == null ? void 0 : _r.text) || "",
|
|
146
252
|
type: step.type || "",
|
|
147
|
-
url: ((
|
|
253
|
+
url: ((_s = step.settings) == null ? void 0 : _s.url) || ""
|
|
148
254
|
};
|
|
149
255
|
};
|
|
256
|
+
const hasWords = (value) => Boolean(String(value || "").replace(/<[^>]*>/g, "").trim());
|
|
150
257
|
const workflowSchema = yup.object({
|
|
151
258
|
steps: yup.array().of(
|
|
152
259
|
yup.object({
|
|
@@ -164,11 +271,9 @@ const workflowSchema = yup.object({
|
|
|
164
271
|
return schema;
|
|
165
272
|
}),
|
|
166
273
|
// @story workflows/edit
|
|
167
|
-
// The editor writes an empty message as "<p></p>", which a plain
|
|
168
|
-
// required() accepts: a message needs words, not only markup.
|
|
169
274
|
message: yup.string().test("words", "Message is required", function(value) {
|
|
170
275
|
var _a;
|
|
171
|
-
return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) ||
|
|
276
|
+
return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) || hasWords(value);
|
|
172
277
|
}).when("type", ([type], schema) => {
|
|
173
278
|
if (type === "step.sms.send") {
|
|
174
279
|
return schema.required("Message is required").max(1500).label("Message");
|
|
@@ -178,6 +283,28 @@ const workflowSchema = yup.object({
|
|
|
178
283
|
}
|
|
179
284
|
return schema;
|
|
180
285
|
}),
|
|
286
|
+
// @story workflows/auto-response
|
|
287
|
+
// A part's fields are required only while that part is on, with the
|
|
288
|
+
// limits the step declares in utils, so the api never refuses a save
|
|
289
|
+
// the form allowed.
|
|
290
|
+
settings: yup.object().nullable().when("type", ([type], schema) => type === RESPONSE ? schema.shape({
|
|
291
|
+
email: yup.object({
|
|
292
|
+
message: yup.string().when("enabled", {
|
|
293
|
+
is: true,
|
|
294
|
+
then: (part) => part.test("words", "Message is required", hasWords).max(2e3).label("Message")
|
|
295
|
+
}),
|
|
296
|
+
subject: yup.string().when("enabled", {
|
|
297
|
+
is: true,
|
|
298
|
+
then: (part) => part.required("Subject is required").max(150).label("Subject")
|
|
299
|
+
})
|
|
300
|
+
}),
|
|
301
|
+
sms: yup.object({
|
|
302
|
+
message: yup.string().when("enabled", {
|
|
303
|
+
is: true,
|
|
304
|
+
then: (part) => part.required("Message is required").max(1500).label("Message")
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
}) : schema),
|
|
181
308
|
// No minimum. The organization owner is always a recipient, so a
|
|
182
309
|
// step with no members chosen is complete — requiring one here
|
|
183
310
|
// made the step unsaveable for a solo merchant, who has no
|
|
@@ -193,18 +320,8 @@ const workflowSchema = yup.object({
|
|
|
193
320
|
})
|
|
194
321
|
)
|
|
195
322
|
});
|
|
196
|
-
const
|
|
197
|
-
{
|
|
198
|
-
key: "New lead",
|
|
199
|
-
value: "lead"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
key: "Verified their email",
|
|
203
|
-
value: "verified"
|
|
204
|
-
}
|
|
205
|
-
];
|
|
206
|
-
const useEmailPreview = ({ campaign, confirmation = false, event, message, organization, sample, subject, text }) => {
|
|
207
|
-
const asked = JSON.stringify({ ...confirmation && { confirmation }, message, sample, subject, text });
|
|
323
|
+
const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
|
|
324
|
+
const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
|
|
208
325
|
const [settled, setSettled] = useState(asked);
|
|
209
326
|
useEffect(() => {
|
|
210
327
|
const timer = setTimeout(() => setSettled(asked), 400);
|
|
@@ -232,18 +349,18 @@ const EmailStepCard = ({
|
|
|
232
349
|
off,
|
|
233
350
|
email: {
|
|
234
351
|
campaign,
|
|
235
|
-
confirmation,
|
|
236
352
|
event,
|
|
237
353
|
name,
|
|
238
|
-
organization
|
|
354
|
+
organization,
|
|
355
|
+
title,
|
|
356
|
+
type
|
|
239
357
|
}
|
|
240
358
|
}) => {
|
|
241
|
-
const [sample, setSample] = useState(samples[0].value);
|
|
242
359
|
const [subject, message, text] = useWatch({
|
|
243
360
|
control,
|
|
244
361
|
name: [name + ".subject", name + ".message", name + ".text"]
|
|
245
362
|
});
|
|
246
|
-
const preview = useEmailPreview({ campaign,
|
|
363
|
+
const preview = useEmailPreview({ campaign, event, message, organization, subject, text, type });
|
|
247
364
|
return /* @__PURE__ */ jsxs(
|
|
248
365
|
CardSection,
|
|
249
366
|
{
|
|
@@ -260,7 +377,7 @@ const EmailStepCard = ({
|
|
|
260
377
|
},
|
|
261
378
|
children: [
|
|
262
379
|
children,
|
|
263
|
-
/* @__PURE__ */ jsx(
|
|
380
|
+
emailSteps.includes(type) && /* @__PURE__ */ jsx(
|
|
264
381
|
Accordion,
|
|
265
382
|
{
|
|
266
383
|
...{
|
|
@@ -288,29 +405,17 @@ const EmailStepCard = ({
|
|
|
288
405
|
...{
|
|
289
406
|
className: off ? "opacity-50" : ""
|
|
290
407
|
},
|
|
291
|
-
children: /* @__PURE__ */ jsx(
|
|
292
|
-
|
|
408
|
+
children: /* @__PURE__ */ jsx(Preview, { children: /* @__PURE__ */ jsx(
|
|
409
|
+
"iframe",
|
|
293
410
|
{
|
|
294
411
|
...{
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
},
|
|
301
|
-
children: /* @__PURE__ */ jsx(
|
|
302
|
-
"iframe",
|
|
303
|
-
{
|
|
304
|
-
...{
|
|
305
|
-
// The rendered email, as a mail app shows it.
|
|
306
|
-
className: "block w-full h-full border-0 bg-white",
|
|
307
|
-
srcDoc: (preview == null ? void 0 : preview.html) || "",
|
|
308
|
-
title: "Send email"
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
)
|
|
412
|
+
// The rendered email, as a mail app shows it.
|
|
413
|
+
className: "block w-full h-full border-0 bg-white",
|
|
414
|
+
srcDoc: (preview == null ? void 0 : preview.html) || "",
|
|
415
|
+
title
|
|
416
|
+
}
|
|
312
417
|
}
|
|
313
|
-
)
|
|
418
|
+
) })
|
|
314
419
|
}
|
|
315
420
|
)
|
|
316
421
|
]
|
|
@@ -320,7 +425,6 @@ const EmailStepCard = ({
|
|
|
320
425
|
const SAMPLE = {
|
|
321
426
|
email: "sam.rivera@example.com",
|
|
322
427
|
name: "Sam Rivera",
|
|
323
|
-
order: "House espresso \xD7 2, Holiday blend \xD7 1",
|
|
324
428
|
phone: "+14165550142"
|
|
325
429
|
};
|
|
326
430
|
const webhookSample = ({ campaign }) => JSON.stringify({
|
|
@@ -335,33 +439,20 @@ const webhookSample = ({ campaign }) => JSON.stringify({
|
|
|
335
439
|
number: SAMPLE.phone
|
|
336
440
|
}
|
|
337
441
|
}, null, 2);
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
title: "New order \u2014 " + ((campaign == null ? void 0 : campaign.title) || "your campaign")
|
|
341
|
-
} : {
|
|
342
|
-
lines: [SAMPLE.name + " (" + SAMPLE.email + ") entered " + ((campaign == null ? void 0 : campaign.title) || "your campaign") + "."],
|
|
343
|
-
title: "1 new entry \u2014 " + ((campaign == null ? void 0 : campaign.title) || "your campaign")
|
|
344
|
-
};
|
|
345
|
-
const StepPreview = ({ campaign, control, event, image, name, organization, type }) => {
|
|
442
|
+
const TextPreview = ({ children }) => /* @__PURE__ */ jsx("div", { className: "p-6 font-sans", children: /* @__PURE__ */ jsx("div", { className: "max-w-xs px-4 py-3 rounded-2xl rounded-bl-sm bg-gray-light text-black break-words", children }) });
|
|
443
|
+
const StepPreview = ({ campaign, control, image, name, organization, type }) => {
|
|
346
444
|
const [message] = useWatch({
|
|
347
445
|
control,
|
|
348
446
|
name: [name + ".message"]
|
|
349
447
|
});
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
/* @__PURE__ */
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
448
|
+
const brand = smsBrandLine(organization == null ? void 0 : organization.title, message);
|
|
449
|
+
if (type === "step.sms.send") return /* @__PURE__ */ jsxs(TextPreview, { children: [
|
|
450
|
+
brand && /* @__PURE__ */ jsx("p", { children: brand }),
|
|
451
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: message }),
|
|
452
|
+
(campaign == null ? void 0 : campaign.awarding) && /* @__PURE__ */ jsx("p", { className: "mt-2 px-2 py-1 rounded border border-dashed border-gray-dark text-gray-dark", children: "The entrant's missions appear here" }),
|
|
453
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2", children: "Reply STOP to opt out" })
|
|
356
454
|
] });
|
|
357
455
|
if (type === "step.webhook.send") return /* @__PURE__ */ jsx("pre", { className: "p-6 text-xs whitespace-pre-wrap break-all font-mono", children: "X-Drawbridge-Signature: t=\u2026,v1=\u2026\n\n" + webhookSample({ campaign }) });
|
|
358
|
-
if (teamSteps.includes(type)) {
|
|
359
|
-
const { lines, title } = teamSample({ campaign, event, organization });
|
|
360
|
-
return /* @__PURE__ */ jsxs("div", { className: "p-6 space-y-3 font-sans", children: [
|
|
361
|
-
/* @__PURE__ */ jsx("p", { className: "text-lg font-bold", children: title }),
|
|
362
|
-
lines.map((line) => /* @__PURE__ */ jsx("p", { children: line }, line))
|
|
363
|
-
] });
|
|
364
|
-
}
|
|
365
456
|
return /* @__PURE__ */ jsxs("div", { className: "min-h-screen flex flex-col items-center justify-center gap-3 p-6 text-gray-dark", children: [
|
|
366
457
|
image && /* @__PURE__ */ jsx(
|
|
367
458
|
Image,
|
|
@@ -379,14 +470,330 @@ const StepPreview = ({ campaign, control, event, image, name, organization, type
|
|
|
379
470
|
/* @__PURE__ */ jsx("p", { children: "No preview available" })
|
|
380
471
|
] });
|
|
381
472
|
};
|
|
473
|
+
const LeadEmailNote = () => /* @__PURE__ */ jsx(
|
|
474
|
+
"p",
|
|
475
|
+
{
|
|
476
|
+
...{
|
|
477
|
+
className: "text-sm text-gray-dark"
|
|
478
|
+
},
|
|
479
|
+
children: "Drawbridge adds the entrant's order and missions under your message. You can't edit or remove them."
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
const RESPONSE_STATES = [
|
|
483
|
+
{
|
|
484
|
+
key: "Email",
|
|
485
|
+
value: "email"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
key: "Text",
|
|
489
|
+
value: "sms"
|
|
490
|
+
}
|
|
491
|
+
];
|
|
492
|
+
const ResponseText = ({ className, id, text }) => /* @__PURE__ */ jsx(
|
|
493
|
+
"div",
|
|
494
|
+
{
|
|
495
|
+
...{
|
|
496
|
+
className,
|
|
497
|
+
id
|
|
498
|
+
},
|
|
499
|
+
children: /* @__PURE__ */ jsx(
|
|
500
|
+
EditorView,
|
|
501
|
+
{
|
|
502
|
+
...{
|
|
503
|
+
value: plainHtml(text)
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
const ResponseStepCard = ({
|
|
510
|
+
card,
|
|
511
|
+
children,
|
|
512
|
+
control,
|
|
513
|
+
disabled,
|
|
514
|
+
formState,
|
|
515
|
+
off,
|
|
516
|
+
onChecking,
|
|
517
|
+
response: {
|
|
518
|
+
autoResponse,
|
|
519
|
+
campaign,
|
|
520
|
+
enabled,
|
|
521
|
+
event,
|
|
522
|
+
id,
|
|
523
|
+
index,
|
|
524
|
+
organization,
|
|
525
|
+
settings,
|
|
526
|
+
title,
|
|
527
|
+
variables
|
|
528
|
+
},
|
|
529
|
+
setValue
|
|
530
|
+
}) => {
|
|
531
|
+
var _a, _b, _c, _d, _e;
|
|
532
|
+
const [picked, setPicked] = useState("email");
|
|
533
|
+
const name = `steps.${index}`;
|
|
534
|
+
const parts = responseParts({ autoResponse, campaign, organization, settings });
|
|
535
|
+
const shown = parts.email.hidden ? "sms" : parts.sms.hidden ? "email" : picked;
|
|
536
|
+
const placeholders = autoResponse == null ? void 0 : autoResponse.placeholders;
|
|
537
|
+
const preview = useEmailPreview({
|
|
538
|
+
campaign,
|
|
539
|
+
event: parts.email.hidden ? null : event,
|
|
540
|
+
message: (_a = settings == null ? void 0 : settings.email) == null ? void 0 : _a.message,
|
|
541
|
+
organization,
|
|
542
|
+
subject: (_b = settings == null ? void 0 : settings.email) == null ? void 0 : _b.subject,
|
|
543
|
+
text: (_c = settings == null ? void 0 : settings.email) == null ? void 0 : _c.text
|
|
544
|
+
});
|
|
545
|
+
const brand = smsBrandLine(title, (_d = settings == null ? void 0 : settings.sms) == null ? void 0 : _d.message);
|
|
546
|
+
const partSwitch = ({ label, message, other, part }) => /* @__PURE__ */ jsx(
|
|
547
|
+
Controller,
|
|
548
|
+
{
|
|
549
|
+
...{
|
|
550
|
+
control,
|
|
551
|
+
name: name + ".settings." + part + ".enabled",
|
|
552
|
+
render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
|
|
553
|
+
InputGroup,
|
|
554
|
+
{
|
|
555
|
+
...{
|
|
556
|
+
input: /* @__PURE__ */ jsx(
|
|
557
|
+
InputSwitch,
|
|
558
|
+
{
|
|
559
|
+
...{
|
|
560
|
+
"aria-label": label,
|
|
561
|
+
disabled: disabled || !parts[part].can,
|
|
562
|
+
onChange: (next) => {
|
|
563
|
+
var _a2;
|
|
564
|
+
onChange(next);
|
|
565
|
+
setValue(name + ".enabled", stepAfterPart({ enabled, next, other: (_a2 = settings == null ? void 0 : settings[other]) == null ? void 0 : _a2.enabled }));
|
|
566
|
+
setPicked(part);
|
|
567
|
+
},
|
|
568
|
+
value: parts[part].can && value === true
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
),
|
|
572
|
+
label,
|
|
573
|
+
message
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
)
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
return /* @__PURE__ */ jsxs(
|
|
581
|
+
CardSection,
|
|
582
|
+
{
|
|
583
|
+
...{
|
|
584
|
+
...card,
|
|
585
|
+
columns: 2
|
|
586
|
+
},
|
|
587
|
+
children: [
|
|
588
|
+
/* @__PURE__ */ jsxs(
|
|
589
|
+
"div",
|
|
590
|
+
{
|
|
591
|
+
...{
|
|
592
|
+
className: "space-y-6" + (off ? " opacity-50" : "")
|
|
593
|
+
},
|
|
594
|
+
children: [
|
|
595
|
+
children,
|
|
596
|
+
/* @__PURE__ */ jsxs(
|
|
597
|
+
"div",
|
|
598
|
+
{
|
|
599
|
+
...{
|
|
600
|
+
className: "pt-6 border-t border-gray space-y-6"
|
|
601
|
+
},
|
|
602
|
+
children: [
|
|
603
|
+
partSwitch({ label: "Email", other: "sms", part: "email" }),
|
|
604
|
+
parts.email.task && /* @__PURE__ */ jsx(CardTask, { ...parts.email.task }),
|
|
605
|
+
!parts.email.hidden && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
606
|
+
/* @__PURE__ */ jsxs(
|
|
607
|
+
"div",
|
|
608
|
+
{
|
|
609
|
+
...{
|
|
610
|
+
className: "space-y-3" + (parts.email.on ? "" : " opacity-50")
|
|
611
|
+
},
|
|
612
|
+
children: [
|
|
613
|
+
/* @__PURE__ */ jsx(
|
|
614
|
+
FormNotification,
|
|
615
|
+
{
|
|
616
|
+
...{
|
|
617
|
+
control,
|
|
618
|
+
disabled: disabled || !parts.email.on,
|
|
619
|
+
formState,
|
|
620
|
+
onChecking,
|
|
621
|
+
setValue,
|
|
622
|
+
values: {
|
|
623
|
+
id,
|
|
624
|
+
name: name + ".settings.email",
|
|
625
|
+
organization,
|
|
626
|
+
variables
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
),
|
|
631
|
+
/* @__PURE__ */ jsx(LeadEmailNote, {})
|
|
632
|
+
]
|
|
633
|
+
}
|
|
634
|
+
),
|
|
635
|
+
/* @__PURE__ */ jsx(
|
|
636
|
+
InputGroup,
|
|
637
|
+
{
|
|
638
|
+
...{
|
|
639
|
+
input: /* @__PURE__ */ jsx(
|
|
640
|
+
ResponseText,
|
|
641
|
+
{
|
|
642
|
+
...{
|
|
643
|
+
className: "w-full border border-inherit rounded px-3 py-2 disabled",
|
|
644
|
+
text: preview == null ? void 0 : preview.text
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
label: "Plain-text version"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
)
|
|
652
|
+
] })
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
/* @__PURE__ */ jsxs(
|
|
657
|
+
"div",
|
|
658
|
+
{
|
|
659
|
+
...{
|
|
660
|
+
className: "mt-10 pt-10 border-t border-gray-dark space-y-6"
|
|
661
|
+
},
|
|
662
|
+
children: [
|
|
663
|
+
partSwitch({
|
|
664
|
+
label: "Text",
|
|
665
|
+
// The line goes with the part's fields when the form lacks the field.
|
|
666
|
+
message: !parts.sms.hidden && "Sends to entrants who agree to texts. Each text costs 2 actions, and a long text costs more.",
|
|
667
|
+
other: "email",
|
|
668
|
+
part: "sms"
|
|
669
|
+
}),
|
|
670
|
+
parts.sms.task && /* @__PURE__ */ jsx(CardTask, { ...parts.sms.task }),
|
|
671
|
+
!parts.sms.hidden && /* @__PURE__ */ jsx(
|
|
672
|
+
Controller,
|
|
673
|
+
{
|
|
674
|
+
...{
|
|
675
|
+
control,
|
|
676
|
+
name: name + ".settings.sms.message",
|
|
677
|
+
render: ({ field: { onChange, value } }) => {
|
|
678
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
679
|
+
return /* @__PURE__ */ jsx(
|
|
680
|
+
"div",
|
|
681
|
+
{
|
|
682
|
+
...{
|
|
683
|
+
className: parts.sms.on ? "" : "opacity-50"
|
|
684
|
+
},
|
|
685
|
+
children: /* @__PURE__ */ jsx(
|
|
686
|
+
InputGroup,
|
|
687
|
+
{
|
|
688
|
+
...{
|
|
689
|
+
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,
|
|
690
|
+
input: /* @__PURE__ */ jsx(
|
|
691
|
+
InputEditor,
|
|
692
|
+
{
|
|
693
|
+
...{
|
|
694
|
+
disabled: disabled || !parts.sms.on,
|
|
695
|
+
...(placeholders == null ? void 0 : placeholders.missions) && {
|
|
696
|
+
locked: /* @__PURE__ */ jsx(ResponseText, { ...{ text: "[" + placeholders.missions + "]" } })
|
|
697
|
+
},
|
|
698
|
+
onChange: ({ text }) => onChange(text),
|
|
699
|
+
plain: true,
|
|
700
|
+
value: value || ""
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
),
|
|
704
|
+
label: "Message"
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
)
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
)
|
|
714
|
+
]
|
|
715
|
+
}
|
|
716
|
+
)
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
),
|
|
720
|
+
/* @__PURE__ */ jsx(
|
|
721
|
+
"div",
|
|
722
|
+
{
|
|
723
|
+
...{
|
|
724
|
+
className: off || !parts[shown].on ? "opacity-50" : ""
|
|
725
|
+
},
|
|
726
|
+
children: /* @__PURE__ */ jsx(
|
|
727
|
+
Preview,
|
|
728
|
+
{
|
|
729
|
+
...{
|
|
730
|
+
...!parts.email.hidden && !parts.sms.hidden && {
|
|
731
|
+
states: {
|
|
732
|
+
onChange: setPicked,
|
|
733
|
+
options: RESPONSE_STATES,
|
|
734
|
+
value: shown
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
children: shown === "email" ? /* @__PURE__ */ jsx(
|
|
739
|
+
"iframe",
|
|
740
|
+
{
|
|
741
|
+
...{
|
|
742
|
+
className: "block w-full h-full border-0 bg-white",
|
|
743
|
+
srcDoc: (preview == null ? void 0 : preview.html) || "",
|
|
744
|
+
title: "Auto response"
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
) : /* @__PURE__ */ jsxs(TextPreview, { children: [
|
|
748
|
+
brand && /* @__PURE__ */ jsx("p", { children: brand }),
|
|
749
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: (_e = settings == null ? void 0 : settings.sms) == null ? void 0 : _e.message }),
|
|
750
|
+
(placeholders == null ? void 0 : placeholders.missions) && /* @__PURE__ */ jsx(
|
|
751
|
+
ResponseText,
|
|
752
|
+
{
|
|
753
|
+
...{
|
|
754
|
+
className: "mt-2",
|
|
755
|
+
text: "[" + placeholders.missions + "]"
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
),
|
|
759
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2", children: "Reply STOP to opt out" })
|
|
760
|
+
] })
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
}
|
|
764
|
+
)
|
|
765
|
+
]
|
|
766
|
+
}
|
|
767
|
+
);
|
|
768
|
+
};
|
|
382
769
|
const StepCard = ({
|
|
383
770
|
children,
|
|
384
771
|
control,
|
|
772
|
+
disabled,
|
|
385
773
|
email,
|
|
774
|
+
formState,
|
|
386
775
|
off,
|
|
776
|
+
onChecking,
|
|
387
777
|
preview,
|
|
778
|
+
response,
|
|
779
|
+
setValue,
|
|
388
780
|
...card
|
|
389
|
-
}) =>
|
|
781
|
+
}) => response ? /* @__PURE__ */ jsx(
|
|
782
|
+
ResponseStepCard,
|
|
783
|
+
{
|
|
784
|
+
...{
|
|
785
|
+
card,
|
|
786
|
+
control,
|
|
787
|
+
disabled,
|
|
788
|
+
formState,
|
|
789
|
+
off,
|
|
790
|
+
onChecking,
|
|
791
|
+
response,
|
|
792
|
+
setValue
|
|
793
|
+
},
|
|
794
|
+
children
|
|
795
|
+
}
|
|
796
|
+
) : email ? /* @__PURE__ */ jsx(
|
|
390
797
|
EmailStepCard,
|
|
391
798
|
{
|
|
392
799
|
...{
|
|
@@ -433,13 +840,14 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
433
840
|
onSuccess,
|
|
434
841
|
values
|
|
435
842
|
}) => {
|
|
436
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
843
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
437
844
|
const event = (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event;
|
|
438
845
|
const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization);
|
|
439
846
|
const queryClient = useQueryClient();
|
|
440
847
|
const organizationData = queryClient.getQueryData(["organization", values == null ? void 0 : values.organization]);
|
|
441
848
|
const ownerEmail = organizationData.owner.email;
|
|
442
849
|
const smsActive = smsNumberActive(organizationData);
|
|
850
|
+
const campaignData = queryClient.getQueryData(["campaign", values == null ? void 0 : values.campaign]);
|
|
443
851
|
const commerceConnectionId = ((_b = ((catalog == null ? void 0 : catalog.steps) || []).find(
|
|
444
852
|
(s) => s.value === "step.commerce.customer.insert" || s.value === "step.commerce.code.issue"
|
|
445
853
|
)) == null ? void 0 : _b.connectionId) || null;
|
|
@@ -474,7 +882,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
474
882
|
control,
|
|
475
883
|
name: "steps"
|
|
476
884
|
});
|
|
477
|
-
const issueIndex = (
|
|
885
|
+
const issueIndex = issueRow({ issue: values == null ? void 0 : values.issue, steps: watchedSteps || [] });
|
|
478
886
|
const getAvailableVariables = (index) => stepVariables(catalog, watchedSteps, index);
|
|
479
887
|
const loading = membersLoading || commerceConnection.isLoading;
|
|
480
888
|
const prefilled = useRef(false);
|
|
@@ -608,13 +1016,14 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
608
1016
|
}) => {
|
|
609
1017
|
try {
|
|
610
1018
|
const body = {
|
|
611
|
-
steps: steps.map(({
|
|
612
|
-
const settings = {};
|
|
1019
|
+
steps: steps.map(({ connectionId, discount, enabled, members, message, score, settings: parts, slug, subject, text, type, url }, index) => {
|
|
1020
|
+
const settings = type === RESPONSE ? responseSave(parts) : {};
|
|
1021
|
+
if (type === RESPONSE && parts.email.score && !settings.email.score) setValue("steps." + index + ".settings.email.score", null);
|
|
613
1022
|
if (type === "step.webhook.send") settings.url = url;
|
|
614
1023
|
if (emailSteps.includes(type)) settings.subject = subject;
|
|
615
1024
|
if (messageSteps.includes(type)) settings.message = message;
|
|
616
1025
|
if (emailSteps.includes(type)) {
|
|
617
|
-
if (
|
|
1026
|
+
if (scoreHolds({ message, score, subject })) settings.score = score;
|
|
618
1027
|
else if (score) setValue("steps." + index + ".score", null);
|
|
619
1028
|
if (text) settings.text = text;
|
|
620
1029
|
}
|
|
@@ -625,8 +1034,6 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
625
1034
|
const resolvedConnectionId = (catalogStep == null ? void 0 : catalogStep.connectionId) || connectionId || null;
|
|
626
1035
|
const resolvedSlug = (catalogStep == null ? void 0 : catalogStep.slug) || slug || null;
|
|
627
1036
|
return {
|
|
628
|
-
// The System email row names itself; the api keeps it only where it was.
|
|
629
|
-
...confirmation && { confirmation: true },
|
|
630
1037
|
...resolvedConnectionId && { connectionId: resolvedConnectionId },
|
|
631
1038
|
enabled: enabled !== false,
|
|
632
1039
|
...resolvedSlug && { slug: resolvedSlug },
|
|
@@ -697,7 +1104,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
697
1104
|
InputGroup,
|
|
698
1105
|
{
|
|
699
1106
|
...{
|
|
700
|
-
error: (
|
|
1107
|
+
error: (_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.steps) == null ? void 0 : _h.message,
|
|
701
1108
|
input: /* @__PURE__ */ jsx(
|
|
702
1109
|
InputArraySortable,
|
|
703
1110
|
{
|
|
@@ -718,6 +1125,12 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
718
1125
|
children: ({ field, handle, index, remove }) => {
|
|
719
1126
|
var _a2;
|
|
720
1127
|
const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
|
|
1128
|
+
const parts = step.type === RESPONSE && responseParts({
|
|
1129
|
+
autoResponse: values == null ? void 0 : values.autoResponse,
|
|
1130
|
+
campaign: values == null ? void 0 : values.campaign,
|
|
1131
|
+
organization: values == null ? void 0 : values.organization,
|
|
1132
|
+
settings: step.settings
|
|
1133
|
+
});
|
|
721
1134
|
return (
|
|
722
1135
|
// @story workflows/edit
|
|
723
1136
|
// EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
|
|
@@ -729,24 +1142,42 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
729
1142
|
{
|
|
730
1143
|
...{
|
|
731
1144
|
control,
|
|
1145
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
|
|
1146
|
+
formState,
|
|
1147
|
+
onChecking,
|
|
1148
|
+
setValue,
|
|
1149
|
+
// @story workflows/auto-response
|
|
1150
|
+
response: step.type === RESPONSE && {
|
|
1151
|
+
autoResponse: values == null ? void 0 : values.autoResponse,
|
|
1152
|
+
campaign: values == null ? void 0 : values.campaign,
|
|
1153
|
+
enabled: step.enabled,
|
|
1154
|
+
event,
|
|
1155
|
+
id: field.id,
|
|
1156
|
+
index,
|
|
1157
|
+
organization: values == null ? void 0 : values.organization,
|
|
1158
|
+
settings: step.settings,
|
|
1159
|
+
title: organizationData == null ? void 0 : organizationData.title,
|
|
1160
|
+
variables: getAvailableVariables(index)
|
|
1161
|
+
},
|
|
732
1162
|
// @story workflows/send-email
|
|
733
1163
|
// A Send email step shows its email beside its form.
|
|
734
1164
|
off: step.enabled === false,
|
|
735
1165
|
// Every other step with a type has its preview too.
|
|
736
|
-
preview: step.type && !
|
|
737
|
-
campaign:
|
|
738
|
-
event,
|
|
1166
|
+
preview: step.type && !renderedSteps.includes(step.type) && {
|
|
1167
|
+
campaign: campaignData,
|
|
739
1168
|
image: ((_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a2.image) || null,
|
|
740
1169
|
name: `steps.${index}`,
|
|
741
1170
|
organization: organizationData,
|
|
742
1171
|
type: step.type
|
|
743
1172
|
},
|
|
744
|
-
email
|
|
1173
|
+
// Send email and Email notification show the email the api renders.
|
|
1174
|
+
email: renderedSteps.includes(step.type) && {
|
|
745
1175
|
campaign: values == null ? void 0 : values.campaign,
|
|
746
|
-
confirmation: step.confirmation,
|
|
747
1176
|
event,
|
|
748
1177
|
name: `steps.${index}`,
|
|
749
|
-
organization: values == null ? void 0 : values.organization
|
|
1178
|
+
organization: values == null ? void 0 : values.organization,
|
|
1179
|
+
title: emailSteps.includes(step.type) ? "Send email" : "Email notification",
|
|
1180
|
+
type: step.type
|
|
750
1181
|
},
|
|
751
1182
|
cta: /* @__PURE__ */ jsxs(
|
|
752
1183
|
"span",
|
|
@@ -756,7 +1187,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
756
1187
|
},
|
|
757
1188
|
children: [
|
|
758
1189
|
renderStepBadge(step),
|
|
759
|
-
!lockedStep(index) &&
|
|
1190
|
+
!lockedStep(index) && /* @__PURE__ */ jsx(
|
|
760
1191
|
InputArrayControl,
|
|
761
1192
|
{
|
|
762
1193
|
...{
|
|
@@ -766,35 +1197,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
766
1197
|
},
|
|
767
1198
|
"remove"
|
|
768
1199
|
),
|
|
769
|
-
|
|
770
|
-
Tooltip,
|
|
771
|
-
{
|
|
772
|
-
...{
|
|
773
|
-
content: "System email"
|
|
774
|
-
},
|
|
775
|
-
children: /* @__PURE__ */ jsx(
|
|
776
|
-
"span",
|
|
777
|
-
{
|
|
778
|
-
...{
|
|
779
|
-
className: "inline-flex pointer-events-none"
|
|
780
|
-
},
|
|
781
|
-
children: /* @__PURE__ */ jsx(
|
|
782
|
-
InputSwitch,
|
|
783
|
-
{
|
|
784
|
-
...{
|
|
785
|
-
"aria-label": "System email, always on",
|
|
786
|
-
disabled: true,
|
|
787
|
-
onChange: () => {
|
|
788
|
-
},
|
|
789
|
-
small: true,
|
|
790
|
-
value: true
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
)
|
|
794
|
-
}
|
|
795
|
-
)
|
|
796
|
-
}
|
|
797
|
-
) : /* @__PURE__ */ jsx(
|
|
1200
|
+
/* @__PURE__ */ jsx(
|
|
798
1201
|
Controller,
|
|
799
1202
|
{
|
|
800
1203
|
...{
|
|
@@ -807,10 +1210,13 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
807
1210
|
{
|
|
808
1211
|
...{
|
|
809
1212
|
"aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
|
|
810
|
-
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
|
|
811
|
-
onChange
|
|
1213
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || parts && !parts.can,
|
|
1214
|
+
onChange: (next) => {
|
|
1215
|
+
onChange(next);
|
|
1216
|
+
if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
|
|
1217
|
+
},
|
|
812
1218
|
small: true,
|
|
813
|
-
value: value !== false
|
|
1219
|
+
value: value !== false && (!parts || parts.can)
|
|
814
1220
|
}
|
|
815
1221
|
}
|
|
816
1222
|
);
|
|
@@ -840,7 +1246,8 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
840
1246
|
{
|
|
841
1247
|
...{
|
|
842
1248
|
// A step switched off is greyed; its settings are kept.
|
|
843
|
-
|
|
1249
|
+
// Auto response's whole card greys, its parts as well.
|
|
1250
|
+
className: "space-y-3" + (step.enabled === false && !parts ? " opacity-50" : "")
|
|
844
1251
|
},
|
|
845
1252
|
children: [
|
|
846
1253
|
issueIndex === index && /* @__PURE__ */ jsx(
|
|
@@ -869,14 +1276,17 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
869
1276
|
{
|
|
870
1277
|
...{
|
|
871
1278
|
onChange: (val) => {
|
|
1279
|
+
var _a4;
|
|
872
1280
|
const [type] = val.split("::");
|
|
873
1281
|
const option = getStepOptions(index).find((o) => o.value === val);
|
|
1282
|
+
const copy = pickedCopy({ row: getValues(`steps.${index}`), type });
|
|
1283
|
+
setValue(`steps.${index}.settings`, type === RESPONSE ? responseStart((_a4 = values == null ? void 0 : values.autoResponse) == null ? void 0 : _a4.number) : null);
|
|
874
1284
|
onChange(type);
|
|
875
1285
|
setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
|
|
876
1286
|
setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
|
|
1287
|
+
if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
|
|
877
1288
|
},
|
|
878
|
-
|
|
879
|
-
disabled: lockedStep(index) || Boolean(step.confirmation),
|
|
1289
|
+
disabled: lockedStep(index),
|
|
880
1290
|
options: getStepOptions(index),
|
|
881
1291
|
// Resolved from the WHOLE ROW, not from this path: the
|
|
882
1292
|
// option value carries a connection the type alone cannot
|
|
@@ -893,6 +1303,15 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
893
1303
|
}
|
|
894
1304
|
}
|
|
895
1305
|
),
|
|
1306
|
+
firstEntryOnly({ campaign: campaignData, event, type: step.type }) && /* @__PURE__ */ jsx(
|
|
1307
|
+
"p",
|
|
1308
|
+
{
|
|
1309
|
+
...{
|
|
1310
|
+
className: "text-sm text-gray-dark"
|
|
1311
|
+
},
|
|
1312
|
+
children: "Runs on a person's first entry only."
|
|
1313
|
+
}
|
|
1314
|
+
),
|
|
896
1315
|
step.type === "step.webhook.send" && /* @__PURE__ */ jsx(
|
|
897
1316
|
Controller,
|
|
898
1317
|
{
|
|
@@ -992,15 +1411,7 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
992
1411
|
}
|
|
993
1412
|
}
|
|
994
1413
|
),
|
|
995
|
-
step.
|
|
996
|
-
"p",
|
|
997
|
-
{
|
|
998
|
-
...{
|
|
999
|
-
className: "text-sm text-gray-dark"
|
|
1000
|
-
},
|
|
1001
|
-
children: "Drawbridge adds the entrant's order and missions under your message. You can't edit or remove them."
|
|
1002
|
-
}
|
|
1003
|
-
),
|
|
1414
|
+
event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ jsx(LeadEmailNote, {}),
|
|
1004
1415
|
step.type === "step.sms.send" && /* @__PURE__ */ jsx(
|
|
1005
1416
|
Controller,
|
|
1006
1417
|
{
|
|
@@ -1134,12 +1545,22 @@ const FormOrganizationWorkflowEdit = ({
|
|
|
1134
1545
|
};
|
|
1135
1546
|
export {
|
|
1136
1547
|
FormOrganizationWorkflowEdit,
|
|
1548
|
+
RESPONSE,
|
|
1137
1549
|
SAMPLE,
|
|
1550
|
+
TextPreview,
|
|
1551
|
+
firstEntryOnly,
|
|
1552
|
+
issueRow,
|
|
1553
|
+
partToStart,
|
|
1554
|
+
pickedCopy,
|
|
1555
|
+
plainHtml,
|
|
1138
1556
|
prefillRow,
|
|
1557
|
+
responseParts,
|
|
1558
|
+
responseSave,
|
|
1559
|
+
responseStart,
|
|
1560
|
+
stepAfterPart,
|
|
1139
1561
|
stepReason,
|
|
1140
1562
|
stepRow,
|
|
1141
1563
|
stepVariables,
|
|
1142
|
-
teamSample,
|
|
1143
1564
|
webhookSample,
|
|
1144
1565
|
workflowSchema
|
|
1145
1566
|
};
|