@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
@@ -1,371 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useQuery, useQueryClient } from "@tanstack/react-query";
4
- import { formatCurrency } from "@drawbridge/drawbridge-utils";
5
- import { request } from "@drawbridge/drawbridge-utils/fetch";
6
- import { DELIVERY, deliveryText, MAX_RATES } from "@drawbridge/drawbridge-utils/products";
7
- import { Controller, useForm } from "../shared/lib/form.mjs";
8
- import yup, { resolver } from "../shared/lib/yup.mjs";
9
- import { useCallbacks, useModal } from "./lib/hooks.mjs";
10
- import { useConfirm } from "./order-sections.mjs";
11
- import CardSection from "./card-section.mjs";
12
- import Paged from "./paged.mjs";
13
- import Table from "./table.mjs";
14
- import TableCellTitle from "./table-cell-title.mjs";
15
- import Button from "../shared/button.mjs";
16
- import Fieldset from "../shared/fieldset.mjs";
17
- import Form from "../shared/form.mjs";
18
- import InputSwitch from "../shared/input-switch.mjs";
19
- import InputGroup from "../input-group.mjs";
20
- import InputNumber from "../input-number.mjs";
21
- import InputSelect from "../input-select.mjs";
22
- import InputText from "../input-text.mjs";
23
- import Pencil from "../icons/pencil.mjs";
24
- import Plus from "../icons/plus.mjs";
25
- import Trash from "../icons/trash.mjs";
26
- const COUNTRIES = [
27
- {
28
- label: "Canada",
29
- value: "CA"
30
- },
31
- {
32
- label: "United States",
33
- value: "US"
34
- }
35
- ];
36
- const countryName = (code) => {
37
- var _a;
38
- return ((_a = COUNTRIES.find((item) => item.value === code)) == null ? void 0 : _a.label) || code;
39
- };
40
- const keyOf = (delivery) => delivery ? delivery.minimum + "-" + delivery.maximum : "";
41
- const FormRate = ({ currency, endpoint, onError, onSuccess, values }) => {
42
- const { control, formState, handleSubmit, watch } = useForm({
43
- resolver: resolver(
44
- yup.object({
45
- free: yup.number().label("Free over").nullable().when("freeOver", ([on], schema) => on ? schema.required().min(0) : schema),
46
- name: yup.string().label("Name").trim().required().max(100),
47
- price: yup.number().label("Price").typeError("Price is a required field").required().min(0)
48
- })
49
- ),
50
- values: {
51
- country: (values == null ? void 0 : values.country) || COUNTRIES[0].value,
52
- delivery: keyOf((values == null ? void 0 : values.delivery) || DELIVERY[2]),
53
- free: (values == null ? void 0 : values.free) ?? null,
54
- freeOver: Number.isFinite(values == null ? void 0 : values.free),
55
- name: (values == null ? void 0 : values.name) || "",
56
- price: (values == null ? void 0 : values.price) ?? null
57
- }
58
- });
59
- const onSubmit = async ({ country, delivery, free, freeOver, name, price }) => {
60
- try {
61
- const [minimum, maximum] = delivery.split("-").map(Number);
62
- onSuccess(await request({
63
- body: {
64
- country,
65
- delivery: {
66
- maximum,
67
- minimum
68
- },
69
- free: freeOver ? Number(free) : null,
70
- name: name.trim(),
71
- price: Number(price)
72
- },
73
- endpoint,
74
- method: (values == null ? void 0 : values.id) ? "PUT" : "POST"
75
- }));
76
- } catch (error) {
77
- onError == null ? void 0 : onError(error);
78
- }
79
- };
80
- const field = (name, label, input, extra = {}) => /* @__PURE__ */ jsx(
81
- Controller,
82
- {
83
- ...{
84
- control,
85
- name,
86
- render: ({ field: { onChange, value } }) => {
87
- var _a, _b;
88
- return /* @__PURE__ */ jsx(
89
- InputGroup,
90
- {
91
- ...{
92
- ...extra,
93
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[name]) == null ? void 0 : _b.message,
94
- input: input({ onChange, value }),
95
- label
96
- }
97
- }
98
- );
99
- }
100
- }
101
- },
102
- name
103
- );
104
- const symbol = { before: formatCurrency({ code: (currency || "usd").toUpperCase(), value: 0 }).replace(/[\d.,\s]/g, "") };
105
- return /* @__PURE__ */ jsxs(
106
- Form,
107
- {
108
- ...{
109
- className: "relative w-full space-y-6",
110
- onSubmit: handleSubmit(onSubmit)
111
- },
112
- children: [
113
- /* @__PURE__ */ jsxs(
114
- Fieldset,
115
- {
116
- ...{
117
- className: "space-y-6",
118
- disabled: formState == null ? void 0 : formState.isSubmitting
119
- },
120
- children: [
121
- field("name", "Name", ({ onChange, value }) => /* @__PURE__ */ jsx(
122
- InputText,
123
- {
124
- ...{
125
- onChange,
126
- placeholder: "Standard",
127
- value: value || ""
128
- }
129
- }
130
- )),
131
- field("price", "Price", ({ onChange, value }) => /* @__PURE__ */ jsx(
132
- InputNumber,
133
- {
134
- ...{
135
- min: 0,
136
- onChange,
137
- step: 0.01,
138
- value: value ?? ""
139
- }
140
- }
141
- ), symbol),
142
- field("country", "Country", ({ onChange, value }) => /* @__PURE__ */ jsx(
143
- InputSelect,
144
- {
145
- ...{
146
- onChange,
147
- options: COUNTRIES,
148
- value
149
- }
150
- }
151
- )),
152
- field("delivery", "Delivery", ({ onChange, value }) => /* @__PURE__ */ jsx(
153
- InputSelect,
154
- {
155
- ...{
156
- onChange,
157
- options: DELIVERY.map((item) => ({
158
- label: deliveryText(item),
159
- value: keyOf(item)
160
- })),
161
- value
162
- }
163
- }
164
- )),
165
- field("freeOver", "Free over", ({ onChange, value }) => /* @__PURE__ */ jsx(
166
- InputSwitch,
167
- {
168
- ...{
169
- "aria-label": "Free over",
170
- onChange,
171
- value: Boolean(value)
172
- }
173
- }
174
- )),
175
- watch("freeOver") && field("free", "Order amount", ({ onChange, value }) => /* @__PURE__ */ jsx(
176
- InputNumber,
177
- {
178
- ...{
179
- min: 0,
180
- onChange,
181
- step: 0.01,
182
- value: value ?? ""
183
- }
184
- }
185
- ), symbol)
186
- ]
187
- }
188
- ),
189
- /* @__PURE__ */ jsx(
190
- Fieldset,
191
- {
192
- ...{
193
- disabled: formState == null ? void 0 : formState.isSubmitting
194
- },
195
- children: /* @__PURE__ */ jsx(
196
- Button,
197
- {
198
- ...{
199
- loading: formState == null ? void 0 : formState.isSubmitting,
200
- type: "submit"
201
- },
202
- children: "Submit"
203
- }
204
- )
205
- }
206
- )
207
- ]
208
- }
209
- );
210
- };
211
- const ShippingRates = ({ currency, manage, organization }) => {
212
- var _a, _b, _c, _d;
213
- const queryClient = useQueryClient();
214
- const modal = useModal({
215
- queryClient
216
- });
217
- const { onError, onSuccess } = useCallbacks({
218
- queryClient
219
- });
220
- const confirm = useConfirm();
221
- const queryKey = ["rates", organization];
222
- const base = "/organization/" + organization;
223
- const listed = useQuery({
224
- enabled: false,
225
- queryKey: [...queryKey, 0]
226
- });
227
- const count = ((_b = (_a = listed.data) == null ? void 0 : _a.pageInfo) == null ? void 0 : _b.total) ?? ((_d = (_c = listed.data) == null ? void 0 : _c.items) == null ? void 0 : _d.length) ?? 0;
228
- const saved = (response) => onSuccess(response, {
229
- invalidate: [
230
- {
231
- queryKey
232
- }
233
- ]
234
- });
235
- const money = (value) => formatCurrency({ code: (currency || "usd").toUpperCase(), value });
236
- const open = (rate) => modal.open({
237
- message: /* @__PURE__ */ jsx(
238
- FormRate,
239
- {
240
- ...{
241
- currency,
242
- endpoint: (rate == null ? void 0 : rate.id) ? base + "/rate/" + rate.id : base + "/rates",
243
- onError,
244
- onSuccess: saved,
245
- values: rate
246
- }
247
- }
248
- ),
249
- title: (rate == null ? void 0 : rate.id) ? "Edit rate" : "New rate"
250
- });
251
- const remove = (rate) => confirm({
252
- action: "Remove",
253
- endpoint: base + "/rate/" + rate.id,
254
- message: "Orders already placed keep the price they recorded.",
255
- method: "DELETE",
256
- onSuccess: saved,
257
- title: "Remove shipping price"
258
- });
259
- const cta = count < MAX_RATES && /* @__PURE__ */ jsx(
260
- Button,
261
- {
262
- ...{
263
- "aria-label": "New rate",
264
- disabled: !manage,
265
- icon: Plus,
266
- inline: true,
267
- onClick: () => open(),
268
- size: "small",
269
- variant: "secondary"
270
- }
271
- }
272
- );
273
- const columns = [
274
- {
275
- id: "name",
276
- header: "Rate",
277
- cell: ({ row }) => /* @__PURE__ */ jsx(
278
- TableCellTitle,
279
- {
280
- ...{
281
- subtitle: deliveryText(row.original.delivery),
282
- title: row.original.name
283
- }
284
- }
285
- ),
286
- sortable: false
287
- },
288
- {
289
- id: "country",
290
- header: "Country",
291
- cell: ({ row }) => countryName(row.original.country),
292
- sortable: false
293
- },
294
- {
295
- id: "price",
296
- header: "Price",
297
- cell: ({ row }) => row.original.price ? money(row.original.price) : "Free",
298
- sortable: false
299
- },
300
- {
301
- id: "free",
302
- header: "Free over",
303
- cell: ({ row }) => Number.isFinite(row.original.free) ? money(row.original.free) : "\u2014",
304
- sortable: false
305
- }
306
- ];
307
- const actions = (row) => ({
308
- controls: [
309
- {
310
- "aria-label": "Edit " + row.name,
311
- disabled: !manage,
312
- element: "button",
313
- icon: Pencil,
314
- onClick: () => open(row),
315
- type: "button"
316
- },
317
- {
318
- "aria-label": "Remove " + row.name,
319
- disabled: !manage,
320
- element: "button",
321
- icon: Trash,
322
- onClick: () => remove(row),
323
- type: "button"
324
- }
325
- ]
326
- });
327
- return /* @__PURE__ */ jsx(
328
- CardSection,
329
- {
330
- ...{
331
- className: "shrink-0",
332
- cta,
333
- title: "Shipping"
334
- },
335
- children: /* @__PURE__ */ jsx(
336
- Paged,
337
- {
338
- ...{
339
- empty: {
340
- message: "No shipping prices",
341
- variant: "secondary"
342
- },
343
- endpoint: base + "/rates",
344
- params: {
345
- limit: MAX_RATES,
346
- sort: {
347
- createdAt: 1
348
- }
349
- },
350
- queryKey
351
- },
352
- children: ({ items }) => /* @__PURE__ */ jsx(
353
- Table,
354
- {
355
- ...{
356
- actions,
357
- columns,
358
- data: items
359
- }
360
- }
361
- )
362
- }
363
- )
364
- }
365
- );
366
- };
367
- var shipping_rates_default = ShippingRates;
368
- export {
369
- FormRate,
370
- shipping_rates_default as default
371
- };
@@ -1,301 +0,0 @@
1
- "use client";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var template_buyer_exports = {};
30
- __export(template_buyer_exports, {
31
- BuyerDownload: () => BuyerDownload,
32
- BuyerOrder: () => BuyerOrder,
33
- default: () => template_buyer_default
34
- });
35
- module.exports = __toCommonJS(template_buyer_exports);
36
- var import_jsx_runtime = require("react/jsx-runtime");
37
- var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
38
- var import_card_section = __toESM(require("./card-section"));
39
- var import_card_shortcut = __toESM(require("./card-shortcut"));
40
- var import_link = __toESM(require("./link"));
41
- var import_loader = __toESM(require("../shared/loader"));
42
- var import_badge = __toESM(require("../shared/badge"));
43
- var import_button = __toESM(require("../shared/button"));
44
- var import_logo_mark = __toESM(require("../icons/logo-mark"));
45
- const TemplateBuyer = ({
46
- children,
47
- home,
48
- isLoading = false
49
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
50
- "div",
51
- {
52
- ...{
53
- className: "fixed h-full w-full bg-gray-light scroll-smooth overflow-y-auto hide-scrollbar"
54
- },
55
- children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
- "div",
57
- {
58
- ...{
59
- className: "flex min-h-full items-center justify-center px-4 py-32"
60
- },
61
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
62
- "div",
63
- {
64
- ...{
65
- className: "space-y-6 mx-auto w-full max-w-[440px]"
66
- },
67
- children: [
68
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- "div",
70
- {
71
- ...{
72
- className: "flex justify-center"
73
- },
74
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
- import_button.default,
76
- {
77
- ...{
78
- "aria-label": "Drawbridge",
79
- element: import_link.default,
80
- href: home || "/",
81
- inline: true,
82
- variant: "link"
83
- },
84
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
- "span",
86
- {
87
- ...{
88
- className: "flex items-center justify-center w-12 h-12 bg-green-dark rounded-sm"
89
- },
90
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
- import_logo_mark.default,
92
- {
93
- ...{
94
- className: "w-6 h-6 text-black"
95
- }
96
- }
97
- )
98
- }
99
- )
100
- }
101
- )
102
- }
103
- ),
104
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card_section.default, { children })
105
- ]
106
- }
107
- )
108
- }
109
- )
110
- }
111
- );
112
- const BuyerOrder = ({
113
- downloading = null,
114
- onDownload,
115
- order
116
- }) => {
117
- const code = ((order == null ? void 0 : order.currency) || "usd").toUpperCase();
118
- const money = (value) => (0, import_drawbridge_utils.formatCurrency)({ code, value: value || 0 });
119
- const refunded = (order == null ? void 0 : order.payment) === "refunded";
120
- const date = (order == null ? void 0 : order.purchasedAt) && (0, import_drawbridge_utils.formatDateString)({
121
- date: order.purchasedAt,
122
- options: {
123
- day: "numeric",
124
- month: "short",
125
- year: "numeric"
126
- }
127
- });
128
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
129
- "div",
130
- {
131
- ...{
132
- className: "space-y-6"
133
- },
134
- children: [
135
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
136
- "div",
137
- {
138
- ...{
139
- className: "space-y-1 text-center"
140
- },
141
- children: [
142
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
- "h1",
144
- {
145
- ...{
146
- className: "text-xl"
147
- },
148
- children: (order == null ? void 0 : order.number) ? "Order " + order.number : "Your order"
149
- }
150
- ),
151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- "p",
153
- {
154
- ...{
155
- className: "text-sm text-gray-dark"
156
- },
157
- children: [order == null ? void 0 : order.organization, date].filter(Boolean).join(" \xB7 ")
158
- }
159
- )
160
- ]
161
- }
162
- ),
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
- "div",
165
- {
166
- ...{
167
- className: "space-y-3"
168
- },
169
- children: ((order == null ? void 0 : order.lines) || []).map((line) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
- import_card_shortcut.default,
171
- {
172
- ...{
173
- ...line.digital && {
174
- controls: refunded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
- import_badge.default,
176
- {
177
- ...{
178
- size: "small"
179
- },
180
- children: "Refunded"
181
- }
182
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
- import_button.default,
184
- {
185
- ...{
186
- disabled: downloading !== null,
187
- loading: downloading === line.index,
188
- onClick: () => onDownload(line.index),
189
- size: "small"
190
- },
191
- children: "Download"
192
- }
193
- )
194
- },
195
- description: [line.variantTitle, (line.quantity || 1) + " \xD7 " + money(line.price)].filter(Boolean).join(" \xB7 "),
196
- title: line.title || "Item"
197
- }
198
- },
199
- line.index
200
- ))
201
- }
202
- ),
203
- (order == null ? void 0 : order.amounts) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
204
- "div",
205
- {
206
- ...{
207
- className: "flex justify-between text-sm"
208
- },
209
- children: [
210
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Total" }),
211
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: money(order.amounts.total) })
212
- ]
213
- }
214
- )
215
- ]
216
- }
217
- );
218
- };
219
- const outcomes = {
220
- expired: {
221
- message: "Download links work for one day. Sign in to your order page to get a new one.",
222
- title: "This link has expired"
223
- },
224
- failed: {
225
- message: "Check your connection and try again.",
226
- title: "We couldn't start your download"
227
- },
228
- refunded: {
229
- message: "This order was refunded, so its downloads have stopped.",
230
- title: "Downloads have stopped"
231
- },
232
- starting: {
233
- message: "If it doesn't start, try again.",
234
- title: "Your download is starting"
235
- },
236
- unavailable: {
237
- message: "This download isn't available.",
238
- title: "Nothing to download"
239
- }
240
- };
241
- const BuyerDownload = ({
242
- href,
243
- onRetry,
244
- status = "starting"
245
- }) => {
246
- const outcome = outcomes[status] || outcomes.unavailable;
247
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
248
- "div",
249
- {
250
- ...{
251
- className: "space-y-6 text-center"
252
- },
253
- children: [
254
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
255
- "h1",
256
- {
257
- ...{
258
- className: "text-xl"
259
- },
260
- children: outcome.title
261
- }
262
- ),
263
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
- "p",
265
- {
266
- ...{
267
- className: "text-gray-dark"
268
- },
269
- children: outcome.message
270
- }
271
- ),
272
- ["failed", "starting"].includes(status) && onRetry && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
- import_button.default,
274
- {
275
- ...{
276
- onClick: onRetry,
277
- variant: "secondary"
278
- },
279
- children: "Try again"
280
- }
281
- ),
282
- ["expired", "refunded", "unavailable"].includes(status) && href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
283
- import_button.default,
284
- {
285
- ...{
286
- element: import_link.default,
287
- href
288
- },
289
- children: "View my order"
290
- }
291
- )
292
- ]
293
- }
294
- );
295
- };
296
- var template_buyer_default = TemplateBuyer;
297
- // Annotate the CommonJS export names for ESM import in node:
298
- 0 && (module.exports = {
299
- BuyerDownload,
300
- BuyerOrder
301
- });