@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
@@ -73,8 +73,9 @@ const FormOrganizationExport = ({
73
73
  const queryClient = (0, import_react_query.useQueryClient)();
74
74
  const capabilities = ((_a = queryClient.getQueryData(["organization", values.organization])) == null ? void 0 : _a.capabilities) || {};
75
75
  const campaigns = canRead((_b = capabilities.campaigns) == null ? void 0 : _b.leads) && canRead((_c = capabilities.campaigns) == null ? void 0 : _c.settings);
76
+ const segments = canRead(capabilities.segments);
76
77
  const availability = {
77
- contacts: canRead(capabilities.contacts) && canRead(capabilities.segments),
78
+ contacts: canRead(capabilities.contacts),
78
79
  leads: campaigns,
79
80
  submissions: campaigns
80
81
  };
@@ -90,11 +91,7 @@ const FormOrganizationExport = ({
90
91
  then: (schema) => schema.required(),
91
92
  otherwise: (schema) => schema.nullable()
92
93
  }),
93
- segment: import_yup.default.object().label("Segment").nullable().when("type", {
94
- is: "contacts",
95
- then: (schema) => schema.required(),
96
- otherwise: (schema) => schema.nullable()
97
- })
94
+ segment: import_yup.default.object().label("Segment").nullable()
98
95
  })
99
96
  ),
100
97
  values: {
@@ -229,7 +226,7 @@ const FormOrganizationExport = ({
229
226
  }
230
227
  }
231
228
  ),
232
- type === "contacts" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
+ type === "contacts" && segments && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
233
230
  import_form.Controller,
234
231
  {
235
232
  ...{
@@ -41,8 +41,9 @@ const FormOrganizationExport = ({
41
41
  const queryClient = useQueryClient();
42
42
  const capabilities = ((_a = queryClient.getQueryData(["organization", values.organization])) == null ? void 0 : _a.capabilities) || {};
43
43
  const campaigns = canRead((_b = capabilities.campaigns) == null ? void 0 : _b.leads) && canRead((_c = capabilities.campaigns) == null ? void 0 : _c.settings);
44
+ const segments = canRead(capabilities.segments);
44
45
  const availability = {
45
- contacts: canRead(capabilities.contacts) && canRead(capabilities.segments),
46
+ contacts: canRead(capabilities.contacts),
46
47
  leads: campaigns,
47
48
  submissions: campaigns
48
49
  };
@@ -58,11 +59,7 @@ const FormOrganizationExport = ({
58
59
  then: (schema) => schema.required(),
59
60
  otherwise: (schema) => schema.nullable()
60
61
  }),
61
- segment: yup.object().label("Segment").nullable().when("type", {
62
- is: "contacts",
63
- then: (schema) => schema.required(),
64
- otherwise: (schema) => schema.nullable()
65
- })
62
+ segment: yup.object().label("Segment").nullable()
66
63
  })
67
64
  ),
68
65
  values: {
@@ -197,7 +194,7 @@ const FormOrganizationExport = ({
197
194
  }
198
195
  }
199
196
  ),
200
- type === "contacts" && /* @__PURE__ */ jsx(
197
+ type === "contacts" && segments && /* @__PURE__ */ jsx(
201
198
  Controller,
202
199
  {
203
200
  ...{
@@ -38,6 +38,7 @@ var import_react = require("react");
38
38
  var import_form = require("../shared/lib/form");
39
39
  var import_yup = __toESM(require("../shared/lib/yup"));
40
40
  var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
41
+ var import_domains = require("@drawbridge/drawbridge-utils/domains");
41
42
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
42
43
  var import_list_resource = __toESM(require("./list-resource"));
43
44
  var import_link_back = __toESM(require("./link-back"));
@@ -492,7 +493,7 @@ const FormOrganizationIdentityEmail = ({
492
493
  onSuccess,
493
494
  values
494
495
  }) => {
495
- var _a, _b, _c;
496
+ var _a, _b, _c, _d;
496
497
  const records = (values == null ? void 0 : values.records) || [];
497
498
  const [verifying, setVerifying] = (0, import_react.useState)(false);
498
499
  const verify = async () => {
@@ -526,21 +527,18 @@ const FormOrganizationIdentityEmail = ({
526
527
  // the part before the @ is free. So the domain is immutable once saved and
527
528
  // the address is editable at will, and neither touches the records.
528
529
  values: {
529
- address: String((values == null ? void 0 : values.from) || "").split("@")[0] || "",
530
- domain: (values == null ? void 0 : values.domain) || String((values == null ? void 0 : values.from) || "").split("@")[1] || ""
530
+ address: String((values == null ? void 0 : values.from) || "").split("@")[0] || ""
531
531
  },
532
- // ONE FIELD PER STATE. Creating asks for the domain and nothing else — the
533
- // address starts as hello@ — and once the row exists the address is the
534
- // only thing left to change. So the form validates whichever it shows.
532
+ // Creating asks for nothing: the domain is the website's and the address
533
+ // starts as hello@. Once the row exists the address is the one field.
535
534
  resolver: (0, import_yup.resolver)(
536
535
  (values == null ? void 0 : values.id) ? import_yup.default.object({
537
536
  address: import_yup.default.string().label("Address").max(64).matches(/^[a-z0-9._%+-]+$/i, { excludeEmptyString: true, message: "Letters, numbers and . _ % + - only \u2014 no @" })
538
- }) : import_yup.default.object({
539
- domain: import_yup.default.string().label("Domain").required().max(253).matches(/^([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/i, "Enter a domain like yourbrand.com")
540
- })
537
+ }) : import_yup.default.object({})
541
538
  )
542
539
  });
543
- const onSubmit = async ({ address, domain }) => {
540
+ const website = (0, import_domains.normalizeDomain)(values == null ? void 0 : values.website);
541
+ const onSubmit = async ({ address }) => {
544
542
  try {
545
543
  const response = await (0, import_fetch.request)({
546
544
  // CREATE AND UPDATE ARE TWO ROUTES with two shapes, and the form uses
@@ -548,7 +546,7 @@ const FormOrganizationIdentityEmail = ({
548
546
  // both fields; PUT changes the address and nothing else. The domain
549
547
  // field is locked once a row exists, and the api would refuse a change
550
548
  // regardless — a different domain is a removal, then a new POST.
551
- body: (values == null ? void 0 : values.id) ? { address: address || "hello" } : { domain },
549
+ body: (values == null ? void 0 : values.id) ? { address: address || "hello" } : {},
552
550
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/identity/email",
553
551
  method: (values == null ? void 0 : values.id) ? "PUT" : "POST"
554
552
  });
@@ -557,23 +555,35 @@ const FormOrganizationIdentityEmail = ({
557
555
  onError(error);
558
556
  }
559
557
  };
560
- if (!(values == null ? void 0 : values.id) && !((_a = values == null ? void 0 : values.address) == null ? void 0 : _a.address)) {
561
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
558
+ if (!(values == null ? void 0 : values.id) && (!((_a = values == null ? void 0 : values.address) == null ? void 0 : _a.address) || !website)) {
559
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
562
560
  "div",
563
561
  {
564
562
  ...{
565
- className: "p-6"
563
+ className: "p-6 space-y-4"
566
564
  },
567
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
568
- import_card_task.default,
569
- {
570
- ...{
571
- // The api's BUSINESS_ADDRESS_REQUIRED, word for word.
572
- message: "You must add your business address",
573
- type: "error"
565
+ children: [
566
+ !website && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
567
+ import_card_task.default,
568
+ {
569
+ ...{
570
+ // The api's WEBSITE_REQUIRED, word for word.
571
+ message: "You must add your website",
572
+ type: "error"
573
+ }
574
574
  }
575
- }
576
- )
575
+ ),
576
+ !((_b = values == null ? void 0 : values.address) == null ? void 0 : _b.address) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
577
+ import_card_task.default,
578
+ {
579
+ ...{
580
+ // The api's BUSINESS_ADDRESS_REQUIRED, word for word.
581
+ message: "You must add your business address",
582
+ type: "error"
583
+ }
584
+ }
585
+ )
586
+ ]
577
587
  }
578
588
  );
579
589
  }
@@ -614,7 +624,7 @@ const FormOrganizationIdentityEmail = ({
614
624
  ...{
615
625
  index: 1,
616
626
  state: states.address,
617
- title: (values == null ? void 0 : values.id) ? "Your email address" : "Enter your domain"
627
+ title: (values == null ? void 0 : values.id) ? "Your email address" : "Your domain"
618
628
  },
619
629
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
620
630
  import_fieldset.default,
@@ -624,35 +634,20 @@ const FormOrganizationIdentityEmail = ({
624
634
  },
625
635
  children: [
626
636
  !(values == null ? void 0 : values.id) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
627
- import_form.Controller,
637
+ import_input_group.default,
628
638
  {
629
639
  ...{
630
- control,
631
- name: "domain",
632
- render: ({ field: { value, onChange } }) => {
633
- var _a2, _b2;
634
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
635
- import_input_group.default,
636
- {
637
- ...{
638
- error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.domain) == null ? void 0 : _b2.message,
639
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
640
- import_input_text.default,
641
- {
642
- ...{
643
- onChange,
644
- placeholder: "yourbrand.com",
645
- type: "text",
646
- value: value || ""
647
- }
648
- }
649
- ),
650
- label: "Domain",
651
- message: "A domain you own and can add DNS records to."
652
- }
640
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
641
+ import_input_text.default,
642
+ {
643
+ ...{
644
+ readOnly: true,
645
+ value: website
653
646
  }
654
- );
655
- }
647
+ }
648
+ ),
649
+ label: "Domain",
650
+ message: "Your website's domain. To use another, change Website in the Business section first."
656
651
  }
657
652
  }
658
653
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -718,7 +713,7 @@ const FormOrganizationIdentityEmail = ({
718
713
  import_card_task.default,
719
714
  {
720
715
  ...{
721
- message: ((_c = (_b = values == null ? void 0 : values.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message) || "We could not find the records. Check them and try again.",
716
+ message: ((_d = (_c = values == null ? void 0 : values.errors) == null ? void 0 : _c[0]) == null ? void 0 : _d.message) || "We could not find the records. Check them and try again.",
722
717
  type: "error"
723
718
  }
724
719
  }
@@ -4,6 +4,7 @@ import { Fragment, useState } from "react";
4
4
  import { useForm, Controller } from "../shared/lib/form.mjs";
5
5
  import yup, { resolver } from "../shared/lib/yup.mjs";
6
6
  import { formatCurrency } from "@drawbridge/drawbridge-utils";
7
+ import { normalizeDomain } from "@drawbridge/drawbridge-utils/domains";
7
8
  import { request } from "@drawbridge/drawbridge-utils/fetch";
8
9
  import ListResource from "./list-resource.mjs";
9
10
  import LinkBack from "./link-back.mjs";
@@ -458,7 +459,7 @@ const FormOrganizationIdentityEmail = ({
458
459
  onSuccess,
459
460
  values
460
461
  }) => {
461
- var _a, _b, _c;
462
+ var _a, _b, _c, _d;
462
463
  const records = (values == null ? void 0 : values.records) || [];
463
464
  const [verifying, setVerifying] = useState(false);
464
465
  const verify = async () => {
@@ -492,21 +493,18 @@ const FormOrganizationIdentityEmail = ({
492
493
  // the part before the @ is free. So the domain is immutable once saved and
493
494
  // the address is editable at will, and neither touches the records.
494
495
  values: {
495
- address: String((values == null ? void 0 : values.from) || "").split("@")[0] || "",
496
- domain: (values == null ? void 0 : values.domain) || String((values == null ? void 0 : values.from) || "").split("@")[1] || ""
496
+ address: String((values == null ? void 0 : values.from) || "").split("@")[0] || ""
497
497
  },
498
- // ONE FIELD PER STATE. Creating asks for the domain and nothing else — the
499
- // address starts as hello@ — and once the row exists the address is the
500
- // only thing left to change. So the form validates whichever it shows.
498
+ // Creating asks for nothing: the domain is the website's and the address
499
+ // starts as hello@. Once the row exists the address is the one field.
501
500
  resolver: resolver(
502
501
  (values == null ? void 0 : values.id) ? yup.object({
503
502
  address: yup.string().label("Address").max(64).matches(/^[a-z0-9._%+-]+$/i, { excludeEmptyString: true, message: "Letters, numbers and . _ % + - only \u2014 no @" })
504
- }) : yup.object({
505
- domain: yup.string().label("Domain").required().max(253).matches(/^([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/i, "Enter a domain like yourbrand.com")
506
- })
503
+ }) : yup.object({})
507
504
  )
508
505
  });
509
- const onSubmit = async ({ address, domain }) => {
506
+ const website = normalizeDomain(values == null ? void 0 : values.website);
507
+ const onSubmit = async ({ address }) => {
510
508
  try {
511
509
  const response = await request({
512
510
  // CREATE AND UPDATE ARE TWO ROUTES with two shapes, and the form uses
@@ -514,7 +512,7 @@ const FormOrganizationIdentityEmail = ({
514
512
  // both fields; PUT changes the address and nothing else. The domain
515
513
  // field is locked once a row exists, and the api would refuse a change
516
514
  // regardless — a different domain is a removal, then a new POST.
517
- body: (values == null ? void 0 : values.id) ? { address: address || "hello" } : { domain },
515
+ body: (values == null ? void 0 : values.id) ? { address: address || "hello" } : {},
518
516
  endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/identity/email",
519
517
  method: (values == null ? void 0 : values.id) ? "PUT" : "POST"
520
518
  });
@@ -523,23 +521,35 @@ const FormOrganizationIdentityEmail = ({
523
521
  onError(error);
524
522
  }
525
523
  };
526
- if (!(values == null ? void 0 : values.id) && !((_a = values == null ? void 0 : values.address) == null ? void 0 : _a.address)) {
527
- return /* @__PURE__ */ jsx(
524
+ if (!(values == null ? void 0 : values.id) && (!((_a = values == null ? void 0 : values.address) == null ? void 0 : _a.address) || !website)) {
525
+ return /* @__PURE__ */ jsxs(
528
526
  "div",
529
527
  {
530
528
  ...{
531
- className: "p-6"
529
+ className: "p-6 space-y-4"
532
530
  },
533
- children: /* @__PURE__ */ jsx(
534
- CardTask,
535
- {
536
- ...{
537
- // The api's BUSINESS_ADDRESS_REQUIRED, word for word.
538
- message: "You must add your business address",
539
- type: "error"
531
+ children: [
532
+ !website && /* @__PURE__ */ jsx(
533
+ CardTask,
534
+ {
535
+ ...{
536
+ // The api's WEBSITE_REQUIRED, word for word.
537
+ message: "You must add your website",
538
+ type: "error"
539
+ }
540
540
  }
541
- }
542
- )
541
+ ),
542
+ !((_b = values == null ? void 0 : values.address) == null ? void 0 : _b.address) && /* @__PURE__ */ jsx(
543
+ CardTask,
544
+ {
545
+ ...{
546
+ // The api's BUSINESS_ADDRESS_REQUIRED, word for word.
547
+ message: "You must add your business address",
548
+ type: "error"
549
+ }
550
+ }
551
+ )
552
+ ]
543
553
  }
544
554
  );
545
555
  }
@@ -580,7 +590,7 @@ const FormOrganizationIdentityEmail = ({
580
590
  ...{
581
591
  index: 1,
582
592
  state: states.address,
583
- title: (values == null ? void 0 : values.id) ? "Your email address" : "Enter your domain"
593
+ title: (values == null ? void 0 : values.id) ? "Your email address" : "Your domain"
584
594
  },
585
595
  children: /* @__PURE__ */ jsxs(
586
596
  Fieldset,
@@ -590,35 +600,20 @@ const FormOrganizationIdentityEmail = ({
590
600
  },
591
601
  children: [
592
602
  !(values == null ? void 0 : values.id) ? /* @__PURE__ */ jsx(
593
- Controller,
603
+ InputGroup,
594
604
  {
595
605
  ...{
596
- control,
597
- name: "domain",
598
- render: ({ field: { value, onChange } }) => {
599
- var _a2, _b2;
600
- return /* @__PURE__ */ jsx(
601
- InputGroup,
602
- {
603
- ...{
604
- error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.domain) == null ? void 0 : _b2.message,
605
- input: /* @__PURE__ */ jsx(
606
- InputText,
607
- {
608
- ...{
609
- onChange,
610
- placeholder: "yourbrand.com",
611
- type: "text",
612
- value: value || ""
613
- }
614
- }
615
- ),
616
- label: "Domain",
617
- message: "A domain you own and can add DNS records to."
618
- }
606
+ input: /* @__PURE__ */ jsx(
607
+ InputText,
608
+ {
609
+ ...{
610
+ readOnly: true,
611
+ value: website
619
612
  }
620
- );
621
- }
613
+ }
614
+ ),
615
+ label: "Domain",
616
+ message: "Your website's domain. To use another, change Website in the Business section first."
622
617
  }
623
618
  }
624
619
  ) : /* @__PURE__ */ jsx(
@@ -684,7 +679,7 @@ const FormOrganizationIdentityEmail = ({
684
679
  CardTask,
685
680
  {
686
681
  ...{
687
- message: ((_c = (_b = values == null ? void 0 : values.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message) || "We could not find the records. Check them and try again.",
682
+ message: ((_d = (_c = values == null ? void 0 : values.errors) == null ? void 0 : _c[0]) == null ? void 0 : _d.message) || "We could not find the records. Check them and try again.",
688
683
  type: "error"
689
684
  }
690
685
  }