@drawbridge/components 0.1.13 → 0.1.15

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.
Files changed (242) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +577 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +540 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +277 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +243 -0
  48. package/dist/dashboard/card-order.js +231 -29
  49. package/dist/dashboard/card-order.mjs +231 -29
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +205 -0
  55. package/dist/dashboard/connection-workflows.mjs +171 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
  81. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  82. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  83. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  84. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  87. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  88. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  89. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  90. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  91. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  92. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  93. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  94. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  95. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  96. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  97. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  99. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  100. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  101. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  102. package/dist/dashboard/form-organization-campaign-section.js +243 -0
  103. package/dist/dashboard/form-organization-campaign-section.mjs +214 -0
  104. package/dist/dashboard/form-organization-campaign.js +114 -469
  105. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  106. package/dist/dashboard/form-organization-export.js +4 -7
  107. package/dist/dashboard/form-organization-export.mjs +4 -7
  108. package/dist/dashboard/form-organization-identity.js +46 -51
  109. package/dist/dashboard/form-organization-identity.mjs +46 -51
  110. package/dist/dashboard/form-organization-workflow.js +708 -687
  111. package/dist/dashboard/form-organization-workflow.mjs +704 -683
  112. package/dist/dashboard/form-organization.js +82 -110
  113. package/dist/dashboard/form-organization.mjs +81 -109
  114. package/dist/dashboard/form-otc.js +4 -5
  115. package/dist/dashboard/form-otc.mjs +4 -5
  116. package/dist/dashboard/form-payment-methods.js +20 -9
  117. package/dist/dashboard/form-payment-methods.mjs +20 -9
  118. package/dist/dashboard/form-stripe.js +30 -0
  119. package/dist/dashboard/form-stripe.mjs +26 -0
  120. package/dist/dashboard/input-array.js +4 -2
  121. package/dist/dashboard/input-array.mjs +4 -2
  122. package/dist/dashboard/input-combobox.js +7 -3
  123. package/dist/dashboard/input-combobox.mjs +7 -3
  124. package/dist/dashboard/input-date.js +7 -0
  125. package/dist/dashboard/input-date.mjs +7 -0
  126. package/dist/dashboard/input-fields.js +80 -20
  127. package/dist/dashboard/input-fields.mjs +80 -20
  128. package/dist/dashboard/input-file.js +21 -1
  129. package/dist/dashboard/input-file.mjs +21 -1
  130. package/dist/dashboard/input-font.js +10 -1
  131. package/dist/dashboard/input-font.mjs +10 -1
  132. package/dist/dashboard/lib/item-list.js +57 -0
  133. package/dist/dashboard/lib/item-list.mjs +33 -0
  134. package/dist/dashboard/lib/menu.js +50 -0
  135. package/dist/dashboard/lib/menu.mjs +26 -0
  136. package/dist/dashboard/locked.js +82 -0
  137. package/dist/dashboard/locked.mjs +53 -0
  138. package/dist/dashboard/menu.js +72 -19
  139. package/dist/dashboard/menu.mjs +72 -19
  140. package/dist/dashboard/note-ai.js +69 -0
  141. package/dist/dashboard/note-ai.mjs +36 -0
  142. package/dist/dashboard/preview.js +419 -0
  143. package/dist/dashboard/preview.mjs +384 -0
  144. package/dist/dashboard/steps.js +39 -13
  145. package/dist/dashboard/steps.mjs +37 -12
  146. package/dist/dashboard/table-contacts.js +136 -0
  147. package/dist/dashboard/table-contacts.mjs +103 -0
  148. package/dist/dashboard/template-not-found.js +4 -2
  149. package/dist/dashboard/template-not-found.mjs +4 -2
  150. package/dist/dashboard/template-socket.js +20 -7
  151. package/dist/dashboard/template-socket.mjs +20 -7
  152. package/dist/icons/desktop.js +46 -0
  153. package/dist/icons/desktop.mjs +27 -0
  154. package/dist/icons/phone.js +46 -0
  155. package/dist/icons/phone.mjs +27 -0
  156. package/dist/icons/puzzle-piece.js +46 -0
  157. package/dist/icons/puzzle-piece.mjs +27 -0
  158. package/dist/icons/tablet.js +46 -0
  159. package/dist/icons/tablet.mjs +27 -0
  160. package/dist/icons/users.js +46 -0
  161. package/dist/icons/users.mjs +27 -0
  162. package/dist/input-checkbox.js +1 -0
  163. package/dist/input-checkbox.mjs +1 -0
  164. package/dist/input-code.js +83 -0
  165. package/dist/input-code.mjs +50 -0
  166. package/dist/input-text.js +2 -1
  167. package/dist/input-text.mjs +2 -1
  168. package/dist/shared/button.js +1 -1
  169. package/dist/shared/button.mjs +1 -1
  170. package/dist/shared/input-checkbox-list.js +0 -1
  171. package/dist/shared/input-checkbox-list.mjs +0 -1
  172. package/dist/shared/input-switch.js +6 -1
  173. package/dist/shared/input-switch.mjs +6 -1
  174. package/dist/shared/lib/campaign.js +123 -0
  175. package/dist/shared/lib/campaign.mjs +96 -0
  176. package/dist/shared/lib/helpers.js +14 -2
  177. package/dist/shared/lib/helpers.mjs +13 -2
  178. package/package.json +133 -13
  179. package/types/bridge/form-subdomain-header.d.ts +2 -0
  180. package/types/bridge/form-subdomain-missions.d.ts +38 -0
  181. package/types/bridge/form-subdomain.d.ts +23 -1
  182. package/types/bridge/lib/entry.d.ts +26 -0
  183. package/types/bridge/lib/location.d.ts +13 -0
  184. package/types/bridge/lib/order.d.ts +30 -0
  185. package/types/bridge/lib/url.d.ts +19 -0
  186. package/types/bridge/template-modal.d.ts +1 -1
  187. package/types/bridge/template-preview.d.ts +10 -0
  188. package/types/bridge/template-subdomain-link.d.ts +2 -0
  189. package/types/dashboard/accordion.d.ts +2 -0
  190. package/types/dashboard/avatar.d.ts +18 -2
  191. package/types/dashboard/buttons-subscription.d.ts +22 -0
  192. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  193. package/types/dashboard/card-order.d.ts +25 -1
  194. package/types/dashboard/card-section.d.ts +2 -0
  195. package/types/dashboard/connection-workflows.d.ts +33 -0
  196. package/types/dashboard/device.d.ts +12 -0
  197. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  198. package/types/dashboard/form-ai.d.ts +2 -2
  199. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  200. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  201. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  202. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  203. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  204. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  205. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  206. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  207. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  208. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  209. package/types/dashboard/form-organization-campaign-section.d.ts +29 -0
  210. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  211. package/types/dashboard/form-organization-identity.d.ts +2 -0
  212. package/types/dashboard/form-organization-workflow.d.ts +56 -47
  213. package/types/dashboard/form-organization.d.ts +7 -2
  214. package/types/dashboard/form-stripe.d.ts +3 -0
  215. package/types/dashboard/input-combobox.d.ts +2 -0
  216. package/types/dashboard/input-date.d.ts +2 -0
  217. package/types/dashboard/input-fields.d.ts +3 -2
  218. package/types/dashboard/input-file.d.ts +4 -0
  219. package/types/dashboard/lib/item-list.d.ts +14 -0
  220. package/types/dashboard/lib/menu.d.ts +17 -0
  221. package/types/dashboard/locked.d.ts +10 -0
  222. package/types/dashboard/menu.d.ts +10 -2
  223. package/types/dashboard/note-ai.d.ts +15 -0
  224. package/types/dashboard/preview.d.ts +33 -0
  225. package/types/dashboard/steps.d.ts +19 -4
  226. package/types/dashboard/table-cell-title.d.ts +2 -2
  227. package/types/dashboard/table-contacts.d.ts +2 -0
  228. package/types/icons/desktop.d.ts +5 -0
  229. package/types/icons/phone.d.ts +5 -0
  230. package/types/icons/puzzle-piece.d.ts +5 -0
  231. package/types/icons/tablet.d.ts +5 -0
  232. package/types/icons/users.d.ts +5 -0
  233. package/types/input-code.d.ts +23 -0
  234. package/types/shared/input-switch.d.ts +2 -0
  235. package/types/shared/lib/campaign.d.ts +35 -0
  236. package/types/shared/lib/helpers.d.ts +3 -0
  237. package/dist/dashboard/card-integration.js +0 -187
  238. package/dist/dashboard/card-integration.mjs +0 -158
  239. package/dist/dashboard/iframe.js +0 -159
  240. package/dist/dashboard/iframe.mjs +0 -130
  241. package/types/dashboard/card-integration.d.ts +0 -24
  242. package/types/dashboard/iframe.d.ts +0 -18
@@ -1,16 +1,15 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback, useState } from "react";
2
+ import { useCallback, useEffect, useState } from "react";
3
3
  import { request } from "@drawbridge/drawbridge-utils/fetch";
4
4
  import { constants } from "@drawbridge/drawbridge-utils";
5
5
  import { useQueryClient } from "@tanstack/react-query";
6
- import { useForm, FormProvider, Controller, useWatch } from "../shared/lib/form.mjs";
6
+ import { useForm, useWatch, FormProvider, Controller } from "../shared/lib/form.mjs";
7
7
  import yup, { resolver } from "../shared/lib/yup.mjs";
8
8
  import { InputFieldsCampaign, schemas } from "./input-fields.mjs";
9
9
  import Form from "../shared/form.mjs";
10
10
  import Fieldset from "../shared/fieldset.mjs";
11
11
  import InputGroup from "../input-group.mjs";
12
12
  import InputText from "../input-text.mjs";
13
- import InputNumber from "../input-number.mjs";
14
13
  import InputCombobox from "./input-combobox.mjs";
15
14
  import InputTextarea from "../input-textarea.mjs";
16
15
  import InputResource from "./input-resource.mjs";
@@ -26,7 +25,7 @@ const FormOrganizationCampaign = ({
26
25
  const queryClient = useQueryClient();
27
26
  const app = queryClient.getQueryData(["app"]);
28
27
  const schema = {
29
- ...schemas.campaign({ typeEnum: app.enums.campaign.type.enum }),
28
+ ...schemas.campaign(),
30
29
  brand: yup.object().label("Brand").nullable(),
31
30
  industry: (values == null ? void 0 : values.template) ? yup.string().label("Industry").oneOf([...app.enums.campaign.industry.enum, "", null]).nullable() : yup.string().label("Industry").oneOf(app.enums.campaign.industry.enum).required()
32
31
  };
@@ -34,26 +33,31 @@ const FormOrganizationCampaign = ({
34
33
  resolver: resolver(
35
34
  yup.object(schema)
36
35
  ),
36
+ // @story campaigns/create
37
+ // Both switches start on.
37
38
  values: {
38
- type: "giveaway",
39
+ form: true,
40
+ giveaway: true,
39
41
  ...values
40
42
  }
41
43
  });
42
44
  const { control, handleSubmit, formState } = methods;
43
45
  const onSubmit = async ({
44
46
  brand,
47
+ form,
48
+ giveaway,
45
49
  industry,
46
- title,
47
- type
50
+ title
48
51
  }) => {
49
52
  try {
50
53
  const response = await request({
51
54
  body: {
52
55
  brand: (brand == null ? void 0 : brand.id) ?? null,
56
+ form,
57
+ giveaway,
53
58
  industry,
54
59
  template: (values == null ? void 0 : values.template) || null,
55
- title,
56
- type
60
+ title
57
61
  },
58
62
  endpoint: "/organization/" + values.organization + "/campaign",
59
63
  method: "POST"
@@ -174,227 +178,133 @@ const FormOrganizationCampaign = ({
174
178
  }
175
179
  ) });
176
180
  };
177
- const FormOrganizationCampaignDefaults = ({
181
+ const copyFields = {
182
+ active: ["Giveaway button text", "The entry button text while the giveaway is awarding entries."],
183
+ button: ["Default button text", "The entry button text while the form is open and no entries are being awarded."],
184
+ confirmation: ["Submission success text", "The message shown to a lead after they successfully submit an entry."],
185
+ inactive: ["Closed button text", "The entry button text while the form is not taking entries."],
186
+ order: ["Order confirmation text", "Shown when a buyer comes back from checkout."],
187
+ rejection: ["Already submitted text", 'The message shown to a lead who has already reached their submission limit. Defaults to "You have already submitted".'],
188
+ title: ["Panel title", 'The title of the panel after a submission. Defaults to "Entry submitted" while entries are being awarded, and "Submitted" otherwise.']
189
+ };
190
+ const copyPlaceholder = (key, awarding) => {
191
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
192
+ return key === "title" ? (_e = (_d = (_c = (_b = (_a = constants) == null ? void 0 : _a.campaign) == null ? void 0 : _b.form) == null ? void 0 : _c.copy) == null ? void 0 : _d.title) == null ? void 0 : _e[awarding ? "awarding" : "open"] : (_i = (_h = (_g = (_f = constants) == null ? void 0 : _f.campaign) == null ? void 0 : _g.form) == null ? void 0 : _h.copy) == null ? void 0 : _i[key];
193
+ };
194
+ const FormOrganizationCampaignCopy = ({
195
+ awarding,
178
196
  disabled,
197
+ onChange,
179
198
  onError,
199
+ onFocus,
180
200
  onSuccess,
201
+ sections = [],
181
202
  values
182
203
  }) => {
183
- const schema = {
184
- defaults: yup.object({
185
- active: yup.string().label("Active message").max(150).nullable(),
186
- inactive: yup.string().label("Inactive message").max(150).nullable(),
187
- confirmation: yup.string().label("Confirmation message").max(150).nullable(),
188
- purchase: yup.string().label("Purchase message").max(150).nullable(),
189
- rejection: yup.string().label("Rejection message").max(150).nullable()
190
- })
191
- };
204
+ const keys = sections.flatMap(([, list]) => list);
192
205
  const { control, handleSubmit, formState } = useForm({
193
206
  resolver: resolver(
194
- yup.object(schema)
207
+ yup.object(
208
+ Object.fromEntries(keys.map((key) => [key, yup.string().label(copyFields[key][0]).max(150).nullable()]))
209
+ )
195
210
  ),
196
- values
211
+ values: Object.fromEntries(keys.map((key) => {
212
+ var _a, _b;
213
+ return [key, ((_b = (_a = values == null ? void 0 : values.form) == null ? void 0 : _a.copy) == null ? void 0 : _b[key]) || ""];
214
+ }))
197
215
  });
198
- const onSubmit = async ({
199
- defaults
200
- }) => {
216
+ const watched = useWatch({
217
+ control
218
+ });
219
+ const typed = JSON.stringify(keys.map((key) => watched == null ? void 0 : watched[key]));
220
+ useEffect(
221
+ () => {
222
+ onChange == null ? void 0 : onChange(Object.fromEntries(keys.map((key) => [key, watched == null ? void 0 : watched[key]])));
223
+ },
224
+ // eslint-disable-next-line react-hooks/exhaustive-deps
225
+ [typed]
226
+ );
227
+ const onSubmit = async (copy) => {
201
228
  try {
202
- const args = {
229
+ const response = await request({
203
230
  body: {
204
- defaults
231
+ form: {
232
+ copy: Object.fromEntries(keys.map((key) => [key, (copy == null ? void 0 : copy[key]) || null]))
233
+ }
205
234
  },
206
235
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.id),
207
236
  method: "PUT"
208
- };
209
- const response = await request(args);
237
+ });
210
238
  onSuccess(response);
211
239
  } catch (error) {
212
240
  onError(error);
213
241
  }
214
242
  };
243
+ const field = (key) => /* @__PURE__ */ jsx(
244
+ Controller,
245
+ {
246
+ ...{
247
+ control,
248
+ name: key,
249
+ render: ({ field: { value, onChange: change } }) => {
250
+ var _a, _b;
251
+ return /* @__PURE__ */ jsx(
252
+ InputGroup,
253
+ {
254
+ ...{
255
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[key]) == null ? void 0 : _b.message,
256
+ input: /* @__PURE__ */ jsx(
257
+ InputText,
258
+ {
259
+ ...{
260
+ onChange: change,
261
+ onFocus: () => onFocus == null ? void 0 : onFocus(key),
262
+ placeholder: copyPlaceholder(key, awarding),
263
+ value: value || ""
264
+ }
265
+ }
266
+ ),
267
+ label: copyFields[key][0],
268
+ message: copyFields[key][1]
269
+ }
270
+ }
271
+ );
272
+ }
273
+ }
274
+ },
275
+ key
276
+ );
215
277
  return /* @__PURE__ */ jsxs(
216
278
  Form,
217
279
  {
218
280
  ...{
219
- className: "relative w-full space-y-8",
281
+ // Divided as the Page editor's form, Save under the last section.
282
+ className: "relative w-full divide-y divide-gray [&>*]:py-6 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0",
220
283
  onSubmit: handleSubmit(onSubmit)
221
284
  },
222
285
  children: [
223
- /* @__PURE__ */ jsxs(
224
- Fieldset,
286
+ sections.map(([title, list]) => /* @__PURE__ */ jsxs(
287
+ "section",
225
288
  {
226
289
  ...{
227
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
290
+ className: "space-y-6",
291
+ "data-guide": "section-" + title.toLowerCase()
228
292
  },
229
293
  children: [
294
+ /* @__PURE__ */ jsx("h3", { children: title }),
230
295
  /* @__PURE__ */ jsx(
231
- Controller,
232
- {
233
- ...{
234
- control,
235
- name: "defaults.active",
236
- render: ({ field: { value, onChange } }) => {
237
- var _a, _b, _c, _d, _e, _f;
238
- return /* @__PURE__ */ jsx(
239
- InputGroup,
240
- {
241
- ...{
242
- error: (_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.defaults) == null ? void 0 : _b.active) == null ? void 0 : _c.message,
243
- input: /* @__PURE__ */ jsx(
244
- InputText,
245
- {
246
- ...{
247
- onChange,
248
- placeholder: (_f = (_e = (_d = constants) == null ? void 0 : _d.campaign) == null ? void 0 : _e.defaults) == null ? void 0 : _f.active,
249
- value: value || ""
250
- }
251
- }
252
- ),
253
- label: "Campaign active button text",
254
- message: "The call-to-action button text shown while the campaign is open and accepting entries."
255
- }
256
- }
257
- );
258
- }
259
- }
260
- }
261
- ),
262
- /* @__PURE__ */ jsx(
263
- Controller,
264
- {
265
- ...{
266
- control,
267
- name: "defaults.inactive",
268
- render: ({ field: { value, onChange } }) => {
269
- var _a, _b, _c, _d, _e, _f;
270
- return /* @__PURE__ */ jsx(
271
- InputGroup,
272
- {
273
- ...{
274
- error: (_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.defaults) == null ? void 0 : _b.inactive) == null ? void 0 : _c.message,
275
- input: /* @__PURE__ */ jsx(
276
- InputText,
277
- {
278
- ...{
279
- onChange,
280
- placeholder: (_f = (_e = (_d = constants) == null ? void 0 : _d.campaign) == null ? void 0 : _e.defaults) == null ? void 0 : _f.inactive,
281
- value: value || ""
282
- }
283
- }
284
- ),
285
- label: "Campaign inactive button text",
286
- message: "The call-to-action button text shown when the campaign is closed or not accepting entries."
287
- }
288
- }
289
- );
290
- }
291
- }
292
- }
293
- ),
294
- /* @__PURE__ */ jsx(
295
- Controller,
296
- {
297
- ...{
298
- control,
299
- name: "defaults.confirmation",
300
- render: ({ field: { value, onChange } }) => {
301
- var _a, _b, _c, _d, _e, _f;
302
- return /* @__PURE__ */ jsx(
303
- InputGroup,
304
- {
305
- ...{
306
- error: (_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.defaults) == null ? void 0 : _b.confirmation) == null ? void 0 : _c.message,
307
- input: /* @__PURE__ */ jsx(
308
- InputText,
309
- {
310
- ...{
311
- onChange,
312
- placeholder: (_f = (_e = (_d = constants) == null ? void 0 : _d.campaign) == null ? void 0 : _e.defaults) == null ? void 0 : _f.confirmation,
313
- value: value || ""
314
- }
315
- }
316
- ),
317
- label: "Submission success text",
318
- message: "The message shown to a lead after they successfully submit an entry."
319
- }
320
- }
321
- );
322
- }
323
- }
324
- }
325
- ),
326
- /* @__PURE__ */ jsx(
327
- Controller,
328
- {
329
- ...{
330
- control,
331
- name: "defaults.purchase",
332
- render: ({ field: { value, onChange } }) => {
333
- var _a, _b, _c;
334
- return /* @__PURE__ */ jsx(
335
- InputGroup,
336
- {
337
- ...{
338
- error: (_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.defaults) == null ? void 0 : _b.purchase) == null ? void 0 : _c.message,
339
- input: /* @__PURE__ */ jsx(
340
- InputText,
341
- {
342
- ...{
343
- onChange,
344
- // Mirrors the fallback drawbridge-share renders when
345
- // defaults.purchase is unset (template-layout.js). The
346
- // sibling fields read theirs from the shared constants;
347
- // this one has no constant, so the copy lives in both
348
- // places and must be changed in both.
349
- placeholder: "Thank you for your purchase",
350
- value: value || ""
351
- }
352
- }
353
- ),
354
- label: "Purchase success text",
355
- message: "The message shown to a buyer after they complete a purchase."
356
- }
357
- }
358
- );
359
- }
360
- }
361
- }
362
- ),
363
- /* @__PURE__ */ jsx(
364
- Controller,
296
+ Fieldset,
365
297
  {
366
298
  ...{
367
- control,
368
- name: "defaults.rejection",
369
- render: ({ field: { value, onChange } }) => {
370
- var _a, _b, _c, _d, _e, _f;
371
- return /* @__PURE__ */ jsx(
372
- InputGroup,
373
- {
374
- ...{
375
- error: (_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.defaults) == null ? void 0 : _b.rejection) == null ? void 0 : _c.message,
376
- input: /* @__PURE__ */ jsx(
377
- InputText,
378
- {
379
- ...{
380
- onChange,
381
- placeholder: (_f = (_e = (_d = constants) == null ? void 0 : _d.campaign) == null ? void 0 : _e.defaults) == null ? void 0 : _f.rejection,
382
- value: value || ""
383
- }
384
- }
385
- ),
386
- label: "Already submitted text",
387
- message: 'The message shown to a lead who has already reached their submission limit. Defaults to "You have already submitted".'
388
- }
389
- }
390
- );
391
- }
392
- }
299
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
300
+ },
301
+ children: list.map(field)
393
302
  }
394
303
  )
395
304
  ]
396
- }
397
- ),
305
+ },
306
+ title
307
+ )),
398
308
  /* @__PURE__ */ jsx(
399
309
  Fieldset,
400
310
  {
@@ -408,7 +318,7 @@ const FormOrganizationCampaignDefaults = ({
408
318
  loading: formState == null ? void 0 : formState.isSubmitting,
409
319
  type: "submit"
410
320
  },
411
- children: "Submit"
321
+ children: "Save"
412
322
  }
413
323
  )
414
324
  }
@@ -423,7 +333,7 @@ const FormOrganizationCampaignNotifications = ({
423
333
  onSuccess,
424
334
  values
425
335
  }) => {
426
- var _a;
336
+ var _a, _b;
427
337
  const notification = yup.object({
428
338
  subject: yup.string().label("Subject").required().max(150),
429
339
  message: yup.string().label("Message").required().max(2e3)
@@ -433,13 +343,12 @@ const FormOrganizationCampaignNotifications = ({
433
343
  draw: notification
434
344
  })
435
345
  };
436
- const draw = (_a = values == null ? void 0 : values.notifications) == null ? void 0 : _a.draw;
346
+ const draw = (_b = (_a = values == null ? void 0 : values.giveaway) == null ? void 0 : _a.notifications) == null ? void 0 : _b.draw;
437
347
  const drawMessage = (draw == null ? void 0 : draw.message) ?? "";
438
348
  const drawSubject = (draw == null ? void 0 : draw.subject) ?? "";
439
349
  const seeded = {
440
350
  ...values,
441
351
  notifications: {
442
- ...values == null ? void 0 : values.notifications,
443
352
  draw: {
444
353
  message: drawMessage,
445
354
  // THE SAVED SCORE, RE-TAGGED WITH THE COPY IT MEASURED.
@@ -489,7 +398,9 @@ const FormOrganizationCampaignNotifications = ({
489
398
  }
490
399
  const args = {
491
400
  body: {
492
- notifications
401
+ giveaway: {
402
+ notifications
403
+ }
493
404
  },
494
405
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.id),
495
406
  method: "PUT"
@@ -677,106 +588,6 @@ const FormOrganizationCampaignTitle = ({
677
588
  }
678
589
  );
679
590
  };
680
- const FormOrganizationCampaignStatus = ({
681
- disabled,
682
- onError,
683
- onSuccess,
684
- values
685
- }) => {
686
- const queryClient = useQueryClient();
687
- const app = queryClient.getQueryData(["app"]);
688
- const { control, handleSubmit, formState } = useForm({
689
- resolver: resolver(
690
- yup.object({
691
- status: yup.string().label("Type").required().oneOf(app.enums.campaign.status.enum)
692
- })
693
- ),
694
- values
695
- });
696
- const onSubmit = async ({
697
- status
698
- }) => {
699
- try {
700
- const response = await request({
701
- body: {
702
- status
703
- },
704
- endpoint: "/organization/" + values.organization + "/campaign/" + values.id,
705
- method: "PUT"
706
- });
707
- onSuccess(response);
708
- } catch (error) {
709
- onError(error);
710
- }
711
- };
712
- return /* @__PURE__ */ jsxs(
713
- Form,
714
- {
715
- ...{
716
- className: "relative w-full space-y-8",
717
- onSubmit: handleSubmit(onSubmit)
718
- },
719
- children: [
720
- /* @__PURE__ */ jsx(
721
- Fieldset,
722
- {
723
- ...{
724
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
725
- },
726
- children: /* @__PURE__ */ jsx(
727
- Controller,
728
- {
729
- ...{
730
- control,
731
- name: "status",
732
- render: ({ field: { value, onChange } }) => {
733
- var _a, _b;
734
- return /* @__PURE__ */ jsx(
735
- InputGroup,
736
- {
737
- ...{
738
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.status) == null ? void 0 : _b.message,
739
- input: /* @__PURE__ */ jsx(
740
- InputCombobox,
741
- {
742
- ...{
743
- onChange,
744
- options: app.enums.campaign.status.options,
745
- value
746
- }
747
- }
748
- )
749
- }
750
- }
751
- );
752
- }
753
- }
754
- }
755
- )
756
- }
757
- ),
758
- /* @__PURE__ */ jsx(
759
- Fieldset,
760
- {
761
- ...{
762
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
763
- },
764
- children: /* @__PURE__ */ jsx(
765
- Button,
766
- {
767
- ...{
768
- loading: formState == null ? void 0 : formState.isSubmitting,
769
- type: "submit"
770
- },
771
- children: "Submit"
772
- }
773
- )
774
- }
775
- )
776
- ]
777
- }
778
- );
779
- };
780
591
  const FormOrganizationCampaignSettingsShop = ({
781
592
  values,
782
593
  disabled,
@@ -892,176 +703,11 @@ const FormOrganizationCampaignSettingsShop = ({
892
703
  }
893
704
  );
894
705
  };
895
- const FormOrganizationCampaignSettingsLimits = ({
896
- values,
897
- disabled,
898
- onError,
899
- onSuccess
900
- }) => {
901
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
902
- const { control, handleSubmit, formState } = useForm({
903
- defaultValues: values,
904
- resolver: resolver(
905
- yup.object({
906
- settings: yup.object({
907
- submissionEntryLimit: yup.number().label("Limit").integer().required().min(1).max(50)
908
- })
909
- })
910
- )
911
- });
912
- const submissionEntryFilterMessage = useWatch({
913
- control,
914
- name: "settings.submissionEntryFilter"
915
- });
916
- const onSubmit = async ({
917
- settings
918
- }) => {
919
- try {
920
- const response = await request({
921
- body: {
922
- settings
923
- },
924
- endpoint: "/organization/" + values.organization + "/campaign/" + values.id,
925
- method: "PUT"
926
- });
927
- onSuccess(response);
928
- } catch (error) {
929
- onError(error);
930
- }
931
- };
932
- return /* @__PURE__ */ jsxs(
933
- Form,
934
- {
935
- ...{
936
- className: "relative w-full space-y-8",
937
- onSubmit: handleSubmit(onSubmit)
938
- },
939
- children: [
940
- /* @__PURE__ */ jsx(
941
- Fieldset,
942
- {
943
- ...{
944
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
945
- },
946
- children: /* @__PURE__ */ jsx(
947
- InputGroup,
948
- {
949
- ...{
950
- error: ((_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.settings) == null ? void 0 : _b.submissionEntryLimit) == null ? void 0 : _c.message) || ((_g = (_f = (_e = (_d = formState == null ? void 0 : formState.errors) == null ? void 0 : _d.settings) == null ? void 0 : _e.submissionEntryLimit) == null ? void 0 : _f.number) == null ? void 0 : _g.message) || ((_j = (_i = (_h = formState == null ? void 0 : formState.errors) == null ? void 0 : _h.settings) == null ? void 0 : _i.submissionEntryFilter) == null ? void 0 : _j.message),
951
- input: /* @__PURE__ */ jsxs(
952
- "div",
953
- {
954
- ...{
955
- className: "flex flex-col md:flex-row items-center w-full gap-3"
956
- },
957
- children: [
958
- /* @__PURE__ */ jsx(
959
- "div",
960
- {
961
- ...{
962
- className: "grow-0 w-full md:w-1/2"
963
- },
964
- children: /* @__PURE__ */ jsx(
965
- Controller,
966
- {
967
- ...{
968
- control,
969
- name: "settings.submissionEntryLimit",
970
- render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
971
- InputNumber,
972
- {
973
- ...{
974
- min: 1,
975
- step: 1,
976
- onChange,
977
- value: value || ""
978
- }
979
- }
980
- )
981
- }
982
- }
983
- )
984
- }
985
- ),
986
- /* @__PURE__ */ jsx(
987
- "p",
988
- {
989
- ...{
990
- className: "hidden md:block"
991
- },
992
- children: "/"
993
- }
994
- ),
995
- /* @__PURE__ */ jsx(
996
- Controller,
997
- {
998
- ...{
999
- control,
1000
- name: "settings.submissionEntryFilter",
1001
- render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
1002
- InputCombobox,
1003
- {
1004
- ...{
1005
- onChange,
1006
- options: [
1007
- {
1008
- key: "Campaign",
1009
- value: "campaign"
1010
- },
1011
- {
1012
- key: "Day",
1013
- value: "day"
1014
- },
1015
- ...values.type !== "default" ? [{
1016
- key: "Range",
1017
- value: "range"
1018
- }] : []
1019
- ],
1020
- value: value || "campaign"
1021
- }
1022
- }
1023
- )
1024
- }
1025
- }
1026
- )
1027
- ]
1028
- }
1029
- ),
1030
- label: "Submission limit",
1031
- message: "The number of entries leads can submit per " + submissionEntryFilterMessage
1032
- }
1033
- }
1034
- )
1035
- }
1036
- ),
1037
- /* @__PURE__ */ jsx(
1038
- Fieldset,
1039
- {
1040
- ...{
1041
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
1042
- },
1043
- children: /* @__PURE__ */ jsx(
1044
- Button,
1045
- {
1046
- ...{
1047
- loading: formState == null ? void 0 : formState.isSubmitting,
1048
- type: "submit"
1049
- },
1050
- children: "Submit"
1051
- }
1052
- )
1053
- }
1054
- )
1055
- ]
1056
- }
1057
- );
1058
- };
1059
706
  export {
1060
707
  FormOrganizationCampaign,
1061
- FormOrganizationCampaignDefaults,
708
+ FormOrganizationCampaignCopy,
1062
709
  FormOrganizationCampaignNotifications,
1063
- FormOrganizationCampaignSettingsLimits,
1064
710
  FormOrganizationCampaignSettingsShop,
1065
- FormOrganizationCampaignStatus,
1066
- FormOrganizationCampaignTitle
711
+ FormOrganizationCampaignTitle,
712
+ copyPlaceholder
1067
713
  };