@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
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var form_organization_campaign_mission_exports = {};
|
|
29
|
+
__export(form_organization_campaign_mission_exports, {
|
|
30
|
+
default: () => form_organization_campaign_mission_default,
|
|
31
|
+
repeats: () => repeats
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(form_organization_campaign_mission_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
37
|
+
var import_missions = require("@drawbridge/drawbridge-utils/missions");
|
|
38
|
+
var import_form = require("../shared/lib/form");
|
|
39
|
+
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
40
|
+
var import_form2 = __toESM(require("../shared/form"));
|
|
41
|
+
var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
42
|
+
var import_input_group = __toESM(require("../input-group"));
|
|
43
|
+
var import_input_number = __toESM(require("../input-number"));
|
|
44
|
+
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
45
|
+
var import_input_combobox = __toESM(require("./input-combobox"));
|
|
46
|
+
var import_button = __toESM(require("../shared/button"));
|
|
47
|
+
const LABELS = {
|
|
48
|
+
campaign: "Campaign",
|
|
49
|
+
day: "Day",
|
|
50
|
+
range: "Range"
|
|
51
|
+
};
|
|
52
|
+
const PER = ["campaign", "range", "day"].filter((value) => import_missions.WINDOWS.includes(value)).map((value) => ({
|
|
53
|
+
key: LABELS[value],
|
|
54
|
+
value
|
|
55
|
+
}));
|
|
56
|
+
const repeats = (values) => {
|
|
57
|
+
var _a;
|
|
58
|
+
return ((_a = import_missions.missions[values == null ? void 0 : values.type]) == null ? void 0 : _a.repeats) !== false;
|
|
59
|
+
};
|
|
60
|
+
const FormOrganizationCampaignMission = ({
|
|
61
|
+
disabled,
|
|
62
|
+
onError,
|
|
63
|
+
onSuccess,
|
|
64
|
+
values
|
|
65
|
+
}) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const repeating = repeats(values);
|
|
68
|
+
const locked = !(values == null ? void 0 : values.enabled) && (values == null ? void 0 : values.locked);
|
|
69
|
+
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
70
|
+
resolver: (0, import_yup.resolver)(
|
|
71
|
+
import_yup.default.object({
|
|
72
|
+
enabled: import_yup.default.boolean(),
|
|
73
|
+
entries: import_yup.default.number().label("Entries per completion").typeError("Entries per completion is a required field").integer().required().min(import_missions.BOUNDS.entries[0]).max(import_missions.BOUNDS.entries[1]),
|
|
74
|
+
...repeating && {
|
|
75
|
+
limit: import_yup.default.number().label("Maximum completions").typeError("Maximum completions is a required field").integer().required().min(import_missions.BOUNDS.count[0]).max(import_missions.BOUNDS.count[1]),
|
|
76
|
+
per: import_yup.default.string().label("Count completions per").required().oneOf(PER.map(({ value }) => value))
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
),
|
|
80
|
+
values: {
|
|
81
|
+
enabled: Boolean(values == null ? void 0 : values.enabled),
|
|
82
|
+
entries: (values == null ? void 0 : values.entries) ?? 1,
|
|
83
|
+
limit: ((_a = values == null ? void 0 : values.limit) == null ? void 0 : _a.count) ?? 1,
|
|
84
|
+
per: ((_b = values == null ? void 0 : values.limit) == null ? void 0 : _b.per) || "campaign"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const onSubmit = async ({
|
|
88
|
+
enabled,
|
|
89
|
+
entries,
|
|
90
|
+
limit,
|
|
91
|
+
per
|
|
92
|
+
}) => {
|
|
93
|
+
try {
|
|
94
|
+
const response = await (0, import_fetch.request)({
|
|
95
|
+
body: {
|
|
96
|
+
enabled,
|
|
97
|
+
entries,
|
|
98
|
+
...repeating && {
|
|
99
|
+
limit: {
|
|
100
|
+
count: limit,
|
|
101
|
+
per
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/mission/" + (values == null ? void 0 : values.id),
|
|
106
|
+
method: "PUT"
|
|
107
|
+
});
|
|
108
|
+
onSuccess(response);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
onError(error);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
114
|
+
import_form2.default,
|
|
115
|
+
{
|
|
116
|
+
...{
|
|
117
|
+
className: "relative w-full space-y-8",
|
|
118
|
+
onSubmit: handleSubmit(onSubmit)
|
|
119
|
+
},
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
122
|
+
import_fieldset.default,
|
|
123
|
+
{
|
|
124
|
+
...{
|
|
125
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
+
import_form.Controller,
|
|
130
|
+
{
|
|
131
|
+
...{
|
|
132
|
+
control,
|
|
133
|
+
name: "enabled",
|
|
134
|
+
render: ({ field: { value, onChange } }) => {
|
|
135
|
+
var _a2, _b2;
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
137
|
+
import_input_group.default,
|
|
138
|
+
{
|
|
139
|
+
...{
|
|
140
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.enabled) == null ? void 0 : _b2.message,
|
|
141
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_input_switch.default,
|
|
143
|
+
{
|
|
144
|
+
...{
|
|
145
|
+
disabled: Boolean(locked),
|
|
146
|
+
helper: value ? "On" : "Off",
|
|
147
|
+
onChange,
|
|
148
|
+
value: Boolean(value)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
label: "Status",
|
|
153
|
+
...locked && {
|
|
154
|
+
message: locked
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
164
|
+
import_form.Controller,
|
|
165
|
+
{
|
|
166
|
+
...{
|
|
167
|
+
control,
|
|
168
|
+
name: "entries",
|
|
169
|
+
render: ({ field: { value, onChange } }) => {
|
|
170
|
+
var _a2, _b2;
|
|
171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
import_input_group.default,
|
|
173
|
+
{
|
|
174
|
+
...{
|
|
175
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.entries) == null ? void 0 : _b2.message,
|
|
176
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
177
|
+
import_input_number.default,
|
|
178
|
+
{
|
|
179
|
+
...{
|
|
180
|
+
max: import_missions.BOUNDS.entries[1],
|
|
181
|
+
min: import_missions.BOUNDS.entries[0],
|
|
182
|
+
onChange,
|
|
183
|
+
value: value ?? ""
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
label: "Entries per completion",
|
|
188
|
+
message: repeating ? "How many entries to award each time a lead completes this mission while a range is running." : "How many entries to award when a lead completes this mission while a range is running."
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
repeating && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
198
|
+
import_form.Controller,
|
|
199
|
+
{
|
|
200
|
+
...{
|
|
201
|
+
control,
|
|
202
|
+
name: "limit",
|
|
203
|
+
render: ({ field: { value, onChange } }) => {
|
|
204
|
+
var _a2, _b2;
|
|
205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
206
|
+
import_input_group.default,
|
|
207
|
+
{
|
|
208
|
+
...{
|
|
209
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.limit) == null ? void 0 : _b2.message,
|
|
210
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
|
+
import_input_number.default,
|
|
212
|
+
{
|
|
213
|
+
...{
|
|
214
|
+
max: import_missions.BOUNDS.count[1],
|
|
215
|
+
min: import_missions.BOUNDS.count[0],
|
|
216
|
+
onChange,
|
|
217
|
+
value: value ?? ""
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
label: "Maximum completions"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
+
import_form.Controller,
|
|
231
|
+
{
|
|
232
|
+
...{
|
|
233
|
+
control,
|
|
234
|
+
name: "per",
|
|
235
|
+
render: ({ field: { value, onChange } }) => {
|
|
236
|
+
var _a2, _b2;
|
|
237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
|
+
import_input_group.default,
|
|
239
|
+
{
|
|
240
|
+
...{
|
|
241
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.per) == null ? void 0 : _b2.message,
|
|
242
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
243
|
+
import_input_combobox.default,
|
|
244
|
+
{
|
|
245
|
+
...{
|
|
246
|
+
onChange,
|
|
247
|
+
options: PER,
|
|
248
|
+
value
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
label: "Count completions per",
|
|
253
|
+
message: "The window Maximum completions counts in. Campaign counts across the whole campaign, Range within each range, and Day within each day."
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
] })
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
266
|
+
import_fieldset.default,
|
|
267
|
+
{
|
|
268
|
+
...{
|
|
269
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
270
|
+
},
|
|
271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
272
|
+
import_button.default,
|
|
273
|
+
{
|
|
274
|
+
...{
|
|
275
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
276
|
+
type: "submit"
|
|
277
|
+
},
|
|
278
|
+
children: "Save"
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
var form_organization_campaign_mission_default = FormOrganizationCampaignMission;
|
|
288
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
289
|
+
0 && (module.exports = {
|
|
290
|
+
repeats
|
|
291
|
+
});
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
4
|
+
import { BOUNDS, missions, WINDOWS } from "@drawbridge/drawbridge-utils/missions";
|
|
5
|
+
import { useForm, Controller } from "../shared/lib/form.mjs";
|
|
6
|
+
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
7
|
+
import Form from "../shared/form.mjs";
|
|
8
|
+
import Fieldset from "../shared/fieldset.mjs";
|
|
9
|
+
import InputGroup from "../input-group.mjs";
|
|
10
|
+
import InputNumber from "../input-number.mjs";
|
|
11
|
+
import InputSwitch from "../shared/input-switch.mjs";
|
|
12
|
+
import InputCombobox from "./input-combobox.mjs";
|
|
13
|
+
import Button from "../shared/button.mjs";
|
|
14
|
+
const LABELS = {
|
|
15
|
+
campaign: "Campaign",
|
|
16
|
+
day: "Day",
|
|
17
|
+
range: "Range"
|
|
18
|
+
};
|
|
19
|
+
const PER = ["campaign", "range", "day"].filter((value) => WINDOWS.includes(value)).map((value) => ({
|
|
20
|
+
key: LABELS[value],
|
|
21
|
+
value
|
|
22
|
+
}));
|
|
23
|
+
const repeats = (values) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return ((_a = missions[values == null ? void 0 : values.type]) == null ? void 0 : _a.repeats) !== false;
|
|
26
|
+
};
|
|
27
|
+
const FormOrganizationCampaignMission = ({
|
|
28
|
+
disabled,
|
|
29
|
+
onError,
|
|
30
|
+
onSuccess,
|
|
31
|
+
values
|
|
32
|
+
}) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const repeating = repeats(values);
|
|
35
|
+
const locked = !(values == null ? void 0 : values.enabled) && (values == null ? void 0 : values.locked);
|
|
36
|
+
const { control, formState, handleSubmit } = useForm({
|
|
37
|
+
resolver: resolver(
|
|
38
|
+
yup.object({
|
|
39
|
+
enabled: yup.boolean(),
|
|
40
|
+
entries: yup.number().label("Entries per completion").typeError("Entries per completion is a required field").integer().required().min(BOUNDS.entries[0]).max(BOUNDS.entries[1]),
|
|
41
|
+
...repeating && {
|
|
42
|
+
limit: yup.number().label("Maximum completions").typeError("Maximum completions is a required field").integer().required().min(BOUNDS.count[0]).max(BOUNDS.count[1]),
|
|
43
|
+
per: yup.string().label("Count completions per").required().oneOf(PER.map(({ value }) => value))
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
),
|
|
47
|
+
values: {
|
|
48
|
+
enabled: Boolean(values == null ? void 0 : values.enabled),
|
|
49
|
+
entries: (values == null ? void 0 : values.entries) ?? 1,
|
|
50
|
+
limit: ((_a = values == null ? void 0 : values.limit) == null ? void 0 : _a.count) ?? 1,
|
|
51
|
+
per: ((_b = values == null ? void 0 : values.limit) == null ? void 0 : _b.per) || "campaign"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const onSubmit = async ({
|
|
55
|
+
enabled,
|
|
56
|
+
entries,
|
|
57
|
+
limit,
|
|
58
|
+
per
|
|
59
|
+
}) => {
|
|
60
|
+
try {
|
|
61
|
+
const response = await request({
|
|
62
|
+
body: {
|
|
63
|
+
enabled,
|
|
64
|
+
entries,
|
|
65
|
+
...repeating && {
|
|
66
|
+
limit: {
|
|
67
|
+
count: limit,
|
|
68
|
+
per
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/mission/" + (values == null ? void 0 : values.id),
|
|
73
|
+
method: "PUT"
|
|
74
|
+
});
|
|
75
|
+
onSuccess(response);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
onError(error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ jsxs(
|
|
81
|
+
Form,
|
|
82
|
+
{
|
|
83
|
+
...{
|
|
84
|
+
className: "relative w-full space-y-8",
|
|
85
|
+
onSubmit: handleSubmit(onSubmit)
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsxs(
|
|
89
|
+
Fieldset,
|
|
90
|
+
{
|
|
91
|
+
...{
|
|
92
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
93
|
+
},
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
Controller,
|
|
97
|
+
{
|
|
98
|
+
...{
|
|
99
|
+
control,
|
|
100
|
+
name: "enabled",
|
|
101
|
+
render: ({ field: { value, onChange } }) => {
|
|
102
|
+
var _a2, _b2;
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
InputGroup,
|
|
105
|
+
{
|
|
106
|
+
...{
|
|
107
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.enabled) == null ? void 0 : _b2.message,
|
|
108
|
+
input: /* @__PURE__ */ jsx(
|
|
109
|
+
InputSwitch,
|
|
110
|
+
{
|
|
111
|
+
...{
|
|
112
|
+
disabled: Boolean(locked),
|
|
113
|
+
helper: value ? "On" : "Off",
|
|
114
|
+
onChange,
|
|
115
|
+
value: Boolean(value)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
label: "Status",
|
|
120
|
+
...locked && {
|
|
121
|
+
message: locked
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
Controller,
|
|
132
|
+
{
|
|
133
|
+
...{
|
|
134
|
+
control,
|
|
135
|
+
name: "entries",
|
|
136
|
+
render: ({ field: { value, onChange } }) => {
|
|
137
|
+
var _a2, _b2;
|
|
138
|
+
return /* @__PURE__ */ jsx(
|
|
139
|
+
InputGroup,
|
|
140
|
+
{
|
|
141
|
+
...{
|
|
142
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.entries) == null ? void 0 : _b2.message,
|
|
143
|
+
input: /* @__PURE__ */ jsx(
|
|
144
|
+
InputNumber,
|
|
145
|
+
{
|
|
146
|
+
...{
|
|
147
|
+
max: BOUNDS.entries[1],
|
|
148
|
+
min: BOUNDS.entries[0],
|
|
149
|
+
onChange,
|
|
150
|
+
value: value ?? ""
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
label: "Entries per completion",
|
|
155
|
+
message: repeating ? "How many entries to award each time a lead completes this mission while a range is running." : "How many entries to award when a lead completes this mission while a range is running."
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
repeating && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
164
|
+
/* @__PURE__ */ jsx(
|
|
165
|
+
Controller,
|
|
166
|
+
{
|
|
167
|
+
...{
|
|
168
|
+
control,
|
|
169
|
+
name: "limit",
|
|
170
|
+
render: ({ field: { value, onChange } }) => {
|
|
171
|
+
var _a2, _b2;
|
|
172
|
+
return /* @__PURE__ */ jsx(
|
|
173
|
+
InputGroup,
|
|
174
|
+
{
|
|
175
|
+
...{
|
|
176
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.limit) == null ? void 0 : _b2.message,
|
|
177
|
+
input: /* @__PURE__ */ jsx(
|
|
178
|
+
InputNumber,
|
|
179
|
+
{
|
|
180
|
+
...{
|
|
181
|
+
max: BOUNDS.count[1],
|
|
182
|
+
min: BOUNDS.count[0],
|
|
183
|
+
onChange,
|
|
184
|
+
value: value ?? ""
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
label: "Maximum completions"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ jsx(
|
|
197
|
+
Controller,
|
|
198
|
+
{
|
|
199
|
+
...{
|
|
200
|
+
control,
|
|
201
|
+
name: "per",
|
|
202
|
+
render: ({ field: { value, onChange } }) => {
|
|
203
|
+
var _a2, _b2;
|
|
204
|
+
return /* @__PURE__ */ jsx(
|
|
205
|
+
InputGroup,
|
|
206
|
+
{
|
|
207
|
+
...{
|
|
208
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.per) == null ? void 0 : _b2.message,
|
|
209
|
+
input: /* @__PURE__ */ jsx(
|
|
210
|
+
InputCombobox,
|
|
211
|
+
{
|
|
212
|
+
...{
|
|
213
|
+
onChange,
|
|
214
|
+
options: PER,
|
|
215
|
+
value
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
label: "Count completions per",
|
|
220
|
+
message: "The window Maximum completions counts in. Campaign counts across the whole campaign, Range within each range, and Day within each day."
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] })
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
Fieldset,
|
|
234
|
+
{
|
|
235
|
+
...{
|
|
236
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
237
|
+
},
|
|
238
|
+
children: /* @__PURE__ */ jsx(
|
|
239
|
+
Button,
|
|
240
|
+
{
|
|
241
|
+
...{
|
|
242
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
243
|
+
type: "submit"
|
|
244
|
+
},
|
|
245
|
+
children: "Save"
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
var form_organization_campaign_mission_default = FormOrganizationCampaignMission;
|
|
255
|
+
export {
|
|
256
|
+
form_organization_campaign_mission_default as default,
|
|
257
|
+
repeats
|
|
258
|
+
};
|
|
@@ -30,7 +30,10 @@ __export(form_organization_campaign_page_embed_exports, {
|
|
|
30
30
|
default: () => form_organization_campaign_page_embed_default
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(form_organization_campaign_page_embed_exports);
|
|
33
|
-
var import_jsx_runtime =
|
|
33
|
+
var import_jsx_runtime = (
|
|
34
|
+
// The Embed drawer is white: the grey box.
|
|
35
|
+
require("react/jsx-runtime")
|
|
36
|
+
);
|
|
34
37
|
var import_hooks = require("./lib/hooks");
|
|
35
38
|
var import_input_group = __toESM(require("../input-group"));
|
|
36
39
|
var import_input_textarea = __toESM(require("../input-textarea"));
|
|
@@ -56,7 +59,15 @@ const FormOrganizationCampaignPageEmbed = ({
|
|
|
56
59
|
value: snippet
|
|
57
60
|
});
|
|
58
61
|
if (!snippet) {
|
|
59
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
63
|
+
import_empty.default,
|
|
64
|
+
{
|
|
65
|
+
...{
|
|
66
|
+
variant: "secondary"
|
|
67
|
+
},
|
|
68
|
+
children: "Publish your page to generate an embed code."
|
|
69
|
+
}
|
|
70
|
+
);
|
|
60
71
|
}
|
|
61
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
62
73
|
"div",
|
|
@@ -24,7 +24,18 @@ const FormOrganizationCampaignPageEmbed = ({
|
|
|
24
24
|
value: snippet
|
|
25
25
|
});
|
|
26
26
|
if (!snippet) {
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
// The Embed drawer is white: the grey box.
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
Empty,
|
|
31
|
+
{
|
|
32
|
+
...{
|
|
33
|
+
variant: "secondary"
|
|
34
|
+
},
|
|
35
|
+
children: "Publish your page to generate an embed code."
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
);
|
|
28
39
|
}
|
|
29
40
|
return /* @__PURE__ */ jsxs(
|
|
30
41
|
"div",
|