@drawbridge/components 0.1.46 → 0.1.48

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 (162) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain-shop.js +4 -1
  10. package/dist/bridge/form-subdomain-shop.mjs +4 -1
  11. package/dist/bridge/form-subdomain.js +24 -5
  12. package/dist/bridge/form-subdomain.mjs +25 -6
  13. package/dist/bridge/lib/age-gate.js +12 -0
  14. package/dist/bridge/lib/age-gate.mjs +11 -0
  15. package/dist/bridge/lib/cart.js +79 -0
  16. package/dist/bridge/lib/cart.mjs +48 -0
  17. package/dist/bridge/lib/checkout-kit.js +2 -32
  18. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  19. package/dist/bridge/lib/entry.js +41 -0
  20. package/dist/bridge/lib/entry.mjs +40 -0
  21. package/dist/bridge/product-tile.js +13 -6
  22. package/dist/bridge/product-tile.mjs +13 -6
  23. package/dist/bridge/template-layout.js +263 -129
  24. package/dist/bridge/template-layout.mjs +264 -130
  25. package/dist/bridge/template-modal.js +39 -74
  26. package/dist/bridge/template-modal.mjs +40 -75
  27. package/dist/dashboard/avatar.js +2 -3
  28. package/dist/dashboard/avatar.mjs +2 -3
  29. package/dist/dashboard/buttons-subscription.js +1 -1
  30. package/dist/dashboard/buttons-subscription.mjs +1 -1
  31. package/dist/dashboard/campaign-form.js +179 -155
  32. package/dist/dashboard/campaign-form.mjs +179 -155
  33. package/dist/dashboard/campaign-share.js +347 -0
  34. package/dist/dashboard/campaign-share.mjs +314 -0
  35. package/dist/dashboard/card-affiliate.js +1 -1
  36. package/dist/dashboard/card-affiliate.mjs +1 -1
  37. package/dist/dashboard/card-campaign-switch.js +4 -1
  38. package/dist/dashboard/card-campaign-switch.mjs +4 -1
  39. package/dist/dashboard/card-order.js +22 -4
  40. package/dist/dashboard/card-order.mjs +22 -4
  41. package/dist/dashboard/embed-stripe.js +145 -0
  42. package/dist/dashboard/embed-stripe.mjs +116 -0
  43. package/dist/dashboard/form-admin-provider.js +71 -17
  44. package/dist/dashboard/form-admin-provider.mjs +71 -17
  45. package/dist/dashboard/form-file-upload.js +3 -2
  46. package/dist/dashboard/form-file-upload.mjs +4 -3
  47. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  48. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  49. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  50. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  51. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  52. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  53. package/dist/dashboard/form-organization-campaign-page.js +73 -39
  54. package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
  55. package/dist/dashboard/form-organization-campaign.js +82 -0
  56. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  57. package/dist/dashboard/form-organization-connection.js +48 -6
  58. package/dist/dashboard/form-organization-connection.mjs +48 -7
  59. package/dist/dashboard/form-organization-product.js +1461 -0
  60. package/dist/dashboard/form-organization-product.mjs +1425 -0
  61. package/dist/dashboard/form-organization-workflow.js +72 -1
  62. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  63. package/dist/dashboard/form-otc.js +4 -5
  64. package/dist/dashboard/form-otc.mjs +4 -5
  65. package/dist/dashboard/form-stripe.js +12 -5
  66. package/dist/dashboard/form-stripe.mjs +12 -5
  67. package/dist/dashboard/input-combobox.js +6 -0
  68. package/dist/dashboard/input-combobox.mjs +6 -0
  69. package/dist/dashboard/input-fields.js +37 -161
  70. package/dist/dashboard/input-fields.mjs +37 -161
  71. package/dist/dashboard/input-file.js +21 -4
  72. package/dist/dashboard/input-file.mjs +21 -4
  73. package/dist/dashboard/input-font.js +2 -0
  74. package/dist/dashboard/input-font.mjs +2 -0
  75. package/dist/dashboard/input-gallery.js +201 -0
  76. package/dist/dashboard/input-gallery.mjs +172 -0
  77. package/dist/dashboard/input-group-ai.js +15 -3
  78. package/dist/dashboard/input-group-ai.mjs +15 -3
  79. package/dist/dashboard/lib/ab-tests.js +2 -2
  80. package/dist/dashboard/lib/ab-tests.mjs +2 -2
  81. package/dist/dashboard/lib/connection-controls.js +5 -2
  82. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  83. package/dist/dashboard/lib/form-page.js +1 -1
  84. package/dist/dashboard/lib/form-page.mjs +1 -1
  85. package/dist/dashboard/lib/menu.js +19 -0
  86. package/dist/dashboard/lib/menu.mjs +18 -0
  87. package/dist/dashboard/lib/products.js +169 -0
  88. package/dist/dashboard/lib/products.mjs +135 -0
  89. package/dist/dashboard/lib/settings-paths.js +35 -0
  90. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  91. package/dist/dashboard/lib/uppy.js +10 -1
  92. package/dist/dashboard/lib/uppy.mjs +11 -2
  93. package/dist/dashboard/menu.js +13 -2
  94. package/dist/dashboard/menu.mjs +13 -2
  95. package/dist/dashboard/order-sections.js +456 -6
  96. package/dist/dashboard/order-sections.mjs +453 -7
  97. package/dist/dashboard/preview.js +119 -52
  98. package/dist/dashboard/preview.mjs +119 -52
  99. package/dist/dashboard/provider-ui.js +9 -7
  100. package/dist/dashboard/provider-ui.mjs +9 -7
  101. package/dist/dashboard/recharts.js +10 -4
  102. package/dist/dashboard/recharts.mjs +10 -4
  103. package/dist/dashboard/shipping-rates.js +404 -0
  104. package/dist/dashboard/shipping-rates.mjs +371 -0
  105. package/dist/dashboard/template-buyer.js +301 -0
  106. package/dist/dashboard/template-buyer.mjs +267 -0
  107. package/dist/dashboard/template-dashboard.js +11 -1
  108. package/dist/dashboard/template-dashboard.mjs +11 -1
  109. package/dist/dashboard/template-design.js +209 -130
  110. package/dist/dashboard/template-design.mjs +210 -131
  111. package/dist/dashboard/template-ui.js +157 -55
  112. package/dist/dashboard/template-ui.mjs +158 -56
  113. package/dist/icons/flags.js +134 -0
  114. package/dist/icons/flags.mjs +115 -0
  115. package/dist/input-checkbox.js +28 -10
  116. package/dist/input-checkbox.mjs +28 -10
  117. package/dist/product.js +96 -24
  118. package/dist/product.mjs +97 -25
  119. package/dist/shared/carousel.js +14 -5
  120. package/dist/shared/carousel.mjs +14 -5
  121. package/dist/shared/lib/helpers.js +54 -6
  122. package/dist/shared/lib/helpers.mjs +53 -8
  123. package/dist/shared/order-summary.js +139 -0
  124. package/dist/shared/order-summary.mjs +110 -0
  125. package/package.json +84 -4
  126. package/types/bridge/cart-drawer.d.ts +31 -0
  127. package/types/bridge/fields.d.ts +14 -2
  128. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  129. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  130. package/types/bridge/form-subdomain.d.ts +13 -0
  131. package/types/bridge/lib/age-gate.d.ts +5 -0
  132. package/types/bridge/lib/cart.d.ts +44 -0
  133. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  134. package/types/bridge/lib/entry.d.ts +5 -0
  135. package/types/bridge/product-tile.d.ts +2 -0
  136. package/types/dashboard/campaign-share.d.ts +16 -0
  137. package/types/dashboard/card-order.d.ts +6 -0
  138. package/types/dashboard/embed-stripe.d.ts +25 -0
  139. package/types/dashboard/form-admin-provider.d.ts +9 -2
  140. package/types/dashboard/form-file-upload.d.ts +2 -1
  141. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  142. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  143. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  144. package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
  145. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  146. package/types/dashboard/form-organization-connection.d.ts +11 -0
  147. package/types/dashboard/form-organization-product.d.ts +24 -0
  148. package/types/dashboard/form-otc.d.ts +5 -1
  149. package/types/dashboard/form-stripe.d.ts +3 -2
  150. package/types/dashboard/input-combobox.d.ts +2 -0
  151. package/types/dashboard/input-file.d.ts +2 -0
  152. package/types/dashboard/input-gallery.d.ts +14 -0
  153. package/types/dashboard/lib/products.d.ts +14 -0
  154. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  155. package/types/dashboard/order-sections.d.ts +24 -1
  156. package/types/dashboard/preview.d.ts +11 -3
  157. package/types/dashboard/shipping-rates.d.ts +26 -0
  158. package/types/dashboard/template-buyer.d.ts +50 -0
  159. package/types/icons/flags.d.ts +5 -0
  160. package/types/input-checkbox.d.ts +2 -0
  161. package/types/shared/lib/helpers.d.ts +4 -0
  162. package/types/shared/order-summary.d.ts +19 -0
@@ -1,15 +1,32 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
3
4
  import { useQueryClient } from "@tanstack/react-query";
4
- import { formatDateString } from "@drawbridge/drawbridge-utils";
5
+ import { formatCurrency, formatDateString } from "@drawbridge/drawbridge-utils";
5
6
  import { request } from "@drawbridge/drawbridge-utils/fetch";
7
+ import { CARRIERS, paymentOf, shopifyOrderUrl } from "@drawbridge/drawbridge-utils/products";
8
+ import { Controller, useForm } from "../shared/lib/form.mjs";
9
+ import { statusBadge } from "../shared/lib/helpers.mjs";
6
10
  import { useCallbacks, useModal } from "./lib/hooks.mjs";
11
+ import CardDataItem from "./card-data-item.mjs";
7
12
  import CardSection from "./card-section.mjs";
13
+ import CardSetting from "./card-setting.mjs";
8
14
  import CardTask from "./card-task.mjs";
15
+ import EmbedStripe from "./embed-stripe.mjs";
9
16
  import FormAction from "./form-action.mjs";
10
17
  import Paged from "./paged.mjs";
18
+ import AddressLines from "../shared/address-lines.mjs";
11
19
  import Badge from "../shared/badge.mjs";
12
20
  import Button from "../shared/button.mjs";
21
+ import Empty from "../shared/empty.mjs";
22
+ import Fieldset from "../shared/fieldset.mjs";
23
+ import Form from "../shared/form.mjs";
24
+ import OrderSummary from "../shared/order-summary.mjs";
25
+ import InputCheckbox from "../input-checkbox.mjs";
26
+ import InputGroup from "../input-group.mjs";
27
+ import InputSelect from "../input-select.mjs";
28
+ import InputText from "../input-text.mjs";
29
+ import External from "../icons/external.mjs";
13
30
  import Plus from "../icons/plus.mjs";
14
31
  const date = (value) => formatDateString({
15
32
  date: value,
@@ -28,8 +45,8 @@ const useConfirm = () => {
28
45
  const { onError } = useCallbacks({
29
46
  queryClient
30
47
  });
31
- return ({ action, body, endpoint, message, method = "PUT", onSuccess, task, warning }) => modal.open({
32
- title: action,
48
+ return ({ action, body, endpoint, message, method = "PUT", onSuccess, task, title, warning }) => modal.open({
49
+ title: title || action,
33
50
  message: /* @__PURE__ */ jsxs(
34
51
  FormAction,
35
52
  {
@@ -76,19 +93,305 @@ const fulfillmentControls = ({ manage, order }) => {
76
93
  var _a;
77
94
  const editable = Boolean(manage) && (order == null ? void 0 : order.status) === "open";
78
95
  return {
79
- add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled",
96
+ add: editable && ((_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status) !== "fulfilled" && (order == null ? void 0 : order.payment) !== "refunded",
80
97
  cancel: editable
81
98
  };
82
99
  };
100
+ const stripeOrder = (order) => {
101
+ var _a;
102
+ return ((_a = order == null ? void 0 : order.provider) == null ? void 0 : _a.slug) === "stripe";
103
+ };
104
+ const moneyOf = (order) => (value) => formatCurrency({ code: ((order == null ? void 0 : order.currency) || "usd").toUpperCase(), value: value || 0 });
105
+ const FormFulfill = ({ endpoint, onError, onSuccess }) => {
106
+ const { control, formState, handleSubmit } = useForm({
107
+ values: {
108
+ carrier: CARRIERS[0],
109
+ emailed: true,
110
+ tracking: ""
111
+ }
112
+ });
113
+ const onSubmit = async ({ carrier, emailed, tracking }) => {
114
+ try {
115
+ onSuccess(await request({
116
+ body: {
117
+ carrier,
118
+ emailed: Boolean(emailed),
119
+ tracking: (tracking || "").trim()
120
+ },
121
+ endpoint: endpoint + "/fulfillment",
122
+ method: "POST"
123
+ }));
124
+ } catch (error) {
125
+ onError == null ? void 0 : onError(error);
126
+ }
127
+ };
128
+ return /* @__PURE__ */ jsxs(
129
+ Form,
130
+ {
131
+ ...{
132
+ className: "relative w-full space-y-6",
133
+ onSubmit: handleSubmit(onSubmit)
134
+ },
135
+ children: [
136
+ /* @__PURE__ */ jsxs(
137
+ Fieldset,
138
+ {
139
+ ...{
140
+ className: "space-y-6",
141
+ disabled: formState == null ? void 0 : formState.isSubmitting
142
+ },
143
+ children: [
144
+ /* @__PURE__ */ jsx(
145
+ Controller,
146
+ {
147
+ ...{
148
+ control,
149
+ name: "carrier",
150
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
151
+ InputGroup,
152
+ {
153
+ ...{
154
+ input: /* @__PURE__ */ jsx(
155
+ InputSelect,
156
+ {
157
+ ...{
158
+ onChange,
159
+ options: CARRIERS.map((carrier) => ({
160
+ label: carrier,
161
+ value: carrier
162
+ })),
163
+ value
164
+ }
165
+ }
166
+ ),
167
+ label: "Carrier"
168
+ }
169
+ }
170
+ )
171
+ }
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsx(
175
+ Controller,
176
+ {
177
+ ...{
178
+ control,
179
+ name: "tracking",
180
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
181
+ InputGroup,
182
+ {
183
+ ...{
184
+ input: /* @__PURE__ */ jsx(
185
+ InputText,
186
+ {
187
+ ...{
188
+ onChange,
189
+ value: value || ""
190
+ }
191
+ }
192
+ ),
193
+ label: "Tracking number"
194
+ }
195
+ }
196
+ )
197
+ }
198
+ }
199
+ ),
200
+ /* @__PURE__ */ jsx(
201
+ Controller,
202
+ {
203
+ ...{
204
+ control,
205
+ name: "emailed",
206
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
207
+ InputCheckbox,
208
+ {
209
+ ...{
210
+ label: "Email the customer their tracking details",
211
+ onChange,
212
+ value
213
+ }
214
+ }
215
+ )
216
+ }
217
+ }
218
+ )
219
+ ]
220
+ }
221
+ ),
222
+ /* @__PURE__ */ jsx(
223
+ Fieldset,
224
+ {
225
+ ...{
226
+ disabled: formState == null ? void 0 : formState.isSubmitting
227
+ },
228
+ children: /* @__PURE__ */ jsx(
229
+ Button,
230
+ {
231
+ ...{
232
+ loading: formState == null ? void 0 : formState.isSubmitting,
233
+ type: "submit"
234
+ },
235
+ children: "Mark as fulfilled"
236
+ }
237
+ )
238
+ }
239
+ )
240
+ ]
241
+ }
242
+ );
243
+ };
244
+ const ShopifyFulfillment = ({ order }) => {
245
+ var _a, _b, _c;
246
+ const status = statusBadge("fulfillment", (_a = order == null ? void 0 : order.fulfillment) == null ? void 0 : _a.status);
247
+ const href = 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 });
248
+ return status && /* @__PURE__ */ jsx(
249
+ CardSection,
250
+ {
251
+ ...{
252
+ className: "shrink-0",
253
+ cta: href && /* @__PURE__ */ jsx(
254
+ Button,
255
+ {
256
+ ...{
257
+ ...small,
258
+ "aria-label": "Open in Shopify",
259
+ element: "a",
260
+ href,
261
+ icon: External,
262
+ target: "_blank"
263
+ }
264
+ }
265
+ ),
266
+ title: "Fulfillment"
267
+ },
268
+ children: /* @__PURE__ */ jsx(
269
+ Empty,
270
+ {
271
+ ...{
272
+ variant: "secondary"
273
+ },
274
+ children: /* @__PURE__ */ jsx("p", { children: "This order is " + status.text.toLowerCase() + " in Shopify" })
275
+ }
276
+ )
277
+ }
278
+ );
279
+ };
83
280
  const small = {
84
281
  inline: true,
85
282
  size: "small",
86
283
  variant: "secondary"
87
284
  };
285
+ const PaidRow = ({ cancel, disabled, item }) => /* @__PURE__ */ jsxs(
286
+ "div",
287
+ {
288
+ ...{
289
+ className: "space-y-3 py-4 first:pt-0 last:pb-0"
290
+ },
291
+ children: [
292
+ /* @__PURE__ */ jsxs(
293
+ "div",
294
+ {
295
+ ...{
296
+ className: "flex items-center justify-between gap-4"
297
+ },
298
+ children: [
299
+ /* @__PURE__ */ jsxs(
300
+ "div",
301
+ {
302
+ ...{
303
+ className: "flex items-center gap-3 min-w-0"
304
+ },
305
+ children: [
306
+ /* @__PURE__ */ jsx(
307
+ "p",
308
+ {
309
+ ...{
310
+ className: "break-words"
311
+ },
312
+ children: item.tracking || "No tracking number"
313
+ }
314
+ ),
315
+ /* @__PURE__ */ jsx(
316
+ Badge,
317
+ {
318
+ ...{
319
+ type: item.status === "active" ? "success" : "secondary"
320
+ },
321
+ children: item.status === "active" ? "Fulfilled" : "Canceled"
322
+ }
323
+ )
324
+ ]
325
+ }
326
+ ),
327
+ item.status === "active" && /* @__PURE__ */ jsx(
328
+ Button,
329
+ {
330
+ ...{
331
+ ...small,
332
+ disabled,
333
+ onClick: cancel
334
+ },
335
+ children: "Cancel"
336
+ }
337
+ )
338
+ ]
339
+ }
340
+ ),
341
+ /* @__PURE__ */ jsx(
342
+ "div",
343
+ {
344
+ ...{
345
+ className: "grid grid-cols-3 gap-6"
346
+ },
347
+ children: [
348
+ ["Carrier", item.carrier || "\u2014"],
349
+ ["Date", date(item.createdAt)],
350
+ ["Customer", item.emailed ? "Emailed" : "Not emailed"]
351
+ ].map(([label, value]) => /* @__PURE__ */ jsx(
352
+ CardDataItem,
353
+ {
354
+ ...{
355
+ className: "flex flex-col min-w-0",
356
+ classNameSlotLeft: "text-sm disabled",
357
+ classNameSlotRight: "break-words",
358
+ element: "div",
359
+ label,
360
+ value
361
+ }
362
+ },
363
+ label
364
+ ))
365
+ }
366
+ )
367
+ ]
368
+ }
369
+ );
88
370
  const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
371
+ var _a;
372
+ const queryClient = useQueryClient();
373
+ const modal = useModal({
374
+ queryClient
375
+ });
376
+ const { onError } = useCallbacks({
377
+ queryClient
378
+ });
89
379
  const confirm = useConfirm();
90
380
  const controls = fulfillmentControls({ manage, order });
91
- const fulfill = () => confirm({
381
+ const paid = stripeOrder(order);
382
+ const fulfill = () => paid ? modal.open({
383
+ message: /* @__PURE__ */ jsx(
384
+ FormFulfill,
385
+ {
386
+ ...{
387
+ endpoint,
388
+ onError,
389
+ onSuccess
390
+ }
391
+ }
392
+ ),
393
+ title: "Mark as fulfilled"
394
+ }) : confirm({
92
395
  action: "Mark as fulfilled",
93
396
  endpoint: endpoint + "/fulfillment",
94
397
  message: "Mark this order as fulfilled?",
@@ -101,9 +404,11 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
101
404
  status: "canceled"
102
405
  },
103
406
  endpoint: endpoint + "/fulfillment/" + item.id,
104
- message: "Cancel this fulfillment?",
407
+ message: paid ? "The order goes back to Unfulfilled. The customer is not emailed." : "Cancel this fulfillment?",
105
408
  onSuccess
106
409
  });
410
+ if (((_a = order == null ? void 0 : order.provider) == null ? void 0 : _a.slug) === "shopify") return /* @__PURE__ */ jsx(ShopifyFulfillment, { ...{ order } });
411
+ if (paid && !(order == null ? void 0 : order.fulfillment)) return null;
107
412
  const cta = /* @__PURE__ */ jsx(
108
413
  Button,
109
414
  {
@@ -144,7 +449,17 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
144
449
  ...{
145
450
  className: "divide-y divide-gray"
146
451
  },
147
- children: items.map((item) => /* @__PURE__ */ jsxs(
452
+ children: items.map((item) => paid ? /* @__PURE__ */ jsx(
453
+ PaidRow,
454
+ {
455
+ ...{
456
+ cancel: () => cancel(item),
457
+ disabled: !controls.cancel,
458
+ item
459
+ }
460
+ },
461
+ item.id
462
+ ) : /* @__PURE__ */ jsxs(
148
463
  "div",
149
464
  {
150
465
  ...{
@@ -193,8 +508,139 @@ const OrderFulfillment = ({ endpoint, manage, onSuccess, order }) => {
193
508
  }
194
509
  );
195
510
  };
511
+ const OrderSummarySection = ({ order }) => {
512
+ var _a, _b;
513
+ const money = moneyOf(order);
514
+ const { shipping, subtotal, tax, total } = (order == null ? void 0 : order.amounts) || {};
515
+ const rate = (_b = (_a = order == null ? void 0 : order.shipping) == null ? void 0 : _a.rate) == null ? void 0 : _b.name;
516
+ return /* @__PURE__ */ jsx(
517
+ CardSection,
518
+ {
519
+ ...{
520
+ className: "shrink-0",
521
+ title: "Summary"
522
+ },
523
+ children: /* @__PURE__ */ jsx(
524
+ OrderSummary,
525
+ {
526
+ ...{
527
+ rows: [
528
+ ["Subtotal", money(subtotal)],
529
+ [rate ? "Shipping (" + rate + ")" : "Shipping", money(shipping)],
530
+ ["Tax", money(tax)],
531
+ ["Total", money(total)]
532
+ ]
533
+ }
534
+ }
535
+ )
536
+ }
537
+ );
538
+ };
539
+ const OrderCustomer = ({ order }) => {
540
+ var _a, _b, _c, _d;
541
+ 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(" ");
542
+ return /* @__PURE__ */ jsx(
543
+ CardSection,
544
+ {
545
+ ...{
546
+ className: "shrink-0",
547
+ title: "Customer"
548
+ },
549
+ children: /* @__PURE__ */ jsx(
550
+ CardSetting,
551
+ {
552
+ ...{
553
+ rows: [
554
+ {
555
+ label: "Name",
556
+ value: name || "\u2014"
557
+ },
558
+ {
559
+ label: "Email",
560
+ value: ((_c = order == null ? void 0 : order.customer) == null ? void 0 : _c.email) || "\u2014"
561
+ },
562
+ ((_d = order == null ? void 0 : order.shipping) == null ? void 0 : _d.address) && {
563
+ label: "Ships to",
564
+ value: /* @__PURE__ */ jsx(AddressLines, { ...order.shipping.address })
565
+ }
566
+ ].filter(Boolean)
567
+ }
568
+ }
569
+ )
570
+ }
571
+ );
572
+ };
573
+ const OrderPayment = ({ endpoint, onClose, order }) => {
574
+ var _a, _b;
575
+ const [open, setOpen] = useState(false);
576
+ const status = statusBadge("payment", paymentOf(order));
577
+ return /* @__PURE__ */ jsxs(
578
+ CardSection,
579
+ {
580
+ ...{
581
+ className: "shrink-0",
582
+ title: "Payment"
583
+ },
584
+ children: [
585
+ /* @__PURE__ */ jsx(
586
+ CardSetting,
587
+ {
588
+ ...{
589
+ rows: [
590
+ {
591
+ label: "Amount",
592
+ value: moneyOf(order)((_a = order == null ? void 0 : order.amounts) == null ? void 0 : _a.total)
593
+ },
594
+ {
595
+ label: "Status",
596
+ value: (status == null ? void 0 : status.text) || "\u2014"
597
+ }
598
+ ]
599
+ }
600
+ }
601
+ ),
602
+ /* @__PURE__ */ jsx(
603
+ "div",
604
+ {
605
+ ...{
606
+ className: "pt-4"
607
+ },
608
+ children: /* @__PURE__ */ jsx(
609
+ Button,
610
+ {
611
+ ...{
612
+ ...small,
613
+ onClick: () => setOpen(true)
614
+ },
615
+ children: "Refund"
616
+ }
617
+ )
618
+ }
619
+ ),
620
+ open && /* @__PURE__ */ jsx(
621
+ EmbedStripe,
622
+ {
623
+ ...{
624
+ component: "payment_details",
625
+ endpoint,
626
+ onClose: () => {
627
+ setOpen(false);
628
+ onClose == null ? void 0 : onClose();
629
+ },
630
+ payment: (_b = order == null ? void 0 : order.provider) == null ? void 0 : _b.id
631
+ }
632
+ }
633
+ )
634
+ ]
635
+ }
636
+ );
637
+ };
196
638
  export {
639
+ FormFulfill,
640
+ OrderCustomer,
197
641
  OrderFulfillment,
642
+ OrderPayment,
643
+ OrderSummarySection,
198
644
  fulfillmentControls,
199
645
  useConfirm
200
646
  };