@drawbridge/components 0.1.47 → 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.
- package/dist/bridge/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain.js +1 -0
- package/dist/bridge/form-subdomain.mjs +2 -1
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/product-tile.js +9 -6
- package/dist/bridge/product-tile.mjs +9 -6
- package/dist/bridge/template-layout.js +237 -122
- package/dist/bridge/template-layout.mjs +237 -122
- package/dist/bridge/template-modal.js +28 -73
- package/dist/bridge/template-modal.mjs +29 -74
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +7 -2
- package/dist/dashboard/campaign-form.mjs +7 -2
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-fields.js +11 -158
- package/dist/dashboard/input-fields.mjs +11 -158
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +74 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -0,0 +1,371 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+
});
|