@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.
Files changed (236) 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 +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -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 +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  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 +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -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-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +20 -7
  147. package/dist/dashboard/template-socket.mjs +20 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -32,6 +32,7 @@ __export(form_organization_campaign_page_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(form_organization_campaign_page_exports);
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_react = require("react");
35
36
  var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
36
37
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
37
38
  var import_yup = __toESM(require("../shared/lib/yup"));
@@ -46,8 +47,7 @@ var import_button = __toESM(require("../shared/button"));
46
47
  var import_accordion = __toESM(require("./accordion"));
47
48
  var import_input_fields = require("./input-fields");
48
49
  const props = {
49
- className: "p-6 bg-white rounded border border-gray",
50
- classNamePanel: "mt-6 pt-6 border-t border-gray"
50
+ classNamePanel: "mt-6"
51
51
  };
52
52
  const FormOrganizationCampaignPage = ({
53
53
  canManageBrands,
@@ -171,6 +171,12 @@ const FormOrganizationCampaignPageEdit = ({
171
171
  var _a, _b, _c, _d, _e, _f;
172
172
  const queryClient = (0, import_react_query.useQueryClient)();
173
173
  const app = queryClient.getQueryData(["app"]);
174
+ const [open, setOpen] = (0, import_react.useState)("Details");
175
+ const section = (title) => ({
176
+ active: open === title,
177
+ onClick: () => setOpen(title),
178
+ title
179
+ });
174
180
  const methods = (0, import_form.useForm)({
175
181
  resolver: (0, import_yup.resolver)(
176
182
  import_yup.default.object({
@@ -197,6 +203,7 @@ const FormOrganizationCampaignPageEdit = ({
197
203
  const { control, handleSubmit, formState, getValues, reset } = methods;
198
204
  const onSubmit = async ({
199
205
  description,
206
+ descriptions,
200
207
  gallery,
201
208
  headline,
202
209
  images: {
@@ -212,6 +219,9 @@ const FormOrganizationCampaignPageEdit = ({
212
219
  const args = {
213
220
  body: {
214
221
  description,
222
+ // @story pages/build
223
+ // Each image's own Description, saved with the rest of the page.
224
+ descriptions: descriptions || {},
215
225
  headline,
216
226
  gallery: gallery.map(({ id }) => id),
217
227
  images: {
@@ -246,7 +256,8 @@ const FormOrganizationCampaignPageEdit = ({
246
256
  import_form2.default,
247
257
  {
248
258
  ...{
249
- className: "relative w-full space-y-6",
259
+ // Divided, Save under the last section.
260
+ className: "relative w-full divide-y divide-gray [&>*]:py-6 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0",
250
261
  onSubmit: handleSubmit(onSubmit)
251
262
  },
252
263
  children: [
@@ -255,9 +266,8 @@ const FormOrganizationCampaignPageEdit = ({
255
266
  {
256
267
  ...{
257
268
  ...props,
258
- error: errors == null ? void 0 : errors[0],
259
- open: true,
260
- title: "Details"
269
+ ...section("Details"),
270
+ error: errors == null ? void 0 : errors[0]
261
271
  },
262
272
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
263
273
  import_fieldset.default,
@@ -326,8 +336,8 @@ const FormOrganizationCampaignPageEdit = ({
326
336
  {
327
337
  ...{
328
338
  ...props,
329
- error: errors == null ? void 0 : errors[1],
330
- title: "Media"
339
+ ...section("Media"),
340
+ error: errors == null ? void 0 : errors[1]
331
341
  },
332
342
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
333
343
  import_fieldset.default,
@@ -354,8 +364,8 @@ const FormOrganizationCampaignPageEdit = ({
354
364
  {
355
365
  ...{
356
366
  ...props,
357
- error: errors == null ? void 0 : errors[2],
358
- title: "Style"
367
+ ...section("Style"),
368
+ error: errors == null ? void 0 : errors[2]
359
369
  },
360
370
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
361
371
  import_input_fields.InputFieldsStyle,
@@ -372,7 +382,6 @@ const FormOrganizationCampaignPageEdit = ({
372
382
  import_fieldset.default,
373
383
  {
374
384
  ...{
375
- className: "pt-6",
376
385
  disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
377
386
  },
378
387
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
2
3
  import { constants } from "@drawbridge/drawbridge-utils";
3
4
  import { request } from "@drawbridge/drawbridge-utils/fetch";
4
5
  import yup, { resolver } from "../shared/lib/yup.mjs";
@@ -13,8 +14,7 @@ import Button from "../shared/button.mjs";
13
14
  import Accordion from "./accordion.mjs";
14
15
  import { InputFieldsDetails, InputFieldsMedia, InputFieldsPage, InputFieldsStyle, schemas } from "./input-fields.mjs";
15
16
  const props = {
16
- className: "p-6 bg-white rounded border border-gray",
17
- classNamePanel: "mt-6 pt-6 border-t border-gray"
17
+ classNamePanel: "mt-6"
18
18
  };
19
19
  const FormOrganizationCampaignPage = ({
20
20
  canManageBrands,
@@ -138,6 +138,12 @@ const FormOrganizationCampaignPageEdit = ({
138
138
  var _a, _b, _c, _d, _e, _f;
139
139
  const queryClient = useQueryClient();
140
140
  const app = queryClient.getQueryData(["app"]);
141
+ const [open, setOpen] = useState("Details");
142
+ const section = (title) => ({
143
+ active: open === title,
144
+ onClick: () => setOpen(title),
145
+ title
146
+ });
141
147
  const methods = useForm({
142
148
  resolver: resolver(
143
149
  yup.object({
@@ -164,6 +170,7 @@ const FormOrganizationCampaignPageEdit = ({
164
170
  const { control, handleSubmit, formState, getValues, reset } = methods;
165
171
  const onSubmit = async ({
166
172
  description,
173
+ descriptions,
167
174
  gallery,
168
175
  headline,
169
176
  images: {
@@ -179,6 +186,9 @@ const FormOrganizationCampaignPageEdit = ({
179
186
  const args = {
180
187
  body: {
181
188
  description,
189
+ // @story pages/build
190
+ // Each image's own Description, saved with the rest of the page.
191
+ descriptions: descriptions || {},
182
192
  headline,
183
193
  gallery: gallery.map(({ id }) => id),
184
194
  images: {
@@ -213,7 +223,8 @@ const FormOrganizationCampaignPageEdit = ({
213
223
  Form,
214
224
  {
215
225
  ...{
216
- className: "relative w-full space-y-6",
226
+ // Divided, Save under the last section.
227
+ className: "relative w-full divide-y divide-gray [&>*]:py-6 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0",
217
228
  onSubmit: handleSubmit(onSubmit)
218
229
  },
219
230
  children: [
@@ -222,9 +233,8 @@ const FormOrganizationCampaignPageEdit = ({
222
233
  {
223
234
  ...{
224
235
  ...props,
225
- error: errors == null ? void 0 : errors[0],
226
- open: true,
227
- title: "Details"
236
+ ...section("Details"),
237
+ error: errors == null ? void 0 : errors[0]
228
238
  },
229
239
  children: /* @__PURE__ */ jsxs(
230
240
  Fieldset,
@@ -293,8 +303,8 @@ const FormOrganizationCampaignPageEdit = ({
293
303
  {
294
304
  ...{
295
305
  ...props,
296
- error: errors == null ? void 0 : errors[1],
297
- title: "Media"
306
+ ...section("Media"),
307
+ error: errors == null ? void 0 : errors[1]
298
308
  },
299
309
  children: /* @__PURE__ */ jsx(
300
310
  Fieldset,
@@ -321,8 +331,8 @@ const FormOrganizationCampaignPageEdit = ({
321
331
  {
322
332
  ...{
323
333
  ...props,
324
- error: errors == null ? void 0 : errors[2],
325
- title: "Style"
334
+ ...section("Style"),
335
+ error: errors == null ? void 0 : errors[2]
326
336
  },
327
337
  children: /* @__PURE__ */ jsx(
328
338
  InputFieldsStyle,
@@ -339,7 +349,6 @@ const FormOrganizationCampaignPageEdit = ({
339
349
  Fieldset,
340
350
  {
341
351
  ...{
342
- className: "pt-6",
343
352
  disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
344
353
  },
345
354
  children: /* @__PURE__ */ jsx(
@@ -62,7 +62,7 @@ const FormOrganizationCampaignPrizeEdit = ({
62
62
  const queryClient = (0, import_react_query.useQueryClient)();
63
63
  const app = queryClient.getQueryData(["app"]);
64
64
  const currencies = queryClient.getQueryData(["currencies"]);
65
- const { control, handleSubmit, formState, getValues, reset } = (0, import_form.useForm)({
65
+ const { control, handleSubmit, formState, getValues, reset, setValue } = (0, import_form.useForm)({
66
66
  resolver: (0, import_yup.resolver)(
67
67
  import_yup.default.object({
68
68
  description: import_yup.default.string().label("Description").nullable().max(150),
@@ -83,9 +83,14 @@ const FormOrganizationCampaignPrizeEdit = ({
83
83
  control,
84
84
  name: "currency"
85
85
  });
86
+ const described = (0, import_form.useWatch)({
87
+ control,
88
+ name: "descriptions.primary"
89
+ });
86
90
  const onSubmit = async ({
87
91
  currency: currency2,
88
92
  description,
93
+ descriptions,
89
94
  images,
90
95
  inventory,
91
96
  shipping,
@@ -100,6 +105,7 @@ const FormOrganizationCampaignPrizeEdit = ({
100
105
  body: {
101
106
  currency: currency2 == null ? void 0 : currency2.code,
102
107
  description,
108
+ descriptions: descriptions || {},
103
109
  images: {
104
110
  primary: ((_a2 = images == null ? void 0 : images.primary) == null ? void 0 : _a2.id) || null
105
111
  },
@@ -321,11 +327,16 @@ const FormOrganizationCampaignPrizeEdit = ({
321
327
  import_input_file.default,
322
328
  {
323
329
  ...{
330
+ description: described,
324
331
  endpoint: "/organization/" + (organization == null ? void 0 : organization.id),
325
332
  onChange: (val) => {
326
333
  onChange(val);
327
334
  onUpdate(getValues());
328
335
  },
336
+ onDescription: (text) => {
337
+ setValue("descriptions.primary", text, { shouldDirty: true });
338
+ onUpdate(getValues());
339
+ },
329
340
  organization,
330
341
  type: "image",
331
342
  value: value || ""
@@ -30,7 +30,7 @@ const FormOrganizationCampaignPrizeEdit = ({
30
30
  const queryClient = useQueryClient();
31
31
  const app = queryClient.getQueryData(["app"]);
32
32
  const currencies = queryClient.getQueryData(["currencies"]);
33
- const { control, handleSubmit, formState, getValues, reset } = useForm({
33
+ const { control, handleSubmit, formState, getValues, reset, setValue } = useForm({
34
34
  resolver: resolver(
35
35
  yup.object({
36
36
  description: yup.string().label("Description").nullable().max(150),
@@ -51,9 +51,14 @@ const FormOrganizationCampaignPrizeEdit = ({
51
51
  control,
52
52
  name: "currency"
53
53
  });
54
+ const described = useWatch({
55
+ control,
56
+ name: "descriptions.primary"
57
+ });
54
58
  const onSubmit = async ({
55
59
  currency: currency2,
56
60
  description,
61
+ descriptions,
57
62
  images,
58
63
  inventory,
59
64
  shipping,
@@ -68,6 +73,7 @@ const FormOrganizationCampaignPrizeEdit = ({
68
73
  body: {
69
74
  currency: currency2 == null ? void 0 : currency2.code,
70
75
  description,
76
+ descriptions: descriptions || {},
71
77
  images: {
72
78
  primary: ((_a2 = images == null ? void 0 : images.primary) == null ? void 0 : _a2.id) || null
73
79
  },
@@ -289,11 +295,16 @@ const FormOrganizationCampaignPrizeEdit = ({
289
295
  InputFile,
290
296
  {
291
297
  ...{
298
+ description: described,
292
299
  endpoint: "/organization/" + (organization == null ? void 0 : organization.id),
293
300
  onChange: (val) => {
294
301
  onChange(val);
295
302
  onUpdate(getValues());
296
303
  },
304
+ onDescription: (text) => {
305
+ setValue("descriptions.primary", text, { shouldDirty: true });
306
+ onUpdate(getValues());
307
+ },
297
308
  organization,
298
309
  type: "image",
299
310
  value: value || ""
@@ -0,0 +1,223 @@
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_section_exports = {};
29
+ __export(form_organization_campaign_section_exports, {
30
+ default: () => form_organization_campaign_section_default
31
+ });
32
+ module.exports = __toCommonJS(form_organization_campaign_section_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_form = require("../shared/lib/form");
35
+ var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
36
+ var import_yup = __toESM(require("../shared/lib/yup"));
37
+ var import_form2 = __toESM(require("../shared/form"));
38
+ var import_fieldset = __toESM(require("../shared/fieldset"));
39
+ var import_input_group = __toESM(require("../input-group"));
40
+ var import_input_text = __toESM(require("../input-text"));
41
+ var import_input_textarea = __toESM(require("../input-textarea"));
42
+ var import_input_switch = __toESM(require("../shared/input-switch"));
43
+ var import_button = __toESM(require("../shared/button"));
44
+ const FormOrganizationCampaignSection = ({
45
+ disabled,
46
+ onError,
47
+ onSuccess,
48
+ values
49
+ }) => {
50
+ var _a;
51
+ const order = (values == null ? void 0 : values.type) === "order";
52
+ const { control, formState, handleSubmit } = (0, import_form.useForm)({
53
+ resolver: (0, import_yup.resolver)(
54
+ import_yup.default.object({
55
+ description: import_yup.default.string().label("Description").max(300).nullable(),
56
+ enabled: import_yup.default.boolean(),
57
+ prices: import_yup.default.boolean(),
58
+ title: import_yup.default.string().label("Title").required().max(150)
59
+ })
60
+ ),
61
+ values: {
62
+ description: (values == null ? void 0 : values.description) || "",
63
+ enabled: (values == null ? void 0 : values.enabled) !== false,
64
+ prices: ((_a = values == null ? void 0 : values.settings) == null ? void 0 : _a.prices) !== false,
65
+ title: (values == null ? void 0 : values.title) || ""
66
+ }
67
+ });
68
+ const onSubmit = async ({
69
+ description,
70
+ enabled,
71
+ prices,
72
+ title
73
+ }) => {
74
+ try {
75
+ const response = await (0, import_fetch.request)({
76
+ body: {
77
+ description: description || null,
78
+ ...order && {
79
+ enabled,
80
+ prices
81
+ },
82
+ title
83
+ },
84
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/section/" + (values == null ? void 0 : values.id),
85
+ method: "PUT"
86
+ });
87
+ onSuccess(response);
88
+ } catch (error) {
89
+ onError(error);
90
+ }
91
+ };
92
+ const toggle = (key, label, message) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ import_form.Controller,
94
+ {
95
+ ...{
96
+ control,
97
+ name: key,
98
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ import_input_group.default,
100
+ {
101
+ ...{
102
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
103
+ import_input_switch.default,
104
+ {
105
+ ...{
106
+ onChange,
107
+ value: Boolean(value)
108
+ }
109
+ }
110
+ ),
111
+ label,
112
+ message
113
+ }
114
+ }
115
+ )
116
+ }
117
+ },
118
+ key
119
+ );
120
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
121
+ import_form2.default,
122
+ {
123
+ ...{
124
+ className: "relative w-full space-y-6",
125
+ onSubmit: handleSubmit(onSubmit)
126
+ },
127
+ children: [
128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
129
+ import_fieldset.default,
130
+ {
131
+ ...{
132
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
133
+ },
134
+ children: [
135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
+ import_form.Controller,
137
+ {
138
+ ...{
139
+ control,
140
+ name: "title",
141
+ render: ({ field: { value, onChange } }) => {
142
+ var _a2, _b;
143
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
+ import_input_group.default,
145
+ {
146
+ ...{
147
+ error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.title) == null ? void 0 : _b.message,
148
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
+ import_input_text.default,
150
+ {
151
+ ...{
152
+ onChange,
153
+ value: value || ""
154
+ }
155
+ }
156
+ ),
157
+ label: "Title"
158
+ }
159
+ }
160
+ );
161
+ }
162
+ }
163
+ }
164
+ ),
165
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
+ import_form.Controller,
167
+ {
168
+ ...{
169
+ control,
170
+ name: "description",
171
+ render: ({ field: { value, onChange } }) => {
172
+ var _a2, _b;
173
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
+ import_input_group.default,
175
+ {
176
+ ...{
177
+ error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.description) == null ? void 0 : _b.message,
178
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
+ import_input_textarea.default,
180
+ {
181
+ ...{
182
+ onChange,
183
+ value: value || ""
184
+ }
185
+ }
186
+ ),
187
+ label: "Description",
188
+ message: "Shown under the title on the share page."
189
+ }
190
+ }
191
+ );
192
+ }
193
+ }
194
+ }
195
+ ),
196
+ order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept."),
197
+ order && toggle("prices", "Show prices", "Show each item's price and an estimated total.")
198
+ ]
199
+ }
200
+ ),
201
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
202
+ import_fieldset.default,
203
+ {
204
+ ...{
205
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
206
+ },
207
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
208
+ import_button.default,
209
+ {
210
+ ...{
211
+ loading: formState == null ? void 0 : formState.isSubmitting,
212
+ type: "submit"
213
+ },
214
+ children: "Save"
215
+ }
216
+ )
217
+ }
218
+ )
219
+ ]
220
+ }
221
+ );
222
+ };
223
+ var form_organization_campaign_section_default = FormOrganizationCampaignSection;