@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.
Files changed (114) 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.js +1 -0
  10. package/dist/bridge/form-subdomain.mjs +2 -1
  11. package/dist/bridge/lib/age-gate.js +12 -0
  12. package/dist/bridge/lib/age-gate.mjs +11 -0
  13. package/dist/bridge/lib/cart.js +79 -0
  14. package/dist/bridge/lib/cart.mjs +48 -0
  15. package/dist/bridge/lib/checkout-kit.js +2 -32
  16. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  17. package/dist/bridge/product-tile.js +9 -6
  18. package/dist/bridge/product-tile.mjs +9 -6
  19. package/dist/bridge/template-layout.js +237 -122
  20. package/dist/bridge/template-layout.mjs +237 -122
  21. package/dist/bridge/template-modal.js +28 -73
  22. package/dist/bridge/template-modal.mjs +29 -74
  23. package/dist/dashboard/buttons-subscription.js +1 -1
  24. package/dist/dashboard/buttons-subscription.mjs +1 -1
  25. package/dist/dashboard/campaign-form.js +7 -2
  26. package/dist/dashboard/campaign-form.mjs +7 -2
  27. package/dist/dashboard/card-order.js +22 -4
  28. package/dist/dashboard/card-order.mjs +22 -4
  29. package/dist/dashboard/embed-stripe.js +145 -0
  30. package/dist/dashboard/embed-stripe.mjs +116 -0
  31. package/dist/dashboard/form-admin-provider.js +71 -17
  32. package/dist/dashboard/form-admin-provider.mjs +71 -17
  33. package/dist/dashboard/form-file-upload.js +3 -2
  34. package/dist/dashboard/form-file-upload.mjs +4 -3
  35. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  36. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  37. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  38. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  39. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  40. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  41. package/dist/dashboard/form-organization-campaign.js +82 -0
  42. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  43. package/dist/dashboard/form-organization-connection.js +48 -6
  44. package/dist/dashboard/form-organization-connection.mjs +48 -7
  45. package/dist/dashboard/form-organization-product.js +1461 -0
  46. package/dist/dashboard/form-organization-product.mjs +1425 -0
  47. package/dist/dashboard/form-organization-workflow.js +72 -1
  48. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  49. package/dist/dashboard/form-otc.js +4 -5
  50. package/dist/dashboard/form-otc.mjs +4 -5
  51. package/dist/dashboard/form-stripe.js +12 -5
  52. package/dist/dashboard/form-stripe.mjs +12 -5
  53. package/dist/dashboard/input-fields.js +11 -158
  54. package/dist/dashboard/input-fields.mjs +11 -158
  55. package/dist/dashboard/input-file.js +21 -4
  56. package/dist/dashboard/input-file.mjs +21 -4
  57. package/dist/dashboard/input-gallery.js +201 -0
  58. package/dist/dashboard/input-gallery.mjs +172 -0
  59. package/dist/dashboard/lib/connection-controls.js +5 -2
  60. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  61. package/dist/dashboard/lib/form-page.js +1 -1
  62. package/dist/dashboard/lib/form-page.mjs +1 -1
  63. package/dist/dashboard/lib/products.js +169 -0
  64. package/dist/dashboard/lib/products.mjs +135 -0
  65. package/dist/dashboard/lib/settings-paths.js +35 -0
  66. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  67. package/dist/dashboard/lib/uppy.js +10 -1
  68. package/dist/dashboard/lib/uppy.mjs +11 -2
  69. package/dist/dashboard/order-sections.js +456 -6
  70. package/dist/dashboard/order-sections.mjs +453 -7
  71. package/dist/dashboard/provider-ui.js +9 -7
  72. package/dist/dashboard/provider-ui.mjs +9 -7
  73. package/dist/dashboard/shipping-rates.js +404 -0
  74. package/dist/dashboard/shipping-rates.mjs +371 -0
  75. package/dist/dashboard/template-buyer.js +301 -0
  76. package/dist/dashboard/template-buyer.mjs +267 -0
  77. package/dist/input-checkbox.js +28 -10
  78. package/dist/input-checkbox.mjs +28 -10
  79. package/dist/product.js +96 -24
  80. package/dist/product.mjs +97 -25
  81. package/dist/shared/lib/helpers.js +54 -6
  82. package/dist/shared/lib/helpers.mjs +53 -8
  83. package/dist/shared/order-summary.js +139 -0
  84. package/dist/shared/order-summary.mjs +110 -0
  85. package/package.json +74 -4
  86. package/types/bridge/cart-drawer.d.ts +31 -0
  87. package/types/bridge/fields.d.ts +14 -2
  88. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  89. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  90. package/types/bridge/lib/age-gate.d.ts +5 -0
  91. package/types/bridge/lib/cart.d.ts +44 -0
  92. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  93. package/types/dashboard/card-order.d.ts +6 -0
  94. package/types/dashboard/embed-stripe.d.ts +25 -0
  95. package/types/dashboard/form-admin-provider.d.ts +9 -2
  96. package/types/dashboard/form-file-upload.d.ts +2 -1
  97. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  98. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  99. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  100. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  101. package/types/dashboard/form-organization-connection.d.ts +11 -0
  102. package/types/dashboard/form-organization-product.d.ts +24 -0
  103. package/types/dashboard/form-otc.d.ts +5 -1
  104. package/types/dashboard/form-stripe.d.ts +3 -2
  105. package/types/dashboard/input-file.d.ts +2 -0
  106. package/types/dashboard/input-gallery.d.ts +14 -0
  107. package/types/dashboard/lib/products.d.ts +14 -0
  108. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  109. package/types/dashboard/order-sections.d.ts +24 -1
  110. package/types/dashboard/shipping-rates.d.ts +26 -0
  111. package/types/dashboard/template-buyer.d.ts +50 -0
  112. package/types/input-checkbox.d.ts +2 -0
  113. package/types/shared/lib/helpers.d.ts +4 -0
  114. package/types/shared/order-summary.d.ts +19 -0
@@ -0,0 +1,1425 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useQueryClient } from "@tanstack/react-query";
5
+ import { request } from "@drawbridge/drawbridge-utils/fetch";
6
+ import { MAX_OPTIONS, MAX_RECOMMENDATIONS, MAX_VARIANTS, PRODUCT_PROVIDER } from "@drawbridge/drawbridge-utils/products";
7
+ import { Controller, FormProvider, useForm, useWatch } from "../shared/lib/form.mjs";
8
+ import yup, { resolver } from "../shared/lib/yup.mjs";
9
+ import Form from "../shared/form.mjs";
10
+ import Fieldset from "../shared/fieldset.mjs";
11
+ import Button from "../shared/button.mjs";
12
+ import Badge from "../shared/badge.mjs";
13
+ import Empty from "../shared/empty.mjs";
14
+ import InputSwitch from "../shared/input-switch.mjs";
15
+ import InputGroup from "../input-group.mjs";
16
+ import InputText from "../input-text.mjs";
17
+ import InputTextarea from "../input-textarea.mjs";
18
+ import InputNumber from "../input-number.mjs";
19
+ import InputSelect from "../input-select.mjs";
20
+ import InputCheckbox from "../input-checkbox.mjs";
21
+ import CardSection from "./card-section.mjs";
22
+ import Table from "./table.mjs";
23
+ import TableCellTitle from "./table-cell-title.mjs";
24
+ import InputGallery from "./input-gallery.mjs";
25
+ import InputFile from "./input-file.mjs";
26
+ import { InputArrayControl, InputArraySortable } from "./input-array.mjs";
27
+ import ListResource from "./list-resource.mjs";
28
+ import { productAsset } from "../shared/lib/helpers.mjs";
29
+ import { useModal } from "./lib/hooks.mjs";
30
+ import { priceText, productBody, totalQuantity, variantCount, variantRows, variantsFor } from "./lib/products.mjs";
31
+ import ChevronDown from "../icons/chevron-down.mjs";
32
+ import ChevronUp from "../icons/chevron-up.mjs";
33
+ import External from "../icons/external.mjs";
34
+ import Pencil from "../icons/pencil.mjs";
35
+ import Plus from "../icons/plus.mjs";
36
+ import Trash from "../icons/trash.mjs";
37
+ const FormOrganizationProductCreate = ({
38
+ campaign,
39
+ onError,
40
+ onSuccess,
41
+ organization
42
+ }) => {
43
+ const { control, formState, handleSubmit } = useForm({
44
+ defaultValues: {
45
+ title: ""
46
+ },
47
+ resolver: resolver(
48
+ yup.object({
49
+ title: yup.string().trim().max(255).required("Title is required")
50
+ })
51
+ )
52
+ });
53
+ const onSubmit = async ({ title }) => {
54
+ try {
55
+ const response = await request({
56
+ body: {
57
+ title
58
+ },
59
+ endpoint: "/organization/" + organization + "/campaign/" + campaign + "/product",
60
+ method: "POST"
61
+ });
62
+ onSuccess(response);
63
+ } catch (error) {
64
+ onError(error);
65
+ }
66
+ };
67
+ return /* @__PURE__ */ jsxs(
68
+ Form,
69
+ {
70
+ ...{
71
+ className: "relative w-full space-y-6",
72
+ onSubmit: handleSubmit(onSubmit)
73
+ },
74
+ children: [
75
+ /* @__PURE__ */ jsx(
76
+ Fieldset,
77
+ {
78
+ ...{
79
+ disabled: formState == null ? void 0 : formState.isSubmitting
80
+ },
81
+ children: /* @__PURE__ */ jsx(
82
+ Controller,
83
+ {
84
+ ...{
85
+ control,
86
+ name: "title",
87
+ render: ({ field: { onChange, value } }) => {
88
+ var _a, _b;
89
+ return /* @__PURE__ */ jsx(
90
+ InputGroup,
91
+ {
92
+ ...{
93
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.title) == null ? void 0 : _b.message,
94
+ input: /* @__PURE__ */ jsx(
95
+ InputText,
96
+ {
97
+ ...{
98
+ onChange,
99
+ placeholder: "House blend",
100
+ value: value || ""
101
+ }
102
+ }
103
+ ),
104
+ label: "Title"
105
+ }
106
+ }
107
+ );
108
+ }
109
+ }
110
+ }
111
+ )
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsx(Fieldset, { children: /* @__PURE__ */ jsx(
115
+ Button,
116
+ {
117
+ ...{
118
+ loading: formState == null ? void 0 : formState.isSubmitting,
119
+ type: "submit"
120
+ },
121
+ children: "Submit"
122
+ }
123
+ ) })
124
+ ]
125
+ }
126
+ );
127
+ };
128
+ const statuses = [
129
+ {
130
+ label: "Published",
131
+ value: "published"
132
+ },
133
+ {
134
+ label: "Drafted",
135
+ value: "drafted"
136
+ }
137
+ ];
138
+ const field = ({ control, input, label, name }) => /* @__PURE__ */ jsx(
139
+ Controller,
140
+ {
141
+ ...{
142
+ control,
143
+ name,
144
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
145
+ InputGroup,
146
+ {
147
+ ...{
148
+ input: input({
149
+ onChange,
150
+ value
151
+ }),
152
+ label
153
+ }
154
+ }
155
+ )
156
+ }
157
+ }
158
+ );
159
+ const VariantFields = ({ control, digital, inline = false, prefix = "", setValue }) => {
160
+ const path = (key) => prefix + key;
161
+ const quantity = useWatch({
162
+ control,
163
+ name: path("inventoryQuantity")
164
+ });
165
+ const tracked = quantity !== null && quantity !== void 0;
166
+ const money = ({ onChange, value }) => /* @__PURE__ */ jsx(
167
+ InputNumber,
168
+ {
169
+ ...{
170
+ min: 0,
171
+ onChange,
172
+ step: 0.01,
173
+ value: value ?? ""
174
+ }
175
+ }
176
+ );
177
+ return /* @__PURE__ */ jsxs(
178
+ "div",
179
+ {
180
+ ...{
181
+ className: "space-y-6"
182
+ },
183
+ children: [
184
+ /* @__PURE__ */ jsxs(
185
+ "div",
186
+ {
187
+ ...{
188
+ className: inline ? "grid grid-cols-2 gap-4" : ""
189
+ },
190
+ children: [
191
+ inline && field({ control, input: money, label: "Price", name: path("price") }),
192
+ field({ control, input: money, label: "Original price", name: path("sale") })
193
+ ]
194
+ }
195
+ ),
196
+ /* @__PURE__ */ jsx(
197
+ Controller,
198
+ {
199
+ ...{
200
+ control,
201
+ name: path("taxable"),
202
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
203
+ InputCheckbox,
204
+ {
205
+ ...{
206
+ label: inline ? "Charge tax on this product" : "Charge tax on this variant",
207
+ onChange,
208
+ value: value !== false
209
+ }
210
+ }
211
+ )
212
+ }
213
+ }
214
+ ),
215
+ field({
216
+ control,
217
+ input: ({ onChange, value }) => /* @__PURE__ */ jsx(
218
+ InputText,
219
+ {
220
+ ...{
221
+ onChange,
222
+ value: value || ""
223
+ }
224
+ }
225
+ ),
226
+ label: "SKU",
227
+ name: path("sku")
228
+ }),
229
+ /* @__PURE__ */ jsx(
230
+ InputGroup,
231
+ {
232
+ ...{
233
+ input: /* @__PURE__ */ jsxs(
234
+ "div",
235
+ {
236
+ ...{
237
+ className: "flex items-center gap-3"
238
+ },
239
+ children: [
240
+ /* @__PURE__ */ jsx(
241
+ InputSwitch,
242
+ {
243
+ ...{
244
+ onChange: (on) => setValue(path("inventoryQuantity"), on ? 0 : null, { shouldDirty: true }),
245
+ value: tracked
246
+ }
247
+ }
248
+ ),
249
+ /* @__PURE__ */ jsx(
250
+ "div",
251
+ {
252
+ ...{
253
+ className: "flex-1"
254
+ },
255
+ children: /* @__PURE__ */ jsx(
256
+ InputNumber,
257
+ {
258
+ ...{
259
+ "aria-label": "Quantity",
260
+ disabled: !tracked,
261
+ min: 0,
262
+ onChange: (value) => setValue(path("inventoryQuantity"), Number.isFinite(value) ? Math.max(0, Math.round(value)) : 0, { shouldDirty: true }),
263
+ value: tracked ? quantity : ""
264
+ }
265
+ }
266
+ )
267
+ }
268
+ )
269
+ ]
270
+ }
271
+ ),
272
+ label: "Track quantity"
273
+ }
274
+ }
275
+ ),
276
+ /* @__PURE__ */ jsx(
277
+ Controller,
278
+ {
279
+ ...{
280
+ control,
281
+ name: path("requiresShipping"),
282
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
283
+ InputGroup,
284
+ {
285
+ ...{
286
+ input: /* @__PURE__ */ jsx(
287
+ InputSwitch,
288
+ {
289
+ ...{
290
+ onChange,
291
+ value: value !== false
292
+ }
293
+ }
294
+ ),
295
+ label: "Physical product"
296
+ }
297
+ }
298
+ )
299
+ }
300
+ }
301
+ ),
302
+ digital && /* @__PURE__ */ jsx(
303
+ Controller,
304
+ {
305
+ ...{
306
+ control,
307
+ name: path("file"),
308
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
309
+ InputGroup,
310
+ {
311
+ ...{
312
+ input: /* @__PURE__ */ jsx(
313
+ InputFile,
314
+ {
315
+ ...{
316
+ button: {
317
+ text: "Upload a file"
318
+ },
319
+ digital: true,
320
+ endpoint: digital.endpoint,
321
+ onChange: (file) => onChange(file || null),
322
+ value
323
+ }
324
+ }
325
+ ),
326
+ label: "Digital file"
327
+ }
328
+ }
329
+ )
330
+ }
331
+ }
332
+ )
333
+ ]
334
+ }
335
+ );
336
+ };
337
+ const FormProductVariant = ({
338
+ digital,
339
+ disabled = false,
340
+ onDone,
341
+ values
342
+ }) => {
343
+ const { control, handleSubmit, setValue } = useForm({
344
+ guard: false,
345
+ values
346
+ });
347
+ return /* @__PURE__ */ jsxs(
348
+ Form,
349
+ {
350
+ ...{
351
+ className: "relative w-full space-y-6",
352
+ onSubmit: handleSubmit(onDone)
353
+ },
354
+ children: [
355
+ /* @__PURE__ */ jsx(
356
+ Fieldset,
357
+ {
358
+ ...{
359
+ disabled
360
+ },
361
+ children: /* @__PURE__ */ jsx(
362
+ VariantFields,
363
+ {
364
+ ...{
365
+ control,
366
+ digital,
367
+ setValue
368
+ }
369
+ }
370
+ )
371
+ }
372
+ ),
373
+ !disabled && /* @__PURE__ */ jsx(Fieldset, { children: /* @__PURE__ */ jsx(
374
+ Button,
375
+ {
376
+ ...{
377
+ type: "submit"
378
+ },
379
+ children: "Done"
380
+ }
381
+ ) })
382
+ ]
383
+ }
384
+ );
385
+ };
386
+ const FormProductOption = ({
387
+ disabled = false,
388
+ onDone,
389
+ others = [],
390
+ values = {
391
+ name: "",
392
+ values: []
393
+ }
394
+ }) => {
395
+ var _a, _b;
396
+ const { control, formState, handleSubmit, setError } = useForm({
397
+ defaultValues: {
398
+ name: values.name,
399
+ values: (values.values || []).map((value) => ({
400
+ value
401
+ }))
402
+ },
403
+ guard: false,
404
+ resolver: resolver(
405
+ yup.object({
406
+ name: yup.string().trim().max(100).required("Option name is required"),
407
+ values: yup.array().of(
408
+ yup.object({
409
+ value: yup.string().trim().max(100)
410
+ })
411
+ )
412
+ })
413
+ )
414
+ });
415
+ const onSubmit = (submitted) => {
416
+ const option = {
417
+ name: submitted.name.trim(),
418
+ values: [...new Set(submitted.values.map((item) => (item.value || "").trim()).filter(Boolean))]
419
+ };
420
+ if (others.some((other) => other.name.toLowerCase() === option.name.toLowerCase())) {
421
+ return setError("name", { message: "Another option has this name" });
422
+ }
423
+ if (!option.values.length) {
424
+ return setError("values", { message: "Add at least one value" });
425
+ }
426
+ if (variantCount([...others, option]) > MAX_VARIANTS) {
427
+ return setError("values", { message: "A product can have up to 2,048 variants" });
428
+ }
429
+ onDone(option);
430
+ };
431
+ return /* @__PURE__ */ jsxs(
432
+ Form,
433
+ {
434
+ ...{
435
+ className: "relative w-full space-y-6",
436
+ onSubmit: handleSubmit(onSubmit)
437
+ },
438
+ children: [
439
+ /* @__PURE__ */ jsxs(
440
+ Fieldset,
441
+ {
442
+ ...{
443
+ disabled
444
+ },
445
+ children: [
446
+ /* @__PURE__ */ jsx(
447
+ Controller,
448
+ {
449
+ ...{
450
+ control,
451
+ name: "name",
452
+ render: ({ field: { onChange, value } }) => {
453
+ var _a2, _b2;
454
+ return /* @__PURE__ */ jsx(
455
+ InputGroup,
456
+ {
457
+ ...{
458
+ error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.name) == null ? void 0 : _b2.message,
459
+ input: /* @__PURE__ */ jsx(
460
+ InputText,
461
+ {
462
+ ...{
463
+ onChange,
464
+ placeholder: "Size",
465
+ value: value || ""
466
+ }
467
+ }
468
+ ),
469
+ label: "Option name"
470
+ }
471
+ }
472
+ );
473
+ }
474
+ }
475
+ }
476
+ ),
477
+ /* @__PURE__ */ jsx(
478
+ InputGroup,
479
+ {
480
+ ...{
481
+ error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.values) == null ? void 0 : _b.message,
482
+ input: /* @__PURE__ */ jsx(
483
+ InputArraySortable,
484
+ {
485
+ ...{
486
+ control,
487
+ empty: "No values yet",
488
+ name: "values",
489
+ renderButton: (append) => /* @__PURE__ */ jsx(
490
+ Button,
491
+ {
492
+ ...{
493
+ icon: Plus,
494
+ justify: "between",
495
+ onClick: () => append({
496
+ value: ""
497
+ }),
498
+ variant: "secondary"
499
+ },
500
+ children: "Add another value"
501
+ }
502
+ ),
503
+ renderControls: ({ index, remove }) => [
504
+ /* @__PURE__ */ jsx(
505
+ InputArrayControl,
506
+ {
507
+ ...{
508
+ icon: Trash,
509
+ onClick: () => remove(index)
510
+ }
511
+ },
512
+ "value-remove-" + index
513
+ )
514
+ ]
515
+ },
516
+ children: ({ field: item, handle, index, update }) => /* @__PURE__ */ jsxs(
517
+ "div",
518
+ {
519
+ ...{
520
+ className: "flex items-center min-w-0 flex-1 space-x-3"
521
+ },
522
+ children: [
523
+ handle,
524
+ /* @__PURE__ */ jsx(
525
+ "div",
526
+ {
527
+ ...{
528
+ className: "flex-1"
529
+ },
530
+ children: /* @__PURE__ */ jsx(
531
+ InputText,
532
+ {
533
+ ...{
534
+ "aria-label": "Option value",
535
+ onChange: (value) => update(index, {
536
+ value
537
+ }),
538
+ value: item.value || ""
539
+ }
540
+ }
541
+ )
542
+ }
543
+ )
544
+ ]
545
+ }
546
+ )
547
+ }
548
+ ),
549
+ label: "Option values"
550
+ }
551
+ }
552
+ )
553
+ ]
554
+ }
555
+ ),
556
+ !disabled && /* @__PURE__ */ jsx(Fieldset, { children: /* @__PURE__ */ jsx(
557
+ Button,
558
+ {
559
+ ...{
560
+ type: "submit"
561
+ },
562
+ children: "Done"
563
+ }
564
+ ) })
565
+ ]
566
+ }
567
+ );
568
+ };
569
+ const ShopifyImages = ({ images = [], updatedAt }) => images.length ? /* @__PURE__ */ jsx(
570
+ Table,
571
+ {
572
+ ...{
573
+ columns: [
574
+ {
575
+ cell: ({ row }) => /* @__PURE__ */ jsx(
576
+ TableCellTitle,
577
+ {
578
+ ...{
579
+ asset: {
580
+ mimetype: "image",
581
+ sizes: {
582
+ "100x100": row.original.url
583
+ },
584
+ updatedAt
585
+ },
586
+ title: row.original.description || "Image " + (row.index + 1)
587
+ }
588
+ }
589
+ ),
590
+ header: "Image",
591
+ id: "image",
592
+ sortable: false
593
+ }
594
+ ],
595
+ data: images,
596
+ headers: false
597
+ }
598
+ }
599
+ ) : /* @__PURE__ */ jsx(
600
+ Empty,
601
+ {
602
+ ...{
603
+ variant: "secondary"
604
+ },
605
+ children: "Gallery is empty"
606
+ }
607
+ );
608
+ const recommendedTitle = (item) => /* @__PURE__ */ jsx(
609
+ TableCellTitle,
610
+ {
611
+ ...{
612
+ asset: productAsset(item),
613
+ subtitle: priceText((item == null ? void 0 : item.variants) || []),
614
+ title: (item == null ? void 0 : item.title) || "Untitled"
615
+ }
616
+ }
617
+ );
618
+ const FormOrganizationProduct = ({
619
+ campaign,
620
+ disabled: readOnly = false,
621
+ onDelete,
622
+ onError,
623
+ onSuccess,
624
+ organization,
625
+ product
626
+ }) => {
627
+ var _a, _b, _c, _d;
628
+ const queryClient = useQueryClient();
629
+ const modal = useModal({ queryClient });
630
+ const editable = Boolean(product == null ? void 0 : product.editable) && !readOnly;
631
+ const currency = ((_c = (_b = (_a = product == null ? void 0 : product.variants) == null ? void 0 : _a[0]) == null ? void 0 : _b.currency) == null ? void 0 : _c.toUpperCase()) || null;
632
+ const digital = (product == null ? void 0 : product.editable) ? {
633
+ endpoint: "/organization/" + (organization == null ? void 0 : organization.id)
634
+ } : null;
635
+ const methods = useForm({
636
+ values: {
637
+ description: (product == null ? void 0 : product.description) || "",
638
+ gallery: ((product == null ? void 0 : product.images) || []).filter((item) => item == null ? void 0 : item.file),
639
+ options: (product == null ? void 0 : product.options) || [],
640
+ recommendations: (product == null ? void 0 : product.recommended) || [],
641
+ status: (product == null ? void 0 : product.status) || "drafted",
642
+ title: (product == null ? void 0 : product.title) || "",
643
+ variants: (product == null ? void 0 : product.variants) || []
644
+ }
645
+ });
646
+ const { control, formState, getValues, handleSubmit, setValue } = methods;
647
+ const options = useWatch({ control, name: "options" }) || [];
648
+ const variants = useWatch({ control, name: "variants" }) || [];
649
+ const recommendations = useWatch({ control, name: "recommendations" }) || [];
650
+ const [group, setGroup] = useState(null);
651
+ const [expanded, setExpanded] = useState([]);
652
+ const grouping = options.some((option) => option.name === group) ? group : (_d = options[0]) == null ? void 0 : _d.name;
653
+ const changeOptions = (next) => {
654
+ setValue("options", next, { shouldDirty: true });
655
+ setValue("variants", variantsFor(next, getValues("variants")), { shouldDirty: true });
656
+ };
657
+ const openOption = (index) => {
658
+ const current = getValues("options");
659
+ modal.open({
660
+ message: /* @__PURE__ */ jsx(
661
+ FormProductOption,
662
+ {
663
+ ...{
664
+ disabled: !editable,
665
+ onDone: (option) => {
666
+ changeOptions(index === null ? [...current, option] : current.map((item, key) => key === index ? option : item));
667
+ modal.close();
668
+ },
669
+ others: current.filter((item, key) => key !== index),
670
+ ...index !== null && {
671
+ values: current[index]
672
+ }
673
+ }
674
+ }
675
+ ),
676
+ title: index === null ? "Add option" : "Edit option"
677
+ });
678
+ };
679
+ const openVariant = (index) => {
680
+ const variant = getValues("variants." + index);
681
+ modal.open({
682
+ message: /* @__PURE__ */ jsx(
683
+ FormProductVariant,
684
+ {
685
+ ...{
686
+ digital,
687
+ disabled: !editable,
688
+ onDone: (values) => {
689
+ setValue("variants." + index, {
690
+ ...variant,
691
+ file: values.file || null,
692
+ inventoryQuantity: values.inventoryQuantity ?? null,
693
+ requiresShipping: values.requiresShipping !== false,
694
+ sale: Number.isFinite(values.sale) ? values.sale : null,
695
+ sku: values.sku || null,
696
+ taxable: values.taxable !== false
697
+ }, { shouldDirty: true });
698
+ modal.close();
699
+ },
700
+ values: variant
701
+ }
702
+ }
703
+ ),
704
+ title: (variant == null ? void 0 : variant.title) || "Variant"
705
+ });
706
+ };
707
+ const onSubmit = async (values) => {
708
+ try {
709
+ const response = await request({
710
+ body: productBody(values, product == null ? void 0 : product.variants),
711
+ endpoint: "/organization/" + (organization == null ? void 0 : organization.id) + "/product/" + product.id,
712
+ method: "PUT"
713
+ });
714
+ onSuccess(response);
715
+ } catch (error) {
716
+ onError(error);
717
+ }
718
+ };
719
+ const openRecommendation = () => {
720
+ const current = getValues("recommendations") || [];
721
+ modal.open({
722
+ message: /* @__PURE__ */ jsx(
723
+ ListResource,
724
+ {
725
+ ...{
726
+ endpoint: "/organization/" + (organization == null ? void 0 : organization.id) + "/products",
727
+ model: "product",
728
+ onChange: (item) => {
729
+ setValue("recommendations", [...current, item].slice(0, MAX_RECOMMENDATIONS), { shouldDirty: true });
730
+ modal.close();
731
+ },
732
+ params: {
733
+ // Left out by the api, so the pages count only what is listed.
734
+ exclude: [product == null ? void 0 : product.id, ...current.map((item) => item == null ? void 0 : item.id)].filter(Boolean),
735
+ provider: PRODUCT_PROVIDER.stripe
736
+ },
737
+ render: recommendedTitle,
738
+ selected: current
739
+ }
740
+ }
741
+ ),
742
+ title: "Select a product"
743
+ });
744
+ };
745
+ const setPrice = (indexes, price) => indexes.forEach((index) => setValue("variants." + index + ".price", price, { shouldDirty: true }));
746
+ const rows = variantRows({ expanded, group: grouping, options, variants });
747
+ const priceCell = (row) => row.price === null && row.range ? /* @__PURE__ */ jsx(
748
+ "span",
749
+ {
750
+ ...{
751
+ className: "text-gray-dark"
752
+ },
753
+ children: row.range
754
+ }
755
+ ) : /* @__PURE__ */ jsx(
756
+ "div",
757
+ {
758
+ ...{
759
+ className: "w-36"
760
+ },
761
+ children: /* @__PURE__ */ jsx(
762
+ InputNumber,
763
+ {
764
+ ...{
765
+ "aria-label": "Price for " + row.title,
766
+ disabled: !editable,
767
+ min: 0,
768
+ onChange: (value) => setPrice(row.group ? row.children : [row.index], value),
769
+ step: 0.01,
770
+ value: row.price ?? ""
771
+ }
772
+ }
773
+ )
774
+ }
775
+ );
776
+ const quantityCell = (row) => {
777
+ if (row.group) return row.inventoryQuantity;
778
+ if (row.inventoryQuantity === null || row.inventoryQuantity === void 0) return "\u2014";
779
+ return /* @__PURE__ */ jsx(
780
+ "div",
781
+ {
782
+ ...{
783
+ className: "w-36"
784
+ },
785
+ children: /* @__PURE__ */ jsx(
786
+ InputNumber,
787
+ {
788
+ ...{
789
+ "aria-label": "Quantity for " + row.title,
790
+ disabled: !editable,
791
+ min: 0,
792
+ onChange: (value) => setValue("variants." + row.index + ".inventoryQuantity", Number.isFinite(value) ? Math.max(0, Math.round(value)) : 0, { shouldDirty: true }),
793
+ value: row.inventoryQuantity
794
+ }
795
+ }
796
+ )
797
+ }
798
+ );
799
+ };
800
+ const columns = [
801
+ {
802
+ cell: ({ row }) => {
803
+ const item = row.original;
804
+ const soldOut = !item.group && item.inventoryQuantity === 0;
805
+ return /* @__PURE__ */ jsx(
806
+ "div",
807
+ {
808
+ ...{
809
+ className: item.child ? "pl-5" : ""
810
+ },
811
+ children: /* @__PURE__ */ jsx(
812
+ TableCellTitle,
813
+ {
814
+ ...{
815
+ status: soldOut ? {
816
+ text: "Sold out",
817
+ type: "error"
818
+ } : null,
819
+ subtitle: item.group ? item.variants + (item.variants === 1 ? " variant" : " variants") : null,
820
+ title: item.title
821
+ }
822
+ }
823
+ )
824
+ }
825
+ );
826
+ },
827
+ header: "Variant",
828
+ id: "title",
829
+ meta: {
830
+ className: "w-full px-4 text-left"
831
+ },
832
+ sortable: false
833
+ },
834
+ {
835
+ cell: ({ row }) => priceCell(row.original),
836
+ header: "Price",
837
+ id: "price",
838
+ meta: {
839
+ className: "w-44 px-4 text-left"
840
+ },
841
+ sortable: false
842
+ },
843
+ {
844
+ cell: ({ row }) => quantityCell(row.original),
845
+ header: "Quantity",
846
+ id: "inventory",
847
+ meta: {
848
+ className: "w-44 px-4 text-left"
849
+ },
850
+ sortable: false
851
+ }
852
+ ];
853
+ const toggle = (value) => setExpanded(expanded.includes(value) ? expanded.filter((item) => item !== value) : [...expanded, value]);
854
+ const campaigns = [
855
+ ...((product == null ? void 0 : product.campaigns) || []).filter((item) => item.id === campaign).map((item) => ({
856
+ ...item,
857
+ current: true
858
+ })),
859
+ ...((product == null ? void 0 : product.campaigns) || []).filter((item) => item.id !== campaign)
860
+ ];
861
+ return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs(
862
+ Form,
863
+ {
864
+ ...{
865
+ className: "grid grid-cols-1 gap-6 xl:grid-cols-3",
866
+ onSubmit: handleSubmit(onSubmit)
867
+ },
868
+ children: [
869
+ /* @__PURE__ */ jsxs(
870
+ "div",
871
+ {
872
+ ...{
873
+ className: "space-y-6 xl:col-span-2"
874
+ },
875
+ children: [
876
+ /* @__PURE__ */ jsx(
877
+ CardSection,
878
+ {
879
+ ...{
880
+ className: "shrink-0"
881
+ },
882
+ children: /* @__PURE__ */ jsxs(
883
+ Fieldset,
884
+ {
885
+ ...{
886
+ disabled: !editable
887
+ },
888
+ children: [
889
+ field({
890
+ control,
891
+ input: ({ onChange, value }) => /* @__PURE__ */ jsx(
892
+ InputText,
893
+ {
894
+ ...{
895
+ onChange,
896
+ placeholder: "House blend",
897
+ value: value || ""
898
+ }
899
+ }
900
+ ),
901
+ label: "Title",
902
+ name: "title"
903
+ }),
904
+ field({
905
+ control,
906
+ input: ({ onChange, value }) => /* @__PURE__ */ jsx(
907
+ InputTextarea,
908
+ {
909
+ ...{
910
+ onChange,
911
+ rows: 4,
912
+ value: value || ""
913
+ }
914
+ }
915
+ ),
916
+ label: "Description",
917
+ name: "description"
918
+ })
919
+ ]
920
+ }
921
+ )
922
+ }
923
+ ),
924
+ /* @__PURE__ */ jsx(
925
+ CardSection,
926
+ {
927
+ ...{
928
+ className: "shrink-0",
929
+ title: "Gallery"
930
+ },
931
+ children: /* @__PURE__ */ jsx("div", { children: editable ? /* @__PURE__ */ jsx(
932
+ InputGallery,
933
+ {
934
+ ...{
935
+ endpoint: "/organization/" + (organization == null ? void 0 : organization.id),
936
+ label: null,
937
+ organization
938
+ }
939
+ }
940
+ ) : /* @__PURE__ */ jsx(
941
+ ShopifyImages,
942
+ {
943
+ ...{
944
+ images: ((product == null ? void 0 : product.images) || []).filter((item) => item == null ? void 0 : item.url),
945
+ updatedAt: product == null ? void 0 : product.updatedAt
946
+ }
947
+ }
948
+ ) })
949
+ }
950
+ ),
951
+ !options.length && variants.length > 0 && /* @__PURE__ */ jsx(
952
+ CardSection,
953
+ {
954
+ ...{
955
+ className: "shrink-0",
956
+ title: "Price"
957
+ },
958
+ children: /* @__PURE__ */ jsx(
959
+ Fieldset,
960
+ {
961
+ ...{
962
+ disabled: !editable
963
+ },
964
+ children: /* @__PURE__ */ jsx(
965
+ VariantFields,
966
+ {
967
+ ...{
968
+ control,
969
+ digital,
970
+ inline: true,
971
+ prefix: "variants.0.",
972
+ setValue
973
+ }
974
+ }
975
+ )
976
+ }
977
+ )
978
+ }
979
+ ),
980
+ /* @__PURE__ */ jsx(
981
+ CardSection,
982
+ {
983
+ ...{
984
+ className: "shrink-0",
985
+ ...editable && options.length < MAX_OPTIONS && {
986
+ cta: /* @__PURE__ */ jsx(
987
+ Button,
988
+ {
989
+ ...{
990
+ icon: Plus,
991
+ inline: true,
992
+ onClick: () => openOption(null),
993
+ size: "small",
994
+ variant: "secondary"
995
+ },
996
+ children: "Add another option"
997
+ }
998
+ )
999
+ },
1000
+ title: "Variants"
1001
+ },
1002
+ children: /* @__PURE__ */ jsxs(
1003
+ "div",
1004
+ {
1005
+ ...{
1006
+ className: "space-y-4"
1007
+ },
1008
+ children: [
1009
+ options.length > 0 && /* @__PURE__ */ jsx(
1010
+ "div",
1011
+ {
1012
+ ...{
1013
+ className: "divide-y divide-gray rounded border border-gray"
1014
+ },
1015
+ children: options.map((option, index) => /* @__PURE__ */ jsxs(
1016
+ "div",
1017
+ {
1018
+ ...{
1019
+ className: "flex w-full items-start gap-3 p-4"
1020
+ },
1021
+ children: [
1022
+ /* @__PURE__ */ jsx(
1023
+ "div",
1024
+ {
1025
+ ...{
1026
+ className: "flex-1 min-w-0"
1027
+ },
1028
+ children: /* @__PURE__ */ jsxs(
1029
+ Button,
1030
+ {
1031
+ ...{
1032
+ "aria-label": "Edit " + option.name,
1033
+ justify: "start",
1034
+ onClick: () => openOption(index),
1035
+ variant: "link"
1036
+ },
1037
+ children: [
1038
+ /* @__PURE__ */ jsx(
1039
+ "span",
1040
+ {
1041
+ ...{
1042
+ className: "block"
1043
+ },
1044
+ children: option.name
1045
+ }
1046
+ ),
1047
+ /* @__PURE__ */ jsx(
1048
+ "span",
1049
+ {
1050
+ ...{
1051
+ className: "flex flex-wrap gap-2"
1052
+ },
1053
+ children: option.values.map((value) => /* @__PURE__ */ jsx(Badge, { children: value }, value))
1054
+ }
1055
+ )
1056
+ ]
1057
+ }
1058
+ )
1059
+ }
1060
+ ),
1061
+ editable && /* @__PURE__ */ jsx(
1062
+ InputArrayControl,
1063
+ {
1064
+ ...{
1065
+ "aria-label": "Remove " + option.name,
1066
+ icon: Trash,
1067
+ onClick: () => changeOptions(options.filter((item, key) => key !== index))
1068
+ }
1069
+ }
1070
+ )
1071
+ ]
1072
+ },
1073
+ "option-" + option.name
1074
+ ))
1075
+ }
1076
+ ),
1077
+ !options.length && /* @__PURE__ */ jsx(
1078
+ Empty,
1079
+ {
1080
+ ...{
1081
+ variant: "secondary"
1082
+ },
1083
+ children: "No options yet"
1084
+ }
1085
+ ),
1086
+ options.length > 0 && /* @__PURE__ */ jsxs(
1087
+ "div",
1088
+ {
1089
+ ...{
1090
+ className: "space-y-4"
1091
+ },
1092
+ children: [
1093
+ options.length > 1 && /* @__PURE__ */ jsx(
1094
+ "div",
1095
+ {
1096
+ ...{
1097
+ className: "w-48"
1098
+ },
1099
+ children: /* @__PURE__ */ jsx(
1100
+ InputGroup,
1101
+ {
1102
+ ...{
1103
+ input: /* @__PURE__ */ jsx(
1104
+ InputSelect,
1105
+ {
1106
+ ...{
1107
+ onChange: setGroup,
1108
+ options: options.map((option) => ({
1109
+ label: option.name,
1110
+ value: option.name
1111
+ })),
1112
+ value: grouping
1113
+ }
1114
+ }
1115
+ ),
1116
+ label: "Group by"
1117
+ }
1118
+ }
1119
+ )
1120
+ }
1121
+ ),
1122
+ /* @__PURE__ */ jsx(
1123
+ "div",
1124
+ {
1125
+ ...{
1126
+ className: "overflow-x-auto"
1127
+ },
1128
+ children: /* @__PURE__ */ jsx(
1129
+ Table,
1130
+ {
1131
+ ...{
1132
+ actions: (row) => row.group ? {
1133
+ button: {
1134
+ "aria-label": (expanded.includes(row.title) ? "Close " : "Open ") + row.title,
1135
+ element: "button",
1136
+ icon: expanded.includes(row.title) ? ChevronUp : ChevronDown,
1137
+ onClick: () => toggle(row.title),
1138
+ text: null
1139
+ }
1140
+ } : {
1141
+ button: {
1142
+ "aria-label": "More for " + row.title,
1143
+ element: "button",
1144
+ icon: Pencil,
1145
+ onClick: () => openVariant(row.index),
1146
+ text: null
1147
+ }
1148
+ },
1149
+ columns,
1150
+ data: rows
1151
+ }
1152
+ }
1153
+ )
1154
+ }
1155
+ ),
1156
+ /* @__PURE__ */ jsx(
1157
+ "p",
1158
+ {
1159
+ ...{
1160
+ className: "text-sm text-gray-dark"
1161
+ },
1162
+ children: "Total quantity: " + totalQuantity(variants)
1163
+ }
1164
+ )
1165
+ ]
1166
+ }
1167
+ )
1168
+ ]
1169
+ }
1170
+ )
1171
+ }
1172
+ ),
1173
+ ((product == null ? void 0 : product.editable) || recommendations.length > 0) && /* @__PURE__ */ jsx(
1174
+ CardSection,
1175
+ {
1176
+ ...{
1177
+ className: "shrink-0",
1178
+ // @story products/recommended
1179
+ // A Drawbridge product's plus, until 10 are chosen; a Shopify
1180
+ // product's picks are changed in Shopify.
1181
+ ...editable && recommendations.length < MAX_RECOMMENDATIONS && {
1182
+ cta: /* @__PURE__ */ jsx(
1183
+ Button,
1184
+ {
1185
+ ...{
1186
+ "aria-label": "Add a recommended product",
1187
+ icon: Plus,
1188
+ inline: true,
1189
+ onClick: openRecommendation,
1190
+ size: "small",
1191
+ variant: "secondary"
1192
+ }
1193
+ }
1194
+ )
1195
+ },
1196
+ ...!(product == null ? void 0 : product.editable) && (product == null ? void 0 : product.edit) && {
1197
+ cta: /* @__PURE__ */ jsx(
1198
+ Button,
1199
+ {
1200
+ ...{
1201
+ element: "a",
1202
+ href: product.edit,
1203
+ icon: External,
1204
+ inline: true,
1205
+ size: "small",
1206
+ target: "_blank",
1207
+ variant: "secondary"
1208
+ },
1209
+ children: "Edit in Shopify"
1210
+ }
1211
+ )
1212
+ },
1213
+ title: "Recommended products"
1214
+ },
1215
+ children: recommendations.length ? /* @__PURE__ */ jsx(
1216
+ Table,
1217
+ {
1218
+ ...{
1219
+ actions: (row) => editable ? {
1220
+ button: {
1221
+ "aria-label": "Remove " + (row.title || "product"),
1222
+ element: "button",
1223
+ icon: Trash,
1224
+ onClick: () => setValue("recommendations", recommendations.filter((item) => item.id !== row.id), { shouldDirty: true }),
1225
+ text: null
1226
+ }
1227
+ } : null,
1228
+ columns: [
1229
+ {
1230
+ cell: ({ row }) => recommendedTitle(row.original),
1231
+ header: "Product",
1232
+ id: "title",
1233
+ sortable: false
1234
+ }
1235
+ ],
1236
+ data: recommendations,
1237
+ headers: false
1238
+ }
1239
+ }
1240
+ ) : /* @__PURE__ */ jsx(
1241
+ Empty,
1242
+ {
1243
+ ...{
1244
+ variant: "secondary"
1245
+ },
1246
+ children: "No recommended products"
1247
+ }
1248
+ )
1249
+ }
1250
+ ),
1251
+ /* @__PURE__ */ jsx(
1252
+ CardSection,
1253
+ {
1254
+ ...{
1255
+ className: "shrink-0",
1256
+ title: "Campaigns"
1257
+ },
1258
+ children: campaigns.length ? /* @__PURE__ */ jsx(
1259
+ Table,
1260
+ {
1261
+ ...{
1262
+ actions: (row) => row.current ? null : {
1263
+ button: {
1264
+ href: "/organizations/" + (organization == null ? void 0 : organization.id) + "/campaigns/" + row.id + "/shop"
1265
+ }
1266
+ },
1267
+ columns: [
1268
+ {
1269
+ cell: ({ row }) => /* @__PURE__ */ jsx(
1270
+ TableCellTitle,
1271
+ {
1272
+ ...{
1273
+ status: row.original.current ? {
1274
+ text: "This campaign",
1275
+ type: "secondary"
1276
+ } : null,
1277
+ title: row.original.title
1278
+ }
1279
+ }
1280
+ ),
1281
+ header: "Campaign",
1282
+ id: "title",
1283
+ sortable: false
1284
+ }
1285
+ ],
1286
+ data: campaigns,
1287
+ headers: false
1288
+ }
1289
+ }
1290
+ ) : /* @__PURE__ */ jsx(
1291
+ Empty,
1292
+ {
1293
+ ...{
1294
+ variant: "secondary"
1295
+ },
1296
+ children: "Not on any campaign"
1297
+ }
1298
+ )
1299
+ }
1300
+ )
1301
+ ]
1302
+ }
1303
+ ),
1304
+ /* @__PURE__ */ jsxs(
1305
+ "div",
1306
+ {
1307
+ ...{
1308
+ className: "space-y-6"
1309
+ },
1310
+ children: [
1311
+ /* @__PURE__ */ jsx(
1312
+ CardSection,
1313
+ {
1314
+ ...{
1315
+ className: "shrink-0",
1316
+ title: "Status"
1317
+ },
1318
+ children: /* @__PURE__ */ jsxs(
1319
+ "div",
1320
+ {
1321
+ ...{
1322
+ className: "space-y-6"
1323
+ },
1324
+ children: [
1325
+ /* @__PURE__ */ jsx(
1326
+ Fieldset,
1327
+ {
1328
+ ...{
1329
+ disabled: !editable
1330
+ },
1331
+ children: /* @__PURE__ */ jsx(
1332
+ Controller,
1333
+ {
1334
+ ...{
1335
+ control,
1336
+ name: "status",
1337
+ render: ({ field: { onChange, value } }) => /* @__PURE__ */ jsx(
1338
+ InputSelect,
1339
+ {
1340
+ ...{
1341
+ "aria-label": "Status",
1342
+ onChange,
1343
+ options: statuses,
1344
+ value
1345
+ }
1346
+ }
1347
+ )
1348
+ }
1349
+ }
1350
+ )
1351
+ }
1352
+ ),
1353
+ editable && /* @__PURE__ */ jsx(
1354
+ Button,
1355
+ {
1356
+ ...{
1357
+ loading: formState == null ? void 0 : formState.isSubmitting,
1358
+ type: "submit"
1359
+ },
1360
+ children: "Save"
1361
+ }
1362
+ ),
1363
+ (product == null ? void 0 : product.edit) && /* @__PURE__ */ jsx(
1364
+ Button,
1365
+ {
1366
+ ...{
1367
+ element: "a",
1368
+ href: product.edit,
1369
+ icon: External,
1370
+ target: "_blank",
1371
+ variant: "secondary"
1372
+ },
1373
+ children: "Edit in Shopify"
1374
+ }
1375
+ ),
1376
+ editable && onDelete && /* @__PURE__ */ jsx(
1377
+ Button,
1378
+ {
1379
+ ...{
1380
+ icon: Trash,
1381
+ onClick: onDelete,
1382
+ variant: "error"
1383
+ },
1384
+ children: "Delete"
1385
+ }
1386
+ )
1387
+ ]
1388
+ }
1389
+ )
1390
+ }
1391
+ ),
1392
+ currency && /* @__PURE__ */ jsx(
1393
+ CardSection,
1394
+ {
1395
+ ...{
1396
+ className: "shrink-0",
1397
+ title: "Currency"
1398
+ },
1399
+ children: /* @__PURE__ */ jsx(
1400
+ InputText,
1401
+ {
1402
+ ...{
1403
+ "aria-label": "Currency",
1404
+ readOnly: true,
1405
+ value: currency
1406
+ }
1407
+ }
1408
+ )
1409
+ }
1410
+ )
1411
+ ]
1412
+ }
1413
+ )
1414
+ ]
1415
+ }
1416
+ ) });
1417
+ };
1418
+ var form_organization_product_default = FormOrganizationProduct;
1419
+ export {
1420
+ FormOrganizationProduct,
1421
+ FormOrganizationProductCreate,
1422
+ FormProductOption,
1423
+ FormProductVariant,
1424
+ form_organization_product_default as default
1425
+ };