@drawbridge/components 0.1.48 → 0.1.49

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 (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +0 -3
  12. package/dist/bridge/lib/entry.mjs +0 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +122 -237
  16. package/dist/bridge/template-layout.mjs +122 -237
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +0 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. package/types/shared/order-summary.d.ts +0 -19
@@ -8,9 +8,7 @@ const connectionControls = (connection) => {
8
8
  remove: (connection == null ? void 0 : connection.id) ? ((_a = connection == null ? void 0 : connection.connect) == null ? void 0 : _a.manage) && !paused ? "manage" : "disconnect" : null
9
9
  };
10
10
  };
11
- const savable = ({ actions, connected, inputs }) => !connected || (inputs || []).length > 0 || Boolean(actions == null ? void 0 : actions.update);
12
11
  export {
13
12
  connectionControls,
14
- isConnected,
15
- savable
13
+ isConnected
16
14
  };
@@ -51,7 +51,7 @@ const MAX_ADS = 5;
51
51
  const adsLimit = (count) => count >= MAX_ADS ? "A campaign can have up to " + MAX_ADS + " advertisements." : null;
52
52
  const advertisementsKey = (params) => ["campaign-advertisements", params == null ? void 0 : params.organization, params == null ? void 0 : params.campaign];
53
53
  const AFTER = ["message", "missions", "advertisements"];
54
- const once = ["birthday", "email", "name", "note", "phone", "pickup"];
54
+ const once = ["email", "name", "note", "phone", "pickup"];
55
55
  const addedOnce = (slug, keys = []) => once.includes(slug) && (keys || []).includes(slug);
56
56
  const planLocked = (section) => Boolean(section == null ? void 0 : section.task) && Boolean((section == null ? void 0 : section.locked) || (section == null ? void 0 : section.disabled));
57
57
  const giveawayLocked = (section) => (section == null ? void 0 : section.type) === "order" && Boolean(section == null ? void 0 : section.giveaway);
@@ -4,7 +4,7 @@ const MAX_ADS = 5;
4
4
  const adsLimit = (count) => count >= MAX_ADS ? "A campaign can have up to " + MAX_ADS + " advertisements." : null;
5
5
  const advertisementsKey = (params) => ["campaign-advertisements", params == null ? void 0 : params.organization, params == null ? void 0 : params.campaign];
6
6
  const AFTER = ["message", "missions", "advertisements"];
7
- const once = ["birthday", "email", "name", "note", "phone", "pickup"];
7
+ const once = ["email", "name", "note", "phone", "pickup"];
8
8
  const addedOnce = (slug, keys = []) => once.includes(slug) && (keys || []).includes(slug);
9
9
  const planLocked = (section) => Boolean(section == null ? void 0 : section.task) && Boolean((section == null ? void 0 : section.locked) || (section == null ? void 0 : section.disabled));
10
10
  const giveawayLocked = (section) => (section == null ? void 0 : section.type) === "order" && Boolean(section == null ? void 0 : section.giveaway);
@@ -65,11 +65,7 @@ const create = async ({
65
65
  // Derived from the allowlist the api validates against, so a wrong
66
66
  // type is refused here for the same reason it would be refused
67
67
  // there — before two gigabytes move rather than after.
68
- //
69
- // @story products/digital-file
70
- // A digital file by its extension: a zip's mime differs by system
71
- // ( application/x-zip-compressed on Windows ).
72
- allowedFileTypes: type === "digital" ? (0, import_helpers.fileTypes)(type).map((extension) => "." + extension) : (0, import_helpers.fileMimes)(type),
68
+ allowedFileTypes: (0, import_helpers.fileMimes)(type),
73
69
  // One number for every type: only a video is large enough to reach
74
70
  // this path, and lib/yup.js enforces the per-type cap before a file
75
71
  // gets here. Defaults to the shared ceiling the api enforces; an
@@ -112,11 +108,6 @@ const create = async ({
112
108
  bytes: file == null ? void 0 : file.size,
113
109
  extension,
114
110
  filename: file == null ? void 0 : file.name,
115
- // @story products/digital-file
116
- // A digital file is stored private, out of the Library.
117
- ...type === "digital" && {
118
- private: true
119
- },
120
111
  type: primary
121
112
  },
122
113
  endpoint: url(),
@@ -1,7 +1,7 @@
1
1
  import { megabyte } from "@drawbridge/drawbridge-utils";
2
2
  import { uploadPartSize } from "@drawbridge/drawbridge-utils/upload";
3
3
  import { request } from "@drawbridge/drawbridge-utils/fetch";
4
- import { fileMimes, fileParts, fileSizeLimits, fileTypes } from "../../shared/lib/helpers.mjs";
4
+ import { fileMimes, fileParts, fileSizeLimits } from "../../shared/lib/helpers.mjs";
5
5
  const partSizeFor = uploadPartSize;
6
6
  const guard = (event) => {
7
7
  if (!isUploading(instance)) return;
@@ -30,11 +30,7 @@ const create = async ({
30
30
  // Derived from the allowlist the api validates against, so a wrong
31
31
  // type is refused here for the same reason it would be refused
32
32
  // there — before two gigabytes move rather than after.
33
- //
34
- // @story products/digital-file
35
- // A digital file by its extension: a zip's mime differs by system
36
- // ( application/x-zip-compressed on Windows ).
37
- allowedFileTypes: type === "digital" ? fileTypes(type).map((extension) => "." + extension) : fileMimes(type),
33
+ allowedFileTypes: fileMimes(type),
38
34
  // One number for every type: only a video is large enough to reach
39
35
  // this path, and lib/yup.js enforces the per-type cap before a file
40
36
  // gets here. Defaults to the shared ceiling the api enforces; an
@@ -77,11 +73,6 @@ const create = async ({
77
73
  bytes: file == null ? void 0 : file.size,
78
74
  extension,
79
75
  filename: file == null ? void 0 : file.name,
80
- // @story products/digital-file
81
- // A digital file is stored private, out of the Library.
82
- ...type === "digital" && {
83
- private: true
84
- },
85
76
  type: primary
86
77
  },
87
78
  endpoint: url(),
@@ -28,43 +28,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var order_sections_exports = {};
30
30
  __export(order_sections_exports, {
31
- FormFulfill: () => FormFulfill,
32
- OrderCustomer: () => OrderCustomer,
33
31
  OrderFulfillment: () => OrderFulfillment,
34
- OrderPayment: () => OrderPayment,
35
- OrderSummarySection: () => OrderSummarySection,
36
32
  fulfillmentControls: () => fulfillmentControls,
37
33
  useConfirm: () => useConfirm
38
34
  });
39
35
  module.exports = __toCommonJS(order_sections_exports);
40
36
  var import_jsx_runtime = require("react/jsx-runtime");
41
- var import_react = require("react");
42
37
  var import_react_query = require("@tanstack/react-query");
43
38
  var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
44
39
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
45
- var import_products = require("@drawbridge/drawbridge-utils/products");
46
- var import_form = require("../shared/lib/form");
47
- var import_helpers = require("../shared/lib/helpers");
48
40
  var import_hooks = require("./lib/hooks");
49
- var import_card_data_item = __toESM(require("./card-data-item"));
50
41
  var import_card_section = __toESM(require("./card-section"));
51
- var import_card_setting = __toESM(require("./card-setting"));
52
42
  var import_card_task = __toESM(require("./card-task"));
53
- var import_embed_stripe = __toESM(require("./embed-stripe"));
54
43
  var import_form_action = __toESM(require("./form-action"));
55
44
  var import_paged = __toESM(require("./paged"));
56
- var import_address_lines = __toESM(require("../shared/address-lines"));
57
45
  var import_badge = __toESM(require("../shared/badge"));
58
46
  var import_button = __toESM(require("../shared/button"));
59
- var import_empty = __toESM(require("../shared/empty"));
60
- var import_fieldset = __toESM(require("../shared/fieldset"));
61
- var import_form2 = __toESM(require("../shared/form"));
62
- var import_order_summary = __toESM(require("../shared/order-summary"));
63
- var import_input_checkbox = __toESM(require("../input-checkbox"));
64
- var import_input_group = __toESM(require("../input-group"));
65
- var import_input_select = __toESM(require("../input-select"));
66
- var import_input_text = __toESM(require("../input-text"));
67
- var import_external = __toESM(require("../icons/external"));
68
47
  var import_plus = __toESM(require("../icons/plus"));
69
48
  const date = (value) => (0, import_drawbridge_utils.formatDateString)({
70
49
  date: value,
@@ -83,8 +62,8 @@ const useConfirm = () => {
83
62
  const { onError } = (0, import_hooks.useCallbacks)({
84
63
  queryClient
85
64
  });
86
- return ({ action, body, endpoint, message, method = "PUT", onSuccess, task, title, warning }) => modal.open({
87
- title: title || action,
65
+ return ({ action, body, endpoint, message, method = "PUT", onSuccess, task, warning }) => modal.open({
66
+ title: action,
88
67
  message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
89
68
  import_form_action.default,
90
69
  {
@@ -131,305 +110,19 @@ const fulfillmentControls = ({ manage, order }) => {
131
110
  var _a;
132
111
  const editable = Boolean(manage) && (order == null ? void 0 : order.status) === "open";
133
112
  return {
134
- add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled" && (order == null ? void 0 : order.payment) !== "refunded",
113
+ add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled",
135
114
  cancel: editable
136
115
  };
137
116
  };
138
- const stripeOrder = (order) => {
139
- var _a;
140
- return ((_a = order == null ? void 0 : order.provider) == null ? void 0 : _a.slug) === "stripe";
141
- };
142
- const moneyOf = (order) => (value) => (0, import_drawbridge_utils.formatCurrency)({ code: ((order == null ? void 0 : order.currency) || "usd").toUpperCase(), value: value || 0 });
143
- const FormFulfill = ({ endpoint, onError, onSuccess }) => {
144
- const { control, formState, handleSubmit } = (0, import_form.useForm)({
145
- values: {
146
- carrier: import_products.CARRIERS[0],
147
- emailed: true,
148
- tracking: ""
149
- }
150
- });
151
- const onSubmit = async ({ carrier, emailed, tracking }) => {
152
- try {
153
- onSuccess(await (0, import_fetch.request)({
154
- body: {
155
- carrier,
156
- emailed: Boolean(emailed),
157
- tracking: (tracking || "").trim()
158
- },
159
- endpoint: endpoint + "/fulfillment",
160
- method: "POST"
161
- }));
162
- } catch (error) {
163
- onError == null ? void 0 : onError(error);
164
- }
165
- };
166
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
167
- import_form2.default,
168
- {
169
- ...{
170
- className: "relative w-full space-y-6",
171
- onSubmit: handleSubmit(onSubmit)
172
- },
173
- children: [
174
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
175
- import_fieldset.default,
176
- {
177
- ...{
178
- className: "space-y-6",
179
- disabled: formState == null ? void 0 : formState.isSubmitting
180
- },
181
- children: [
182
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
- import_form.Controller,
184
- {
185
- ...{
186
- control,
187
- name: "carrier",
188
- render: ({ field: { onChange, value } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
- import_input_group.default,
190
- {
191
- ...{
192
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
- import_input_select.default,
194
- {
195
- ...{
196
- onChange,
197
- options: import_products.CARRIERS.map((carrier) => ({
198
- label: carrier,
199
- value: carrier
200
- })),
201
- value
202
- }
203
- }
204
- ),
205
- label: "Carrier"
206
- }
207
- }
208
- )
209
- }
210
- }
211
- ),
212
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
- import_form.Controller,
214
- {
215
- ...{
216
- control,
217
- name: "tracking",
218
- render: ({ field: { onChange, value } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
- import_input_group.default,
220
- {
221
- ...{
222
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
- import_input_text.default,
224
- {
225
- ...{
226
- onChange,
227
- value: value || ""
228
- }
229
- }
230
- ),
231
- label: "Tracking number"
232
- }
233
- }
234
- )
235
- }
236
- }
237
- ),
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
- import_form.Controller,
240
- {
241
- ...{
242
- control,
243
- name: "emailed",
244
- render: ({ field: { onChange, value } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
- import_input_checkbox.default,
246
- {
247
- ...{
248
- label: "Email the customer their tracking details",
249
- onChange,
250
- value
251
- }
252
- }
253
- )
254
- }
255
- }
256
- )
257
- ]
258
- }
259
- ),
260
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
- import_fieldset.default,
262
- {
263
- ...{
264
- disabled: formState == null ? void 0 : formState.isSubmitting
265
- },
266
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
267
- import_button.default,
268
- {
269
- ...{
270
- loading: formState == null ? void 0 : formState.isSubmitting,
271
- type: "submit"
272
- },
273
- children: "Mark as fulfilled"
274
- }
275
- )
276
- }
277
- )
278
- ]
279
- }
280
- );
281
- };
282
- const ShopifyFulfillment = ({ order }) => {
283
- var _a, _b, _c;
284
- const status = (0, import_helpers.statusBadge)("fulfillment", (_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status);
285
- const href = (0, import_products.shopifyOrderUrl)({ domain: (_b = order == null ? void 0 : order.source) == null ? void 0 : _b.domain, providerId: (_c = order == null ? void 0 : order.provider) == null ? void 0 : _c.id });
286
- return status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
287
- import_card_section.default,
288
- {
289
- ...{
290
- className: "shrink-0",
291
- cta: href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
292
- import_button.default,
293
- {
294
- ...{
295
- ...small,
296
- "aria-label": "Open in Shopify",
297
- element: "a",
298
- href,
299
- icon: import_external.default,
300
- target: "_blank"
301
- }
302
- }
303
- ),
304
- title: "Fulfillment"
305
- },
306
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
307
- import_empty.default,
308
- {
309
- ...{
310
- variant: "secondary"
311
- },
312
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "This order is " + status.text.toLowerCase() + " in Shopify" })
313
- }
314
- )
315
- }
316
- );
317
- };
318
117
  const small = {
319
118
  inline: true,
320
119
  size: "small",
321
120
  variant: "secondary"
322
121
  };
323
- const PaidRow = ({ cancel, disabled, item }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
324
- "div",
325
- {
326
- ...{
327
- className: "space-y-3 py-4 first:pt-0 last:pb-0"
328
- },
329
- children: [
330
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
331
- "div",
332
- {
333
- ...{
334
- className: "flex items-center justify-between gap-4"
335
- },
336
- children: [
337
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
338
- "div",
339
- {
340
- ...{
341
- className: "flex items-center gap-3 min-w-0"
342
- },
343
- children: [
344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
- "p",
346
- {
347
- ...{
348
- className: "break-words"
349
- },
350
- children: item.tracking || "No tracking number"
351
- }
352
- ),
353
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
354
- import_badge.default,
355
- {
356
- ...{
357
- type: item.status === "active" ? "success" : "secondary"
358
- },
359
- children: item.status === "active" ? "Fulfilled" : "Canceled"
360
- }
361
- )
362
- ]
363
- }
364
- ),
365
- item.status === "active" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
366
- import_button.default,
367
- {
368
- ...{
369
- ...small,
370
- disabled,
371
- onClick: cancel
372
- },
373
- children: "Cancel"
374
- }
375
- )
376
- ]
377
- }
378
- ),
379
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
380
- "div",
381
- {
382
- ...{
383
- className: "grid grid-cols-3 gap-6"
384
- },
385
- children: [
386
- ["Carrier", item.carrier || "\u2014"],
387
- ["Date", date(item.createdAt)],
388
- ["Customer", item.emailed ? "Emailed" : "Not emailed"]
389
- ].map(([label, value]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
390
- import_card_data_item.default,
391
- {
392
- ...{
393
- className: "flex flex-col min-w-0",
394
- classNameSlotLeft: "text-sm disabled",
395
- classNameSlotRight: "break-words",
396
- element: "div",
397
- label,
398
- value
399
- }
400
- },
401
- label
402
- ))
403
- }
404
- )
405
- ]
406
- }
407
- );
408
122
  const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
409
- var _a;
410
- const queryClient = (0, import_react_query.useQueryClient)();
411
- const modal = (0, import_hooks.useModal)({
412
- queryClient
413
- });
414
- const { onError } = (0, import_hooks.useCallbacks)({
415
- queryClient
416
- });
417
123
  const confirm = useConfirm();
418
124
  const controls = fulfillmentControls({ manage, order });
419
- const paid = stripeOrder(order);
420
- const fulfill = () => paid ? modal.open({
421
- message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
422
- FormFulfill,
423
- {
424
- ...{
425
- endpoint,
426
- onError,
427
- onSuccess
428
- }
429
- }
430
- ),
431
- title: "Mark as fulfilled"
432
- }) : confirm({
125
+ const fulfill = () => confirm({
433
126
  action: "Mark as fulfilled",
434
127
  endpoint: endpoint + "/fulfillment",
435
128
  message: "Mark this order as fulfilled?",
@@ -442,11 +135,9 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
442
135
  status: "canceled"
443
136
  },
444
137
  endpoint: endpoint + "/fulfillment/" + item.id,
445
- message: paid ? "The order goes back to Unfulfilled. The customer is not emailed." : "Cancel this fulfillment?",
138
+ message: "Cancel this fulfillment?",
446
139
  onSuccess
447
140
  });
448
- if (((_a = order == null ? void 0 : order.provider) == null ? void 0 : _a.slug) === "shopify") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShopifyFulfillment, { ...{ order } });
449
- if (paid && !(order == null ? void 0 : order.fulfillment)) return null;
450
141
  const cta = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
451
142
  import_button.default,
452
143
  {
@@ -487,17 +178,7 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
487
178
  ...{
488
179
  className: "divide-y divide-gray"
489
180
  },
490
- children: items.map((item) => paid ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
491
- PaidRow,
492
- {
493
- ...{
494
- cancel: () => cancel(item),
495
- disabled: !controls.cancel,
496
- item
497
- }
498
- },
499
- item.id
500
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
181
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
501
182
  "div",
502
183
  {
503
184
  ...{
@@ -546,140 +227,9 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
546
227
  }
547
228
  );
548
229
  };
549
- const OrderSummarySection = ({ order }) => {
550
- var _a, _b;
551
- const money = moneyOf(order);
552
- const { shipping, subtotal, tax, total } = (order == null ? void 0 : order.amounts) || {};
553
- const rate = (_b = (_a = order == null ? void 0 : order.shipping) == null ? void 0 : _a.rate) == null ? void 0 : _b.name;
554
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
555
- import_card_section.default,
556
- {
557
- ...{
558
- className: "shrink-0",
559
- title: "Summary"
560
- },
561
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
562
- import_order_summary.default,
563
- {
564
- ...{
565
- rows: [
566
- ["Subtotal", money(subtotal)],
567
- [rate ? "Shipping (" + rate + ")" : "Shipping", money(shipping)],
568
- ["Tax", money(tax)],
569
- ["Total", money(total)]
570
- ]
571
- }
572
- }
573
- )
574
- }
575
- );
576
- };
577
- const OrderCustomer = ({ order }) => {
578
- var _a, _b, _c, _d;
579
- const name = [(_a = order == null ? void 0 : order.customer) == null ? void 0 : _a.firstName, (_b = order == null ? void 0 : order.customer) == null ? void 0 : _b.lastName].filter(Boolean).join(" ");
580
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
581
- import_card_section.default,
582
- {
583
- ...{
584
- className: "shrink-0",
585
- title: "Customer"
586
- },
587
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
588
- import_card_setting.default,
589
- {
590
- ...{
591
- rows: [
592
- {
593
- label: "Name",
594
- value: name || "\u2014"
595
- },
596
- {
597
- label: "Email",
598
- value: ((_c = order == null ? void 0 : order.customer) == null ? void 0 : _c.email) || "\u2014"
599
- },
600
- ((_d = order == null ? void 0 : order.shipping) == null ? void 0 : _d.address) && {
601
- label: "Ships to",
602
- value: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_address_lines.default, { ...order.shipping.address })
603
- }
604
- ].filter(Boolean)
605
- }
606
- }
607
- )
608
- }
609
- );
610
- };
611
- const OrderPayment = ({ endpoint, onClose, order }) => {
612
- var _a, _b;
613
- const [open, setOpen] = (0, import_react.useState)(false);
614
- const status = (0, import_helpers.statusBadge)("payment", (0, import_products.paymentOf)(order));
615
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
616
- import_card_section.default,
617
- {
618
- ...{
619
- className: "shrink-0",
620
- title: "Payment"
621
- },
622
- children: [
623
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
624
- import_card_setting.default,
625
- {
626
- ...{
627
- rows: [
628
- {
629
- label: "Amount",
630
- value: moneyOf(order)((_a = order == null ? void 0 : order.amounts) == null ? void 0 : _a.total)
631
- },
632
- {
633
- label: "Status",
634
- value: (status == null ? void 0 : status.text) || "\u2014"
635
- }
636
- ]
637
- }
638
- }
639
- ),
640
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
641
- "div",
642
- {
643
- ...{
644
- className: "pt-4"
645
- },
646
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
647
- import_button.default,
648
- {
649
- ...{
650
- ...small,
651
- onClick: () => setOpen(true)
652
- },
653
- children: "Refund"
654
- }
655
- )
656
- }
657
- ),
658
- open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
659
- import_embed_stripe.default,
660
- {
661
- ...{
662
- component: "payment_details",
663
- endpoint,
664
- onClose: () => {
665
- setOpen(false);
666
- onClose == null ? void 0 : onClose();
667
- },
668
- payment: (_b = order == null ? void 0 : order.provider) == null ? void 0 : _b.id
669
- }
670
- }
671
- )
672
- ]
673
- }
674
- );
675
- };
676
230
  // Annotate the CommonJS export names for ESM import in node:
677
231
  0 && (module.exports = {
678
- FormFulfill,
679
- OrderCustomer,
680
232
  OrderFulfillment,
681
- OrderPayment,
682
- OrderSummarySection,
683
233
  fulfillmentControls,
684
234
  useConfirm
685
235
  });