@develemit/commerce-admin 0.7.0 → 0.9.0
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/CHANGELOG.md +69 -0
- package/README.md +8 -4
- package/dist/client/admin-client.d.ts +1 -0
- package/dist/client/errors.d.ts +4 -0
- package/dist/client/index.js +1 -1
- package/dist/{client-DCL5DSHP.js → client-ClTCzt-p.js} +34 -28
- package/dist/client-ClTCzt-p.js.map +1 -0
- package/dist/components/admin-layout/admin-layout.d.ts +2 -1
- package/dist/components/admin-layout/current-item.d.ts +1 -0
- package/dist/components/admin-layout/nav-items.d.ts +3 -0
- package/dist/components/admin-layout/use-current-href.d.ts +1 -0
- package/dist/components/empty-state/empty-state.d.ts +1 -1
- package/dist/index.js +1428 -1057
- package/dist/index.js.map +1 -1
- package/dist/lib/admin-labels.d.ts +3 -0
- package/dist/lib/currency-symbol.d.ts +1 -0
- package/dist/lib/fill-alts.d.ts +1 -1
- package/dist/lib/order-action-labels.d.ts +2 -0
- package/dist/lib/order-labels.d.ts +2 -1
- package/dist/lib/product-draft.d.ts +3 -0
- package/dist/lib/product-flow-labels.d.ts +11 -0
- package/dist/lib/product-form.d.ts +2 -1
- package/dist/lib/product-labels.d.ts +8 -0
- package/dist/lib/provider.d.ts +2 -0
- package/dist/lib/stock-labels.d.ts +2 -0
- package/dist/lib/use-batch-upload.d.ts +7 -1
- package/dist/lib/use-order-pages.d.ts +1 -0
- package/dist/lib/use-product-autosave.d.ts +8 -0
- package/dist/lib/use-product-pages.d.ts +2 -0
- package/dist/styles.css +470 -29
- package/dist/views/orders/admin-order-detail.d.ts +2 -1
- package/dist/views/orders/order-actions.d.ts +2 -1
- package/dist/views/orders/resolve-button.d.ts +3 -1
- package/dist/views/orders/ship-form.d.ts +4 -1
- package/dist/views/products/add-several/photo-picker.d.ts +3 -1
- package/dist/views/products/admin-product-images.d.ts +2 -0
- package/dist/views/products/finish-drafts/piece-summary.d.ts +2 -1
- package/dist/views/products/finish-drafts/use-publish-pieces.d.ts +4 -0
- package/dist/views/products/product-flow/admin-product-flow.d.ts +4 -0
- package/dist/views/products/product-flow/basics-section.d.ts +5 -1
- package/dist/views/products/product-flow/flow-actions.d.ts +3 -0
- package/dist/views/products/product-flow/flow-frame.d.ts +4 -2
- package/dist/views/products/product-flow/materials-field.d.ts +6 -0
- package/dist/views/products/product-flow/use-product-flow.d.ts +10 -0
- package/dist/views/products/product-sheet/delete-draft-button.d.ts +9 -0
- package/dist/views/shipping/shipping-rate-row.d.ts +2 -1
- package/package.json +2 -2
- package/dist/client-DCL5DSHP.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, o as l, p as u, r as d, s as f, u as p } from "./client-ClTCzt-p.js";
|
|
3
3
|
import { createContext as m, useCallback as h, useContext as g, useEffect as _, useId as v, useRef as y, useState as b, useSyncExternalStore as x } from "react";
|
|
4
4
|
import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
5
|
+
import { formatOrderRef as T, shippingRatesInputSchema as E } from "@develemit/commerce-contracts";
|
|
6
6
|
// src/lib/order-labels.ts
|
|
7
|
-
var
|
|
7
|
+
var D = {
|
|
8
8
|
title: "Orders",
|
|
9
9
|
searchLabel: "Search orders",
|
|
10
|
-
searchPlaceholder: "Search
|
|
10
|
+
searchPlaceholder: "Search orders",
|
|
11
11
|
tabs: {
|
|
12
12
|
paid: "To ship",
|
|
13
13
|
shipped: "Shipped",
|
|
@@ -47,6 +47,7 @@ var E = {
|
|
|
47
47
|
},
|
|
48
48
|
subtotal: "Subtotal",
|
|
49
49
|
shipping: "Shipping",
|
|
50
|
+
tax: "Tax",
|
|
50
51
|
total: "Total",
|
|
51
52
|
shippingAddress: "Shipping address",
|
|
52
53
|
noAddress: "No shipping address.",
|
|
@@ -87,6 +88,8 @@ var E = {
|
|
|
87
88
|
trackingUrl: "Tracking URL",
|
|
88
89
|
trackingUrlInvalid: "Enter a full link starting with http:// or https://.",
|
|
89
90
|
shipped: "Shipping details saved.",
|
|
91
|
+
shipWithoutTracking: "Ship without tracking",
|
|
92
|
+
trackingRequired: "Add a carrier and tracking number, or choose Ship without tracking.",
|
|
90
93
|
refund: "Refund…",
|
|
91
94
|
refundTitle: "Refund order",
|
|
92
95
|
refundAmount: "Amount",
|
|
@@ -105,7 +108,7 @@ var E = {
|
|
|
105
108
|
resolved: "Order resolved.",
|
|
106
109
|
restockThenResolve: "Restock, then resolve"
|
|
107
110
|
}
|
|
108
|
-
},
|
|
111
|
+
}, O = {
|
|
109
112
|
title: "Shipping rates",
|
|
110
113
|
loading: "Loading shipping rates…",
|
|
111
114
|
emptyTitle: "No shipping options yet",
|
|
@@ -138,7 +141,7 @@ var E = {
|
|
|
138
141
|
daysInvalid: "Use a whole number of days, or leave blank.",
|
|
139
142
|
daysOrder: "Fastest cannot be more than slowest.",
|
|
140
143
|
rowInvalid: "These details are not valid."
|
|
141
|
-
},
|
|
144
|
+
}, k = {
|
|
142
145
|
title: "Discounts",
|
|
143
146
|
newDiscount: "New discount",
|
|
144
147
|
searchLabel: "Search discounts",
|
|
@@ -202,12 +205,13 @@ var E = {
|
|
|
202
205
|
invalid: "This value is not valid."
|
|
203
206
|
},
|
|
204
207
|
orderRow: "Discount"
|
|
205
|
-
},
|
|
208
|
+
}, A = {
|
|
206
209
|
addSeveral: {
|
|
207
210
|
title: "Add several pieces",
|
|
208
211
|
introTitle: "One photo, one piece",
|
|
209
212
|
introBody: "Choose a stack of photos from your camera roll. Each one becomes a draft, and you name and price them one at a time next.",
|
|
210
213
|
choose: "Choose photos",
|
|
214
|
+
dropHint: "Pick as many as you like. Each photo becomes its own piece.",
|
|
211
215
|
progress: "Adding {done} of {total}…",
|
|
212
216
|
failedTitle: "{count} did not upload",
|
|
213
217
|
retry: "Try again",
|
|
@@ -233,6 +237,7 @@ var E = {
|
|
|
233
237
|
title: "Ready for the shop?",
|
|
234
238
|
lede: "Pieces with their details can go in the shop now. The rest stay as drafts.",
|
|
235
239
|
needsDetails: "Needs details",
|
|
240
|
+
openPiece: "Finish {name}",
|
|
236
241
|
untitled: "Untitled piece",
|
|
237
242
|
publish: "Put {count} in the shop",
|
|
238
243
|
keepDrafts: "Keep as drafts",
|
|
@@ -241,7 +246,7 @@ var E = {
|
|
|
241
246
|
publishedBody: "Customers can see them now.",
|
|
242
247
|
allSkipped: "None of these are ready yet."
|
|
243
248
|
}
|
|
244
|
-
},
|
|
249
|
+
}, j = {
|
|
245
250
|
title: "Photos",
|
|
246
251
|
empty: "Add a photo so this can go live.",
|
|
247
252
|
add: "Add photos",
|
|
@@ -266,12 +271,12 @@ var E = {
|
|
|
266
271
|
wrongType: "{name} must be a JPEG, PNG, WebP or HEIC image.",
|
|
267
272
|
reorderFailed: "The photos could not be reordered. The old order is back.",
|
|
268
273
|
dismiss: "Dismiss"
|
|
269
|
-
},
|
|
274
|
+
}, M = [
|
|
270
275
|
"photos",
|
|
271
276
|
"basics",
|
|
272
277
|
"story",
|
|
273
278
|
"preview"
|
|
274
|
-
],
|
|
279
|
+
], N = {
|
|
275
280
|
title: "Products",
|
|
276
281
|
newProduct: "New product",
|
|
277
282
|
searchLabel: "Search products",
|
|
@@ -291,6 +296,10 @@ var E = {
|
|
|
291
296
|
archived: "No archived products."
|
|
292
297
|
},
|
|
293
298
|
noMatches: "No products match that search.",
|
|
299
|
+
emptyActions: {
|
|
300
|
+
start: "Start a piece",
|
|
301
|
+
clearSearch: "Clear search"
|
|
302
|
+
},
|
|
294
303
|
loadMore: "Load more",
|
|
295
304
|
welcome: {
|
|
296
305
|
title: "Your shop is ready for its first piece",
|
|
@@ -328,11 +337,15 @@ var E = {
|
|
|
328
337
|
edit: "Edit details",
|
|
329
338
|
photos: "Photos ({count})",
|
|
330
339
|
featureOn: "Feature on home",
|
|
331
|
-
featureOff: "
|
|
332
|
-
hide: "Hide from shop",
|
|
340
|
+
featureOff: "Take off the home page",
|
|
341
|
+
hide: "Hide from the shop",
|
|
333
342
|
copyLink: "Copy shop link",
|
|
334
343
|
linkCopied: "Link copied.",
|
|
335
344
|
archive: "Archive",
|
|
345
|
+
deleteDraft: "Delete draft",
|
|
346
|
+
deleteTitle: "Delete this draft?",
|
|
347
|
+
deleteBody: "This removes the draft and its photos for good. There is no undo.",
|
|
348
|
+
deleteConfirm: "Delete draft",
|
|
336
349
|
undo: "Undo",
|
|
337
350
|
missingTitle: "Before it can go in the shop, it needs:",
|
|
338
351
|
missing: {
|
|
@@ -391,7 +404,7 @@ var E = {
|
|
|
391
404
|
status: "Status",
|
|
392
405
|
featured: "Feature this product on the home page"
|
|
393
406
|
},
|
|
394
|
-
images:
|
|
407
|
+
images: j,
|
|
395
408
|
flow: {
|
|
396
409
|
newTitle: "New product",
|
|
397
410
|
editTitle: "Edit product",
|
|
@@ -412,7 +425,7 @@ var E = {
|
|
|
412
425
|
},
|
|
413
426
|
ledes: {
|
|
414
427
|
photos: "The first photo is the one customers see in the shop. Tap any photo to make it the cover.",
|
|
415
|
-
basics: "That is all
|
|
428
|
+
basics: "That is all it needs to go in the shop.",
|
|
416
429
|
story: "Optional, but it helps it sell. You can add this later.",
|
|
417
430
|
preview: "This is how customers will see it."
|
|
418
431
|
},
|
|
@@ -426,15 +439,26 @@ var E = {
|
|
|
426
439
|
removePhoto: "Remove photo {n}",
|
|
427
440
|
uploading: "Uploading {name}…",
|
|
428
441
|
pricePlaceholder: "0.00",
|
|
429
|
-
otherCategory: "
|
|
442
|
+
otherCategory: "New category…",
|
|
430
443
|
newCategory: "New category",
|
|
431
444
|
oneOfAKind: "One of a kind",
|
|
432
445
|
howMany: "How many do you have?",
|
|
433
446
|
descriptionPrompts: [],
|
|
447
|
+
descriptionPlaceholder: "",
|
|
448
|
+
sizePlaceholder: "",
|
|
449
|
+
altPlaceholder: "",
|
|
450
|
+
previewHeadingLive: "Your changes",
|
|
451
|
+
saveChanges: "Save changes",
|
|
452
|
+
seeInShop: "See it in the shop",
|
|
453
|
+
continueNeeds: "Add {things} to continue",
|
|
454
|
+
addPhotoTile: "Add photo",
|
|
455
|
+
stepCount: "Step {n} of {total}",
|
|
434
456
|
materialsOther: "Or type your own",
|
|
435
457
|
size: "Size",
|
|
458
|
+
taxCode: "Tax category",
|
|
459
|
+
taxCodeDefault: "Default",
|
|
436
460
|
altTitle: "Describe each photo",
|
|
437
|
-
altHelp: "
|
|
461
|
+
altHelp: "Describe the photo for shoppers who can’t see it. Left blank, it uses the name.",
|
|
438
462
|
altFallback: "{name}, photo {n}",
|
|
439
463
|
inTheShop: "In the shop",
|
|
440
464
|
untitled: "Untitled product",
|
|
@@ -448,17 +472,17 @@ var E = {
|
|
|
448
472
|
publish: "Put it in the shop",
|
|
449
473
|
done: "Done",
|
|
450
474
|
saving: "Saving…",
|
|
451
|
-
savedNew: "Saved as
|
|
475
|
+
savedNew: "Saved as you go",
|
|
452
476
|
savedEdit: "Saved",
|
|
453
477
|
saveFailed: "Your changes have not been saved yet.",
|
|
454
478
|
retry: "Try again",
|
|
455
479
|
savedAsDraft: "Saved as a draft",
|
|
456
480
|
success: "It’s in the shop!",
|
|
457
|
-
successFirst: "Your first
|
|
481
|
+
successFirst: "Your first one is in the shop!",
|
|
458
482
|
addAnother: "Add another",
|
|
459
|
-
backToList: "Back to
|
|
483
|
+
backToList: "Back to the list"
|
|
460
484
|
},
|
|
461
|
-
stock:
|
|
485
|
+
stock: A,
|
|
462
486
|
statusHelp: "Draft is hidden. Active is live in the shop. Archived is hidden and kept. Mark a piece sold from the product list.",
|
|
463
487
|
priceHelp: "In dollars, for example 48.00.",
|
|
464
488
|
validation: {
|
|
@@ -466,7 +490,7 @@ var E = {
|
|
|
466
490
|
price: "Enter a price like 48 or 48.50.",
|
|
467
491
|
quantity: "Enter a whole number, zero or more."
|
|
468
492
|
}
|
|
469
|
-
},
|
|
493
|
+
}, P = {
|
|
470
494
|
loading: "Loading…",
|
|
471
495
|
empty: "Nothing here yet.",
|
|
472
496
|
save: "Save",
|
|
@@ -479,7 +503,10 @@ var E = {
|
|
|
479
503
|
orders: "Orders",
|
|
480
504
|
shippingRates: "Shipping rates",
|
|
481
505
|
more: "More",
|
|
482
|
-
closeMore: "Close menu"
|
|
506
|
+
closeMore: "Close menu",
|
|
507
|
+
viewShop: "View shop",
|
|
508
|
+
badge: (e) => `${e} waiting`,
|
|
509
|
+
productsBadge: (e) => `${e} drafts`
|
|
483
510
|
},
|
|
484
511
|
statuses: {
|
|
485
512
|
draft: "Draft",
|
|
@@ -511,14 +538,14 @@ var E = {
|
|
|
511
538
|
imageTooLarge: "That image is too large. Choose a smaller one.",
|
|
512
539
|
generic: "Something went wrong. Try again."
|
|
513
540
|
},
|
|
514
|
-
products:
|
|
515
|
-
orders:
|
|
516
|
-
shipping:
|
|
517
|
-
discounts:
|
|
541
|
+
products: N,
|
|
542
|
+
orders: D,
|
|
543
|
+
shipping: O,
|
|
544
|
+
discounts: k
|
|
518
545
|
};
|
|
519
546
|
// src/lib/merge-labels.ts
|
|
520
547
|
function ee(e) {
|
|
521
|
-
let t =
|
|
548
|
+
let t = D;
|
|
522
549
|
return {
|
|
523
550
|
...t,
|
|
524
551
|
...e,
|
|
@@ -556,8 +583,8 @@ function ee(e) {
|
|
|
556
583
|
}
|
|
557
584
|
};
|
|
558
585
|
}
|
|
559
|
-
function
|
|
560
|
-
let t =
|
|
586
|
+
function te(e) {
|
|
587
|
+
let t = N;
|
|
561
588
|
return {
|
|
562
589
|
...t,
|
|
563
590
|
...e,
|
|
@@ -581,6 +608,10 @@ function P(e) {
|
|
|
581
608
|
...t.welcome,
|
|
582
609
|
...e?.welcome
|
|
583
610
|
},
|
|
611
|
+
emptyActions: {
|
|
612
|
+
...t.emptyActions,
|
|
613
|
+
...e?.emptyActions
|
|
614
|
+
},
|
|
584
615
|
card: {
|
|
585
616
|
...t.card,
|
|
586
617
|
...e?.card
|
|
@@ -649,8 +680,8 @@ function P(e) {
|
|
|
649
680
|
}
|
|
650
681
|
};
|
|
651
682
|
}
|
|
652
|
-
function
|
|
653
|
-
let t =
|
|
683
|
+
function ne(e) {
|
|
684
|
+
let t = k;
|
|
654
685
|
return {
|
|
655
686
|
...t,
|
|
656
687
|
...e,
|
|
@@ -680,8 +711,8 @@ function te(e) {
|
|
|
680
711
|
}
|
|
681
712
|
};
|
|
682
713
|
}
|
|
683
|
-
function
|
|
684
|
-
let t =
|
|
714
|
+
function re(e) {
|
|
715
|
+
let t = P;
|
|
685
716
|
return {
|
|
686
717
|
...t,
|
|
687
718
|
...e,
|
|
@@ -697,20 +728,21 @@ function ne(e) {
|
|
|
697
728
|
...t.errors,
|
|
698
729
|
...e?.errors
|
|
699
730
|
},
|
|
700
|
-
products:
|
|
731
|
+
products: te(e?.products),
|
|
701
732
|
orders: ee(e?.orders),
|
|
702
733
|
shipping: {
|
|
703
|
-
...
|
|
734
|
+
...O,
|
|
704
735
|
...e?.shipping
|
|
705
736
|
},
|
|
706
|
-
discounts:
|
|
737
|
+
discounts: ne(e?.discounts)
|
|
707
738
|
};
|
|
708
739
|
}
|
|
709
740
|
// src/lib/provider.tsx
|
|
710
|
-
var
|
|
711
|
-
renderLink: ({ href: e, children: t, className: n }) => /* @__PURE__ */ C("a", {
|
|
741
|
+
var ie = {
|
|
742
|
+
renderLink: ({ href: e, children: t, className: n, "aria-current": r }) => /* @__PURE__ */ C("a", {
|
|
712
743
|
href: e,
|
|
713
744
|
className: n,
|
|
745
|
+
"aria-current": r,
|
|
714
746
|
children: t
|
|
715
747
|
}),
|
|
716
748
|
renderImage: ({ src: e, alt: t, sizes: n, className: r, priority: i }) => /* @__PURE__ */ C("img", {
|
|
@@ -736,25 +768,25 @@ var re = {
|
|
|
736
768
|
newDiscount: "/admin/discounts/new"
|
|
737
769
|
},
|
|
738
770
|
client: null,
|
|
739
|
-
labels:
|
|
740
|
-
},
|
|
741
|
-
function
|
|
771
|
+
labels: P
|
|
772
|
+
}, ae = m(ie);
|
|
773
|
+
function oe({ children: e, hrefs: t, labels: n, ...r }) {
|
|
742
774
|
let i = {
|
|
743
|
-
...
|
|
775
|
+
...ie,
|
|
744
776
|
...r,
|
|
745
777
|
hrefs: {
|
|
746
|
-
...
|
|
778
|
+
...ie.hrefs,
|
|
747
779
|
...t
|
|
748
780
|
},
|
|
749
|
-
labels:
|
|
781
|
+
labels: re(n)
|
|
750
782
|
};
|
|
751
|
-
return /* @__PURE__ */ C(
|
|
783
|
+
return /* @__PURE__ */ C(ae.Provider, {
|
|
752
784
|
value: i,
|
|
753
785
|
children: e
|
|
754
786
|
});
|
|
755
787
|
}
|
|
756
788
|
function F() {
|
|
757
|
-
return g(
|
|
789
|
+
return g(ae);
|
|
758
790
|
}
|
|
759
791
|
function I() {
|
|
760
792
|
let { client: e } = F();
|
|
@@ -884,16 +916,17 @@ var B = {
|
|
|
884
916
|
r: "3"
|
|
885
917
|
}))
|
|
886
918
|
};
|
|
887
|
-
function
|
|
919
|
+
function se(e) {
|
|
888
920
|
return e !== void 0 && e !== "" && e !== 0;
|
|
889
921
|
}
|
|
890
|
-
function
|
|
922
|
+
function ce(e, t, n, r) {
|
|
891
923
|
let i = [
|
|
892
924
|
{
|
|
893
925
|
href: e.products,
|
|
894
926
|
label: t.products,
|
|
895
927
|
icon: B.products,
|
|
896
|
-
badge: r.products
|
|
928
|
+
badge: r.products,
|
|
929
|
+
badgeLabel: se(r.products) ? t.productsBadge(r.products) : void 0
|
|
897
930
|
},
|
|
898
931
|
{
|
|
899
932
|
href: e.orders,
|
|
@@ -919,10 +952,13 @@ function se(e, t, n, r) {
|
|
|
919
952
|
...n.filter((e) => e.position !== "start").map(a)
|
|
920
953
|
].map((e) => ({
|
|
921
954
|
...e,
|
|
922
|
-
badge:
|
|
955
|
+
badge: se(e.badge) ? e.badge : void 0
|
|
956
|
+
})).map((e) => ({
|
|
957
|
+
...e,
|
|
958
|
+
badgeLabel: e.badge === void 0 ? void 0 : e.badgeLabel ?? t.badge(e.badge)
|
|
923
959
|
}));
|
|
924
960
|
}
|
|
925
|
-
function
|
|
961
|
+
function le(e) {
|
|
926
962
|
return e.length <= 5 ? {
|
|
927
963
|
bar: e,
|
|
928
964
|
overflow: []
|
|
@@ -931,8 +967,31 @@ function ce(e) {
|
|
|
931
967
|
overflow: e.slice(4)
|
|
932
968
|
};
|
|
933
969
|
}
|
|
970
|
+
// src/components/admin-layout/current-item.ts
|
|
971
|
+
function ue(e) {
|
|
972
|
+
let t = e.split(/[?#]/)[0] ?? "";
|
|
973
|
+
return t.length > 1 ? t.replace(/\/+$/, "") : t;
|
|
974
|
+
}
|
|
975
|
+
function de(e, t) {
|
|
976
|
+
if (!t) return;
|
|
977
|
+
let n = ue(t), r, i = -1;
|
|
978
|
+
for (let t of e) {
|
|
979
|
+
let e = ue(t);
|
|
980
|
+
(n === e || e !== "/" && n.startsWith(`${e}/`)) && e.length > i && (r = t, i = e.length);
|
|
981
|
+
}
|
|
982
|
+
return r;
|
|
983
|
+
}
|
|
984
|
+
// src/components/admin-layout/use-current-href.ts
|
|
985
|
+
function fe(e) {
|
|
986
|
+
let [t, n] = b();
|
|
987
|
+
return _(() => {
|
|
988
|
+
if (e !== void 0) return;
|
|
989
|
+
let t = () => n(window.location.pathname);
|
|
990
|
+
return t(), window.addEventListener("popstate", t), () => window.removeEventListener("popstate", t);
|
|
991
|
+
}, [e]), e ?? t;
|
|
992
|
+
}
|
|
934
993
|
// src/components/admin-layout/use-more-sheet.ts
|
|
935
|
-
function
|
|
994
|
+
function pe() {
|
|
936
995
|
let [e, t] = b(!1), n = h(() => t(!1), []), r = h(() => t((e) => !e), []);
|
|
937
996
|
return _(() => {
|
|
938
997
|
if (!e) return;
|
|
@@ -947,10 +1006,11 @@ function le() {
|
|
|
947
1006
|
};
|
|
948
1007
|
}
|
|
949
1008
|
// src/components/admin-layout/admin-layout.tsx
|
|
950
|
-
function
|
|
951
|
-
let { hrefs:
|
|
1009
|
+
function me({ children: e, extraNav: t = [], navBadges: n = {}, header: r, footer: i, currentHref: a }) {
|
|
1010
|
+
let { hrefs: o, labels: s, renderLink: c } = F(), l = v(), u = pe(), d = ce(o, s.nav, t, n), { bar: f, overflow: p } = le(d), m = de(d.map((e) => e.href), fe(a)), h = (e, t) => c({
|
|
952
1011
|
href: e.href,
|
|
953
|
-
className: t,
|
|
1012
|
+
className: e.href === m ? `${t} is-current` : t,
|
|
1013
|
+
"aria-current": e.href === m ? "page" : void 0,
|
|
954
1014
|
children: /* @__PURE__ */ w(S, { children: [
|
|
955
1015
|
/* @__PURE__ */ C("span", {
|
|
956
1016
|
className: "sfa-nav__icon",
|
|
@@ -962,6 +1022,9 @@ function ue({ children: e, extraNav: t = [], navBadges: n = {}, header: r, foote
|
|
|
962
1022
|
}),
|
|
963
1023
|
e.badge === void 0 ? null : /* @__PURE__ */ C("span", {
|
|
964
1024
|
className: "sfa-nav__badge",
|
|
1025
|
+
role: "img",
|
|
1026
|
+
"aria-label": e.badgeLabel,
|
|
1027
|
+
title: e.badgeLabel,
|
|
965
1028
|
children: e.badge
|
|
966
1029
|
})
|
|
967
1030
|
] })
|
|
@@ -978,8 +1041,8 @@ function ue({ children: e, extraNav: t = [], navBadges: n = {}, header: r, foote
|
|
|
978
1041
|
}) : null,
|
|
979
1042
|
/* @__PURE__ */ C("nav", {
|
|
980
1043
|
className: "sfa-nav",
|
|
981
|
-
"aria-label":
|
|
982
|
-
children: /* @__PURE__ */ C("ul", { children:
|
|
1044
|
+
"aria-label": s.navLabel,
|
|
1045
|
+
children: /* @__PURE__ */ C("ul", { children: d.map((e) => /* @__PURE__ */ C("li", { children: h(e, "sfa-nav__link") }, e.href)) })
|
|
983
1046
|
}),
|
|
984
1047
|
i ? /* @__PURE__ */ C("div", {
|
|
985
1048
|
className: "sfa-layout__footer",
|
|
@@ -993,13 +1056,13 @@ function ue({ children: e, extraNav: t = [], navBadges: n = {}, header: r, foote
|
|
|
993
1056
|
}),
|
|
994
1057
|
/* @__PURE__ */ C("nav", {
|
|
995
1058
|
className: "sfa-tabbar",
|
|
996
|
-
"aria-label":
|
|
997
|
-
children: /* @__PURE__ */ w("ul", { children: [
|
|
1059
|
+
"aria-label": s.navLabel,
|
|
1060
|
+
children: /* @__PURE__ */ w("ul", { children: [f.map((e) => /* @__PURE__ */ C("li", { children: h(e, "sfa-tabbar__item") }, e.href)), p.length > 0 || o.storefront || r || i ? /* @__PURE__ */ C("li", { children: /* @__PURE__ */ w("button", {
|
|
998
1061
|
type: "button",
|
|
999
1062
|
className: "sfa-tabbar__item",
|
|
1000
|
-
"aria-expanded":
|
|
1001
|
-
"aria-controls":
|
|
1002
|
-
onClick:
|
|
1063
|
+
"aria-expanded": u.open,
|
|
1064
|
+
"aria-controls": l,
|
|
1065
|
+
onClick: u.toggle,
|
|
1003
1066
|
children: [
|
|
1004
1067
|
/* @__PURE__ */ C("span", {
|
|
1005
1068
|
className: "sfa-nav__icon",
|
|
@@ -1007,33 +1070,43 @@ function ue({ children: e, extraNav: t = [], navBadges: n = {}, header: r, foote
|
|
|
1007
1070
|
}),
|
|
1008
1071
|
/* @__PURE__ */ C("span", {
|
|
1009
1072
|
className: "sfa-nav__label",
|
|
1010
|
-
children:
|
|
1073
|
+
children: s.nav.more
|
|
1011
1074
|
}),
|
|
1012
|
-
|
|
1075
|
+
p.some((e) => e.badge !== void 0) ? /* @__PURE__ */ C("span", { className: "sfa-nav__badge sfa-nav__badge--dot" }) : null
|
|
1013
1076
|
]
|
|
1014
1077
|
}) }) : null] })
|
|
1015
1078
|
}),
|
|
1016
|
-
|
|
1079
|
+
u.open ? /* @__PURE__ */ C("button", {
|
|
1017
1080
|
type: "button",
|
|
1018
1081
|
className: "sfa-more__backdrop",
|
|
1019
|
-
"aria-label":
|
|
1020
|
-
onClick:
|
|
1082
|
+
"aria-label": s.nav.closeMore,
|
|
1083
|
+
onClick: u.close
|
|
1021
1084
|
}) : null,
|
|
1022
1085
|
/* @__PURE__ */ w("div", {
|
|
1023
|
-
id:
|
|
1086
|
+
id: l,
|
|
1024
1087
|
className: "sfa-more",
|
|
1025
|
-
hidden: !
|
|
1088
|
+
hidden: !u.open,
|
|
1026
1089
|
onClick: (e) => {
|
|
1027
|
-
e.target.closest("a") &&
|
|
1090
|
+
e.target.closest("a") && u.close();
|
|
1028
1091
|
},
|
|
1029
1092
|
children: [
|
|
1093
|
+
/* @__PURE__ */ C("button", {
|
|
1094
|
+
type: "button",
|
|
1095
|
+
className: "sfa-btn sfa-btn--ghost sfa-more__close",
|
|
1096
|
+
onClick: u.close,
|
|
1097
|
+
children: s.nav.closeMore
|
|
1098
|
+
}),
|
|
1030
1099
|
r ? /* @__PURE__ */ C("div", {
|
|
1031
1100
|
className: "sfa-layout__header",
|
|
1032
1101
|
children: r
|
|
1033
1102
|
}) : null,
|
|
1034
|
-
|
|
1103
|
+
p.length > 0 || o.storefront ? /* @__PURE__ */ w("ul", {
|
|
1035
1104
|
className: "sfa-more__list",
|
|
1036
|
-
children:
|
|
1105
|
+
children: [p.map((e) => /* @__PURE__ */ C("li", { children: h(e, "sfa-nav__link") }, e.href)), o.storefront ? /* @__PURE__ */ C("li", { children: c({
|
|
1106
|
+
href: o.storefront,
|
|
1107
|
+
className: "sfa-nav__link",
|
|
1108
|
+
children: s.nav.viewShop
|
|
1109
|
+
}) }) : null]
|
|
1037
1110
|
}) : null,
|
|
1038
1111
|
i ? /* @__PURE__ */ C("div", {
|
|
1039
1112
|
className: "sfa-layout__footer",
|
|
@@ -1079,6 +1152,7 @@ function H({ columns: e, rows: t, rowKey: n, caption: r }) {
|
|
|
1079
1152
|
}, e.key)) }) }),
|
|
1080
1153
|
/* @__PURE__ */ C("tbody", { children: t.map((t) => /* @__PURE__ */ C("tr", { children: e.map((e) => /* @__PURE__ */ C("td", {
|
|
1081
1154
|
"data-label": e.header,
|
|
1155
|
+
"data-col": e.key,
|
|
1082
1156
|
children: e.render(t)
|
|
1083
1157
|
}, e.key)) }, n(t))) })
|
|
1084
1158
|
]
|
|
@@ -1104,12 +1178,12 @@ function W({ cents: e, currency: t }) {
|
|
|
1104
1178
|
});
|
|
1105
1179
|
}
|
|
1106
1180
|
// src/lib/use-focus-trap.ts
|
|
1107
|
-
var
|
|
1108
|
-
function
|
|
1181
|
+
var he = "button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])";
|
|
1182
|
+
function ge(e, t, n) {
|
|
1109
1183
|
return _(() => {
|
|
1110
1184
|
if (!t) return;
|
|
1111
1185
|
let n = document.activeElement;
|
|
1112
|
-
return e.current?.querySelector(
|
|
1186
|
+
return e.current?.querySelector(he)?.focus({ focusVisible: !0 }), () => n?.focus();
|
|
1113
1187
|
}, [t, e]), _(() => {
|
|
1114
1188
|
if (!t) return;
|
|
1115
1189
|
let e = (e) => {
|
|
@@ -1122,7 +1196,7 @@ function fe(e, t, n) {
|
|
|
1122
1196
|
return;
|
|
1123
1197
|
}
|
|
1124
1198
|
if (t.key !== "Tab") return;
|
|
1125
|
-
let r = Array.from(e.current?.querySelectorAll(
|
|
1199
|
+
let r = Array.from(e.current?.querySelectorAll(he) ?? []);
|
|
1126
1200
|
if (r.length === 0) return;
|
|
1127
1201
|
let i = r[0], a = r[r.length - 1];
|
|
1128
1202
|
t.shiftKey && document.activeElement === i ? (t.preventDefault(), a.focus()) : !t.shiftKey && document.activeElement === a && (t.preventDefault(), i.focus());
|
|
@@ -1130,7 +1204,7 @@ function fe(e, t, n) {
|
|
|
1130
1204
|
}
|
|
1131
1205
|
// src/components/confirm-dialog/confirm-dialog.tsx
|
|
1132
1206
|
function G({ open: e, title: t, children: n, confirmLabel: r, destructive: i = !1, pending: a = !1, onConfirm: o, onCancel: s }) {
|
|
1133
|
-
let { labels: c } = F(), l = y(null), u =
|
|
1207
|
+
let { labels: c } = F(), l = y(null), u = ge(l, e, s);
|
|
1134
1208
|
return e ? /* @__PURE__ */ C("div", {
|
|
1135
1209
|
className: "sfa-dialog-backdrop",
|
|
1136
1210
|
onKeyDown: u,
|
|
@@ -1167,8 +1241,11 @@ function G({ open: e, title: t, children: n, confirmLabel: r, destructive: i = !
|
|
|
1167
1241
|
}
|
|
1168
1242
|
// src/components/notice/notice.tsx
|
|
1169
1243
|
function K({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismiss: i, action: a }) {
|
|
1170
|
-
let { labels: o } = F();
|
|
1244
|
+
let { labels: o } = F(), s = y(null);
|
|
1171
1245
|
_(() => {
|
|
1246
|
+
let e = s.current;
|
|
1247
|
+
!n && e && "scrollIntoView" in e && e.scrollIntoView({ block: "nearest" });
|
|
1248
|
+
}, [n]), _(() => {
|
|
1172
1249
|
if (!n || !i) return;
|
|
1173
1250
|
let e = setTimeout(i, r);
|
|
1174
1251
|
return () => clearTimeout(e);
|
|
@@ -1177,10 +1254,11 @@ function K({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismis
|
|
|
1177
1254
|
r,
|
|
1178
1255
|
i
|
|
1179
1256
|
]);
|
|
1180
|
-
let
|
|
1257
|
+
let c = e === "error" ? "alert" : "status", l = `sfa-notice sfa-notice--${e}${n ? " sfa-notice--toast" : ""}`;
|
|
1181
1258
|
return /* @__PURE__ */ w("div", {
|
|
1182
|
-
|
|
1183
|
-
|
|
1259
|
+
ref: s,
|
|
1260
|
+
role: c,
|
|
1261
|
+
className: l,
|
|
1184
1262
|
children: [
|
|
1185
1263
|
/* @__PURE__ */ C("span", {
|
|
1186
1264
|
className: "sfa-notice__body",
|
|
@@ -1202,79 +1280,132 @@ function K({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismis
|
|
|
1202
1280
|
});
|
|
1203
1281
|
}
|
|
1204
1282
|
// src/components/error-message/error-message.tsx
|
|
1205
|
-
var
|
|
1206
|
-
[
|
|
1207
|
-
[
|
|
1283
|
+
var _e = [
|
|
1284
|
+
[t, "unauthorized"],
|
|
1285
|
+
[s, "notFound"],
|
|
1208
1286
|
[d, "invalidInput"],
|
|
1209
|
-
[
|
|
1210
|
-
[
|
|
1211
|
-
[
|
|
1287
|
+
[r, "invalidOrderState"],
|
|
1288
|
+
[c, "insufficientStock"],
|
|
1289
|
+
[o, "refundExceedsBalance"],
|
|
1212
1290
|
[a, "refundGateway"],
|
|
1213
|
-
[
|
|
1291
|
+
[e, "refundOutcomeUnknown"],
|
|
1214
1292
|
[l, "discountCodeTaken"],
|
|
1215
1293
|
[f, "discountInUse"],
|
|
1216
|
-
[
|
|
1294
|
+
[n, "imageTooLarge"],
|
|
1217
1295
|
[p, "imageInvalid"]
|
|
1218
1296
|
];
|
|
1219
|
-
function
|
|
1220
|
-
return
|
|
1297
|
+
function ve(e) {
|
|
1298
|
+
return _e.find(([t]) => e instanceof t)?.[1] ?? "generic";
|
|
1221
1299
|
}
|
|
1222
1300
|
function q({ error: e }) {
|
|
1223
1301
|
let { labels: t } = F();
|
|
1224
1302
|
return e ? /* @__PURE__ */ C(K, {
|
|
1225
1303
|
variant: "error",
|
|
1226
|
-
children: t.errors[
|
|
1304
|
+
children: t.errors[ve(e)]
|
|
1227
1305
|
}) : null;
|
|
1228
1306
|
}
|
|
1307
|
+
// src/components/empty-state/empty-state.tsx
|
|
1308
|
+
var ye = {
|
|
1309
|
+
orders: "M4 8l8-4 8 4v8l-8 4-8-4V8zm0 0l8 4m0 0l8-4m-8 4v8",
|
|
1310
|
+
discounts: "M3 12V4h8l10 10-8 8L3 12zm5-5h.01",
|
|
1311
|
+
shipping: "M2 6h11v9H2V6zm11 3h4l3 3v3h-7V9zM6 18.5h.01M17 18.5h.01",
|
|
1312
|
+
products: "M4 7h16v13H4V7zm0 0l2-3h12l2 3M9 12h6",
|
|
1313
|
+
search: "M11 4a7 7 0 100 14 7 7 0 000-14zm9 16l-4-4"
|
|
1314
|
+
};
|
|
1315
|
+
function J({ icon: e, title: t, body: n, action: r, children: i }) {
|
|
1316
|
+
return /* @__PURE__ */ w("div", {
|
|
1317
|
+
className: "sfa-empty-state",
|
|
1318
|
+
children: [
|
|
1319
|
+
/* @__PURE__ */ C("svg", {
|
|
1320
|
+
className: "sfa-empty-state__icon",
|
|
1321
|
+
viewBox: "0 0 24 24",
|
|
1322
|
+
width: "48",
|
|
1323
|
+
height: "48",
|
|
1324
|
+
fill: "none",
|
|
1325
|
+
stroke: "currentColor",
|
|
1326
|
+
strokeWidth: "1.5",
|
|
1327
|
+
strokeLinecap: "round",
|
|
1328
|
+
strokeLinejoin: "round",
|
|
1329
|
+
"aria-hidden": "true",
|
|
1330
|
+
focusable: "false",
|
|
1331
|
+
children: /* @__PURE__ */ C("path", { d: ye[e] })
|
|
1332
|
+
}),
|
|
1333
|
+
/* @__PURE__ */ C("h2", {
|
|
1334
|
+
className: "sfa-empty-state__title",
|
|
1335
|
+
children: t
|
|
1336
|
+
}),
|
|
1337
|
+
n ? /* @__PURE__ */ C("p", {
|
|
1338
|
+
className: "sfa-empty-state__body",
|
|
1339
|
+
children: n
|
|
1340
|
+
}) : null,
|
|
1341
|
+
i,
|
|
1342
|
+
r ? /* @__PURE__ */ C("div", {
|
|
1343
|
+
className: "sfa-empty-state__action",
|
|
1344
|
+
children: r
|
|
1345
|
+
}) : null
|
|
1346
|
+
]
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1229
1349
|
// src/lib/product-missing.ts
|
|
1230
|
-
function
|
|
1350
|
+
function be(e, t) {
|
|
1231
1351
|
return e.status === "draft" ? e.priceCents === null ? t.needsPrice : e.category ? e.images.length === 0 ? t.needsPhoto : null : t.needsCategory : null;
|
|
1232
1352
|
}
|
|
1233
|
-
function
|
|
1353
|
+
function Y(e, t) {
|
|
1234
1354
|
return e.replace(/\{(\w+)\}/g, (e, n) => String(t[n] ?? ""));
|
|
1235
1355
|
}
|
|
1236
1356
|
// src/components/setup-checklist/setup-checklist.tsx
|
|
1237
|
-
function
|
|
1357
|
+
function xe({ step: e }) {
|
|
1238
1358
|
let t = e.locked ? e.lockedDetail : e.detail;
|
|
1239
|
-
return /* @__PURE__ */ w(S, { children: [
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
className: "sfa-
|
|
1247
|
-
children:
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1359
|
+
return /* @__PURE__ */ w(S, { children: [
|
|
1360
|
+
/* @__PURE__ */ C("span", {
|
|
1361
|
+
className: "sfa-setup__mark",
|
|
1362
|
+
"aria-hidden": "true",
|
|
1363
|
+
children: e.done ? "✓" : ""
|
|
1364
|
+
}),
|
|
1365
|
+
/* @__PURE__ */ w("span", {
|
|
1366
|
+
className: "sfa-setup__text",
|
|
1367
|
+
children: [/* @__PURE__ */ C("span", {
|
|
1368
|
+
className: "sfa-setup__name",
|
|
1369
|
+
children: e.title
|
|
1370
|
+
}), t ? /* @__PURE__ */ C("span", {
|
|
1371
|
+
className: "sfa-setup__detail",
|
|
1372
|
+
children: t
|
|
1373
|
+
}) : null]
|
|
1374
|
+
}),
|
|
1375
|
+
Se(e) ? /* @__PURE__ */ C("span", {
|
|
1376
|
+
className: "sfa-setup__chevron",
|
|
1377
|
+
"aria-hidden": "true",
|
|
1378
|
+
children: "›"
|
|
1379
|
+
}) : null
|
|
1380
|
+
] });
|
|
1253
1381
|
}
|
|
1254
|
-
function
|
|
1382
|
+
function Se(e) {
|
|
1383
|
+
return !e.done && !e.locked && !!(e.href || e.onSelect);
|
|
1384
|
+
}
|
|
1385
|
+
function Ce({ step: e }) {
|
|
1255
1386
|
let { renderLink: t } = F(), n = `sfa-setup__step${e.done ? " is-done" : ""}${e.locked ? " is-locked" : ""}`, r = !e.done && !e.locked, i;
|
|
1256
1387
|
return i = r && e.href ? t({
|
|
1257
1388
|
href: e.href,
|
|
1258
|
-
children: /* @__PURE__ */ C(
|
|
1389
|
+
children: /* @__PURE__ */ C(xe, { step: e }),
|
|
1259
1390
|
className: "sfa-setup__action"
|
|
1260
1391
|
}) : r && e.onSelect ? /* @__PURE__ */ C("button", {
|
|
1261
1392
|
type: "button",
|
|
1262
1393
|
className: "sfa-setup__action",
|
|
1263
1394
|
onClick: e.onSelect,
|
|
1264
|
-
children: /* @__PURE__ */ C(
|
|
1395
|
+
children: /* @__PURE__ */ C(xe, { step: e })
|
|
1265
1396
|
}) : /* @__PURE__ */ C("span", {
|
|
1266
1397
|
className: "sfa-setup__action",
|
|
1267
|
-
children: /* @__PURE__ */ C(
|
|
1398
|
+
children: /* @__PURE__ */ C(xe, { step: e })
|
|
1268
1399
|
}), /* @__PURE__ */ C("li", {
|
|
1269
1400
|
className: n,
|
|
1270
1401
|
"data-step": e.id,
|
|
1271
1402
|
children: i
|
|
1272
1403
|
});
|
|
1273
1404
|
}
|
|
1274
|
-
function
|
|
1275
|
-
let { labels: n } = F(), r = n.products.setup, [i, a] = b(!
|
|
1405
|
+
function we({ steps: e, compact: t = !1 }) {
|
|
1406
|
+
let { labels: n } = F(), r = n.products.setup, [i, a] = b(!0), o = e.filter((e) => e.done).length;
|
|
1276
1407
|
if (e.length === 0 || o === e.length) return null;
|
|
1277
|
-
let s =
|
|
1408
|
+
let s = Y(r.progress, {
|
|
1278
1409
|
done: o,
|
|
1279
1410
|
total: e.length
|
|
1280
1411
|
}), c = !t || i;
|
|
@@ -1313,19 +1444,19 @@ function ve({ steps: e, compact: t = !1 }) {
|
|
|
1313
1444
|
}),
|
|
1314
1445
|
c ? /* @__PURE__ */ C("ul", {
|
|
1315
1446
|
className: "sfa-setup__list",
|
|
1316
|
-
children: e.map((e) => /* @__PURE__ */ C(
|
|
1447
|
+
children: e.map((e) => /* @__PURE__ */ C(Ce, { step: e }, e.id))
|
|
1317
1448
|
}) : null
|
|
1318
1449
|
]
|
|
1319
1450
|
});
|
|
1320
1451
|
}
|
|
1321
1452
|
// src/lib/product-filter.ts
|
|
1322
|
-
function
|
|
1453
|
+
function Te(e) {
|
|
1323
1454
|
return e.status === "active" && e.quantity === 0;
|
|
1324
1455
|
}
|
|
1325
|
-
function
|
|
1326
|
-
return
|
|
1456
|
+
function Ee(e) {
|
|
1457
|
+
return Te(e) ? "sold" : e.status;
|
|
1327
1458
|
}
|
|
1328
|
-
function
|
|
1459
|
+
function De(e) {
|
|
1329
1460
|
switch (e) {
|
|
1330
1461
|
case "live":
|
|
1331
1462
|
case "sold": return "active";
|
|
@@ -1334,12 +1465,12 @@ function xe(e) {
|
|
|
1334
1465
|
case "all": return;
|
|
1335
1466
|
}
|
|
1336
1467
|
}
|
|
1337
|
-
function
|
|
1468
|
+
function Oe(e) {
|
|
1338
1469
|
if (e === "live") return "in";
|
|
1339
1470
|
if (e === "sold") return "sold";
|
|
1340
1471
|
}
|
|
1341
1472
|
// src/lib/use-debounced.ts
|
|
1342
|
-
function
|
|
1473
|
+
function ke(e, t) {
|
|
1343
1474
|
let [n, r] = b(e);
|
|
1344
1475
|
return _(() => {
|
|
1345
1476
|
let n = setTimeout(() => r(e), t);
|
|
@@ -1347,7 +1478,7 @@ function Ce(e, t) {
|
|
|
1347
1478
|
}, [e, t]), n;
|
|
1348
1479
|
}
|
|
1349
1480
|
// src/lib/use-paged-list.ts
|
|
1350
|
-
function
|
|
1481
|
+
function Ae(e, t) {
|
|
1351
1482
|
let n = L(e, () => t()), [r, i] = b(null), a = R(async (e, n) => {
|
|
1352
1483
|
let r = await t(e);
|
|
1353
1484
|
i((e) => ({
|
|
@@ -1370,21 +1501,21 @@ function we(e, t) {
|
|
|
1370
1501
|
};
|
|
1371
1502
|
}
|
|
1372
1503
|
// src/lib/use-product-pages.ts
|
|
1373
|
-
function
|
|
1504
|
+
function je(e) {
|
|
1374
1505
|
let t = I();
|
|
1375
|
-
return
|
|
1506
|
+
return Ae(["admin-products", e], (n) => t.listProducts(n ? {
|
|
1376
1507
|
...e,
|
|
1377
1508
|
cursor: n
|
|
1378
1509
|
} : e));
|
|
1379
1510
|
}
|
|
1380
1511
|
// src/lib/product-sheet-actions.ts
|
|
1381
|
-
function
|
|
1512
|
+
function Me(e) {
|
|
1382
1513
|
return e.name.trim() !== "" && e.priceCents !== null && !!e.category && e.images.length > 0;
|
|
1383
1514
|
}
|
|
1384
|
-
function
|
|
1385
|
-
return e.status === "draft" ?
|
|
1515
|
+
function Ne(e) {
|
|
1516
|
+
return e.status === "draft" ? Me(e) ? "publish" : "finish" : e.status === "archived" ? "restore" : e.quantity > 0 ? "sold" : "restock";
|
|
1386
1517
|
}
|
|
1387
|
-
function
|
|
1518
|
+
function Pe(e, t) {
|
|
1388
1519
|
switch (t) {
|
|
1389
1520
|
case "publish": return {
|
|
1390
1521
|
patch: { status: "active" },
|
|
@@ -1405,25 +1536,52 @@ function Oe(e, t) {
|
|
|
1405
1536
|
case "finish": return null;
|
|
1406
1537
|
}
|
|
1407
1538
|
}
|
|
1408
|
-
var
|
|
1539
|
+
var Fe = {
|
|
1409
1540
|
patch: { status: "draft" },
|
|
1410
1541
|
undo: { status: "active" }
|
|
1411
1542
|
};
|
|
1412
|
-
function
|
|
1543
|
+
function Ie(e) {
|
|
1413
1544
|
return {
|
|
1414
1545
|
patch: { status: "archived" },
|
|
1415
1546
|
undo: { status: e.status }
|
|
1416
1547
|
};
|
|
1417
1548
|
}
|
|
1418
|
-
function
|
|
1549
|
+
function Le(e) {
|
|
1419
1550
|
return {
|
|
1420
1551
|
patch: { featured: !e.featured },
|
|
1421
1552
|
undo: { featured: e.featured }
|
|
1422
1553
|
};
|
|
1423
1554
|
}
|
|
1424
|
-
var
|
|
1555
|
+
var Re = (e) => e.status === "active";
|
|
1556
|
+
// src/views/products/product-sheet/delete-draft-button.tsx
|
|
1557
|
+
function ze(e) {
|
|
1558
|
+
return e.status === "draft" && !e.everPublished;
|
|
1559
|
+
}
|
|
1560
|
+
function Be({ product: e, disabled: t, onDeleted: n }) {
|
|
1561
|
+
let r = F().labels.products.sheet, i = I(), [a, o] = b(!1), s = R(async () => (await i.deleteProduct(e.id), !0));
|
|
1562
|
+
return /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("button", {
|
|
1563
|
+
type: "button",
|
|
1564
|
+
className: "sfa-btn",
|
|
1565
|
+
disabled: t,
|
|
1566
|
+
onClick: () => {
|
|
1567
|
+
s.reset(), o(!0);
|
|
1568
|
+
},
|
|
1569
|
+
children: r.deleteDraft
|
|
1570
|
+
}), /* @__PURE__ */ w(G, {
|
|
1571
|
+
open: a,
|
|
1572
|
+
title: r.deleteTitle,
|
|
1573
|
+
destructive: !0,
|
|
1574
|
+
confirmLabel: r.deleteConfirm,
|
|
1575
|
+
pending: s.pending,
|
|
1576
|
+
onConfirm: async () => {
|
|
1577
|
+
await s.run() && (o(!1), n());
|
|
1578
|
+
},
|
|
1579
|
+
onCancel: () => o(!1),
|
|
1580
|
+
children: [/* @__PURE__ */ C("p", { children: r.deleteBody }), /* @__PURE__ */ C(q, { error: s.error })]
|
|
1581
|
+
})] });
|
|
1582
|
+
}
|
|
1425
1583
|
// src/views/products/product-sheet/sheet-carousel.tsx
|
|
1426
|
-
function
|
|
1584
|
+
function Ve({ product: e }) {
|
|
1427
1585
|
let { labels: t, renderImage: n } = F(), r = t.products.sheet, [i, a] = b(0), o = e.images.length, s = e.images[Math.min(i, Math.max(o - 1, 0))];
|
|
1428
1586
|
if (!s) return /* @__PURE__ */ C("div", {
|
|
1429
1587
|
className: "sfa-sheet__photo",
|
|
@@ -1433,7 +1591,7 @@ function Ne({ product: e }) {
|
|
|
1433
1591
|
return /* @__PURE__ */ w("div", {
|
|
1434
1592
|
className: "sfa-sheet__photo",
|
|
1435
1593
|
role: "group",
|
|
1436
|
-
"aria-label":
|
|
1594
|
+
"aria-label": Y(r.photoOf, {
|
|
1437
1595
|
current: i + 1,
|
|
1438
1596
|
total: o
|
|
1439
1597
|
}),
|
|
@@ -1457,7 +1615,7 @@ function Ne({ product: e }) {
|
|
|
1457
1615
|
});
|
|
1458
1616
|
}
|
|
1459
1617
|
// src/views/products/product-sheet/use-product-change.ts
|
|
1460
|
-
function
|
|
1618
|
+
function He(e, t, n) {
|
|
1461
1619
|
let r = I(), [i, a] = b(null), o = R((t) => r.updateProduct(e.id, t)), s = async (e, r) => {
|
|
1462
1620
|
a(null);
|
|
1463
1621
|
let i = await o.run(e.patch);
|
|
@@ -1482,13 +1640,13 @@ function Pe(e, t, n) {
|
|
|
1482
1640
|
};
|
|
1483
1641
|
}
|
|
1484
1642
|
// src/views/products/product-sheet/sheet-edit-link.tsx
|
|
1485
|
-
function
|
|
1643
|
+
function Ue(e, t) {
|
|
1486
1644
|
return `${e}${e.includes("?") ? "&" : "?"}step=${t}`;
|
|
1487
1645
|
}
|
|
1488
|
-
function
|
|
1646
|
+
function We(e) {
|
|
1489
1647
|
return !e.name || e.priceCents === null || !e.category || e.images.length > 0 ? "basics" : "photos";
|
|
1490
1648
|
}
|
|
1491
|
-
function
|
|
1649
|
+
function Ge({ product: e, step: t, onEdit: n, className: r, children: i }) {
|
|
1492
1650
|
let { hrefs: a, renderLink: o } = F();
|
|
1493
1651
|
return n ? /* @__PURE__ */ C("button", {
|
|
1494
1652
|
type: "button",
|
|
@@ -1496,30 +1654,31 @@ function Le({ product: e, step: t, onEdit: n, className: r, children: i }) {
|
|
|
1496
1654
|
onClick: () => n(e, t),
|
|
1497
1655
|
children: i
|
|
1498
1656
|
}) : o({
|
|
1499
|
-
href:
|
|
1657
|
+
href: Ue(a.product(e.id), t),
|
|
1500
1658
|
children: i,
|
|
1501
1659
|
className: r
|
|
1502
1660
|
});
|
|
1503
1661
|
}
|
|
1504
1662
|
// src/views/products/product-sheet/admin-product-sheet.tsx
|
|
1505
|
-
function
|
|
1663
|
+
function Ke({ productId: e, onClose: t, onEdit: n, onChanged: r }) {
|
|
1506
1664
|
let i = I(), a = L(["admin-product", e], () => i.getProduct(e)), [o, s] = b(null), c = o && o.id === e ? o : a.data;
|
|
1507
|
-
return /* @__PURE__ */ C(
|
|
1665
|
+
return /* @__PURE__ */ C(Je, {
|
|
1508
1666
|
onClose: t,
|
|
1509
|
-
children: c ? /* @__PURE__ */ C(
|
|
1667
|
+
children: c ? /* @__PURE__ */ C(Ye, {
|
|
1510
1668
|
product: c,
|
|
1511
1669
|
setProduct: s,
|
|
1512
1670
|
onEdit: n,
|
|
1513
|
-
onChanged: r ?? (() => void 0)
|
|
1514
|
-
|
|
1671
|
+
onChanged: r ?? (() => void 0),
|
|
1672
|
+
onClose: t
|
|
1673
|
+
}) : /* @__PURE__ */ C(qe, { error: a.error })
|
|
1515
1674
|
});
|
|
1516
1675
|
}
|
|
1517
|
-
function
|
|
1676
|
+
function qe({ error: e }) {
|
|
1518
1677
|
let { labels: t } = F();
|
|
1519
1678
|
return e ? /* @__PURE__ */ C(q, { error: e }) : /* @__PURE__ */ C("p", { children: t.loading });
|
|
1520
1679
|
}
|
|
1521
|
-
function
|
|
1522
|
-
let { labels: n } = F(), r = y(null), i =
|
|
1680
|
+
function Je({ onClose: e, children: t }) {
|
|
1681
|
+
let { labels: n } = F(), r = y(null), i = ge(r, !0, e);
|
|
1523
1682
|
return /* @__PURE__ */ w("div", {
|
|
1524
1683
|
className: "sfa-sheet-layer",
|
|
1525
1684
|
onKeyDown: i,
|
|
@@ -1550,17 +1709,17 @@ function Be({ onClose: e, children: t }) {
|
|
|
1550
1709
|
})]
|
|
1551
1710
|
});
|
|
1552
1711
|
}
|
|
1553
|
-
function
|
|
1554
|
-
let { labels:
|
|
1712
|
+
function Ye({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i }) {
|
|
1713
|
+
let { labels: a, hrefs: o } = F(), s = a.products.sheet, c = He(e, t, r), l = Ne(e), u = Pe(e, l), d = o.storefrontProduct?.(e.slug), f = {
|
|
1555
1714
|
product: e,
|
|
1556
1715
|
onEdit: n
|
|
1557
|
-
},
|
|
1558
|
-
|
|
1716
|
+
}, p = async () => {
|
|
1717
|
+
d && (await navigator.clipboard.writeText(new URL(d, window.location.href).href), c.announce(s.linkCopied));
|
|
1559
1718
|
};
|
|
1560
1719
|
return /* @__PURE__ */ w("div", {
|
|
1561
1720
|
className: "sfa-sheet__body",
|
|
1562
1721
|
children: [
|
|
1563
|
-
/* @__PURE__ */ C(
|
|
1722
|
+
/* @__PURE__ */ C(Ve, { product: e }),
|
|
1564
1723
|
/* @__PURE__ */ C("h2", {
|
|
1565
1724
|
className: "sfa-sheet__name",
|
|
1566
1725
|
children: e.name
|
|
@@ -1568,99 +1727,105 @@ function Ve({ product: e, setProduct: t, onEdit: n, onChanged: r }) {
|
|
|
1568
1727
|
/* @__PURE__ */ w("p", {
|
|
1569
1728
|
className: "sfa-sheet__meta",
|
|
1570
1729
|
children: [
|
|
1571
|
-
/* @__PURE__ */ C(U, { status:
|
|
1730
|
+
/* @__PURE__ */ C(U, { status: Ee(e) }),
|
|
1572
1731
|
/* @__PURE__ */ C("span", { children: e.priceCents === null ? "—" : /* @__PURE__ */ C(W, {
|
|
1573
1732
|
cents: e.priceCents,
|
|
1574
1733
|
currency: e.currency
|
|
1575
1734
|
}) }),
|
|
1576
|
-
/* @__PURE__ */ C("span", { children: e.category ??
|
|
1735
|
+
/* @__PURE__ */ C("span", { children: e.category ?? s.noCategory })
|
|
1577
1736
|
]
|
|
1578
1737
|
}),
|
|
1579
|
-
|
|
1738
|
+
c.missing ? /* @__PURE__ */ w(K, {
|
|
1580
1739
|
variant: "warning",
|
|
1581
1740
|
children: [
|
|
1582
|
-
|
|
1741
|
+
s.missingTitle,
|
|
1583
1742
|
" ",
|
|
1584
|
-
|
|
1743
|
+
c.missing.map((e) => s.missing[e] ?? e).join(", ")
|
|
1585
1744
|
]
|
|
1586
1745
|
}) : null,
|
|
1587
|
-
/* @__PURE__ */ C(q, { error:
|
|
1588
|
-
|
|
1746
|
+
/* @__PURE__ */ C(q, { error: c.error }),
|
|
1747
|
+
u ? /* @__PURE__ */ C("button", {
|
|
1589
1748
|
type: "button",
|
|
1590
1749
|
className: "sfa-btn sfa-btn--primary sfa-sheet__primary",
|
|
1591
|
-
disabled:
|
|
1592
|
-
onClick: () =>
|
|
1593
|
-
children:
|
|
1750
|
+
disabled: c.pending,
|
|
1751
|
+
onClick: () => c.apply(u, s.done[l]),
|
|
1752
|
+
children: s.primary[l]
|
|
1594
1753
|
}) : /* @__PURE__ */ C("span", {
|
|
1595
1754
|
className: "sfa-sheet__primary",
|
|
1596
|
-
children: /* @__PURE__ */ C(
|
|
1597
|
-
...
|
|
1598
|
-
step:
|
|
1755
|
+
children: /* @__PURE__ */ C(Ge, {
|
|
1756
|
+
...f,
|
|
1757
|
+
step: We(e),
|
|
1599
1758
|
className: "sfa-btn sfa-btn--primary",
|
|
1600
|
-
children:
|
|
1759
|
+
children: s.primary.finish
|
|
1601
1760
|
})
|
|
1602
1761
|
}),
|
|
1603
1762
|
/* @__PURE__ */ w("div", {
|
|
1604
1763
|
className: "sfa-sheet__actions",
|
|
1605
1764
|
children: [
|
|
1606
|
-
/* @__PURE__ */ C(
|
|
1607
|
-
...
|
|
1765
|
+
/* @__PURE__ */ C(Ge, {
|
|
1766
|
+
...f,
|
|
1608
1767
|
step: "basics",
|
|
1609
1768
|
className: "sfa-btn",
|
|
1610
|
-
children:
|
|
1769
|
+
children: s.edit
|
|
1611
1770
|
}),
|
|
1612
|
-
/* @__PURE__ */ C(
|
|
1613
|
-
...
|
|
1771
|
+
/* @__PURE__ */ C(Ge, {
|
|
1772
|
+
...f,
|
|
1614
1773
|
step: "photos",
|
|
1615
1774
|
className: "sfa-btn",
|
|
1616
|
-
children:
|
|
1775
|
+
children: Y(s.photos, { count: e.images.length })
|
|
1617
1776
|
}),
|
|
1618
|
-
|
|
1777
|
+
Re(e) ? /* @__PURE__ */ C("button", {
|
|
1619
1778
|
type: "button",
|
|
1620
1779
|
className: "sfa-btn",
|
|
1621
|
-
disabled:
|
|
1622
|
-
onClick: () =>
|
|
1623
|
-
children: e.featured ?
|
|
1780
|
+
disabled: c.pending,
|
|
1781
|
+
onClick: () => c.apply(Le(e), s.done.feature),
|
|
1782
|
+
children: e.featured ? s.featureOff : s.featureOn
|
|
1624
1783
|
}) : null,
|
|
1625
1784
|
e.status === "active" ? /* @__PURE__ */ C("button", {
|
|
1626
1785
|
type: "button",
|
|
1627
1786
|
className: "sfa-btn",
|
|
1628
|
-
disabled:
|
|
1629
|
-
onClick: () =>
|
|
1630
|
-
children:
|
|
1787
|
+
disabled: c.pending,
|
|
1788
|
+
onClick: () => c.apply(Fe, s.done.hide),
|
|
1789
|
+
children: s.hide
|
|
1631
1790
|
}) : null,
|
|
1632
|
-
|
|
1791
|
+
d ? /* @__PURE__ */ C("button", {
|
|
1633
1792
|
type: "button",
|
|
1634
1793
|
className: "sfa-btn",
|
|
1635
|
-
onClick:
|
|
1636
|
-
children:
|
|
1794
|
+
onClick: p,
|
|
1795
|
+
children: s.copyLink
|
|
1637
1796
|
}) : null,
|
|
1638
|
-
e
|
|
1797
|
+
ze(e) ? /* @__PURE__ */ C(Be, {
|
|
1798
|
+
product: e,
|
|
1799
|
+
disabled: c.pending,
|
|
1800
|
+
onDeleted: () => {
|
|
1801
|
+
r(), i();
|
|
1802
|
+
}
|
|
1803
|
+
}) : e.status === "archived" ? null : /* @__PURE__ */ C("button", {
|
|
1639
1804
|
type: "button",
|
|
1640
1805
|
className: "sfa-btn",
|
|
1641
|
-
disabled:
|
|
1642
|
-
onClick: () =>
|
|
1643
|
-
children:
|
|
1806
|
+
disabled: c.pending,
|
|
1807
|
+
onClick: () => c.apply(Ie(e), s.done.archive),
|
|
1808
|
+
children: s.archive
|
|
1644
1809
|
})
|
|
1645
1810
|
]
|
|
1646
1811
|
}),
|
|
1647
|
-
|
|
1812
|
+
c.notice ? /* @__PURE__ */ C(K, {
|
|
1648
1813
|
variant: "success",
|
|
1649
1814
|
toast: !0,
|
|
1650
1815
|
duration: 8e3,
|
|
1651
|
-
onDismiss:
|
|
1652
|
-
action:
|
|
1653
|
-
label:
|
|
1654
|
-
onAction:
|
|
1816
|
+
onDismiss: c.dismiss,
|
|
1817
|
+
action: c.notice.undo ? {
|
|
1818
|
+
label: s.undo,
|
|
1819
|
+
onAction: c.undo
|
|
1655
1820
|
} : void 0,
|
|
1656
|
-
children:
|
|
1821
|
+
children: c.notice.text
|
|
1657
1822
|
}) : null
|
|
1658
1823
|
]
|
|
1659
1824
|
});
|
|
1660
1825
|
}
|
|
1661
1826
|
// src/views/products/product-card.tsx
|
|
1662
|
-
function
|
|
1663
|
-
let { labels: n, renderImage: r } = F(), i = n.products, a =
|
|
1827
|
+
function Xe({ product: e, onOpen: t }) {
|
|
1828
|
+
let { labels: n, renderImage: r } = F(), i = n.products, a = Ee(e), o = be(e, i.card), s = e.images[0], c = /* @__PURE__ */ C("button", {
|
|
1664
1829
|
type: "button",
|
|
1665
1830
|
className: "sfa-card__name sfa-link--tap",
|
|
1666
1831
|
onClick: t,
|
|
@@ -1708,17 +1873,17 @@ function He({ product: e, onOpen: t }) {
|
|
|
1708
1873
|
});
|
|
1709
1874
|
}
|
|
1710
1875
|
// src/views/products/product-toolbar.tsx
|
|
1711
|
-
var
|
|
1876
|
+
var Ze = [
|
|
1712
1877
|
"all",
|
|
1713
1878
|
"live",
|
|
1714
1879
|
"sold",
|
|
1715
1880
|
"draft",
|
|
1716
1881
|
"archived"
|
|
1717
1882
|
];
|
|
1718
|
-
function
|
|
1883
|
+
function Qe(e, t) {
|
|
1719
1884
|
return t === "all" ? e.all : e[t];
|
|
1720
1885
|
}
|
|
1721
|
-
function
|
|
1886
|
+
function $e({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
1722
1887
|
let { labels: a } = F(), o = a.products, [s, c] = b(!1);
|
|
1723
1888
|
return /* @__PURE__ */ w("div", {
|
|
1724
1889
|
className: "sfa-products__toolbar",
|
|
@@ -1727,14 +1892,14 @@ function Ge({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
|
1727
1892
|
role: "group",
|
|
1728
1893
|
"aria-label": o.columns.status,
|
|
1729
1894
|
className: "sfa-filter-group",
|
|
1730
|
-
children:
|
|
1895
|
+
children: Ze.map((n) => /* @__PURE__ */ w("button", {
|
|
1731
1896
|
type: "button",
|
|
1732
1897
|
className: "sfa-chip",
|
|
1733
1898
|
"aria-pressed": e === n,
|
|
1734
1899
|
onClick: () => t(n),
|
|
1735
1900
|
children: [o.filters[n], i ? /* @__PURE__ */ C("span", {
|
|
1736
1901
|
className: "sfa-chip__count",
|
|
1737
|
-
children:
|
|
1902
|
+
children: Qe(i, n)
|
|
1738
1903
|
}) : null]
|
|
1739
1904
|
}, n))
|
|
1740
1905
|
}),
|
|
@@ -1757,7 +1922,7 @@ function Ge({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
|
1757
1922
|
});
|
|
1758
1923
|
}
|
|
1759
1924
|
// src/views/products/product-welcome.tsx
|
|
1760
|
-
function
|
|
1925
|
+
function et() {
|
|
1761
1926
|
return /* @__PURE__ */ w("svg", {
|
|
1762
1927
|
className: "sfa-welcome__art",
|
|
1763
1928
|
viewBox: "0 0 120 120",
|
|
@@ -1794,14 +1959,14 @@ function Ke() {
|
|
|
1794
1959
|
]
|
|
1795
1960
|
});
|
|
1796
1961
|
}
|
|
1797
|
-
function
|
|
1962
|
+
function tt({ art: e, steps: t, onAddMany: n }) {
|
|
1798
1963
|
let { labels: r, hrefs: i, renderLink: a } = F(), o = r.products.welcome;
|
|
1799
1964
|
return /* @__PURE__ */ w("div", {
|
|
1800
1965
|
className: "sfa-welcome",
|
|
1801
1966
|
children: [/* @__PURE__ */ w("div", {
|
|
1802
1967
|
className: "sfa-welcome__hero",
|
|
1803
1968
|
children: [
|
|
1804
|
-
e ?? /* @__PURE__ */ C(
|
|
1969
|
+
e ?? /* @__PURE__ */ C(et, {}),
|
|
1805
1970
|
/* @__PURE__ */ C("h2", {
|
|
1806
1971
|
className: "sfa-welcome__title",
|
|
1807
1972
|
children: o.title
|
|
@@ -1824,12 +1989,12 @@ function qe({ art: e, steps: t, onAddMany: n }) {
|
|
|
1824
1989
|
}) : null]
|
|
1825
1990
|
})
|
|
1826
1991
|
]
|
|
1827
|
-
}), t ? /* @__PURE__ */ C(
|
|
1992
|
+
}), t ? /* @__PURE__ */ C(we, { steps: t }) : null]
|
|
1828
1993
|
});
|
|
1829
1994
|
}
|
|
1830
1995
|
// src/views/products/admin-product-list.tsx
|
|
1831
|
-
function
|
|
1832
|
-
let o = I(), { labels: s, hrefs: c, renderLink: l } = F(), u = s.products, [d, f] = b("all"), [p, m] = b(""), h =
|
|
1996
|
+
function nt({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProduct: i, onEditProduct: a } = {}) {
|
|
1997
|
+
let o = I(), { labels: s, hrefs: c, renderLink: l } = F(), u = s.products, [d, f] = b("all"), [p, m] = b(""), h = ke(p.trim(), 300), g = De(d), _ = Oe(d), v = je({
|
|
1833
1998
|
...g ? { status: g } : {},
|
|
1834
1999
|
...d === "all" ? { excludeArchived: "true" } : {},
|
|
1835
2000
|
..._ ? { stock: _ } : {},
|
|
@@ -1849,38 +2014,53 @@ function Je({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
1849
2014
|
floatingAction: O ? void 0 : N
|
|
1850
2015
|
}),
|
|
1851
2016
|
/* @__PURE__ */ C(q, { error: v.error ?? y.error }),
|
|
1852
|
-
k || v.loading && !v.loaded && !O ? /* @__PURE__ */ C("p", { children: s.loading }) : O ? /* @__PURE__ */ C(
|
|
2017
|
+
k || v.loading && !v.loaded && !O ? /* @__PURE__ */ C("p", { children: s.loading }) : O ? /* @__PURE__ */ C(tt, {
|
|
1853
2018
|
art: e,
|
|
1854
2019
|
steps: t,
|
|
1855
2020
|
onAddMany: n
|
|
1856
2021
|
}) : /* @__PURE__ */ w(S, { children: [
|
|
1857
|
-
t ? /* @__PURE__ */ C(
|
|
2022
|
+
t ? /* @__PURE__ */ C(we, {
|
|
1858
2023
|
steps: t,
|
|
1859
2024
|
compact: !0
|
|
1860
2025
|
}) : null,
|
|
1861
2026
|
M > 0 ? /* @__PURE__ */ w("div", {
|
|
1862
2027
|
className: "sfa-banner",
|
|
1863
2028
|
role: "status",
|
|
1864
|
-
children: [/* @__PURE__ */ C("span", { children:
|
|
2029
|
+
children: [/* @__PURE__ */ C("span", { children: Y(M === 1 ? u.draftsBanner.one : u.draftsBanner.many, { count: M }) }), r ? /* @__PURE__ */ C("button", {
|
|
1865
2030
|
type: "button",
|
|
1866
2031
|
className: "sfa-btn",
|
|
1867
2032
|
onClick: r,
|
|
1868
2033
|
children: u.draftsBanner.finish
|
|
1869
2034
|
}) : null]
|
|
1870
2035
|
}) : null,
|
|
1871
|
-
/* @__PURE__ */ C(
|
|
2036
|
+
/* @__PURE__ */ C($e, {
|
|
1872
2037
|
filter: d,
|
|
1873
2038
|
onFilter: f,
|
|
1874
2039
|
search: p,
|
|
1875
2040
|
onSearch: m,
|
|
1876
2041
|
counts: D
|
|
1877
2042
|
}),
|
|
1878
|
-
A.length === 0 ? /* @__PURE__ */ C(
|
|
1879
|
-
|
|
1880
|
-
|
|
2043
|
+
A.length === 0 ? /* @__PURE__ */ C(J, {
|
|
2044
|
+
icon: h ? "search" : "products",
|
|
2045
|
+
title: j,
|
|
2046
|
+
action: h ? /* @__PURE__ */ C("button", {
|
|
2047
|
+
type: "button",
|
|
2048
|
+
className: "sfa-btn",
|
|
2049
|
+
onClick: () => m(""),
|
|
2050
|
+
children: u.emptyActions.clearSearch
|
|
2051
|
+
}) : /* @__PURE__ */ w(S, { children: [l({
|
|
2052
|
+
href: c.newProduct,
|
|
2053
|
+
children: u.emptyActions.start,
|
|
2054
|
+
className: "sfa-btn sfa-btn--primary"
|
|
2055
|
+
}), n ? /* @__PURE__ */ C("button", {
|
|
2056
|
+
type: "button",
|
|
2057
|
+
className: "sfa-btn",
|
|
2058
|
+
onClick: n,
|
|
2059
|
+
children: u.welcome.addMany
|
|
2060
|
+
}) : null] })
|
|
1881
2061
|
}) : /* @__PURE__ */ C("ul", {
|
|
1882
2062
|
className: "sfa-grid",
|
|
1883
|
-
children: A.map((e) => /* @__PURE__ */ C(
|
|
2063
|
+
children: A.map((e) => /* @__PURE__ */ C(Xe, {
|
|
1884
2064
|
product: e,
|
|
1885
2065
|
onOpen: () => i ? i(e) : T(e.id)
|
|
1886
2066
|
}, e.id))
|
|
@@ -1893,7 +2073,7 @@ function Je({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
1893
2073
|
children: u.loadMore
|
|
1894
2074
|
}) : null
|
|
1895
2075
|
] }),
|
|
1896
|
-
x ? /* @__PURE__ */ C(
|
|
2076
|
+
x ? /* @__PURE__ */ C(Ke, {
|
|
1897
2077
|
productId: x,
|
|
1898
2078
|
onClose: () => T(null),
|
|
1899
2079
|
onEdit: a,
|
|
@@ -1903,7 +2083,7 @@ function Je({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
1903
2083
|
});
|
|
1904
2084
|
}
|
|
1905
2085
|
// src/components/switch/switch.tsx
|
|
1906
|
-
function
|
|
2086
|
+
function rt({ id: e, label: t, checked: n, onChange: r }) {
|
|
1907
2087
|
return /* @__PURE__ */ w("label", {
|
|
1908
2088
|
className: "sfa-switch",
|
|
1909
2089
|
htmlFor: e,
|
|
@@ -1917,89 +2097,98 @@ function Ye({ id: e, label: t, checked: n, onChange: r }) {
|
|
|
1917
2097
|
});
|
|
1918
2098
|
}
|
|
1919
2099
|
// src/lib/money-input.ts
|
|
1920
|
-
var
|
|
1921
|
-
function
|
|
1922
|
-
let t = e.trim(), n =
|
|
2100
|
+
var it = /^\$?\s*(\d+|\d{1,3}(?:,\d{3})+)?(?:\.(\d{1,2}))?$/;
|
|
2101
|
+
function X(e) {
|
|
2102
|
+
let t = e.trim(), n = it.exec(t);
|
|
1923
2103
|
if (!n || !n[1] && !n[2]) return null;
|
|
1924
2104
|
let r = Number((n[1] ?? "0").replace(/,/g, "")), i = Number((n[2] ?? "").padEnd(2, "0")), a = r * 100 + i;
|
|
1925
2105
|
return Number.isSafeInteger(a) ? a : null;
|
|
1926
2106
|
}
|
|
1927
|
-
function
|
|
2107
|
+
function Z(e) {
|
|
1928
2108
|
return `${Math.floor(e / 100)}.${String(e % 100).padStart(2, "0")}`;
|
|
1929
2109
|
}
|
|
1930
2110
|
// src/lib/product-draft.ts
|
|
1931
|
-
function
|
|
2111
|
+
function at(e) {
|
|
1932
2112
|
let t = e.trim();
|
|
1933
2113
|
return t === "" ? null : t;
|
|
1934
2114
|
}
|
|
1935
|
-
function
|
|
2115
|
+
function ot(e) {
|
|
1936
2116
|
return /^\d+$/.test(e.trim()) ? Number(e.trim()) : null;
|
|
1937
2117
|
}
|
|
1938
|
-
function
|
|
1939
|
-
let t = e.name.trim(), n = e.category.trim(), r =
|
|
2118
|
+
function st(e) {
|
|
2119
|
+
let t = e.name.trim(), n = e.category.trim(), r = X(e.price), i = ot(e.quantity);
|
|
1940
2120
|
return {
|
|
1941
2121
|
...t ? { name: t } : {},
|
|
1942
2122
|
...n ? { category: n } : {},
|
|
1943
2123
|
...r === null ? {} : { priceCents: r },
|
|
1944
2124
|
...i === null ? {} : { quantity: i },
|
|
1945
2125
|
description: e.description,
|
|
1946
|
-
materials:
|
|
1947
|
-
dimensions:
|
|
1948
|
-
featured: e.featured
|
|
2126
|
+
materials: at(e.materials),
|
|
2127
|
+
dimensions: at(e.dimensions),
|
|
2128
|
+
featured: e.featured,
|
|
2129
|
+
taxCode: at(e.taxCode)
|
|
1949
2130
|
};
|
|
1950
2131
|
}
|
|
1951
|
-
function
|
|
2132
|
+
function ct(e) {
|
|
1952
2133
|
return e.name.trim() !== "";
|
|
1953
2134
|
}
|
|
1954
|
-
function
|
|
2135
|
+
function lt(e, t) {
|
|
2136
|
+
let { taxCode: n, ...r } = st(e);
|
|
1955
2137
|
return {
|
|
1956
|
-
|
|
2138
|
+
...r,
|
|
2139
|
+
...n ? { taxCode: n } : {},
|
|
1957
2140
|
...t ? { currency: t } : {},
|
|
1958
2141
|
status: "draft"
|
|
1959
2142
|
};
|
|
1960
2143
|
}
|
|
1961
|
-
function
|
|
2144
|
+
function ut(e, t) {
|
|
1962
2145
|
let n = {};
|
|
1963
|
-
for (let [r, i] of Object.entries(
|
|
2146
|
+
for (let [r, i] of Object.entries(st(t))) i !== (e[r] ?? null) && (n[r] = i);
|
|
1964
2147
|
return n;
|
|
1965
2148
|
}
|
|
1966
|
-
function
|
|
1967
|
-
return e.name.trim() !== "" && e.category.trim() !== "" &&
|
|
2149
|
+
function dt(e) {
|
|
2150
|
+
return e.name.trim() !== "" && e.category.trim() !== "" && X(e.price) !== null;
|
|
2151
|
+
}
|
|
2152
|
+
function ft(e) {
|
|
2153
|
+
let t = [];
|
|
2154
|
+
return e.name.trim() === "" && t.push("name"), X(e.price) === null && t.push("price"), e.category.trim() === "" && t.push("category"), t;
|
|
2155
|
+
}
|
|
2156
|
+
function pt(e) {
|
|
2157
|
+
return e.replace(/(^|[\s-])(\p{L})/gu, (e, t, n) => t + n.toUpperCase());
|
|
1968
2158
|
}
|
|
1969
|
-
function
|
|
2159
|
+
function mt(e) {
|
|
1970
2160
|
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
1971
2161
|
}
|
|
1972
|
-
function
|
|
1973
|
-
|
|
1974
|
-
return (n.includes(t) ? n.filter((e) => e !== t) : [...n, t]).join(", ");
|
|
2162
|
+
function ht(e, t) {
|
|
2163
|
+
return [...e, ...mt(t)].join(", ");
|
|
1975
2164
|
}
|
|
1976
|
-
function
|
|
2165
|
+
function gt(e, t) {
|
|
1977
2166
|
let n = e.trimEnd();
|
|
1978
2167
|
return n ? `${n}\n${t}` : t;
|
|
1979
2168
|
}
|
|
1980
|
-
function
|
|
2169
|
+
function _t(e, t) {
|
|
1981
2170
|
return new Intl.NumberFormat(e, {
|
|
1982
2171
|
style: "currency",
|
|
1983
2172
|
currency: t
|
|
1984
2173
|
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? t;
|
|
1985
2174
|
}
|
|
1986
|
-
function
|
|
2175
|
+
function Q(e, t) {
|
|
1987
2176
|
return e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? "");
|
|
1988
2177
|
}
|
|
1989
2178
|
// src/views/products/product-flow/basics-section.tsx
|
|
1990
|
-
function
|
|
1991
|
-
let
|
|
1992
|
-
return r
|
|
2179
|
+
function vt(e, t, n) {
|
|
2180
|
+
let r = t.trim();
|
|
2181
|
+
return n || !r || e.includes(r) ? e : [...e, r];
|
|
1993
2182
|
}
|
|
1994
|
-
function
|
|
1995
|
-
let { labels:
|
|
2183
|
+
function yt({ form: e, update: t, categories: n, currency: r, taxCodes: i }) {
|
|
2184
|
+
let { labels: a, locale: o } = F(), s = a.products.flow, c = a.products.fields, l = n ?? [], [u, d] = b(!1), f = vt(l, e.category, u), p = f.some((e) => e.trim().toLowerCase() === "other"), [m, h] = b(e.quantity.trim() === "1");
|
|
1996
2185
|
return /* @__PURE__ */ w(S, { children: [
|
|
1997
2186
|
/* @__PURE__ */ w("div", {
|
|
1998
2187
|
className: "sfa-field",
|
|
1999
2188
|
children: [/* @__PURE__ */ C("label", {
|
|
2000
2189
|
className: "sfa-field__label",
|
|
2001
2190
|
htmlFor: "sfa-flow-name",
|
|
2002
|
-
children:
|
|
2191
|
+
children: c.name
|
|
2003
2192
|
}), /* @__PURE__ */ C("input", {
|
|
2004
2193
|
id: "sfa-flow-name",
|
|
2005
2194
|
type: "text",
|
|
@@ -2013,23 +2202,23 @@ function lt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2013
2202
|
children: [/* @__PURE__ */ C("label", {
|
|
2014
2203
|
className: "sfa-field__label",
|
|
2015
2204
|
htmlFor: "sfa-flow-price",
|
|
2016
|
-
children:
|
|
2205
|
+
children: c.price
|
|
2017
2206
|
}), /* @__PURE__ */ w("span", {
|
|
2018
2207
|
className: "sfa-flow__price",
|
|
2019
2208
|
children: [/* @__PURE__ */ C("span", {
|
|
2020
2209
|
"aria-hidden": "true",
|
|
2021
|
-
children:
|
|
2210
|
+
children: _t(o, r)
|
|
2022
2211
|
}), /* @__PURE__ */ C("input", {
|
|
2023
2212
|
id: "sfa-flow-price",
|
|
2024
2213
|
type: "text",
|
|
2025
2214
|
inputMode: "decimal",
|
|
2026
|
-
placeholder:
|
|
2215
|
+
placeholder: s.pricePlaceholder,
|
|
2027
2216
|
value: e.price,
|
|
2028
2217
|
onChange: (e) => t("price", e.target.value)
|
|
2029
2218
|
})]
|
|
2030
2219
|
})]
|
|
2031
2220
|
}),
|
|
2032
|
-
|
|
2221
|
+
l.length ? /* @__PURE__ */ w("div", {
|
|
2033
2222
|
className: "sfa-field",
|
|
2034
2223
|
role: "group",
|
|
2035
2224
|
"aria-labelledby": "sfa-flow-category-label",
|
|
@@ -2037,31 +2226,31 @@ function lt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2037
2226
|
/* @__PURE__ */ C("span", {
|
|
2038
2227
|
id: "sfa-flow-category-label",
|
|
2039
2228
|
className: "sfa-field__label",
|
|
2040
|
-
children:
|
|
2229
|
+
children: c.category
|
|
2041
2230
|
}),
|
|
2042
2231
|
/* @__PURE__ */ w("div", {
|
|
2043
2232
|
className: "sfa-flow__chips",
|
|
2044
|
-
children: [
|
|
2233
|
+
children: [f.map((n) => /* @__PURE__ */ C("button", {
|
|
2045
2234
|
type: "button",
|
|
2046
2235
|
className: "sfa-chip",
|
|
2047
|
-
"aria-pressed": !
|
|
2236
|
+
"aria-pressed": !u && e.category.trim() === n,
|
|
2048
2237
|
onClick: () => {
|
|
2049
|
-
|
|
2238
|
+
d(!1), t("category", n);
|
|
2050
2239
|
},
|
|
2051
|
-
children: n
|
|
2052
|
-
}, n)), /* @__PURE__ */ C("button", {
|
|
2240
|
+
children: pt(n)
|
|
2241
|
+
}, n)), p ? null : /* @__PURE__ */ C("button", {
|
|
2053
2242
|
type: "button",
|
|
2054
2243
|
className: "sfa-chip",
|
|
2055
|
-
"aria-pressed":
|
|
2244
|
+
"aria-pressed": u,
|
|
2056
2245
|
onClick: () => {
|
|
2057
|
-
|
|
2246
|
+
d(!0), t("category", "");
|
|
2058
2247
|
},
|
|
2059
|
-
children:
|
|
2248
|
+
children: s.otherCategory
|
|
2060
2249
|
})]
|
|
2061
2250
|
}),
|
|
2062
|
-
|
|
2251
|
+
u ? /* @__PURE__ */ C("input", {
|
|
2063
2252
|
type: "text",
|
|
2064
|
-
"aria-label":
|
|
2253
|
+
"aria-label": s.newCategory,
|
|
2065
2254
|
value: e.category,
|
|
2066
2255
|
onChange: (e) => t("category", e.target.value)
|
|
2067
2256
|
}) : null
|
|
@@ -2071,7 +2260,7 @@ function lt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2071
2260
|
children: [/* @__PURE__ */ C("label", {
|
|
2072
2261
|
className: "sfa-field__label",
|
|
2073
2262
|
htmlFor: "sfa-flow-category",
|
|
2074
|
-
children:
|
|
2263
|
+
children: c.category
|
|
2075
2264
|
}), /* @__PURE__ */ C("input", {
|
|
2076
2265
|
id: "sfa-flow-category",
|
|
2077
2266
|
type: "text",
|
|
@@ -2079,20 +2268,20 @@ function lt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2079
2268
|
onChange: (e) => t("category", e.target.value)
|
|
2080
2269
|
})]
|
|
2081
2270
|
}),
|
|
2082
|
-
/* @__PURE__ */ C(
|
|
2271
|
+
/* @__PURE__ */ C(rt, {
|
|
2083
2272
|
id: "sfa-flow-one-of-a-kind",
|
|
2084
|
-
label:
|
|
2085
|
-
checked:
|
|
2273
|
+
label: s.oneOfAKind,
|
|
2274
|
+
checked: m,
|
|
2086
2275
|
onChange: (n) => {
|
|
2087
|
-
|
|
2276
|
+
h(n), n ? t("quantity", "1") : e.quantity.trim() === "1" && t("quantity", "2");
|
|
2088
2277
|
}
|
|
2089
2278
|
}),
|
|
2090
|
-
|
|
2279
|
+
m ? null : /* @__PURE__ */ w("div", {
|
|
2091
2280
|
className: "sfa-field",
|
|
2092
2281
|
children: [/* @__PURE__ */ C("label", {
|
|
2093
2282
|
className: "sfa-field__label",
|
|
2094
2283
|
htmlFor: "sfa-flow-quantity",
|
|
2095
|
-
children:
|
|
2284
|
+
children: s.howMany
|
|
2096
2285
|
}), /* @__PURE__ */ C("input", {
|
|
2097
2286
|
id: "sfa-flow-quantity",
|
|
2098
2287
|
type: "text",
|
|
@@ -2100,19 +2289,38 @@ function lt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2100
2289
|
value: e.quantity,
|
|
2101
2290
|
onChange: (e) => t("quantity", e.target.value)
|
|
2102
2291
|
})]
|
|
2103
|
-
})
|
|
2292
|
+
}),
|
|
2293
|
+
i?.length ? /* @__PURE__ */ w("div", {
|
|
2294
|
+
className: "sfa-field",
|
|
2295
|
+
children: [/* @__PURE__ */ C("label", {
|
|
2296
|
+
className: "sfa-field__label",
|
|
2297
|
+
htmlFor: "sfa-flow-tax-code",
|
|
2298
|
+
children: s.taxCode
|
|
2299
|
+
}), /* @__PURE__ */ w("select", {
|
|
2300
|
+
id: "sfa-flow-tax-code",
|
|
2301
|
+
value: e.taxCode,
|
|
2302
|
+
onChange: (e) => t("taxCode", e.target.value),
|
|
2303
|
+
children: [/* @__PURE__ */ C("option", {
|
|
2304
|
+
value: "",
|
|
2305
|
+
children: s.taxCodeDefault
|
|
2306
|
+
}), i.map(({ code: e, label: t }) => /* @__PURE__ */ C("option", {
|
|
2307
|
+
value: e,
|
|
2308
|
+
children: t
|
|
2309
|
+
}, e))]
|
|
2310
|
+
})]
|
|
2311
|
+
}) : null
|
|
2104
2312
|
] });
|
|
2105
2313
|
}
|
|
2106
2314
|
// src/views/products/product-flow/flow-actions.tsx
|
|
2107
|
-
function
|
|
2108
|
-
let t =
|
|
2109
|
-
return
|
|
2315
|
+
function bt(e) {
|
|
2316
|
+
let t = M.indexOf(e);
|
|
2317
|
+
return M[Math.min(t + 1, M.length - 1)];
|
|
2110
2318
|
}
|
|
2111
|
-
function
|
|
2112
|
-
let t =
|
|
2113
|
-
return t > 0 ?
|
|
2319
|
+
function xt(e) {
|
|
2320
|
+
let t = M.indexOf(e);
|
|
2321
|
+
return t > 0 ? M[t - 1] : null;
|
|
2114
2322
|
}
|
|
2115
|
-
function
|
|
2323
|
+
function St({ flow: e }) {
|
|
2116
2324
|
let { labels: t } = F(), n = t.products.flow;
|
|
2117
2325
|
return (e.product?.status ?? "draft") === "draft" ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("button", {
|
|
2118
2326
|
type: "button",
|
|
@@ -2131,11 +2339,11 @@ function ft({ flow: e }) {
|
|
|
2131
2339
|
className: "sfa-btn sfa-btn--primary",
|
|
2132
2340
|
disabled: e.pending,
|
|
2133
2341
|
onClick: e.saveDraft,
|
|
2134
|
-
children: n.
|
|
2342
|
+
children: n.saveChanges
|
|
2135
2343
|
});
|
|
2136
2344
|
}
|
|
2137
|
-
function
|
|
2138
|
-
let { labels: t } = F(), n = t.products.flow, r = () => e.goTo(
|
|
2345
|
+
function Ct({ flow: e }) {
|
|
2346
|
+
let { labels: t } = F(), n = t.products.flow, r = () => e.goTo(bt(e.step));
|
|
2139
2347
|
if (e.step === "photos") {
|
|
2140
2348
|
let t = (e.product?.images.length ?? 0) > 0;
|
|
2141
2349
|
return /* @__PURE__ */ C("button", {
|
|
@@ -2148,7 +2356,8 @@ function pt({ flow: e }) {
|
|
|
2148
2356
|
return e.step === "basics" ? /* @__PURE__ */ C("button", {
|
|
2149
2357
|
type: "button",
|
|
2150
2358
|
className: "sfa-btn sfa-btn--primary",
|
|
2151
|
-
disabled: !
|
|
2359
|
+
disabled: !dt(e.form),
|
|
2360
|
+
"aria-describedby": "sfa-flow-continue-hint",
|
|
2152
2361
|
onClick: r,
|
|
2153
2362
|
children: n.continue
|
|
2154
2363
|
}) : e.step === "story" ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("button", {
|
|
@@ -2161,36 +2370,69 @@ function pt({ flow: e }) {
|
|
|
2161
2370
|
className: "sfa-btn sfa-btn--primary",
|
|
2162
2371
|
onClick: r,
|
|
2163
2372
|
children: n.continue
|
|
2164
|
-
})] }) : /* @__PURE__ */ C(
|
|
2373
|
+
})] }) : /* @__PURE__ */ C(St, { flow: e });
|
|
2374
|
+
}
|
|
2375
|
+
function wt({ flow: e }) {
|
|
2376
|
+
let { labels: t, locale: n } = F(), r = t.products.flow;
|
|
2377
|
+
if (e.step !== "basics") return null;
|
|
2378
|
+
let i = ft(e.form);
|
|
2379
|
+
if (!i.length) return null;
|
|
2380
|
+
let a = new Intl.ListFormat(n, {
|
|
2381
|
+
style: "long",
|
|
2382
|
+
type: "conjunction"
|
|
2383
|
+
}).format(i.map((e) => t.products.fields[e].toLowerCase()));
|
|
2384
|
+
return /* @__PURE__ */ C("p", {
|
|
2385
|
+
id: "sfa-flow-continue-hint",
|
|
2386
|
+
className: "sfa-flow__hint",
|
|
2387
|
+
children: Q(r.continueNeeds, { things: a })
|
|
2388
|
+
});
|
|
2165
2389
|
}
|
|
2166
2390
|
// src/views/products/product-flow/flow-frame.tsx
|
|
2167
|
-
function
|
|
2168
|
-
let { labels:
|
|
2391
|
+
function Tt({ title: e, step: t, onBack: n, canGoBack: r, close: i }) {
|
|
2392
|
+
let { labels: a } = F(), o = a.products.flow;
|
|
2169
2393
|
return /* @__PURE__ */ w("div", {
|
|
2170
2394
|
className: "sfa-flow__head",
|
|
2171
2395
|
children: [
|
|
2172
|
-
/* @__PURE__ */
|
|
2396
|
+
/* @__PURE__ */ w("button", {
|
|
2173
2397
|
type: "button",
|
|
2174
2398
|
className: "sfa-btn sfa-btn--ghost sfa-flow__back",
|
|
2175
|
-
"aria-label":
|
|
2176
|
-
disabled: !
|
|
2177
|
-
onClick:
|
|
2178
|
-
children: "
|
|
2399
|
+
"aria-label": o.back,
|
|
2400
|
+
disabled: !r,
|
|
2401
|
+
onClick: n,
|
|
2402
|
+
children: [/* @__PURE__ */ C("span", {
|
|
2403
|
+
"aria-hidden": "true",
|
|
2404
|
+
children: "‹"
|
|
2405
|
+
}), /* @__PURE__ */ C("span", {
|
|
2406
|
+
className: "sfa-flow__btn-text",
|
|
2407
|
+
"aria-hidden": "true",
|
|
2408
|
+
children: o.back
|
|
2409
|
+
})]
|
|
2179
2410
|
}),
|
|
2180
2411
|
/* @__PURE__ */ C("h1", {
|
|
2181
2412
|
className: "sfa-flow__title",
|
|
2182
2413
|
children: e
|
|
2183
2414
|
}),
|
|
2184
|
-
|
|
2415
|
+
/* @__PURE__ */ w("p", {
|
|
2416
|
+
className: "sfa-flow__step-count",
|
|
2417
|
+
children: [
|
|
2418
|
+
Q(o.stepCount, {
|
|
2419
|
+
n: String(M.indexOf(t) + 1),
|
|
2420
|
+
total: String(M.length)
|
|
2421
|
+
}),
|
|
2422
|
+
" · ",
|
|
2423
|
+
o.steps[t]
|
|
2424
|
+
]
|
|
2425
|
+
}),
|
|
2426
|
+
i
|
|
2185
2427
|
]
|
|
2186
2428
|
});
|
|
2187
2429
|
}
|
|
2188
|
-
function
|
|
2189
|
-
let { labels: r } = F(), i = r.products.flow, a =
|
|
2430
|
+
function Et({ step: e, allOpen: t, onStep: n }) {
|
|
2431
|
+
let { labels: r } = F(), i = r.products.flow, a = M.indexOf(e);
|
|
2190
2432
|
return /* @__PURE__ */ C("nav", {
|
|
2191
2433
|
className: "sfa-flow__steps",
|
|
2192
2434
|
"aria-label": i.stepsLabel,
|
|
2193
|
-
children: /* @__PURE__ */ C("ol", { children:
|
|
2435
|
+
children: /* @__PURE__ */ C("ol", { children: M.map((e, r) => /* @__PURE__ */ C("li", { children: /* @__PURE__ */ C("button", {
|
|
2194
2436
|
type: "button",
|
|
2195
2437
|
"aria-current": r === a ? "step" : void 0,
|
|
2196
2438
|
"data-state": r < a ? "done" : void 0,
|
|
@@ -2200,7 +2442,7 @@ function ht({ step: e, allOpen: t, onStep: n }) {
|
|
|
2200
2442
|
}) }, e)) })
|
|
2201
2443
|
});
|
|
2202
2444
|
}
|
|
2203
|
-
function
|
|
2445
|
+
function Dt({ state: e, isNew: t, onRetry: n }) {
|
|
2204
2446
|
let { labels: r } = F(), i = r.products.flow;
|
|
2205
2447
|
return e === "idle" ? null : e === "error" ? /* @__PURE__ */ w("div", {
|
|
2206
2448
|
className: "sfa-flow__saved is-error",
|
|
@@ -2211,14 +2453,18 @@ function gt({ state: e, isNew: t, onRetry: n }) {
|
|
|
2211
2453
|
onClick: n,
|
|
2212
2454
|
children: i.retry
|
|
2213
2455
|
})]
|
|
2214
|
-
}) : /* @__PURE__ */
|
|
2215
|
-
className:
|
|
2456
|
+
}) : /* @__PURE__ */ w("p", {
|
|
2457
|
+
className: `sfa-flow__saved${e === "saving" ? " is-saving" : " is-saved"}`,
|
|
2216
2458
|
role: "status",
|
|
2217
|
-
children: e === "saving" ?
|
|
2459
|
+
children: [e === "saving" ? null : /* @__PURE__ */ C("span", {
|
|
2460
|
+
className: "sfa-flow__saved-check",
|
|
2461
|
+
"aria-hidden": "true",
|
|
2462
|
+
children: "✓"
|
|
2463
|
+
}), e === "saving" ? i.saving : t ? i.savedNew : i.savedEdit]
|
|
2218
2464
|
});
|
|
2219
2465
|
}
|
|
2220
|
-
function
|
|
2221
|
-
let { labels:
|
|
2466
|
+
function Ot({ step: e, active: t, live: n, children: r }) {
|
|
2467
|
+
let { labels: i } = F(), a = i.products.flow;
|
|
2222
2468
|
return /* @__PURE__ */ w("section", {
|
|
2223
2469
|
id: `sfa-flow-${e}`,
|
|
2224
2470
|
className: `sfa-flow__section sfa-flow__section--${e}`,
|
|
@@ -2227,23 +2473,23 @@ function _t({ step: e, active: t, children: n }) {
|
|
|
2227
2473
|
children: [
|
|
2228
2474
|
/* @__PURE__ */ C("h2", {
|
|
2229
2475
|
id: `sfa-flow-${e}-title`,
|
|
2230
|
-
children:
|
|
2476
|
+
children: n && e === "preview" ? a.previewHeadingLive : a.headings[e]
|
|
2231
2477
|
}),
|
|
2232
2478
|
/* @__PURE__ */ C("p", {
|
|
2233
2479
|
className: "sfa-flow__lede",
|
|
2234
|
-
children:
|
|
2480
|
+
children: a.ledes[e]
|
|
2235
2481
|
}),
|
|
2236
|
-
|
|
2482
|
+
r
|
|
2237
2483
|
]
|
|
2238
2484
|
});
|
|
2239
2485
|
}
|
|
2240
2486
|
// src/views/products/product-flow/flow-images.ts
|
|
2241
|
-
function
|
|
2487
|
+
function $(e) {
|
|
2242
2488
|
return [...e?.images ?? []].sort((e, t) => e.position - t.position);
|
|
2243
2489
|
}
|
|
2244
2490
|
// src/views/products/product-flow/flow-success.tsx
|
|
2245
|
-
function
|
|
2246
|
-
let { labels: r, hrefs: i, renderImage: a, renderLink: o } = F(), s = r.products.flow, { product: c, first: l } = e, u =
|
|
2491
|
+
function kt({ success: e, onAddAnother: t, onDone: n }) {
|
|
2492
|
+
let { labels: r, hrefs: i, renderImage: a, renderLink: o } = F(), s = r.products.flow, { product: c, first: l } = e, u = $(c)[0], d = i.storefrontProduct?.(c.slug);
|
|
2247
2493
|
return /* @__PURE__ */ w("section", {
|
|
2248
2494
|
className: "sfa-flow-success",
|
|
2249
2495
|
"aria-labelledby": "sfa-flow-success",
|
|
@@ -2271,6 +2517,11 @@ function vt({ success: e, onAddAnother: t, onDone: n }) {
|
|
|
2271
2517
|
onClick: t,
|
|
2272
2518
|
children: s.addAnother
|
|
2273
2519
|
}),
|
|
2520
|
+
d ? o({
|
|
2521
|
+
href: d,
|
|
2522
|
+
children: s.seeInShop,
|
|
2523
|
+
className: "sfa-btn"
|
|
2524
|
+
}) : null,
|
|
2274
2525
|
n ? /* @__PURE__ */ C("button", {
|
|
2275
2526
|
type: "button",
|
|
2276
2527
|
className: "sfa-btn",
|
|
@@ -2284,20 +2535,20 @@ function vt({ success: e, onAddAnother: t, onDone: n }) {
|
|
|
2284
2535
|
]
|
|
2285
2536
|
});
|
|
2286
2537
|
}
|
|
2287
|
-
var
|
|
2538
|
+
var At = [
|
|
2288
2539
|
"image/jpeg",
|
|
2289
2540
|
"image/png",
|
|
2290
2541
|
"image/webp",
|
|
2291
2542
|
"image/heic"
|
|
2292
2543
|
];
|
|
2293
|
-
function
|
|
2544
|
+
function jt(e, t) {
|
|
2294
2545
|
return e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? "");
|
|
2295
2546
|
}
|
|
2296
|
-
function
|
|
2297
|
-
return
|
|
2547
|
+
function Mt(e, t) {
|
|
2548
|
+
return At.includes(e.type) ? e.size > 8388608 ? jt(t.tooLarge, { name: e.name }) : null : jt(t.wrongType, { name: e.name });
|
|
2298
2549
|
}
|
|
2299
2550
|
// src/lib/use-image-upload.ts
|
|
2300
|
-
function
|
|
2551
|
+
function Nt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
2301
2552
|
let r = I(), { labels: i } = F(), [a, o] = b([]), s = y(0), c = y(Promise.resolve()), l = y(n), u = y({
|
|
2302
2553
|
productId: e,
|
|
2303
2554
|
resolveProductId: t
|
|
@@ -2334,7 +2585,7 @@ function xt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
|
2334
2585
|
let n = e.map((e) => ({
|
|
2335
2586
|
id: s.current++,
|
|
2336
2587
|
file: e,
|
|
2337
|
-
reason:
|
|
2588
|
+
reason: Mt(e, i.products.images)
|
|
2338
2589
|
}));
|
|
2339
2590
|
o((e) => [...e, ...n.map(({ id: e, file: t, reason: n }) => ({
|
|
2340
2591
|
id: e,
|
|
@@ -2348,16 +2599,16 @@ function xt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
|
2348
2599
|
};
|
|
2349
2600
|
}
|
|
2350
2601
|
// src/views/products/product-flow/photos-section.tsx
|
|
2351
|
-
function
|
|
2352
|
-
let i = I(), { labels: a, renderImage: o } = F(), s = a.products.flow, [c, l] = b(void 0), [u, d] = b(!1), f =
|
|
2602
|
+
function Pt({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
2603
|
+
let i = I(), { labels: a, renderImage: o } = F(), s = a.products.flow, [c, l] = b(void 0), [u, d] = b(!1), f = $(e), { entries: p, upload: m, dismiss: h } = Nt({
|
|
2353
2604
|
productId: e?.id,
|
|
2354
2605
|
resolveProductId: async () => (await t()).id,
|
|
2355
2606
|
onUploaded: n
|
|
2356
2607
|
});
|
|
2357
2608
|
if (r) return r;
|
|
2358
|
-
let g = (e) => {
|
|
2609
|
+
let g = f.length > 0 || p.length > 0, _ = (e) => {
|
|
2359
2610
|
m(Array.from(e.target.files ?? []), ""), e.target.value = "";
|
|
2360
|
-
},
|
|
2611
|
+
}, v = async (t) => {
|
|
2361
2612
|
if (e && !u) {
|
|
2362
2613
|
d(!0), l(void 0);
|
|
2363
2614
|
try {
|
|
@@ -2368,62 +2619,69 @@ function St({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
|
2368
2619
|
d(!1);
|
|
2369
2620
|
}
|
|
2370
2621
|
}
|
|
2371
|
-
},
|
|
2622
|
+
}, y = (e) => v((t) => i.reorderProductImages(t, [e, ...f.filter((t) => t.id !== e).map((e) => e.id)])), x = /* @__PURE__ */ w("label", {
|
|
2623
|
+
className: `sfa-flow__dropzone${g ? " sfa-flow__dropzone--tile" : ""}`,
|
|
2624
|
+
children: [
|
|
2625
|
+
/* @__PURE__ */ C("span", {
|
|
2626
|
+
className: "sfa-flow__dropzone-icon",
|
|
2627
|
+
"aria-hidden": "true",
|
|
2628
|
+
children: "+"
|
|
2629
|
+
}),
|
|
2630
|
+
/* @__PURE__ */ C("strong", { children: g ? s.addPhotoTile : s.addPhotos }),
|
|
2631
|
+
g ? null : /* @__PURE__ */ C("small", { children: s.photoHint }),
|
|
2632
|
+
/* @__PURE__ */ C("input", {
|
|
2633
|
+
type: "file",
|
|
2634
|
+
accept: "image/*",
|
|
2635
|
+
multiple: !0,
|
|
2636
|
+
className: "sfa-sr-only",
|
|
2637
|
+
onChange: _
|
|
2638
|
+
})
|
|
2639
|
+
]
|
|
2640
|
+
});
|
|
2372
2641
|
return /* @__PURE__ */ w(S, { children: [
|
|
2373
|
-
|
|
2374
|
-
|
|
2642
|
+
f.length || p.length ? null : x,
|
|
2643
|
+
/* @__PURE__ */ C(q, { error: c }),
|
|
2644
|
+
f.length || p.length ? /* @__PURE__ */ w("ul", {
|
|
2645
|
+
className: "sfa-flow__thumbs",
|
|
2375
2646
|
children: [
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2647
|
+
f.map((e, t) => {
|
|
2648
|
+
let n = String(t + 1);
|
|
2649
|
+
return /* @__PURE__ */ w("li", {
|
|
2650
|
+
className: `sfa-flow__thumb${t === 0 ? " is-cover" : ""}`,
|
|
2651
|
+
children: [/* @__PURE__ */ w("button", {
|
|
2652
|
+
type: "button",
|
|
2653
|
+
className: "sfa-flow__thumb-pick",
|
|
2654
|
+
"aria-label": t === 0 ? `${Q(s.photoN, { n })}, ${s.cover}` : Q(s.makeCover, { n }),
|
|
2655
|
+
"aria-pressed": t === 0,
|
|
2656
|
+
disabled: u,
|
|
2657
|
+
onClick: () => t === 0 ? void 0 : y(e.id),
|
|
2658
|
+
children: [o({
|
|
2659
|
+
src: e.url,
|
|
2660
|
+
alt: "",
|
|
2661
|
+
sizes: "120px"
|
|
2662
|
+
}), t === 0 ? /* @__PURE__ */ C("span", {
|
|
2663
|
+
className: "sfa-flow__badge",
|
|
2664
|
+
children: s.cover
|
|
2665
|
+
}) : null]
|
|
2666
|
+
}), /* @__PURE__ */ C("button", {
|
|
2667
|
+
type: "button",
|
|
2668
|
+
className: "sfa-flow__thumb-remove",
|
|
2669
|
+
"aria-label": Q(s.removePhoto, { n }),
|
|
2670
|
+
disabled: u,
|
|
2671
|
+
onClick: () => v((t) => i.deleteProductImage(t, e.id)),
|
|
2672
|
+
children: "✕"
|
|
2673
|
+
})]
|
|
2674
|
+
}, e.id);
|
|
2380
2675
|
}),
|
|
2381
|
-
/* @__PURE__ */ C(
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
onChange: g
|
|
2676
|
+
p.map((e) => /* @__PURE__ */ C(Ft, {
|
|
2677
|
+
entry: e,
|
|
2678
|
+
onDismiss: h
|
|
2679
|
+
}, e.id)),
|
|
2680
|
+
/* @__PURE__ */ C("li", {
|
|
2681
|
+
className: "sfa-flow__thumb sfa-flow__thumb--add",
|
|
2682
|
+
children: x
|
|
2389
2683
|
})
|
|
2390
2684
|
]
|
|
2391
|
-
}),
|
|
2392
|
-
/* @__PURE__ */ C(q, { error: c }),
|
|
2393
|
-
f.length || p.length ? /* @__PURE__ */ w("ul", {
|
|
2394
|
-
className: "sfa-flow__thumbs",
|
|
2395
|
-
children: [f.map((e, t) => {
|
|
2396
|
-
let n = String(t + 1);
|
|
2397
|
-
return /* @__PURE__ */ w("li", {
|
|
2398
|
-
className: `sfa-flow__thumb${t === 0 ? " is-cover" : ""}`,
|
|
2399
|
-
children: [/* @__PURE__ */ w("button", {
|
|
2400
|
-
type: "button",
|
|
2401
|
-
className: "sfa-flow__thumb-pick",
|
|
2402
|
-
"aria-label": t === 0 ? `${Z(s.photoN, { n })}, ${s.cover}` : Z(s.makeCover, { n }),
|
|
2403
|
-
"aria-pressed": t === 0,
|
|
2404
|
-
disabled: u,
|
|
2405
|
-
onClick: () => t === 0 ? void 0 : v(e.id),
|
|
2406
|
-
children: [o({
|
|
2407
|
-
src: e.url,
|
|
2408
|
-
alt: "",
|
|
2409
|
-
sizes: "120px"
|
|
2410
|
-
}), t === 0 ? /* @__PURE__ */ C("span", {
|
|
2411
|
-
className: "sfa-flow__badge",
|
|
2412
|
-
children: s.cover
|
|
2413
|
-
}) : null]
|
|
2414
|
-
}), /* @__PURE__ */ C("button", {
|
|
2415
|
-
type: "button",
|
|
2416
|
-
className: "sfa-flow__thumb-remove",
|
|
2417
|
-
"aria-label": Z(s.removePhoto, { n }),
|
|
2418
|
-
disabled: u,
|
|
2419
|
-
onClick: () => _((t) => i.deleteProductImage(t, e.id)),
|
|
2420
|
-
children: "✕"
|
|
2421
|
-
})]
|
|
2422
|
-
}, e.id);
|
|
2423
|
-
}), p.map((e) => /* @__PURE__ */ C(Ct, {
|
|
2424
|
-
entry: e,
|
|
2425
|
-
onDismiss: h
|
|
2426
|
-
}, e.id))]
|
|
2427
2685
|
}) : null,
|
|
2428
2686
|
/* @__PURE__ */ C("p", {
|
|
2429
2687
|
className: "sfa-flow__tip",
|
|
@@ -2431,7 +2689,7 @@ function St({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
|
2431
2689
|
})
|
|
2432
2690
|
] });
|
|
2433
2691
|
}
|
|
2434
|
-
function
|
|
2692
|
+
function Ft({ entry: e, onDismiss: t }) {
|
|
2435
2693
|
let { labels: n } = F();
|
|
2436
2694
|
return e.status === "error" ? /* @__PURE__ */ w("li", {
|
|
2437
2695
|
className: "sfa-flow__thumb is-failed",
|
|
@@ -2450,13 +2708,13 @@ function Ct({ entry: e, onDismiss: t }) {
|
|
|
2450
2708
|
children: /* @__PURE__ */ C("span", {
|
|
2451
2709
|
className: "sfa-spinner",
|
|
2452
2710
|
role: "status",
|
|
2453
|
-
children:
|
|
2711
|
+
children: Q(n.products.flow.uploading, { name: e.name })
|
|
2454
2712
|
})
|
|
2455
2713
|
});
|
|
2456
2714
|
}
|
|
2457
2715
|
// src/views/products/product-flow/preview-section.tsx
|
|
2458
|
-
function
|
|
2459
|
-
let { labels: o, renderImage: s } = F(), c = o.products.flow, l = o.products.sheet.missing, u =
|
|
2716
|
+
function It({ form: e, update: t, product: n, currency: r, missing: i, actions: a }) {
|
|
2717
|
+
let { labels: o, renderImage: s } = F(), c = o.products.flow, l = o.products.sheet.missing, u = $(n)[0], d = X(e.price);
|
|
2460
2718
|
return /* @__PURE__ */ w(S, { children: [
|
|
2461
2719
|
/* @__PURE__ */ w("div", {
|
|
2462
2720
|
className: "sfa-flow__preview",
|
|
@@ -2498,7 +2756,7 @@ function wt({ form: e, update: t, product: n, currency: r, missing: i, actions:
|
|
|
2498
2756
|
}) : null
|
|
2499
2757
|
]
|
|
2500
2758
|
}),
|
|
2501
|
-
/* @__PURE__ */ C(
|
|
2759
|
+
/* @__PURE__ */ C(rt, {
|
|
2502
2760
|
id: "sfa-flow-featured",
|
|
2503
2761
|
label: c.featured,
|
|
2504
2762
|
checked: e.featured,
|
|
@@ -2518,9 +2776,52 @@ function wt({ form: e, update: t, product: n, currency: r, missing: i, actions:
|
|
|
2518
2776
|
})
|
|
2519
2777
|
] });
|
|
2520
2778
|
}
|
|
2779
|
+
// src/views/products/product-flow/materials-field.tsx
|
|
2780
|
+
function Lt(e, t) {
|
|
2781
|
+
let n = mt(e);
|
|
2782
|
+
return {
|
|
2783
|
+
picked: n.filter((e) => t.includes(e)),
|
|
2784
|
+
custom: n.filter((e) => !t.includes(e)).join(", ")
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
function Rt({ value: e, suggestions: t = [], onChange: n }) {
|
|
2788
|
+
let { labels: r } = F(), i = Lt(e, t), [a, o] = b(i.picked), [s, c] = b(i.custom), l = (e) => {
|
|
2789
|
+
let t = a.includes(e) ? a.filter((t) => t !== e) : [...a, e];
|
|
2790
|
+
o(t), n(ht(t, s));
|
|
2791
|
+
}, u = (e) => {
|
|
2792
|
+
c(e), n(ht(a, e));
|
|
2793
|
+
};
|
|
2794
|
+
return /* @__PURE__ */ w("div", {
|
|
2795
|
+
className: "sfa-field",
|
|
2796
|
+
children: [
|
|
2797
|
+
/* @__PURE__ */ C("label", {
|
|
2798
|
+
className: "sfa-field__label",
|
|
2799
|
+
htmlFor: "sfa-flow-materials",
|
|
2800
|
+
children: r.products.fields.materials
|
|
2801
|
+
}),
|
|
2802
|
+
t.length ? /* @__PURE__ */ C("div", {
|
|
2803
|
+
className: "sfa-flow__chips",
|
|
2804
|
+
children: t.map((e) => /* @__PURE__ */ C("button", {
|
|
2805
|
+
type: "button",
|
|
2806
|
+
className: "sfa-chip",
|
|
2807
|
+
"aria-pressed": a.includes(e),
|
|
2808
|
+
onClick: () => l(e),
|
|
2809
|
+
children: e
|
|
2810
|
+
}, e))
|
|
2811
|
+
}) : null,
|
|
2812
|
+
/* @__PURE__ */ C("input", {
|
|
2813
|
+
id: "sfa-flow-materials",
|
|
2814
|
+
type: "text",
|
|
2815
|
+
placeholder: t.length ? r.products.flow.materialsOther : "",
|
|
2816
|
+
value: s,
|
|
2817
|
+
onChange: (e) => u(e.target.value)
|
|
2818
|
+
})
|
|
2819
|
+
]
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2521
2822
|
// src/views/products/product-flow/story-section.tsx
|
|
2522
|
-
function
|
|
2523
|
-
let { labels: a } = F(), o = a.products.flow, s = a.products.fields, c = o.descriptionPrompts, l =
|
|
2823
|
+
function zt({ form: e, update: t, product: n, setProduct: r, materialSuggestions: i }) {
|
|
2824
|
+
let { labels: a } = F(), o = a.products.flow, s = a.products.fields, c = o.descriptionPrompts, l = $(n);
|
|
2524
2825
|
return /* @__PURE__ */ w(S, { children: [
|
|
2525
2826
|
/* @__PURE__ */ w("div", {
|
|
2526
2827
|
className: "sfa-field",
|
|
@@ -2533,6 +2834,7 @@ function Tt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2533
2834
|
/* @__PURE__ */ C("textarea", {
|
|
2534
2835
|
id: "sfa-flow-description",
|
|
2535
2836
|
rows: 5,
|
|
2837
|
+
placeholder: o.descriptionPlaceholder,
|
|
2536
2838
|
value: e.description,
|
|
2537
2839
|
onChange: (e) => t("description", e.target.value)
|
|
2538
2840
|
}),
|
|
@@ -2541,38 +2843,16 @@ function Tt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2541
2843
|
children: c.map((n) => /* @__PURE__ */ w("button", {
|
|
2542
2844
|
type: "button",
|
|
2543
2845
|
className: "sfa-chip",
|
|
2544
|
-
onClick: () => t("description",
|
|
2846
|
+
onClick: () => t("description", gt(e.description, n)),
|
|
2545
2847
|
children: ["+ ", n]
|
|
2546
2848
|
}, n))
|
|
2547
2849
|
}) : null
|
|
2548
2850
|
]
|
|
2549
2851
|
}),
|
|
2550
|
-
/* @__PURE__ */
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
className: "sfa-field__label",
|
|
2555
|
-
htmlFor: "sfa-flow-materials",
|
|
2556
|
-
children: s.materials
|
|
2557
|
-
}),
|
|
2558
|
-
i?.length ? /* @__PURE__ */ C("div", {
|
|
2559
|
-
className: "sfa-flow__chips",
|
|
2560
|
-
children: i.map((n) => /* @__PURE__ */ C("button", {
|
|
2561
|
-
type: "button",
|
|
2562
|
-
className: "sfa-chip",
|
|
2563
|
-
"aria-pressed": l.includes(n),
|
|
2564
|
-
onClick: () => t("materials", at(e.materials, n)),
|
|
2565
|
-
children: n
|
|
2566
|
-
}, n))
|
|
2567
|
-
}) : null,
|
|
2568
|
-
/* @__PURE__ */ C("input", {
|
|
2569
|
-
id: "sfa-flow-materials",
|
|
2570
|
-
type: "text",
|
|
2571
|
-
placeholder: i?.length ? o.materialsOther : "",
|
|
2572
|
-
value: e.materials,
|
|
2573
|
-
onChange: (e) => t("materials", e.target.value)
|
|
2574
|
-
})
|
|
2575
|
-
]
|
|
2852
|
+
/* @__PURE__ */ C(Rt, {
|
|
2853
|
+
value: e.materials,
|
|
2854
|
+
suggestions: i,
|
|
2855
|
+
onChange: (e) => t("materials", e)
|
|
2576
2856
|
}),
|
|
2577
2857
|
/* @__PURE__ */ w("div", {
|
|
2578
2858
|
className: "sfa-field",
|
|
@@ -2583,11 +2863,12 @@ function Tt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2583
2863
|
}), /* @__PURE__ */ C("input", {
|
|
2584
2864
|
id: "sfa-flow-size",
|
|
2585
2865
|
type: "text",
|
|
2866
|
+
placeholder: o.sizePlaceholder,
|
|
2586
2867
|
value: e.dimensions,
|
|
2587
2868
|
onChange: (e) => t("dimensions", e.target.value)
|
|
2588
2869
|
})]
|
|
2589
2870
|
}),
|
|
2590
|
-
n &&
|
|
2871
|
+
n && l.length ? /* @__PURE__ */ w("fieldset", {
|
|
2591
2872
|
className: "sfa-flow__alts",
|
|
2592
2873
|
children: [
|
|
2593
2874
|
/* @__PURE__ */ C("legend", {
|
|
@@ -2598,11 +2879,11 @@ function Tt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2598
2879
|
className: "sfa-field__help",
|
|
2599
2880
|
children: o.altHelp
|
|
2600
2881
|
}),
|
|
2601
|
-
|
|
2882
|
+
l.map((t, i) => /* @__PURE__ */ C(Bt, {
|
|
2602
2883
|
productId: n.id,
|
|
2603
2884
|
image: t,
|
|
2604
|
-
label:
|
|
2605
|
-
placeholder:
|
|
2885
|
+
label: Q(o.photoN, { n: String(i + 1) }),
|
|
2886
|
+
placeholder: o.altPlaceholder || Q(o.altFallback, {
|
|
2606
2887
|
name: e.name.trim() || o.untitled,
|
|
2607
2888
|
n: String(i + 1)
|
|
2608
2889
|
}),
|
|
@@ -2612,7 +2893,7 @@ function Tt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2612
2893
|
}) : null
|
|
2613
2894
|
] });
|
|
2614
2895
|
}
|
|
2615
|
-
function
|
|
2896
|
+
function Bt({ productId: e, image: t, label: n, placeholder: r, onSaved: i }) {
|
|
2616
2897
|
let a = I(), [o, s] = b(t.alt), [c, l] = b(void 0), u = `sfa-flow-alt-${t.id}`;
|
|
2617
2898
|
return /* @__PURE__ */ w("div", {
|
|
2618
2899
|
className: "sfa-field",
|
|
@@ -2643,8 +2924,23 @@ function Et({ productId: e, image: t, label: n, placeholder: r, onSaved: i }) {
|
|
|
2643
2924
|
]
|
|
2644
2925
|
});
|
|
2645
2926
|
}
|
|
2927
|
+
// src/lib/fill-alts.ts
|
|
2928
|
+
async function Vt(e, t, n, r = t.name) {
|
|
2929
|
+
let i = r.trim();
|
|
2930
|
+
if (!i) return t;
|
|
2931
|
+
let a = t, o = [...t.images].sort((e, t) => e.position - t.position);
|
|
2932
|
+
for (let [r, s] of o.entries()) {
|
|
2933
|
+
if (s.alt.trim()) continue;
|
|
2934
|
+
let o = Q(n, {
|
|
2935
|
+
name: i,
|
|
2936
|
+
n: String(r + 1)
|
|
2937
|
+
});
|
|
2938
|
+
a = await e.updateProductImage(t.id, s.id, { alt: o });
|
|
2939
|
+
}
|
|
2940
|
+
return a;
|
|
2941
|
+
}
|
|
2646
2942
|
// src/lib/product-form.ts
|
|
2647
|
-
var
|
|
2943
|
+
var Ht = {
|
|
2648
2944
|
name: "",
|
|
2649
2945
|
category: "",
|
|
2650
2946
|
description: "",
|
|
@@ -2653,34 +2949,39 @@ var Dt = {
|
|
|
2653
2949
|
price: "",
|
|
2654
2950
|
quantity: "1",
|
|
2655
2951
|
status: "draft",
|
|
2656
|
-
featured: !1
|
|
2952
|
+
featured: !1,
|
|
2953
|
+
taxCode: ""
|
|
2657
2954
|
};
|
|
2658
|
-
function
|
|
2955
|
+
function Ut(e) {
|
|
2659
2956
|
return {
|
|
2660
2957
|
name: e.name,
|
|
2661
2958
|
category: e.category ?? "",
|
|
2662
2959
|
description: e.description,
|
|
2663
2960
|
materials: e.materials ?? "",
|
|
2664
2961
|
dimensions: e.dimensions ?? "",
|
|
2665
|
-
price: e.priceCents === null ? "" :
|
|
2962
|
+
price: e.priceCents === null ? "" : Z(e.priceCents),
|
|
2666
2963
|
quantity: String(e.quantity),
|
|
2667
2964
|
status: e.status,
|
|
2668
|
-
featured: e.featured
|
|
2965
|
+
featured: e.featured,
|
|
2966
|
+
taxCode: e.taxCode ?? ""
|
|
2669
2967
|
};
|
|
2670
2968
|
}
|
|
2671
2969
|
// src/lib/use-product-autosave.ts
|
|
2672
|
-
function
|
|
2970
|
+
function Wt({ initial: e, form: t, currency: n, delayMs: r = 600 }) {
|
|
2673
2971
|
let i = I(), [a, o] = b(e), [s, c] = b(e ? "saved" : "idle"), [l, u] = b(void 0), d = y(e), f = y(t), p = y(t), m = y(Promise.resolve()), g = h((e) => {
|
|
2674
2972
|
d.current = e, o(e);
|
|
2675
2973
|
}, []), v = h(async (e) => {
|
|
2676
2974
|
let t = d.current, r = f.current;
|
|
2677
|
-
if (!t && !e && !
|
|
2678
|
-
let a = t ?
|
|
2975
|
+
if (!t && !e && !ct(r)) return null;
|
|
2976
|
+
let a = t ? ut(t, r) : null;
|
|
2679
2977
|
if (t && a && Object.keys(a).length === 0) return t;
|
|
2680
2978
|
c("saving");
|
|
2681
2979
|
try {
|
|
2682
|
-
let e = t ? await i.updateProduct(t.id, a) : await i.createProduct(
|
|
2683
|
-
return g(
|
|
2980
|
+
let e = t ? await i.updateProduct(t.id, a) : await i.createProduct(lt(r, n)), o = d.current;
|
|
2981
|
+
return g(t && o && o !== t ? {
|
|
2982
|
+
...e,
|
|
2983
|
+
images: o.images
|
|
2984
|
+
} : e), u(void 0), c("saved"), d.current ?? e;
|
|
2684
2985
|
} catch (e) {
|
|
2685
2986
|
return u(e), c("error"), null;
|
|
2686
2987
|
}
|
|
@@ -2715,8 +3016,8 @@ function kt({ initial: e, form: t, currency: n, delayMs: r = 600 }) {
|
|
|
2715
3016
|
};
|
|
2716
3017
|
}
|
|
2717
3018
|
// src/views/products/product-flow/use-product-flow.ts
|
|
2718
|
-
function
|
|
2719
|
-
let a = I(), { labels: o } = F(), s = o.products.flow, [c, l] = b(e ?
|
|
3019
|
+
function Gt({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose: i }) {
|
|
3020
|
+
let a = I(), { labels: o } = F(), s = o.products.flow, [c, l] = b(e ? Ut(e) : Ht), [d, f] = b(t ?? "photos"), p = Wt({
|
|
2720
3021
|
initial: e,
|
|
2721
3022
|
form: c
|
|
2722
3023
|
}), [m, h] = b(null), [g, _] = b(void 0), [v, y] = b(!1), [x, S] = b(null), [C, w] = b(null), [T, E] = b(!1), D = p.product, O = e === null, k = (e, t) => {
|
|
@@ -2725,18 +3026,8 @@ function At({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
2725
3026
|
[e]: t
|
|
2726
3027
|
}));
|
|
2727
3028
|
}, A = async (e) => {
|
|
2728
|
-
let t = c.name
|
|
2729
|
-
|
|
2730
|
-
let n = e, r = [...e.images].sort((e, t) => e.position - t.position);
|
|
2731
|
-
for (let [i, o] of r.entries()) {
|
|
2732
|
-
if (o.alt.trim()) continue;
|
|
2733
|
-
let r = Z(s.altFallback, {
|
|
2734
|
-
name: t,
|
|
2735
|
-
n: String(i + 1)
|
|
2736
|
-
});
|
|
2737
|
-
n = await a.updateProductImage(e.id, o.id, { alt: r });
|
|
2738
|
-
}
|
|
2739
|
-
return n !== e && p.setProduct(n), n;
|
|
3029
|
+
let t = await Vt(a, e, s.altFallback, c.name);
|
|
3030
|
+
return t !== e && p.setProduct(t), t;
|
|
2740
3031
|
}, j = async (e) => {
|
|
2741
3032
|
y(!0), _(void 0), h(null);
|
|
2742
3033
|
try {
|
|
@@ -2750,8 +3041,8 @@ function At({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
2750
3041
|
r ? r(e) : w(o.products.saved);
|
|
2751
3042
|
}, N = () => j(async () => {
|
|
2752
3043
|
let e = await p.flush();
|
|
2753
|
-
e ? M(await A(e)) :
|
|
2754
|
-
}),
|
|
3044
|
+
e ? M(await A(e)) : ct(c) || await ee();
|
|
3045
|
+
}), P = () => j(async () => {
|
|
2755
3046
|
let e = (D?.status ?? "draft") === "draft", t = await A(await p.ensureProduct()), r = t.status === "active" ? t : await a.updateProduct(t.id, { status: "active" });
|
|
2756
3047
|
if (p.setProduct(r), !e) return M(r);
|
|
2757
3048
|
let i = n ?? (await a.getProductCounts()).live === 1;
|
|
@@ -2759,7 +3050,7 @@ function At({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
2759
3050
|
product: r,
|
|
2760
3051
|
first: i
|
|
2761
3052
|
});
|
|
2762
|
-
}),
|
|
3053
|
+
}), ee = async () => {
|
|
2763
3054
|
let e = await p.flush() ?? p.product;
|
|
2764
3055
|
O && e && e.status === "draft" && !x ? E(!0) : i?.(e);
|
|
2765
3056
|
};
|
|
@@ -2782,12 +3073,12 @@ function At({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
2782
3073
|
E(!1), i?.(p.product);
|
|
2783
3074
|
},
|
|
2784
3075
|
saveDraft: N,
|
|
2785
|
-
publish:
|
|
2786
|
-
close:
|
|
3076
|
+
publish: P,
|
|
3077
|
+
close: ee
|
|
2787
3078
|
};
|
|
2788
3079
|
}
|
|
2789
3080
|
// src/views/products/product-flow/admin-product-flow.tsx
|
|
2790
|
-
function
|
|
3081
|
+
function Kt(e) {
|
|
2791
3082
|
let [t, n] = b({
|
|
2792
3083
|
key: 0,
|
|
2793
3084
|
productId: e.productId
|
|
@@ -2795,11 +3086,11 @@ function jt(e) {
|
|
|
2795
3086
|
key: e.key + 1,
|
|
2796
3087
|
productId: void 0
|
|
2797
3088
|
}));
|
|
2798
|
-
return t.productId ? /* @__PURE__ */ C(
|
|
3089
|
+
return t.productId ? /* @__PURE__ */ C(qt, {
|
|
2799
3090
|
...e,
|
|
2800
3091
|
productId: t.productId,
|
|
2801
3092
|
onAddAnother: r
|
|
2802
|
-
}, t.key) : /* @__PURE__ */ C(
|
|
3093
|
+
}, t.key) : /* @__PURE__ */ C(Jt, {
|
|
2803
3094
|
...e,
|
|
2804
3095
|
initial: null,
|
|
2805
3096
|
initialStep: void 0,
|
|
@@ -2807,158 +3098,179 @@ function jt(e) {
|
|
|
2807
3098
|
onAddAnother: r
|
|
2808
3099
|
}, t.key);
|
|
2809
3100
|
}
|
|
2810
|
-
function
|
|
3101
|
+
function qt({ productId: e, ...t }) {
|
|
2811
3102
|
let n = I(), { labels: r } = F(), i = L(["admin-product", e], () => n.getProduct(e));
|
|
2812
|
-
return i.error ? /* @__PURE__ */ C(q, { error: i.error }) : i.data ? /* @__PURE__ */ C(
|
|
3103
|
+
return i.error ? /* @__PURE__ */ C(q, { error: i.error }) : i.data ? /* @__PURE__ */ C(Jt, {
|
|
2813
3104
|
...t,
|
|
2814
3105
|
initial: i.data
|
|
2815
3106
|
}, i.data.id) : /* @__PURE__ */ C("p", { children: r.loading });
|
|
2816
3107
|
}
|
|
2817
|
-
function
|
|
2818
|
-
let { labels:
|
|
3108
|
+
function Jt({ initial: e, initialStep: t, onDone: n, onClose: r, categories: i, materialSuggestions: a, taxCodes: o, isFirstProduct: s, imagesSlot: c, onAddAnother: l }) {
|
|
3109
|
+
let { labels: u, hrefs: d, renderLink: f, currency: p } = F(), m = u.products.flow, h = Gt({
|
|
2819
3110
|
initial: e,
|
|
2820
3111
|
initialStep: t,
|
|
2821
|
-
isFirstProduct:
|
|
3112
|
+
isFirstProduct: s,
|
|
2822
3113
|
onDone: n,
|
|
2823
3114
|
onClose: r
|
|
2824
|
-
}),
|
|
2825
|
-
form:
|
|
2826
|
-
update:
|
|
2827
|
-
},
|
|
3115
|
+
}), g = h.product?.currency ?? p, v = {
|
|
3116
|
+
form: h.form,
|
|
3117
|
+
update: h.update
|
|
3118
|
+
}, b = y(null), x = y(!0);
|
|
2828
3119
|
if (_(() => {
|
|
2829
|
-
let e = !
|
|
2830
|
-
|
|
2831
|
-
}, [
|
|
3120
|
+
let e = !x.current || t !== void 0;
|
|
3121
|
+
x.current = !1, e && b.current?.querySelector(`#sfa-flow-${h.step}`)?.scrollIntoView?.({ block: "start" });
|
|
3122
|
+
}, [h.step, t]), h.success) return /* @__PURE__ */ C("div", {
|
|
2832
3123
|
className: "sfa-flow sfa-flow--done",
|
|
2833
|
-
children: /* @__PURE__ */ C(
|
|
2834
|
-
success:
|
|
2835
|
-
onAddAnother:
|
|
3124
|
+
children: /* @__PURE__ */ C(kt, {
|
|
3125
|
+
success: h.success,
|
|
3126
|
+
onAddAnother: l,
|
|
2836
3127
|
onDone: n
|
|
2837
3128
|
})
|
|
2838
3129
|
});
|
|
2839
|
-
let
|
|
2840
|
-
let e =
|
|
2841
|
-
e ?
|
|
2842
|
-
},
|
|
3130
|
+
let T = () => {
|
|
3131
|
+
let e = xt(h.step);
|
|
3132
|
+
e ? h.goTo(e) : r && h.close();
|
|
3133
|
+
}, E = r ? /* @__PURE__ */ w("button", {
|
|
2843
3134
|
type: "button",
|
|
2844
3135
|
className: "sfa-btn sfa-btn--ghost",
|
|
2845
|
-
"aria-label":
|
|
2846
|
-
onClick: () => void
|
|
2847
|
-
children: "
|
|
2848
|
-
}) : d({
|
|
2849
|
-
href: u.products,
|
|
2850
|
-
className: "sfa-btn sfa-btn--ghost",
|
|
2851
|
-
children: /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("span", {
|
|
3136
|
+
"aria-label": m.close,
|
|
3137
|
+
onClick: () => void h.close(),
|
|
3138
|
+
children: [/* @__PURE__ */ C("span", {
|
|
2852
3139
|
"aria-hidden": "true",
|
|
2853
3140
|
children: "✕"
|
|
2854
3141
|
}), /* @__PURE__ */ C("span", {
|
|
2855
|
-
className: "sfa-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
3142
|
+
className: "sfa-flow__btn-text",
|
|
3143
|
+
"aria-hidden": "true",
|
|
3144
|
+
children: m.close
|
|
3145
|
+
})]
|
|
3146
|
+
}) : f({
|
|
3147
|
+
href: d.products,
|
|
3148
|
+
className: "sfa-btn sfa-btn--ghost",
|
|
3149
|
+
children: /* @__PURE__ */ w(S, { children: [
|
|
3150
|
+
/* @__PURE__ */ C("span", {
|
|
3151
|
+
"aria-hidden": "true",
|
|
3152
|
+
children: "✕"
|
|
3153
|
+
}),
|
|
3154
|
+
/* @__PURE__ */ C("span", {
|
|
3155
|
+
className: "sfa-sr-only",
|
|
3156
|
+
children: m.close
|
|
3157
|
+
}),
|
|
3158
|
+
/* @__PURE__ */ C("span", {
|
|
3159
|
+
className: "sfa-flow__btn-text",
|
|
3160
|
+
"aria-hidden": "true",
|
|
3161
|
+
children: m.close
|
|
3162
|
+
})
|
|
3163
|
+
] })
|
|
3164
|
+
}), D = (e) => h.step === e;
|
|
2859
3165
|
return /* @__PURE__ */ w("div", {
|
|
2860
|
-
ref:
|
|
3166
|
+
ref: b,
|
|
2861
3167
|
className: "sfa-flow",
|
|
2862
|
-
"data-step":
|
|
3168
|
+
"data-step": h.step,
|
|
2863
3169
|
children: [
|
|
2864
|
-
/* @__PURE__ */ C(
|
|
2865
|
-
title:
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
3170
|
+
/* @__PURE__ */ C(Tt, {
|
|
3171
|
+
title: h.isNew ? m.newTitle : m.editTitle,
|
|
3172
|
+
step: h.step,
|
|
3173
|
+
onBack: T,
|
|
3174
|
+
canGoBack: !!r || h.step !== "photos",
|
|
3175
|
+
close: E
|
|
2869
3176
|
}),
|
|
2870
|
-
/* @__PURE__ */ C(
|
|
2871
|
-
step:
|
|
2872
|
-
allOpen: !
|
|
2873
|
-
onStep:
|
|
3177
|
+
/* @__PURE__ */ C(Et, {
|
|
3178
|
+
step: h.step,
|
|
3179
|
+
allOpen: !h.isNew,
|
|
3180
|
+
onStep: h.goTo
|
|
2874
3181
|
}),
|
|
2875
3182
|
/* @__PURE__ */ w("div", {
|
|
2876
3183
|
className: "sfa-flow__body",
|
|
2877
3184
|
children: [/* @__PURE__ */ w("div", {
|
|
2878
3185
|
className: "sfa-flow__main",
|
|
2879
3186
|
children: [
|
|
2880
|
-
/* @__PURE__ */ C(
|
|
3187
|
+
/* @__PURE__ */ C(Ot, {
|
|
2881
3188
|
step: "photos",
|
|
2882
|
-
active:
|
|
2883
|
-
children: /* @__PURE__ */ C(
|
|
2884
|
-
product:
|
|
2885
|
-
ensureProduct:
|
|
2886
|
-
setProduct:
|
|
2887
|
-
imagesSlot:
|
|
3189
|
+
active: D("photos"),
|
|
3190
|
+
children: /* @__PURE__ */ C(Pt, {
|
|
3191
|
+
product: h.product,
|
|
3192
|
+
ensureProduct: h.autosave.ensureProduct,
|
|
3193
|
+
setProduct: h.autosave.setProduct,
|
|
3194
|
+
imagesSlot: c
|
|
2888
3195
|
})
|
|
2889
3196
|
}),
|
|
2890
|
-
/* @__PURE__ */ C(
|
|
3197
|
+
/* @__PURE__ */ C(Ot, {
|
|
2891
3198
|
step: "basics",
|
|
2892
|
-
active:
|
|
2893
|
-
children: /* @__PURE__ */ C(
|
|
2894
|
-
...
|
|
3199
|
+
active: D("basics"),
|
|
3200
|
+
children: /* @__PURE__ */ C(yt, {
|
|
3201
|
+
...v,
|
|
2895
3202
|
categories: i,
|
|
2896
|
-
currency:
|
|
3203
|
+
currency: g,
|
|
3204
|
+
taxCodes: o
|
|
2897
3205
|
})
|
|
2898
3206
|
}),
|
|
2899
|
-
/* @__PURE__ */ C(
|
|
3207
|
+
/* @__PURE__ */ C(Ot, {
|
|
2900
3208
|
step: "story",
|
|
2901
|
-
active:
|
|
2902
|
-
children: /* @__PURE__ */ C(
|
|
2903
|
-
...
|
|
2904
|
-
product:
|
|
2905
|
-
setProduct:
|
|
3209
|
+
active: D("story"),
|
|
3210
|
+
children: /* @__PURE__ */ C(zt, {
|
|
3211
|
+
...v,
|
|
3212
|
+
product: h.product,
|
|
3213
|
+
setProduct: h.autosave.setProduct,
|
|
2906
3214
|
materialSuggestions: a
|
|
2907
3215
|
})
|
|
2908
3216
|
})
|
|
2909
3217
|
]
|
|
2910
3218
|
}), /* @__PURE__ */ w("aside", {
|
|
2911
3219
|
className: "sfa-flow__aside",
|
|
2912
|
-
children: [
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
})
|
|
2923
|
-
}),
|
|
2924
|
-
/* @__PURE__ */ C(q, { error: m.failure }),
|
|
2925
|
-
/* @__PURE__ */ C(gt, {
|
|
2926
|
-
state: m.autosave.state,
|
|
2927
|
-
isNew: m.isNew,
|
|
2928
|
-
onRetry: () => void m.autosave.retry()
|
|
3220
|
+
children: [/* @__PURE__ */ C(Ot, {
|
|
3221
|
+
step: "preview",
|
|
3222
|
+
active: D("preview"),
|
|
3223
|
+
live: (h.product?.status ?? "draft") !== "draft",
|
|
3224
|
+
children: /* @__PURE__ */ C(It, {
|
|
3225
|
+
...v,
|
|
3226
|
+
product: h.product,
|
|
3227
|
+
currency: g,
|
|
3228
|
+
missing: h.missing,
|
|
3229
|
+
actions: /* @__PURE__ */ C(St, { flow: h })
|
|
2929
3230
|
})
|
|
2930
|
-
]
|
|
3231
|
+
}), /* @__PURE__ */ C(q, { error: h.failure })]
|
|
2931
3232
|
})]
|
|
2932
3233
|
}),
|
|
2933
|
-
/* @__PURE__ */
|
|
3234
|
+
/* @__PURE__ */ w("div", {
|
|
2934
3235
|
className: "sfa-flow__foot",
|
|
2935
|
-
children:
|
|
3236
|
+
children: [
|
|
3237
|
+
/* @__PURE__ */ C(wt, { flow: h }),
|
|
3238
|
+
/* @__PURE__ */ C(Dt, {
|
|
3239
|
+
state: h.autosave.state,
|
|
3240
|
+
isNew: h.isNew,
|
|
3241
|
+
onRetry: () => void h.autosave.retry()
|
|
3242
|
+
}),
|
|
3243
|
+
/* @__PURE__ */ C("div", {
|
|
3244
|
+
className: "sfa-flow__foot-actions",
|
|
3245
|
+
children: /* @__PURE__ */ C(Ct, { flow: h })
|
|
3246
|
+
})
|
|
3247
|
+
]
|
|
2936
3248
|
}),
|
|
2937
|
-
|
|
3249
|
+
h.notice ? /* @__PURE__ */ C(K, {
|
|
2938
3250
|
variant: "success",
|
|
2939
3251
|
toast: !0,
|
|
2940
|
-
onDismiss:
|
|
2941
|
-
children:
|
|
3252
|
+
onDismiss: h.dismissNotice,
|
|
3253
|
+
children: h.notice
|
|
2942
3254
|
}) : null,
|
|
2943
|
-
|
|
3255
|
+
h.closing ? /* @__PURE__ */ C(K, {
|
|
2944
3256
|
variant: "success",
|
|
2945
3257
|
toast: !0,
|
|
2946
3258
|
duration: 1500,
|
|
2947
|
-
onDismiss:
|
|
2948
|
-
children:
|
|
3259
|
+
onDismiss: h.finishClosing,
|
|
3260
|
+
children: m.savedAsDraft
|
|
2949
3261
|
}) : null
|
|
2950
3262
|
]
|
|
2951
3263
|
});
|
|
2952
3264
|
}
|
|
2953
3265
|
// src/views/products/admin-product-editor.tsx
|
|
2954
|
-
function
|
|
3266
|
+
function Yt() {
|
|
2955
3267
|
let e = new URLSearchParams(window.location.search).get("step");
|
|
2956
|
-
return
|
|
3268
|
+
return M.find((t) => t === e);
|
|
2957
3269
|
}
|
|
2958
|
-
var
|
|
2959
|
-
function
|
|
2960
|
-
let a = x(
|
|
2961
|
-
return /* @__PURE__ */ C(
|
|
3270
|
+
var Xt = () => () => void 0;
|
|
3271
|
+
function Zt({ productId: e, onSaved: t, imagesSlot: n, categories: r, initialStep: i }) {
|
|
3272
|
+
let a = x(Xt, Yt, () => void 0);
|
|
3273
|
+
return /* @__PURE__ */ C(Kt, {
|
|
2962
3274
|
productId: e,
|
|
2963
3275
|
initialStep: i ?? a,
|
|
2964
3276
|
onDone: t,
|
|
@@ -2967,7 +3279,7 @@ function It({ productId: e, onSaved: t, imagesSlot: n, categories: r, initialSte
|
|
|
2967
3279
|
});
|
|
2968
3280
|
}
|
|
2969
3281
|
// src/views/products/image-alt-editor.tsx
|
|
2970
|
-
function
|
|
3282
|
+
function Qt({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
|
|
2971
3283
|
let [a, o] = b(null), [s, c] = b(!1), [l, u] = b(void 0), d = () => {
|
|
2972
3284
|
o(null), u(void 0);
|
|
2973
3285
|
};
|
|
@@ -3021,8 +3333,8 @@ function Lt({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
|
|
|
3021
3333
|
});
|
|
3022
3334
|
}
|
|
3023
3335
|
// src/views/products/image-tile.tsx
|
|
3024
|
-
function
|
|
3025
|
-
let { renderImage: c } = F(), l = e.alt ||
|
|
3336
|
+
function $t({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRemove: o, onSaveAlt: s }) {
|
|
3337
|
+
let { renderImage: c } = F(), l = e.alt || jt(i.photoName, { n: String(t + 1) }), u = (t, n, r) => /* @__PURE__ */ C("button", {
|
|
3026
3338
|
type: "button",
|
|
3027
3339
|
className: "sfa-btn",
|
|
3028
3340
|
"data-image-id": e.id,
|
|
@@ -3057,7 +3369,7 @@ function Rt({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRem
|
|
|
3057
3369
|
children: [
|
|
3058
3370
|
u("earlier", i.moveEarlier, t === 0),
|
|
3059
3371
|
u("later", i.moveLater, t === n - 1),
|
|
3060
|
-
/* @__PURE__ */ C(
|
|
3372
|
+
/* @__PURE__ */ C(Qt, {
|
|
3061
3373
|
imageId: e.id,
|
|
3062
3374
|
alt: e.alt,
|
|
3063
3375
|
name: l,
|
|
@@ -3077,7 +3389,7 @@ function Rt({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRem
|
|
|
3077
3389
|
});
|
|
3078
3390
|
}
|
|
3079
3391
|
// src/views/products/upload-picker.tsx
|
|
3080
|
-
function
|
|
3392
|
+
function en({ labels: e, onFiles: t }) {
|
|
3081
3393
|
let n = (e) => {
|
|
3082
3394
|
t(Array.from(e.target.files ?? [])), e.target.value = "";
|
|
3083
3395
|
};
|
|
@@ -3105,11 +3417,11 @@ function zt({ labels: e, onFiles: t }) {
|
|
|
3105
3417
|
});
|
|
3106
3418
|
}
|
|
3107
3419
|
// src/views/products/admin-product-images.tsx
|
|
3108
|
-
var
|
|
3109
|
-
function
|
|
3110
|
-
let n = I(), { labels: r } = F(), i = r.products.images, [a, o] = b(() =>
|
|
3420
|
+
var tn = (e) => [...e].sort((e, t) => e.position - t.position);
|
|
3421
|
+
function nn({ productId: e, images: t }) {
|
|
3422
|
+
let n = I(), { labels: r } = F(), i = r.products.images, [a, o] = b(() => tn(t)), [s, c] = b(null), [l, u] = b(!1), [d, f] = b(""), [p, m] = b(void 0), [h, g] = b(!1), [v, x] = b(null), T = y(null), E = y(null), { entries: D, upload: O, dismiss: k } = Nt({
|
|
3111
3423
|
productId: e,
|
|
3112
|
-
onUploaded: (e) => o(
|
|
3424
|
+
onUploaded: (e) => o(tn(e.images))
|
|
3113
3425
|
});
|
|
3114
3426
|
_(() => {
|
|
3115
3427
|
let e = T.current;
|
|
@@ -3128,7 +3440,7 @@ function Vt({ productId: e, images: t }) {
|
|
|
3128
3440
|
}, o(d), u(!0), c(a[t].id), m(void 0), g(!1);
|
|
3129
3441
|
try {
|
|
3130
3442
|
let t = await n.reorderProductImages(e, d.map((e) => e.id));
|
|
3131
|
-
o(
|
|
3443
|
+
o(tn(t.images));
|
|
3132
3444
|
} catch (e) {
|
|
3133
3445
|
T.current = {
|
|
3134
3446
|
id: a[t].id,
|
|
@@ -3143,7 +3455,7 @@ function Vt({ productId: e, images: t }) {
|
|
|
3143
3455
|
x(null), c(t.id), m(void 0), g(!1);
|
|
3144
3456
|
try {
|
|
3145
3457
|
let r = await n.deleteProductImage(e, t.id);
|
|
3146
|
-
o(
|
|
3458
|
+
o(tn(r.images));
|
|
3147
3459
|
} catch (e) {
|
|
3148
3460
|
m(e);
|
|
3149
3461
|
} finally {
|
|
@@ -3151,7 +3463,7 @@ function Vt({ productId: e, images: t }) {
|
|
|
3151
3463
|
}
|
|
3152
3464
|
}, M = async (t, r) => {
|
|
3153
3465
|
let i = await n.updateProductImage(e, t, { alt: r });
|
|
3154
|
-
o(
|
|
3466
|
+
o(tn(i.images));
|
|
3155
3467
|
};
|
|
3156
3468
|
return /* @__PURE__ */ w("div", {
|
|
3157
3469
|
className: "sfa-images",
|
|
@@ -3192,7 +3504,7 @@ function Vt({ productId: e, images: t }) {
|
|
|
3192
3504
|
}) : null
|
|
3193
3505
|
]
|
|
3194
3506
|
}),
|
|
3195
|
-
/* @__PURE__ */ C(
|
|
3507
|
+
/* @__PURE__ */ C(en, {
|
|
3196
3508
|
labels: i,
|
|
3197
3509
|
onFiles: (e) => O(e, d)
|
|
3198
3510
|
}),
|
|
@@ -3204,7 +3516,7 @@ function Vt({ productId: e, images: t }) {
|
|
|
3204
3516
|
/* @__PURE__ */ w("ul", {
|
|
3205
3517
|
ref: E,
|
|
3206
3518
|
className: "sfa-image-grid",
|
|
3207
|
-
children: [a.map((e, t) => /* @__PURE__ */ C(
|
|
3519
|
+
children: [a.map((e, t) => /* @__PURE__ */ C($t, {
|
|
3208
3520
|
image: e,
|
|
3209
3521
|
index: t,
|
|
3210
3522
|
total: a.length,
|
|
@@ -3243,69 +3555,28 @@ function Vt({ productId: e, images: t }) {
|
|
|
3243
3555
|
]
|
|
3244
3556
|
});
|
|
3245
3557
|
}
|
|
3246
|
-
// src/components/empty-state/empty-state.tsx
|
|
3247
|
-
var Ht = {
|
|
3248
|
-
orders: "M4 8l8-4 8 4v8l-8 4-8-4V8zm0 0l8 4m0 0l8-4m-8 4v8",
|
|
3249
|
-
discounts: "M3 12V4h8l10 10-8 8L3 12zm5-5h.01",
|
|
3250
|
-
shipping: "M2 6h11v9H2V6zm11 3h4l3 3v3h-7V9zM6 18.5h.01M17 18.5h.01",
|
|
3251
|
-
search: "M11 4a7 7 0 100 14 7 7 0 000-14zm9 16l-4-4"
|
|
3252
|
-
};
|
|
3253
|
-
function Ut({ icon: e, title: t, body: n, action: r, children: i }) {
|
|
3254
|
-
return /* @__PURE__ */ w("div", {
|
|
3255
|
-
className: "sfa-empty-state",
|
|
3256
|
-
children: [
|
|
3257
|
-
/* @__PURE__ */ C("svg", {
|
|
3258
|
-
className: "sfa-empty-state__icon",
|
|
3259
|
-
viewBox: "0 0 24 24",
|
|
3260
|
-
width: "48",
|
|
3261
|
-
height: "48",
|
|
3262
|
-
fill: "none",
|
|
3263
|
-
stroke: "currentColor",
|
|
3264
|
-
strokeWidth: "1.5",
|
|
3265
|
-
strokeLinecap: "round",
|
|
3266
|
-
strokeLinejoin: "round",
|
|
3267
|
-
"aria-hidden": "true",
|
|
3268
|
-
focusable: "false",
|
|
3269
|
-
children: /* @__PURE__ */ C("path", { d: Ht[e] })
|
|
3270
|
-
}),
|
|
3271
|
-
/* @__PURE__ */ C("h2", {
|
|
3272
|
-
className: "sfa-empty-state__title",
|
|
3273
|
-
children: t
|
|
3274
|
-
}),
|
|
3275
|
-
n ? /* @__PURE__ */ C("p", {
|
|
3276
|
-
className: "sfa-empty-state__body",
|
|
3277
|
-
children: n
|
|
3278
|
-
}) : null,
|
|
3279
|
-
i,
|
|
3280
|
-
r ? /* @__PURE__ */ C("div", {
|
|
3281
|
-
className: "sfa-empty-state__action",
|
|
3282
|
-
children: r
|
|
3283
|
-
}) : null
|
|
3284
|
-
]
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
3558
|
// src/lib/use-order-pages.ts
|
|
3288
|
-
function
|
|
3559
|
+
function rn(e) {
|
|
3289
3560
|
let t = I();
|
|
3290
|
-
return
|
|
3561
|
+
return Ae(["admin-orders", e], (n) => t.listOrders(n ? {
|
|
3291
3562
|
...e,
|
|
3292
3563
|
cursor: n
|
|
3293
3564
|
} : e));
|
|
3294
3565
|
}
|
|
3295
3566
|
// src/views/orders/admin-order-list.tsx
|
|
3296
|
-
var
|
|
3567
|
+
var an = [
|
|
3297
3568
|
"paid",
|
|
3298
3569
|
"shipped",
|
|
3299
3570
|
"needs_attention",
|
|
3300
3571
|
"pending_refund",
|
|
3301
3572
|
"all"
|
|
3302
3573
|
];
|
|
3303
|
-
function
|
|
3574
|
+
function on(e) {
|
|
3304
3575
|
return e === "pending_refund" ? { hasPendingRefund: !0 } : e === "all" ? {} : { status: e };
|
|
3305
3576
|
}
|
|
3306
|
-
function
|
|
3307
|
-
let { labels: e, locale: t, hrefs: n, renderLink: r } = F(), i = e.orders, [a, o] = b("paid"), [s, c] = b(""), l =
|
|
3308
|
-
...
|
|
3577
|
+
function sn() {
|
|
3578
|
+
let { labels: e, locale: t, hrefs: n, renderLink: r } = F(), i = e.orders, [a, o] = b("paid"), [s, c] = b(""), l = ke(s.trim(), 300), u = rn({
|
|
3579
|
+
...on(a),
|
|
3309
3580
|
...l ? { q: l } : {}
|
|
3310
3581
|
}), d = new Intl.DateTimeFormat(t), f = [
|
|
3311
3582
|
{
|
|
@@ -3313,7 +3584,7 @@ function qt() {
|
|
|
3313
3584
|
header: i.columns.order,
|
|
3314
3585
|
render: (e) => r({
|
|
3315
3586
|
href: n.order(e.id),
|
|
3316
|
-
children: e.id,
|
|
3587
|
+
children: T(e.id),
|
|
3317
3588
|
className: "sfa-link--tap"
|
|
3318
3589
|
})
|
|
3319
3590
|
},
|
|
@@ -3356,7 +3627,7 @@ function qt() {
|
|
|
3356
3627
|
role: "group",
|
|
3357
3628
|
"aria-label": i.columns.status,
|
|
3358
3629
|
className: "sfa-filter-group",
|
|
3359
|
-
children:
|
|
3630
|
+
children: an.map((e) => /* @__PURE__ */ C("button", {
|
|
3360
3631
|
type: "button",
|
|
3361
3632
|
className: "sfa-chip",
|
|
3362
3633
|
"aria-pressed": a === e,
|
|
@@ -3372,10 +3643,10 @@ function qt() {
|
|
|
3372
3643
|
})]
|
|
3373
3644
|
}),
|
|
3374
3645
|
/* @__PURE__ */ C(q, { error: u.error }),
|
|
3375
|
-
u.loading ? /* @__PURE__ */ C("p", { children: e.loading }) : u.items.length === 0 ? /* @__PURE__ */ C(
|
|
3646
|
+
u.loading ? /* @__PURE__ */ C("p", { children: e.loading }) : u.items.length === 0 ? /* @__PURE__ */ C(J, {
|
|
3376
3647
|
icon: l ? "search" : "orders",
|
|
3377
3648
|
title: l ? i.noMatches : i.empty[a],
|
|
3378
|
-
body: l
|
|
3649
|
+
body: !l && a === "all" ? i.emptyHint : void 0
|
|
3379
3650
|
}) : /* @__PURE__ */ C(H, {
|
|
3380
3651
|
columns: f,
|
|
3381
3652
|
rows: u.items,
|
|
@@ -3392,27 +3663,27 @@ function qt() {
|
|
|
3392
3663
|
});
|
|
3393
3664
|
}
|
|
3394
3665
|
// src/lib/refund-rules.ts
|
|
3395
|
-
function
|
|
3666
|
+
function cn(e) {
|
|
3396
3667
|
return e.refunds.filter((e) => e.status === "pending").reduce((e, t) => e + t.amountCents, 0);
|
|
3397
3668
|
}
|
|
3398
|
-
function
|
|
3399
|
-
return e.totalCents - e.refundedCents -
|
|
3669
|
+
function ln(e) {
|
|
3670
|
+
return e.totalCents - e.refundedCents - cn(e);
|
|
3400
3671
|
}
|
|
3401
|
-
function
|
|
3672
|
+
function un(e) {
|
|
3402
3673
|
return e.refunds.some((e) => e.status === "pending");
|
|
3403
3674
|
}
|
|
3404
|
-
function
|
|
3405
|
-
return e.status !== "needs_attention" && t !== null && t ===
|
|
3675
|
+
function dn(e, t) {
|
|
3676
|
+
return e.status !== "needs_attention" && t !== null && t === ln(e);
|
|
3406
3677
|
}
|
|
3407
|
-
function
|
|
3678
|
+
function fn(e) {
|
|
3408
3679
|
return e.status === "paid" || e.status === "shipped";
|
|
3409
3680
|
}
|
|
3410
|
-
function
|
|
3411
|
-
return (
|
|
3681
|
+
function pn(e) {
|
|
3682
|
+
return (fn(e) || e.status === "needs_attention") && ln(e) > 0;
|
|
3412
3683
|
}
|
|
3413
3684
|
// src/views/orders/refund-dialog.tsx
|
|
3414
|
-
function
|
|
3415
|
-
let
|
|
3685
|
+
function mn({ order: t, onClose: n, onDone: r }) {
|
|
3686
|
+
let i = I(), o = F().labels.orders.actions, s = y(crypto.randomUUID()), c = ln(t), [l, u] = b(Z(c)), [d, f] = b(""), [p, m] = b(!1), [h, g] = b(!1), _ = R(i.refundOrder), v = X(l), x = v !== null && v > 0 && v <= c, S = dn(t, v), T = _.error instanceof a || _.error instanceof e;
|
|
3416
3687
|
return /* @__PURE__ */ w(G, {
|
|
3417
3688
|
open: !0,
|
|
3418
3689
|
title: o.refundTitle,
|
|
@@ -3420,15 +3691,15 @@ function en({ order: e, onClose: t, onDone: n }) {
|
|
|
3420
3691
|
destructive: !0,
|
|
3421
3692
|
pending: _.pending,
|
|
3422
3693
|
onConfirm: async () => {
|
|
3423
|
-
x ? (g(!1), await _.run(
|
|
3694
|
+
x ? (g(!1), await _.run(t.id, {
|
|
3424
3695
|
amountCents: v,
|
|
3425
3696
|
reason: d.trim() || void 0,
|
|
3426
3697
|
restock: p && S
|
|
3427
|
-
}, { idempotencyKey: s.current }) &&
|
|
3698
|
+
}, { idempotencyKey: s.current }) && r(o.refundDone)) : g(!0);
|
|
3428
3699
|
},
|
|
3429
|
-
onCancel:
|
|
3700
|
+
onCancel: n,
|
|
3430
3701
|
children: [
|
|
3431
|
-
|
|
3702
|
+
un(t) ? /* @__PURE__ */ C(K, {
|
|
3432
3703
|
variant: "warning",
|
|
3433
3704
|
children: o.refundPending
|
|
3434
3705
|
}) : null,
|
|
@@ -3470,21 +3741,20 @@ function en({ order: e, onClose: t, onDone: n }) {
|
|
|
3470
3741
|
}),
|
|
3471
3742
|
S ? /* @__PURE__ */ w("div", {
|
|
3472
3743
|
className: "sfa-field",
|
|
3473
|
-
children: [/* @__PURE__ */ w("label", {
|
|
3474
|
-
|
|
3744
|
+
children: [/* @__PURE__ */ w("label", {
|
|
3745
|
+
className: "sfa-check",
|
|
3746
|
+
children: [/* @__PURE__ */ C("input", {
|
|
3475
3747
|
type: "checkbox",
|
|
3476
3748
|
checked: p,
|
|
3477
3749
|
disabled: T,
|
|
3478
3750
|
onChange: (e) => m(e.target.checked)
|
|
3479
|
-
}),
|
|
3480
|
-
|
|
3481
|
-
o.restock
|
|
3482
|
-
] }), /* @__PURE__ */ C("p", {
|
|
3751
|
+
}), o.restock]
|
|
3752
|
+
}), /* @__PURE__ */ C("p", {
|
|
3483
3753
|
className: "sfa-field__help",
|
|
3484
3754
|
children: o.restockWarning
|
|
3485
3755
|
})]
|
|
3486
3756
|
}) : null,
|
|
3487
|
-
_.error instanceof
|
|
3757
|
+
_.error instanceof e ? /* @__PURE__ */ C(K, {
|
|
3488
3758
|
variant: "warning",
|
|
3489
3759
|
children: o.refundUnknown
|
|
3490
3760
|
}) : _.error instanceof a ? /* @__PURE__ */ C(K, {
|
|
@@ -3495,34 +3765,35 @@ function en({ order: e, onClose: t, onDone: n }) {
|
|
|
3495
3765
|
});
|
|
3496
3766
|
}
|
|
3497
3767
|
// src/views/orders/resolve-button.tsx
|
|
3498
|
-
function
|
|
3499
|
-
let
|
|
3500
|
-
await
|
|
3501
|
-
},
|
|
3768
|
+
function hn({ order: e, onDone: t, notice: n }) {
|
|
3769
|
+
let r = I(), { labels: i, hrefs: a, renderLink: o } = F(), s = i.orders.actions, l = R(r.resolveOrder), u = async () => {
|
|
3770
|
+
await l.run(e.id) && t(s.resolved);
|
|
3771
|
+
}, d = l.error instanceof c ? l.error : null, f = new Map(e.items.map((e) => [e.productId, e.name]));
|
|
3502
3772
|
return /* @__PURE__ */ w("div", {
|
|
3503
3773
|
className: "sfa-order__action",
|
|
3504
3774
|
children: [
|
|
3505
|
-
/* @__PURE__ */ C("p", { children:
|
|
3506
|
-
|
|
3775
|
+
/* @__PURE__ */ C("p", { children: s.resolveHelp }),
|
|
3776
|
+
d ? /* @__PURE__ */ w(K, {
|
|
3507
3777
|
variant: "error",
|
|
3508
|
-
children: [
|
|
3509
|
-
href:
|
|
3510
|
-
children: `${
|
|
3778
|
+
children: [i.errors.insufficientStock, /* @__PURE__ */ C("ul", { children: d.productIds.map((e) => /* @__PURE__ */ C("li", { children: o({
|
|
3779
|
+
href: a.product(e),
|
|
3780
|
+
children: `${s.restockThenResolve}: ${f.get(e) ?? e}`,
|
|
3511
3781
|
className: "sfa-link--tap"
|
|
3512
3782
|
}) }, e)) })]
|
|
3513
|
-
}) : /* @__PURE__ */ C(q, { error:
|
|
3783
|
+
}) : /* @__PURE__ */ C(q, { error: l.error }),
|
|
3514
3784
|
/* @__PURE__ */ C("button", {
|
|
3515
3785
|
type: "button",
|
|
3516
3786
|
className: "sfa-btn sfa-btn--primary",
|
|
3517
|
-
disabled:
|
|
3518
|
-
onClick:
|
|
3519
|
-
children:
|
|
3520
|
-
})
|
|
3787
|
+
disabled: l.pending,
|
|
3788
|
+
onClick: u,
|
|
3789
|
+
children: s.resolve
|
|
3790
|
+
}),
|
|
3791
|
+
n
|
|
3521
3792
|
]
|
|
3522
3793
|
});
|
|
3523
3794
|
}
|
|
3524
3795
|
// src/views/orders/ship-form.tsx
|
|
3525
|
-
function
|
|
3796
|
+
function gn(e) {
|
|
3526
3797
|
try {
|
|
3527
3798
|
let { protocol: t } = new URL(e);
|
|
3528
3799
|
return t === "http:" || t === "https:";
|
|
@@ -3530,31 +3801,39 @@ function nn(e) {
|
|
|
3530
3801
|
return !1;
|
|
3531
3802
|
}
|
|
3532
3803
|
}
|
|
3533
|
-
function
|
|
3534
|
-
let
|
|
3804
|
+
function _n({ order: e, onDone: t, requireTracking: n = !0, notice: r }) {
|
|
3805
|
+
let i = I(), a = F().labels.orders.actions, o = e.fulfillment, [s, c] = b(o?.carrier ?? ""), [l, u] = b(o?.trackingNumber ?? ""), [d, f] = b(o?.trackingUrl ?? ""), [p, m] = b(!1), [h, g] = b(!1), _ = R(i.shipOrder), v = e.status === "shipped", y = async () => {
|
|
3806
|
+
let n = d.trim();
|
|
3807
|
+
n && !gn(n) ? m(!0) : (m(!1), await _.run(e.id, {
|
|
3808
|
+
carrier: s.trim() || void 0,
|
|
3809
|
+
trackingNumber: l.trim() || void 0,
|
|
3810
|
+
trackingUrl: n || void 0
|
|
3811
|
+
}) && t(a.shipped));
|
|
3812
|
+
};
|
|
3535
3813
|
return /* @__PURE__ */ w("form", {
|
|
3536
3814
|
className: "sfa-order__action",
|
|
3537
|
-
onSubmit: async (
|
|
3538
|
-
|
|
3539
|
-
let
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3815
|
+
onSubmit: async (e) => {
|
|
3816
|
+
e.preventDefault();
|
|
3817
|
+
let t = d.trim();
|
|
3818
|
+
if (t && !gn(t)) {
|
|
3819
|
+
m(!0);
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
let r = !s.trim() || !l.trim();
|
|
3823
|
+
g(n && r), !(n && r) && await y();
|
|
3545
3824
|
},
|
|
3546
3825
|
children: [
|
|
3547
|
-
/* @__PURE__ */ C("h3", { children:
|
|
3826
|
+
/* @__PURE__ */ C("h3", { children: a.shipHeading }),
|
|
3548
3827
|
/* @__PURE__ */ w("div", {
|
|
3549
3828
|
className: "sfa-field",
|
|
3550
3829
|
children: [/* @__PURE__ */ C("label", {
|
|
3551
3830
|
htmlFor: "sfa-ship-carrier",
|
|
3552
3831
|
className: "sfa-field__label",
|
|
3553
|
-
children:
|
|
3832
|
+
children: a.carrier
|
|
3554
3833
|
}), /* @__PURE__ */ C("input", {
|
|
3555
3834
|
id: "sfa-ship-carrier",
|
|
3556
|
-
value:
|
|
3557
|
-
onChange: (e) =>
|
|
3835
|
+
value: s,
|
|
3836
|
+
onChange: (e) => c(e.target.value)
|
|
3558
3837
|
})]
|
|
3559
3838
|
}),
|
|
3560
3839
|
/* @__PURE__ */ w("div", {
|
|
@@ -3562,11 +3841,11 @@ function rn({ order: e, onDone: t }) {
|
|
|
3562
3841
|
children: [/* @__PURE__ */ C("label", {
|
|
3563
3842
|
htmlFor: "sfa-ship-number",
|
|
3564
3843
|
className: "sfa-field__label",
|
|
3565
|
-
children:
|
|
3844
|
+
children: a.trackingNumber
|
|
3566
3845
|
}), /* @__PURE__ */ C("input", {
|
|
3567
3846
|
id: "sfa-ship-number",
|
|
3568
|
-
value:
|
|
3569
|
-
onChange: (e) =>
|
|
3847
|
+
value: l,
|
|
3848
|
+
onChange: (e) => u(e.target.value)
|
|
3570
3849
|
})]
|
|
3571
3850
|
}),
|
|
3572
3851
|
/* @__PURE__ */ w("div", {
|
|
@@ -3575,71 +3854,91 @@ function rn({ order: e, onDone: t }) {
|
|
|
3575
3854
|
/* @__PURE__ */ C("label", {
|
|
3576
3855
|
htmlFor: "sfa-ship-url",
|
|
3577
3856
|
className: "sfa-field__label",
|
|
3578
|
-
children:
|
|
3857
|
+
children: a.trackingUrl
|
|
3579
3858
|
}),
|
|
3580
3859
|
/* @__PURE__ */ C("input", {
|
|
3581
3860
|
id: "sfa-ship-url",
|
|
3582
|
-
value:
|
|
3583
|
-
"aria-invalid":
|
|
3584
|
-
"aria-describedby":
|
|
3585
|
-
onChange: (e) =>
|
|
3861
|
+
value: d,
|
|
3862
|
+
"aria-invalid": p,
|
|
3863
|
+
"aria-describedby": p ? "sfa-ship-url-error" : void 0,
|
|
3864
|
+
onChange: (e) => f(e.target.value)
|
|
3586
3865
|
}),
|
|
3587
|
-
|
|
3866
|
+
p ? /* @__PURE__ */ C("p", {
|
|
3588
3867
|
id: "sfa-ship-url-error",
|
|
3589
3868
|
className: "sfa-field__error",
|
|
3590
|
-
children:
|
|
3869
|
+
children: a.trackingUrlInvalid
|
|
3591
3870
|
}) : null
|
|
3592
3871
|
]
|
|
3593
3872
|
}),
|
|
3594
|
-
/* @__PURE__ */ C(
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3873
|
+
h ? /* @__PURE__ */ C(K, {
|
|
3874
|
+
variant: "error",
|
|
3875
|
+
children: a.trackingRequired
|
|
3876
|
+
}) : null,
|
|
3877
|
+
/* @__PURE__ */ w("div", {
|
|
3878
|
+
className: "sfa-order__buttons",
|
|
3879
|
+
children: [/* @__PURE__ */ C("button", {
|
|
3880
|
+
type: "submit",
|
|
3881
|
+
className: "sfa-btn sfa-btn--primary",
|
|
3882
|
+
disabled: _.pending,
|
|
3883
|
+
children: v ? a.reship : a.ship
|
|
3884
|
+
}), n ? /* @__PURE__ */ C("button", {
|
|
3885
|
+
type: "button",
|
|
3886
|
+
className: "sfa-btn",
|
|
3887
|
+
disabled: _.pending,
|
|
3888
|
+
onClick: () => (g(!1), y()),
|
|
3889
|
+
children: a.shipWithoutTracking
|
|
3890
|
+
}) : null]
|
|
3891
|
+
}),
|
|
3892
|
+
/* @__PURE__ */ C(q, { error: _.error }),
|
|
3893
|
+
r
|
|
3601
3894
|
]
|
|
3602
3895
|
});
|
|
3603
3896
|
}
|
|
3604
3897
|
// src/views/orders/order-actions.tsx
|
|
3605
|
-
function
|
|
3606
|
-
let
|
|
3607
|
-
|
|
3608
|
-
|
|
3898
|
+
function vn({ order: e, reload: t, requireTracking: n = !0 }) {
|
|
3899
|
+
let r = F().labels.orders.actions, [i, a] = b(!1), [o, s] = b(null), c = (e) => (n) => {
|
|
3900
|
+
a(!1), s({
|
|
3901
|
+
source: e,
|
|
3902
|
+
text: n
|
|
3903
|
+
}), t();
|
|
3904
|
+
}, l = (e) => o?.source === e ? /* @__PURE__ */ C(K, {
|
|
3905
|
+
variant: "success",
|
|
3906
|
+
onDismiss: () => s(null),
|
|
3907
|
+
children: o.text
|
|
3908
|
+
}) : null;
|
|
3609
3909
|
return /* @__PURE__ */ w("div", {
|
|
3610
3910
|
className: "sfa-order__actions",
|
|
3611
3911
|
children: [
|
|
3612
|
-
|
|
3613
|
-
variant: "success",
|
|
3614
|
-
onDismiss: () => o(null),
|
|
3615
|
-
children: a
|
|
3616
|
-
}) : null,
|
|
3617
|
-
Qt(e) ? /* @__PURE__ */ C(rn, {
|
|
3912
|
+
fn(e) ? /* @__PURE__ */ C(_n, {
|
|
3618
3913
|
order: e,
|
|
3619
|
-
|
|
3914
|
+
requireTracking: n,
|
|
3915
|
+
onDone: c("ship"),
|
|
3916
|
+
notice: l("ship")
|
|
3620
3917
|
}) : null,
|
|
3621
|
-
e.status === "needs_attention" ? /* @__PURE__ */ C(
|
|
3918
|
+
e.status === "needs_attention" ? /* @__PURE__ */ C(hn, {
|
|
3622
3919
|
order: e,
|
|
3623
|
-
onDone:
|
|
3920
|
+
onDone: c("resolve"),
|
|
3921
|
+
notice: l("resolve")
|
|
3624
3922
|
}) : null,
|
|
3625
|
-
|
|
3923
|
+
pn(e) ? /* @__PURE__ */ C("button", {
|
|
3626
3924
|
type: "button",
|
|
3627
|
-
className: "sfa-btn sfa-btn--danger",
|
|
3628
|
-
onClick: () =>
|
|
3629
|
-
children:
|
|
3925
|
+
className: "sfa-btn sfa-btn--quiet-danger sfa-order__refund-btn",
|
|
3926
|
+
onClick: () => a(!0),
|
|
3927
|
+
children: r.refund
|
|
3630
3928
|
}) : null,
|
|
3631
|
-
|
|
3929
|
+
l("refund"),
|
|
3930
|
+
i ? /* @__PURE__ */ C(mn, {
|
|
3632
3931
|
order: e,
|
|
3633
3932
|
onClose: () => {
|
|
3634
|
-
|
|
3933
|
+
a(!1), t();
|
|
3635
3934
|
},
|
|
3636
|
-
onDone:
|
|
3935
|
+
onDone: c("refund")
|
|
3637
3936
|
}) : null
|
|
3638
3937
|
]
|
|
3639
3938
|
});
|
|
3640
3939
|
}
|
|
3641
3940
|
// src/views/orders/order-fulfillment.tsx
|
|
3642
|
-
function
|
|
3941
|
+
function yn({ order: e }) {
|
|
3643
3942
|
let { labels: t, locale: n, renderLink: r } = F(), i = t.orders, a = e.fulfillment;
|
|
3644
3943
|
return /* @__PURE__ */ w("section", {
|
|
3645
3944
|
className: "sfa-order__section",
|
|
@@ -3651,13 +3950,13 @@ function on({ order: e }) {
|
|
|
3651
3950
|
a.trackingUrl ? /* @__PURE__ */ C("dd", { children: r({
|
|
3652
3951
|
href: a.trackingUrl,
|
|
3653
3952
|
children: i.trackShipment,
|
|
3654
|
-
className: "sfa-link--tap"
|
|
3953
|
+
className: "sfa-link--tap sfa-link--external"
|
|
3655
3954
|
}) }) : null
|
|
3656
3955
|
] }) : /* @__PURE__ */ C("p", { children: i.notShipped })]
|
|
3657
3956
|
});
|
|
3658
3957
|
}
|
|
3659
3958
|
// src/views/orders/order-items.tsx
|
|
3660
|
-
function
|
|
3959
|
+
function bn({ order: e }) {
|
|
3661
3960
|
let { labels: t } = F(), n = t.orders, { currency: r } = e, i = [
|
|
3662
3961
|
{
|
|
3663
3962
|
key: "name",
|
|
@@ -3712,6 +4011,10 @@ function sn({ order: e }) {
|
|
|
3712
4011
|
cents: e.shippingCents,
|
|
3713
4012
|
currency: r
|
|
3714
4013
|
}) }),
|
|
4014
|
+
e.taxCents > 0 ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("dt", { children: n.tax }), /* @__PURE__ */ C("dd", { children: /* @__PURE__ */ C(W, {
|
|
4015
|
+
cents: e.taxCents,
|
|
4016
|
+
currency: r
|
|
4017
|
+
}) })] }) : null,
|
|
3715
4018
|
/* @__PURE__ */ C("dt", { children: n.total }),
|
|
3716
4019
|
/* @__PURE__ */ C("dd", { children: /* @__PURE__ */ C(W, {
|
|
3717
4020
|
cents: e.totalCents,
|
|
@@ -3723,7 +4026,7 @@ function sn({ order: e }) {
|
|
|
3723
4026
|
});
|
|
3724
4027
|
}
|
|
3725
4028
|
// src/views/orders/order-refunds.tsx
|
|
3726
|
-
function
|
|
4029
|
+
function xn({ order: e }) {
|
|
3727
4030
|
let { labels: t, locale: n } = F(), r = t.orders, { currency: i } = e, a = new Intl.DateTimeFormat(n), o = [
|
|
3728
4031
|
{
|
|
3729
4032
|
key: "amount",
|
|
@@ -3787,7 +4090,7 @@ function cn({ order: e }) {
|
|
|
3787
4090
|
});
|
|
3788
4091
|
}
|
|
3789
4092
|
// src/views/orders/admin-order-detail.tsx
|
|
3790
|
-
function
|
|
4093
|
+
function Sn(e) {
|
|
3791
4094
|
let t = e.shippingAddress;
|
|
3792
4095
|
if (!t) return [];
|
|
3793
4096
|
let n = [
|
|
@@ -3803,81 +4106,94 @@ function ln(e) {
|
|
|
3803
4106
|
t.country
|
|
3804
4107
|
].filter((e) => !!e);
|
|
3805
4108
|
}
|
|
3806
|
-
function
|
|
3807
|
-
let
|
|
3808
|
-
if (
|
|
3809
|
-
let
|
|
3810
|
-
if (!
|
|
3811
|
-
let
|
|
4109
|
+
function Cn({ orderId: e, actions: t, requireTracking: n = !0 }) {
|
|
4110
|
+
let r = I(), { labels: i, locale: a, hrefs: o, renderLink: s } = F(), c = i.orders, l = L(["admin-order", e], () => r.getOrder(e));
|
|
4111
|
+
if (l.error) return /* @__PURE__ */ C(q, { error: l.error });
|
|
4112
|
+
let u = l.data;
|
|
4113
|
+
if (!u) return /* @__PURE__ */ C("p", { children: i.loading });
|
|
4114
|
+
let d = Sn(u);
|
|
3812
4115
|
return /* @__PURE__ */ w("article", {
|
|
3813
4116
|
className: "sfa-order",
|
|
3814
4117
|
children: [
|
|
3815
|
-
|
|
3816
|
-
href:
|
|
3817
|
-
children:
|
|
4118
|
+
s({
|
|
4119
|
+
href: o.orders,
|
|
4120
|
+
children: c.back,
|
|
3818
4121
|
className: "sfa-link--tap"
|
|
3819
4122
|
}),
|
|
3820
4123
|
/* @__PURE__ */ C(V, {
|
|
3821
|
-
title: `${
|
|
4124
|
+
title: `${c.detailTitle} ${T(u.id)}`,
|
|
3822
4125
|
children: /* @__PURE__ */ w("div", {
|
|
3823
4126
|
className: "sfa-order__header",
|
|
3824
4127
|
children: [
|
|
3825
|
-
/* @__PURE__ */ C(U, { status:
|
|
4128
|
+
/* @__PURE__ */ C(U, { status: u.status }),
|
|
3826
4129
|
/* @__PURE__ */ w("span", { children: [
|
|
3827
|
-
|
|
4130
|
+
c.placed,
|
|
3828
4131
|
" ",
|
|
3829
|
-
new Intl.DateTimeFormat(
|
|
4132
|
+
new Intl.DateTimeFormat(a).format(new Date(u.createdAt))
|
|
3830
4133
|
] }),
|
|
3831
4134
|
/* @__PURE__ */ C(W, {
|
|
3832
|
-
cents:
|
|
3833
|
-
currency:
|
|
4135
|
+
cents: u.totalCents,
|
|
4136
|
+
currency: u.currency
|
|
3834
4137
|
})
|
|
3835
4138
|
]
|
|
3836
4139
|
})
|
|
3837
4140
|
}),
|
|
3838
|
-
/* @__PURE__ */ w("
|
|
3839
|
-
className: "sfa-
|
|
3840
|
-
children: [/* @__PURE__ */
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
4141
|
+
/* @__PURE__ */ w("div", {
|
|
4142
|
+
className: "sfa-order__columns",
|
|
4143
|
+
children: [/* @__PURE__ */ w("div", {
|
|
4144
|
+
className: "sfa-order__main",
|
|
4145
|
+
children: [
|
|
4146
|
+
/* @__PURE__ */ w("section", {
|
|
4147
|
+
className: "sfa-order__section",
|
|
4148
|
+
children: [/* @__PURE__ */ C("h2", { children: c.buyer }), /* @__PURE__ */ C("p", { children: u.email ?? i.orders.noEmail })]
|
|
4149
|
+
}),
|
|
4150
|
+
/* @__PURE__ */ C(bn, { order: u }),
|
|
4151
|
+
/* @__PURE__ */ w("section", {
|
|
4152
|
+
className: "sfa-order__section",
|
|
4153
|
+
children: [/* @__PURE__ */ C("h2", { children: c.shippingAddress }), d.length === 0 ? /* @__PURE__ */ C("p", { children: c.noAddress }) : /* @__PURE__ */ C("address", {
|
|
4154
|
+
className: "sfa-order__address",
|
|
4155
|
+
children: d.map((e) => /* @__PURE__ */ C("div", { children: e }, e))
|
|
4156
|
+
})]
|
|
4157
|
+
})
|
|
4158
|
+
]
|
|
4159
|
+
}), /* @__PURE__ */ w("div", {
|
|
4160
|
+
className: "sfa-order__side",
|
|
4161
|
+
children: [
|
|
4162
|
+
/* @__PURE__ */ C(yn, { order: u }),
|
|
4163
|
+
/* @__PURE__ */ C(xn, { order: u }),
|
|
4164
|
+
/* @__PURE__ */ C("section", {
|
|
4165
|
+
className: "sfa-order__section",
|
|
4166
|
+
children: t ? t({
|
|
4167
|
+
order: u,
|
|
4168
|
+
reload: l.reload
|
|
4169
|
+
}) : /* @__PURE__ */ C(vn, {
|
|
4170
|
+
order: u,
|
|
4171
|
+
reload: l.reload,
|
|
4172
|
+
requireTracking: n
|
|
4173
|
+
})
|
|
4174
|
+
})
|
|
4175
|
+
]
|
|
3848
4176
|
})]
|
|
3849
|
-
}),
|
|
3850
|
-
/* @__PURE__ */ C(on, { order: l }),
|
|
3851
|
-
/* @__PURE__ */ C(cn, { order: l }),
|
|
3852
|
-
/* @__PURE__ */ C("section", {
|
|
3853
|
-
className: "sfa-order__section",
|
|
3854
|
-
children: t ? t({
|
|
3855
|
-
order: l,
|
|
3856
|
-
reload: c.reload
|
|
3857
|
-
}) : /* @__PURE__ */ C(an, {
|
|
3858
|
-
order: l,
|
|
3859
|
-
reload: c.reload
|
|
3860
|
-
})
|
|
3861
4177
|
})
|
|
3862
4178
|
]
|
|
3863
4179
|
});
|
|
3864
4180
|
}
|
|
3865
4181
|
// src/lib/shipping-rates.ts
|
|
3866
|
-
var
|
|
3867
|
-
function
|
|
4182
|
+
var wn = 0, Tn = () => `rate-${++wn}`;
|
|
4183
|
+
function En(e) {
|
|
3868
4184
|
return [...e].sort((e, t) => e.sort - t.sort).map((e) => ({
|
|
3869
|
-
key:
|
|
4185
|
+
key: Tn(),
|
|
3870
4186
|
label: e.label,
|
|
3871
|
-
amount:
|
|
4187
|
+
amount: Z(e.amountCents),
|
|
3872
4188
|
currency: e.currency,
|
|
3873
4189
|
minDays: e.minDays == null ? "" : String(e.minDays),
|
|
3874
4190
|
maxDays: e.maxDays == null ? "" : String(e.maxDays),
|
|
3875
4191
|
active: e.active
|
|
3876
4192
|
}));
|
|
3877
4193
|
}
|
|
3878
|
-
function
|
|
4194
|
+
function Dn(e, t) {
|
|
3879
4195
|
return {
|
|
3880
|
-
key:
|
|
4196
|
+
key: Tn(),
|
|
3881
4197
|
label: t,
|
|
3882
4198
|
amount: "",
|
|
3883
4199
|
currency: e,
|
|
@@ -3886,18 +4202,18 @@ function mn(e, t) {
|
|
|
3886
4202
|
active: !0
|
|
3887
4203
|
};
|
|
3888
4204
|
}
|
|
3889
|
-
var
|
|
3890
|
-
function
|
|
4205
|
+
var On = (e) => JSON.stringify(e.map(({ key: e, ...t }) => t));
|
|
4206
|
+
function kn(e) {
|
|
3891
4207
|
let t = e.trim();
|
|
3892
4208
|
return t === "" ? null : /^\d+$/.test(t) ? Number(t) : void 0;
|
|
3893
4209
|
}
|
|
3894
|
-
function
|
|
4210
|
+
function An(e, t) {
|
|
3895
4211
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
3896
4212
|
if (e.forEach((e) => {
|
|
3897
4213
|
let t = e.label.trim();
|
|
3898
4214
|
i.set(t, (i.get(t) ?? 0) + 1);
|
|
3899
4215
|
}), e.forEach((e, a) => {
|
|
3900
|
-
let o = {}, s = e.label.trim(), c =
|
|
4216
|
+
let o = {}, s = e.label.trim(), c = X(e.amount), l = kn(e.minDays), u = kn(e.maxDays);
|
|
3901
4217
|
s === "" ? o.label = t.labelRequired : (i.get(s) ?? 0) > 1 && (o.label = t.labelDuplicate), /^[A-Z]{3}$/.test(e.currency) || (o.currency = t.currencyInvalid), c === null && (o.amount = t.amountInvalid), l === void 0 && (o.minDays = t.daysInvalid), u === void 0 && (o.maxDays = t.daysInvalid), typeof l == "number" && typeof u == "number" && l > u && (o.minDays = t.daysOrder), Object.keys(o).length > 0 && (n[e.key] = o), r.push({
|
|
3902
4218
|
label: s,
|
|
3903
4219
|
amountCents: c ?? 0,
|
|
@@ -3908,7 +4224,7 @@ function _n(e, t) {
|
|
|
3908
4224
|
sort: a
|
|
3909
4225
|
});
|
|
3910
4226
|
}), Object.keys(n).length === 0) {
|
|
3911
|
-
let i =
|
|
4227
|
+
let i = E.safeParse(r);
|
|
3912
4228
|
if (!i.success) for (let r of i.error.issues) {
|
|
3913
4229
|
let i = typeof r.path[0] == "number" ? e[r.path[0]]?.key : void 0;
|
|
3914
4230
|
i && (n[i] = { row: t.rowInvalid });
|
|
@@ -3922,19 +4238,19 @@ function _n(e, t) {
|
|
|
3922
4238
|
valid: Object.keys(n).length === 0 && !a
|
|
3923
4239
|
};
|
|
3924
4240
|
}
|
|
3925
|
-
var
|
|
4241
|
+
var jn = {
|
|
3926
4242
|
label: "label",
|
|
3927
4243
|
amountCents: "amount",
|
|
3928
4244
|
currency: "currency",
|
|
3929
4245
|
minDays: "minDays",
|
|
3930
4246
|
maxDays: "maxDays"
|
|
3931
4247
|
};
|
|
3932
|
-
function
|
|
4248
|
+
function Mn(e, t, n) {
|
|
3933
4249
|
let r = {};
|
|
3934
4250
|
for (let i of e) {
|
|
3935
4251
|
let e = i?.path ?? [], a = e.findIndex((e) => typeof e == "number"), o = a >= 0 ? t[e[a]]?.key : void 0;
|
|
3936
4252
|
if (!o) continue;
|
|
3937
|
-
let s = e[e.length - 1], c = e.length - 1 > a && typeof s == "string" ?
|
|
4253
|
+
let s = e[e.length - 1], c = e.length - 1 > a && typeof s == "string" ? jn[s] : void 0;
|
|
3938
4254
|
r[o] = {
|
|
3939
4255
|
...r[o],
|
|
3940
4256
|
[c ?? "row"]: n.rowInvalid
|
|
@@ -3942,31 +4258,50 @@ function yn(e, t, n) {
|
|
|
3942
4258
|
}
|
|
3943
4259
|
return r;
|
|
3944
4260
|
}
|
|
4261
|
+
// src/lib/currency-symbol.ts
|
|
4262
|
+
function Nn(e, t) {
|
|
4263
|
+
try {
|
|
4264
|
+
return new Intl.NumberFormat(t, {
|
|
4265
|
+
style: "currency",
|
|
4266
|
+
currency: e,
|
|
4267
|
+
currencyDisplay: "narrowSymbol"
|
|
4268
|
+
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? e;
|
|
4269
|
+
} catch {
|
|
4270
|
+
return e;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
3945
4273
|
// src/views/shipping/shipping-rate-row.tsx
|
|
3946
|
-
function
|
|
3947
|
-
let
|
|
3948
|
-
let
|
|
4274
|
+
function Pn({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, locale: o, onChange: s, onMove: c, onRemove: l }) {
|
|
4275
|
+
let u = e.label.trim() || jt(a.rowName, { n: String(t + 1) }), d = Nn(e.currency, o), f = (t, n, a, o, c, l) => {
|
|
4276
|
+
let u = r[o], d = `${e.key}-${t}`, f = /* @__PURE__ */ C("input", {
|
|
4277
|
+
id: d,
|
|
4278
|
+
value: a,
|
|
4279
|
+
inputMode: c,
|
|
4280
|
+
disabled: i,
|
|
4281
|
+
"aria-invalid": !!u,
|
|
4282
|
+
"aria-describedby": u ? `${d}-error` : void 0,
|
|
4283
|
+
onChange: (e) => s({ [o]: e.target.value })
|
|
4284
|
+
});
|
|
3949
4285
|
return /* @__PURE__ */ w("div", {
|
|
3950
4286
|
className: "sfa-field",
|
|
3951
4287
|
children: [
|
|
3952
4288
|
/* @__PURE__ */ C("label", {
|
|
3953
4289
|
className: "sfa-field__label",
|
|
3954
|
-
htmlFor:
|
|
4290
|
+
htmlFor: d,
|
|
3955
4291
|
children: n
|
|
3956
4292
|
}),
|
|
3957
|
-
/* @__PURE__ */
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
id: `${u}-error`,
|
|
4293
|
+
l ? /* @__PURE__ */ w("div", {
|
|
4294
|
+
className: "sfa-rate__money",
|
|
4295
|
+
children: [/* @__PURE__ */ C("span", {
|
|
4296
|
+
className: "sfa-rate__prefix",
|
|
4297
|
+
"aria-hidden": "true",
|
|
4298
|
+
children: l
|
|
4299
|
+
}), f]
|
|
4300
|
+
}) : f,
|
|
4301
|
+
u ? /* @__PURE__ */ C("p", {
|
|
4302
|
+
id: `${d}-error`,
|
|
3968
4303
|
className: "sfa-field__error",
|
|
3969
|
-
children:
|
|
4304
|
+
children: u
|
|
3970
4305
|
}) : null
|
|
3971
4306
|
]
|
|
3972
4307
|
});
|
|
@@ -3975,35 +4310,21 @@ function bn({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
|
|
|
3975
4310
|
className: "sfa-rate",
|
|
3976
4311
|
"data-rate-key": e.key,
|
|
3977
4312
|
children: [
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
/* @__PURE__ */
|
|
3981
|
-
className: "sfa-
|
|
3982
|
-
children:
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
}),
|
|
3987
|
-
/* @__PURE__ */ C("span", {
|
|
3988
|
-
className: "sfa-rate__currency",
|
|
3989
|
-
"aria-invalid": !!r.currency,
|
|
3990
|
-
children: e.currency
|
|
3991
|
-
}),
|
|
3992
|
-
r.currency ? /* @__PURE__ */ C("p", {
|
|
3993
|
-
className: "sfa-field__error",
|
|
3994
|
-
children: r.currency
|
|
3995
|
-
}) : null
|
|
3996
|
-
]
|
|
3997
|
-
}),
|
|
3998
|
-
u("min", a.minDays, e.minDays, "minDays", "numeric"),
|
|
3999
|
-
u("max", a.maxDays, e.maxDays, "maxDays", "numeric"),
|
|
4313
|
+
f("label", a.label, e.label, "label"),
|
|
4314
|
+
f("amount", a.amount, e.amount, "amount", "decimal", d),
|
|
4315
|
+
r.currency ? /* @__PURE__ */ C("p", {
|
|
4316
|
+
className: "sfa-field__error",
|
|
4317
|
+
children: r.currency
|
|
4318
|
+
}) : null,
|
|
4319
|
+
f("min", a.minDays, e.minDays, "minDays", "numeric"),
|
|
4320
|
+
f("max", a.maxDays, e.maxDays, "maxDays", "numeric"),
|
|
4000
4321
|
/* @__PURE__ */ w("label", {
|
|
4001
4322
|
className: "sfa-rate__active",
|
|
4002
4323
|
children: [/* @__PURE__ */ C("input", {
|
|
4003
4324
|
type: "checkbox",
|
|
4004
4325
|
checked: e.active,
|
|
4005
4326
|
disabled: i,
|
|
4006
|
-
onChange: (e) =>
|
|
4327
|
+
onChange: (e) => s({ active: e.target.checked })
|
|
4007
4328
|
}), a.active]
|
|
4008
4329
|
}),
|
|
4009
4330
|
r.row ? /* @__PURE__ */ C("p", {
|
|
@@ -4015,27 +4336,39 @@ function bn({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
|
|
|
4015
4336
|
children: [
|
|
4016
4337
|
/* @__PURE__ */ C("button", {
|
|
4017
4338
|
type: "button",
|
|
4018
|
-
className: "sfa-btn",
|
|
4019
|
-
"aria-label": `${a.moveEarlier}: ${
|
|
4339
|
+
className: "sfa-btn sfa-btn--icon",
|
|
4340
|
+
"aria-label": `${a.moveEarlier}: ${u}`,
|
|
4341
|
+
title: a.moveEarlier,
|
|
4020
4342
|
disabled: i || t === 0,
|
|
4021
|
-
onClick: () =>
|
|
4022
|
-
children:
|
|
4343
|
+
onClick: () => c("earlier"),
|
|
4344
|
+
children: /* @__PURE__ */ C("span", {
|
|
4345
|
+
"aria-hidden": "true",
|
|
4346
|
+
children: "↑"
|
|
4347
|
+
})
|
|
4023
4348
|
}),
|
|
4024
4349
|
/* @__PURE__ */ C("button", {
|
|
4025
4350
|
type: "button",
|
|
4026
|
-
className: "sfa-btn",
|
|
4027
|
-
"aria-label": `${a.moveLater}: ${
|
|
4351
|
+
className: "sfa-btn sfa-btn--icon",
|
|
4352
|
+
"aria-label": `${a.moveLater}: ${u}`,
|
|
4353
|
+
title: a.moveLater,
|
|
4028
4354
|
disabled: i || t === n - 1,
|
|
4029
|
-
onClick: () =>
|
|
4030
|
-
children:
|
|
4355
|
+
onClick: () => c("later"),
|
|
4356
|
+
children: /* @__PURE__ */ C("span", {
|
|
4357
|
+
"aria-hidden": "true",
|
|
4358
|
+
children: "↓"
|
|
4359
|
+
})
|
|
4031
4360
|
}),
|
|
4032
4361
|
/* @__PURE__ */ C("button", {
|
|
4033
4362
|
type: "button",
|
|
4034
|
-
className: "sfa-btn sfa-btn--danger",
|
|
4035
|
-
"aria-label": `${a.remove}: ${
|
|
4363
|
+
className: "sfa-btn sfa-btn--icon sfa-btn--quiet-danger",
|
|
4364
|
+
"aria-label": `${a.remove}: ${u}`,
|
|
4365
|
+
title: a.remove,
|
|
4036
4366
|
disabled: i,
|
|
4037
|
-
onClick:
|
|
4038
|
-
children:
|
|
4367
|
+
onClick: l,
|
|
4368
|
+
children: /* @__PURE__ */ C("span", {
|
|
4369
|
+
"aria-hidden": "true",
|
|
4370
|
+
children: "✕"
|
|
4371
|
+
})
|
|
4039
4372
|
})
|
|
4040
4373
|
]
|
|
4041
4374
|
})
|
|
@@ -4043,164 +4376,175 @@ function bn({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
|
|
|
4043
4376
|
});
|
|
4044
4377
|
}
|
|
4045
4378
|
// src/views/shipping/admin-shipping-rates.tsx
|
|
4046
|
-
function
|
|
4047
|
-
let n = I(), { labels: r, currency: i } = F(),
|
|
4048
|
-
if (
|
|
4049
|
-
let e =
|
|
4050
|
-
|
|
4379
|
+
function Fn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
4380
|
+
let n = I(), { labels: r, currency: i, locale: a } = F(), o = r.shipping, s = L(["shipping-rates"], () => n.listShippingRates()), [c, l] = b([]), [u, f] = b("[]"), [p, m] = b(void 0), [h, g] = b(null), [v, x] = b({}), [S, T] = b(!1), [E, D] = b(!1), [O, k] = b(!1), A = R((e) => n.replaceShippingRates(e)), j = y(void 0), M = y(null);
|
|
4381
|
+
if (s.data && s.data !== p) {
|
|
4382
|
+
let e = En(s.data);
|
|
4383
|
+
m(s.data), l(e), f(On(e));
|
|
4051
4384
|
}
|
|
4052
|
-
let
|
|
4385
|
+
let N = p !== void 0 && On(c) !== u;
|
|
4053
4386
|
_(() => {
|
|
4054
|
-
|
|
4055
|
-
}, [
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4387
|
+
j.current !== N && (j.current = N, e?.(N));
|
|
4388
|
+
}, [N, e]), _(() => {
|
|
4389
|
+
if (Object.keys(v).length === 0) return;
|
|
4390
|
+
let e = M.current?.querySelector("[aria-invalid=\"true\"]");
|
|
4391
|
+
e && "scrollIntoView" in e && e.scrollIntoView({ block: "center" });
|
|
4392
|
+
}, [v]);
|
|
4393
|
+
let P = (e) => {
|
|
4394
|
+
l(e), D(!1), T(!1);
|
|
4395
|
+
}, ee = (e, t) => {
|
|
4396
|
+
P(c.map((n) => n.key === e ? {
|
|
4060
4397
|
...n,
|
|
4061
4398
|
...t
|
|
4062
|
-
} : n)),
|
|
4063
|
-
},
|
|
4399
|
+
} : n)), x(({ [e]: t, ...n }) => n);
|
|
4400
|
+
}, te = (e, t) => {
|
|
4064
4401
|
let n = t === "earlier" ? e - 1 : e + 1;
|
|
4065
|
-
if (n < 0 || n >=
|
|
4066
|
-
let r = [...
|
|
4067
|
-
[r[e], r[n]] = [r[n], r[e]],
|
|
4068
|
-
},
|
|
4069
|
-
...
|
|
4070
|
-
amount:
|
|
4071
|
-
}]),
|
|
4072
|
-
|
|
4073
|
-
},
|
|
4074
|
-
let e =
|
|
4075
|
-
if (
|
|
4076
|
-
let t = await
|
|
4402
|
+
if (n < 0 || n >= c.length) return;
|
|
4403
|
+
let r = [...c];
|
|
4404
|
+
[r[e], r[n]] = [r[n], r[e]], P(r);
|
|
4405
|
+
}, ne = () => P([...c, Dn(i, o.newRateLabel)]), re = (e) => P([...c, {
|
|
4406
|
+
...Dn(i, e.label),
|
|
4407
|
+
amount: Z(e.amountCents)
|
|
4408
|
+
}]), ie = () => {
|
|
4409
|
+
h && (P(c.filter((e) => e.key !== h.key)), k(!0), g(null));
|
|
4410
|
+
}, ae = async () => {
|
|
4411
|
+
let e = An(c, o);
|
|
4412
|
+
if (x(e.rowErrors), T(e.noActive), !e.valid) return;
|
|
4413
|
+
let t = await A.run(e.rates);
|
|
4077
4414
|
if (!t) return;
|
|
4078
|
-
let n =
|
|
4079
|
-
|
|
4080
|
-
},
|
|
4081
|
-
return
|
|
4415
|
+
let n = En(t);
|
|
4416
|
+
l(n), f(On(n)), x({}), k(!1), D(!0);
|
|
4417
|
+
}, oe = c.some((e) => e.currency !== i), z = A.error instanceof d ? Mn(A.error.issues, c, o) : {};
|
|
4418
|
+
return s.loading && !s.data ? /* @__PURE__ */ C("p", {
|
|
4082
4419
|
role: "status",
|
|
4083
|
-
children:
|
|
4084
|
-
}) :
|
|
4420
|
+
children: o.loading
|
|
4421
|
+
}) : s.data ? /* @__PURE__ */ w("div", {
|
|
4085
4422
|
className: "sfa-shipping",
|
|
4423
|
+
ref: M,
|
|
4086
4424
|
children: [
|
|
4087
|
-
/* @__PURE__ */ C(V, { title:
|
|
4088
|
-
|
|
4425
|
+
/* @__PURE__ */ C(V, { title: o.title }),
|
|
4426
|
+
O ? /* @__PURE__ */ C(K, {
|
|
4089
4427
|
variant: "warning",
|
|
4090
|
-
children:
|
|
4428
|
+
children: o.removalWarning
|
|
4091
4429
|
}) : null,
|
|
4092
|
-
|
|
4430
|
+
oe ? /* @__PURE__ */ C(K, {
|
|
4093
4431
|
variant: "warning",
|
|
4094
|
-
children:
|
|
4095
|
-
}) : null,
|
|
4096
|
-
x ? /* @__PURE__ */ C(K, {
|
|
4097
|
-
variant: "error",
|
|
4098
|
-
children: a.noActive
|
|
4432
|
+
children: jt(o.mixedCurrency, { currency: i })
|
|
4099
4433
|
}) : null,
|
|
4100
|
-
/* @__PURE__ */ C(
|
|
4101
|
-
T ? /* @__PURE__ */ C(K, {
|
|
4102
|
-
variant: "success",
|
|
4103
|
-
children: a.saved
|
|
4104
|
-
}) : null,
|
|
4105
|
-
j ? /* @__PURE__ */ C("p", {
|
|
4434
|
+
N ? /* @__PURE__ */ C("p", {
|
|
4106
4435
|
className: "sfa-field__help",
|
|
4107
|
-
children:
|
|
4436
|
+
children: o.unsaved
|
|
4108
4437
|
}) : null,
|
|
4109
|
-
|
|
4438
|
+
c.length === 0 ? /* @__PURE__ */ C(J, {
|
|
4110
4439
|
icon: "shipping",
|
|
4111
|
-
title:
|
|
4112
|
-
body:
|
|
4440
|
+
title: o.emptyTitle,
|
|
4441
|
+
body: o.empty,
|
|
4113
4442
|
action: /* @__PURE__ */ C("button", {
|
|
4114
4443
|
type: "button",
|
|
4115
4444
|
className: "sfa-btn sfa-btn--primary",
|
|
4116
|
-
onClick:
|
|
4117
|
-
children:
|
|
4445
|
+
onClick: ne,
|
|
4446
|
+
children: o.addOption
|
|
4118
4447
|
}),
|
|
4119
4448
|
children: t.length ? /* @__PURE__ */ C("ul", {
|
|
4120
4449
|
className: "sfa-empty-state__chips",
|
|
4121
4450
|
children: t.map((e) => /* @__PURE__ */ C("li", { children: /* @__PURE__ */ C("button", {
|
|
4122
4451
|
type: "button",
|
|
4123
4452
|
className: "sfa-chip",
|
|
4124
|
-
onClick: () =>
|
|
4453
|
+
onClick: () => re(e),
|
|
4125
4454
|
children: e.label
|
|
4126
4455
|
}) }, e.label))
|
|
4127
4456
|
}) : null
|
|
4128
4457
|
}) : null,
|
|
4129
4458
|
/* @__PURE__ */ C("ul", {
|
|
4130
4459
|
className: "sfa-rates",
|
|
4131
|
-
children:
|
|
4460
|
+
children: c.map((e, t) => /* @__PURE__ */ C(Pn, {
|
|
4132
4461
|
draft: e,
|
|
4133
4462
|
index: t,
|
|
4134
|
-
total:
|
|
4463
|
+
total: c.length,
|
|
4135
4464
|
errors: {
|
|
4136
|
-
...
|
|
4137
|
-
...
|
|
4465
|
+
...z[e.key],
|
|
4466
|
+
...v[e.key]
|
|
4138
4467
|
},
|
|
4139
|
-
disabled:
|
|
4140
|
-
labels:
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4468
|
+
disabled: A.pending,
|
|
4469
|
+
labels: o,
|
|
4470
|
+
locale: a,
|
|
4471
|
+
onChange: (t) => ee(e.key, t),
|
|
4472
|
+
onMove: (e) => te(t, e),
|
|
4473
|
+
onRemove: () => g(e)
|
|
4144
4474
|
}, e.key))
|
|
4145
4475
|
}),
|
|
4146
4476
|
/* @__PURE__ */ w("div", {
|
|
4147
4477
|
className: "sfa-shipping__actions",
|
|
4148
|
-
children: [
|
|
4478
|
+
children: [c.length > 0 ? /* @__PURE__ */ C("button", {
|
|
4149
4479
|
type: "button",
|
|
4150
4480
|
className: "sfa-btn",
|
|
4151
|
-
onClick:
|
|
4152
|
-
children:
|
|
4481
|
+
onClick: ne,
|
|
4482
|
+
children: o.add
|
|
4153
4483
|
}) : null, /* @__PURE__ */ C("button", {
|
|
4154
4484
|
type: "button",
|
|
4155
4485
|
className: "sfa-btn sfa-btn--primary",
|
|
4156
|
-
disabled:
|
|
4157
|
-
onClick:
|
|
4158
|
-
children:
|
|
4486
|
+
disabled: A.pending,
|
|
4487
|
+
onClick: ae,
|
|
4488
|
+
children: o.save
|
|
4159
4489
|
})]
|
|
4160
4490
|
}),
|
|
4491
|
+
/* @__PURE__ */ w("div", {
|
|
4492
|
+
className: "sfa-shipping__feedback",
|
|
4493
|
+
children: [
|
|
4494
|
+
S ? /* @__PURE__ */ C(K, {
|
|
4495
|
+
variant: "error",
|
|
4496
|
+
children: o.noActive
|
|
4497
|
+
}) : null,
|
|
4498
|
+
/* @__PURE__ */ C(q, { error: A.error }),
|
|
4499
|
+
E ? /* @__PURE__ */ C(K, {
|
|
4500
|
+
variant: "success",
|
|
4501
|
+
children: o.saved
|
|
4502
|
+
}) : null
|
|
4503
|
+
]
|
|
4504
|
+
}),
|
|
4161
4505
|
/* @__PURE__ */ C(G, {
|
|
4162
|
-
open:
|
|
4163
|
-
title:
|
|
4506
|
+
open: h !== null,
|
|
4507
|
+
title: o.removeTitle,
|
|
4164
4508
|
destructive: !0,
|
|
4165
|
-
confirmLabel:
|
|
4166
|
-
onConfirm:
|
|
4167
|
-
onCancel: () =>
|
|
4168
|
-
children: /* @__PURE__ */ C("p", { children:
|
|
4509
|
+
confirmLabel: o.remove,
|
|
4510
|
+
onConfirm: ie,
|
|
4511
|
+
onCancel: () => g(null),
|
|
4512
|
+
children: /* @__PURE__ */ C("p", { children: o.removeBody })
|
|
4169
4513
|
})
|
|
4170
4514
|
]
|
|
4171
|
-
}) : /* @__PURE__ */ C(q, { error:
|
|
4515
|
+
}) : /* @__PURE__ */ C(q, { error: s.error });
|
|
4172
4516
|
}
|
|
4173
4517
|
// src/lib/discount-status.ts
|
|
4174
|
-
function
|
|
4518
|
+
function In(e, t = /* @__PURE__ */ new Date()) {
|
|
4175
4519
|
return e.active ? e.startsAt && new Date(e.startsAt) > t ? "scheduled" : e.endsAt && new Date(e.endsAt) <= t ? "expired" : "active" : "inactive";
|
|
4176
4520
|
}
|
|
4177
|
-
function
|
|
4521
|
+
function Ln(e, t) {
|
|
4178
4522
|
return e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e);
|
|
4179
4523
|
}
|
|
4180
4524
|
// src/lib/use-discount-pages.ts
|
|
4181
|
-
function
|
|
4525
|
+
function Rn(e) {
|
|
4182
4526
|
let t = I();
|
|
4183
|
-
return
|
|
4527
|
+
return Ae(["admin-discounts", e], (n) => t.listDiscounts(n ? {
|
|
4184
4528
|
...e,
|
|
4185
4529
|
cursor: n
|
|
4186
4530
|
} : e));
|
|
4187
4531
|
}
|
|
4188
4532
|
// src/views/discounts/discount-value.tsx
|
|
4189
|
-
function
|
|
4533
|
+
function zn({ discount: e }) {
|
|
4190
4534
|
return e.type === "percent" ? /* @__PURE__ */ w("span", { children: [e.percentOff, "%"] }) : /* @__PURE__ */ C(W, {
|
|
4191
4535
|
cents: e.amountOffCents ?? 0,
|
|
4192
4536
|
currency: e.currency ?? "USD"
|
|
4193
4537
|
});
|
|
4194
4538
|
}
|
|
4195
4539
|
// src/views/discounts/admin-discount-list.tsx
|
|
4196
|
-
var
|
|
4540
|
+
var Bn = [
|
|
4197
4541
|
"active",
|
|
4198
4542
|
"scheduled",
|
|
4199
4543
|
"expired",
|
|
4200
4544
|
"inactive"
|
|
4201
4545
|
];
|
|
4202
|
-
function
|
|
4203
|
-
let { labels: e, hrefs: t, renderLink: n } = F(), r = e.discounts, [i, a] = b("active"), [o, s] = b(""), c =
|
|
4546
|
+
function Vn() {
|
|
4547
|
+
let { labels: e, hrefs: t, renderLink: n } = F(), r = e.discounts, [i, a] = b("active"), [o, s] = b(""), c = ke(o.trim(), 300), l = Rn({
|
|
4204
4548
|
status: i,
|
|
4205
4549
|
...c ? { q: c } : {}
|
|
4206
4550
|
}), u = [
|
|
@@ -4216,22 +4560,22 @@ function Dn() {
|
|
|
4216
4560
|
{
|
|
4217
4561
|
key: "value",
|
|
4218
4562
|
header: r.columns.value,
|
|
4219
|
-
render: (e) => /* @__PURE__ */ C(
|
|
4563
|
+
render: (e) => /* @__PURE__ */ C(zn, { discount: e })
|
|
4220
4564
|
},
|
|
4221
4565
|
{
|
|
4222
4566
|
key: "status",
|
|
4223
4567
|
header: r.columns.status,
|
|
4224
|
-
render: (e) => /* @__PURE__ */ C(U, { status:
|
|
4568
|
+
render: (e) => /* @__PURE__ */ C(U, { status: In(e) })
|
|
4225
4569
|
},
|
|
4226
4570
|
{
|
|
4227
4571
|
key: "usage",
|
|
4228
4572
|
header: r.columns.usage,
|
|
4229
4573
|
render: (e) => {
|
|
4230
4574
|
let t = e.redeemedCount + e.reservedCount;
|
|
4231
|
-
return e.maxRedemptions ?
|
|
4575
|
+
return e.maxRedemptions ? Ln(r.usage, {
|
|
4232
4576
|
used: t,
|
|
4233
4577
|
max: e.maxRedemptions
|
|
4234
|
-
}) :
|
|
4578
|
+
}) : Ln(r.usageUnlimited, { used: t });
|
|
4235
4579
|
}
|
|
4236
4580
|
}
|
|
4237
4581
|
];
|
|
@@ -4252,7 +4596,7 @@ function Dn() {
|
|
|
4252
4596
|
role: "group",
|
|
4253
4597
|
"aria-label": r.columns.status,
|
|
4254
4598
|
className: "sfa-filter-group",
|
|
4255
|
-
children:
|
|
4599
|
+
children: Bn.map((e) => /* @__PURE__ */ C("button", {
|
|
4256
4600
|
type: "button",
|
|
4257
4601
|
className: "sfa-chip",
|
|
4258
4602
|
"aria-pressed": i === e,
|
|
@@ -4268,7 +4612,7 @@ function Dn() {
|
|
|
4268
4612
|
})]
|
|
4269
4613
|
}),
|
|
4270
4614
|
/* @__PURE__ */ C(q, { error: l.error }),
|
|
4271
|
-
l.loading && !l.loaded ? /* @__PURE__ */ C("p", { children: e.loading }) : l.items.length === 0 ? /* @__PURE__ */ C(
|
|
4615
|
+
l.loading && !l.loaded ? /* @__PURE__ */ C("p", { children: e.loading }) : l.items.length === 0 ? /* @__PURE__ */ C(J, {
|
|
4272
4616
|
icon: c ? "search" : "discounts",
|
|
4273
4617
|
title: c ? r.noMatches : r.empty[i],
|
|
4274
4618
|
body: c ? void 0 : r.emptyHint
|
|
@@ -4288,7 +4632,7 @@ function Dn() {
|
|
|
4288
4632
|
});
|
|
4289
4633
|
}
|
|
4290
4634
|
// src/lib/discount-form.ts
|
|
4291
|
-
var
|
|
4635
|
+
var Hn = {
|
|
4292
4636
|
code: "",
|
|
4293
4637
|
type: "percent",
|
|
4294
4638
|
percentOff: "",
|
|
@@ -4297,43 +4641,43 @@ var On = {
|
|
|
4297
4641
|
startsAt: "",
|
|
4298
4642
|
endsAt: "",
|
|
4299
4643
|
maxRedemptions: ""
|
|
4300
|
-
},
|
|
4301
|
-
function
|
|
4644
|
+
}, Un = (e) => String(e).padStart(2, "0");
|
|
4645
|
+
function Wn(e) {
|
|
4302
4646
|
if (!e) return "";
|
|
4303
4647
|
let t = new Date(e);
|
|
4304
|
-
return Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${
|
|
4648
|
+
return Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${Un(t.getMonth() + 1)}-${Un(t.getDate())}T${Un(t.getHours())}:${Un(t.getMinutes())}`;
|
|
4305
4649
|
}
|
|
4306
|
-
function
|
|
4650
|
+
function Gn(e) {
|
|
4307
4651
|
if (e.trim() === "") return null;
|
|
4308
4652
|
let t = new Date(e);
|
|
4309
4653
|
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
4310
4654
|
}
|
|
4311
|
-
function
|
|
4655
|
+
function Kn(e) {
|
|
4312
4656
|
return {
|
|
4313
4657
|
code: e.code,
|
|
4314
4658
|
type: e.type,
|
|
4315
4659
|
percentOff: e.percentOff ? String(e.percentOff) : "",
|
|
4316
|
-
amountOff: e.amountOffCents ?
|
|
4317
|
-
minSubtotal: e.minSubtotalCents ?
|
|
4318
|
-
startsAt:
|
|
4319
|
-
endsAt:
|
|
4660
|
+
amountOff: e.amountOffCents ? Z(e.amountOffCents) : "",
|
|
4661
|
+
minSubtotal: e.minSubtotalCents ? Z(e.minSubtotalCents) : "",
|
|
4662
|
+
startsAt: Wn(e.startsAt),
|
|
4663
|
+
endsAt: Wn(e.endsAt),
|
|
4320
4664
|
maxRedemptions: e.maxRedemptions ? String(e.maxRedemptions) : ""
|
|
4321
4665
|
};
|
|
4322
4666
|
}
|
|
4323
|
-
function
|
|
4667
|
+
function qn(e) {
|
|
4324
4668
|
return !!(e && e.redeemedCount + e.reservedCount > 0);
|
|
4325
4669
|
}
|
|
4326
|
-
var
|
|
4327
|
-
function
|
|
4670
|
+
var Jn = (e) => /^\d+$/.test(e.trim()) && Number(e) > 0 ? Number(e) : null;
|
|
4671
|
+
function Yn(e, t, n, r = 0) {
|
|
4328
4672
|
let i = t.validation, a = {}, o = e.code.trim().toUpperCase();
|
|
4329
4673
|
/^[A-Z0-9_-]{1,40}$/.test(o) || (a.code = i.code);
|
|
4330
|
-
let s =
|
|
4674
|
+
let s = Jn(e.percentOff), c = X(e.amountOff);
|
|
4331
4675
|
e.type === "percent" && (s === null || s > 100) && (a.percentOff = i.percentOff), e.type === "fixed" && !c && (a.amountOff = i.amountOff);
|
|
4332
|
-
let l = e.minSubtotal.trim(), u = l === "" ? null :
|
|
4676
|
+
let l = e.minSubtotal.trim(), u = l === "" ? null : X(l);
|
|
4333
4677
|
l !== "" && !u && (a.minSubtotal = i.minSubtotal);
|
|
4334
|
-
let d = e.maxRedemptions.trim(), f = d === "" ? null :
|
|
4678
|
+
let d = e.maxRedemptions.trim(), f = d === "" ? null : Jn(d);
|
|
4335
4679
|
d !== "" && f === null ? a.maxRedemptions = i.maxRedemptions : f !== null && f < r && (a.maxRedemptions = i.maxRedemptionsBelowUsage);
|
|
4336
|
-
let p =
|
|
4680
|
+
let p = Gn(e.startsAt), m = Gn(e.endsAt);
|
|
4337
4681
|
return e.startsAt.trim() !== "" && !p && (a.startsAt = i.date), e.endsAt.trim() !== "" && !m && (a.endsAt = i.date), p && m && new Date(m) <= new Date(p) && (a.endsAt = i.endsBeforeStart), Object.keys(a).length > 0 ? {
|
|
4338
4682
|
ok: !1,
|
|
4339
4683
|
errors: a
|
|
@@ -4353,25 +4697,25 @@ function Fn(e, t, n, r = 0) {
|
|
|
4353
4697
|
}
|
|
4354
4698
|
};
|
|
4355
4699
|
}
|
|
4356
|
-
var
|
|
4700
|
+
var Xn = [
|
|
4357
4701
|
"type",
|
|
4358
4702
|
"percentOff",
|
|
4359
4703
|
"amountOffCents",
|
|
4360
4704
|
"currency"
|
|
4361
|
-
],
|
|
4705
|
+
], Zn = [
|
|
4362
4706
|
"minSubtotalCents",
|
|
4363
4707
|
"startsAt",
|
|
4364
4708
|
"endsAt",
|
|
4365
4709
|
"maxRedemptions"
|
|
4366
4710
|
];
|
|
4367
|
-
function
|
|
4711
|
+
function Qn(e, t, n) {
|
|
4368
4712
|
let r = {}, i = t, a = e, o = (e) => (i[e] ?? null) !== (a[e] ?? null);
|
|
4369
|
-
for (let e of
|
|
4713
|
+
for (let e of Zn) o(e) && (r[e] = i[e]);
|
|
4370
4714
|
if (n) return r;
|
|
4371
|
-
if (o("code") && (r.code = t.code),
|
|
4715
|
+
if (o("code") && (r.code = t.code), Xn.some(o)) for (let e of Xn) r[e] = i[e];
|
|
4372
4716
|
return r;
|
|
4373
4717
|
}
|
|
4374
|
-
function
|
|
4718
|
+
function $n(e, t) {
|
|
4375
4719
|
let n = {
|
|
4376
4720
|
code: "code",
|
|
4377
4721
|
percentOff: "percentOff",
|
|
@@ -4388,7 +4732,7 @@ function zn(e, t) {
|
|
|
4388
4732
|
return r;
|
|
4389
4733
|
}
|
|
4390
4734
|
// src/views/discounts/discount-fields.tsx
|
|
4391
|
-
function
|
|
4735
|
+
function er({ name: e, label: t, error: n, help: r, disabled: i, children: a }) {
|
|
4392
4736
|
let o = `sfa-field-${e}`, s = [r ? `${o}-help` : "", n ? `${o}-error` : ""].filter(Boolean).join(" ");
|
|
4393
4737
|
return /* @__PURE__ */ w("div", {
|
|
4394
4738
|
className: "sfa-field",
|
|
@@ -4418,9 +4762,9 @@ function Bn({ name: e, label: t, error: n, help: r, disabled: i, children: a })
|
|
|
4418
4762
|
]
|
|
4419
4763
|
});
|
|
4420
4764
|
}
|
|
4421
|
-
var
|
|
4422
|
-
function
|
|
4423
|
-
let a = r > 0, o = a ?
|
|
4765
|
+
var tr = ["percent", "fixed"];
|
|
4766
|
+
function nr({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
4767
|
+
let a = r > 0, o = a ? Ln(n.lockedHelp, { count: r }) : void 0, s = (n, r, a = {}) => /* @__PURE__ */ C(er, {
|
|
4424
4768
|
name: n,
|
|
4425
4769
|
label: r,
|
|
4426
4770
|
error: t[n],
|
|
@@ -4433,7 +4777,7 @@ function Hn({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4433
4777
|
value: e[n],
|
|
4434
4778
|
onChange: (e) => i(n, e.target.value)
|
|
4435
4779
|
})
|
|
4436
|
-
}), c = (r) => /* @__PURE__ */ C(
|
|
4780
|
+
}), c = (r) => /* @__PURE__ */ C(er, {
|
|
4437
4781
|
name: r,
|
|
4438
4782
|
label: n.fields[r],
|
|
4439
4783
|
error: t[r],
|
|
@@ -4450,7 +4794,7 @@ function Hn({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4450
4794
|
help: o,
|
|
4451
4795
|
locked: a
|
|
4452
4796
|
}),
|
|
4453
|
-
/* @__PURE__ */ C(
|
|
4797
|
+
/* @__PURE__ */ C(er, {
|
|
4454
4798
|
name: "type",
|
|
4455
4799
|
label: n.fields.type,
|
|
4456
4800
|
disabled: a,
|
|
@@ -4458,7 +4802,7 @@ function Hn({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4458
4802
|
...t,
|
|
4459
4803
|
value: e.type,
|
|
4460
4804
|
onChange: (e) => i("type", e.target.value),
|
|
4461
|
-
children:
|
|
4805
|
+
children: tr.map((e) => /* @__PURE__ */ C("option", {
|
|
4462
4806
|
value: e,
|
|
4463
4807
|
children: n.types[e]
|
|
4464
4808
|
}, e))
|
|
@@ -4484,52 +4828,52 @@ function Hn({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4484
4828
|
] });
|
|
4485
4829
|
}
|
|
4486
4830
|
// src/views/discounts/admin-discount-editor.tsx
|
|
4487
|
-
function
|
|
4488
|
-
return e ? /* @__PURE__ */ C(
|
|
4831
|
+
function rr({ discountId: e, onSaved: t }) {
|
|
4832
|
+
return e ? /* @__PURE__ */ C(ir, {
|
|
4489
4833
|
discountId: e,
|
|
4490
4834
|
onSaved: t
|
|
4491
|
-
}) : /* @__PURE__ */ C(
|
|
4835
|
+
}) : /* @__PURE__ */ C(ar, {
|
|
4492
4836
|
discount: void 0,
|
|
4493
4837
|
onSaved: t
|
|
4494
4838
|
});
|
|
4495
4839
|
}
|
|
4496
|
-
function
|
|
4840
|
+
function ir({ discountId: e, onSaved: t }) {
|
|
4497
4841
|
let n = I(), { labels: r } = F(), i = L(["admin-discount", e], () => n.getDiscount(e));
|
|
4498
|
-
return i.error ? /* @__PURE__ */ C(q, { error: i.error }) : i.data ? /* @__PURE__ */ C(
|
|
4842
|
+
return i.error ? /* @__PURE__ */ C(q, { error: i.error }) : i.data ? /* @__PURE__ */ C(ar, {
|
|
4499
4843
|
discount: i.data,
|
|
4500
4844
|
onSaved: t
|
|
4501
4845
|
}, i.data.id) : /* @__PURE__ */ C("p", { children: r.loading });
|
|
4502
4846
|
}
|
|
4503
|
-
function
|
|
4504
|
-
let n = I(), { labels:
|
|
4847
|
+
function ar({ discount: e, onSaved: t }) {
|
|
4848
|
+
let n = I(), { labels: r, currency: a } = F(), o = r.discounts, [s, c] = b(e), [u, f] = b(e ? Kn(e) : Hn), [p, m] = b({}), [h, g] = b(!1), [_, v] = b(!1), y = s ? s.redeemedCount + s.reservedCount : 0, x = qn(s), S = (e, t) => {
|
|
4505
4849
|
m(t);
|
|
4506
4850
|
let n = Object.keys(t)[0];
|
|
4507
4851
|
n && e.elements.namedItem(n)?.focus();
|
|
4508
4852
|
}, T = R(async (e) => {
|
|
4509
|
-
let t =
|
|
4853
|
+
let t = Yn(u, o, s?.currency ?? a, y);
|
|
4510
4854
|
if (!t.ok) S(e, t.errors);
|
|
4511
4855
|
else try {
|
|
4512
4856
|
if (!s) return await n.createDiscount(t.input);
|
|
4513
|
-
let e =
|
|
4857
|
+
let e = Qn(s, t.input, x);
|
|
4514
4858
|
return Object.keys(e).length === 0 ? s : await n.updateDiscount(s.id, e);
|
|
4515
4859
|
} catch (t) {
|
|
4516
4860
|
if (t instanceof l) {
|
|
4517
4861
|
S(e, { code: o.validation.codeTaken });
|
|
4518
4862
|
return;
|
|
4519
4863
|
}
|
|
4520
|
-
if (t instanceof
|
|
4864
|
+
if (t instanceof i) {
|
|
4521
4865
|
S(e, { maxRedemptions: o.validation.maxRedemptionsBelowUsage });
|
|
4522
4866
|
return;
|
|
4523
4867
|
}
|
|
4524
4868
|
if (!(t instanceof d)) throw t;
|
|
4525
|
-
S(e,
|
|
4869
|
+
S(e, $n(t.issues, o.validation.invalid));
|
|
4526
4870
|
return;
|
|
4527
4871
|
}
|
|
4528
4872
|
}), E = R((e) => {
|
|
4529
4873
|
if (!s) throw Error("Discount has not been created yet.");
|
|
4530
4874
|
return n.updateDiscount(s.id, { active: e });
|
|
4531
4875
|
}), D = (e) => {
|
|
4532
|
-
c(e), f(
|
|
4876
|
+
c(e), f(Kn(e)), g(!0), t?.(e);
|
|
4533
4877
|
}, O = (e, t) => {
|
|
4534
4878
|
f((n) => ({
|
|
4535
4879
|
...n,
|
|
@@ -4554,7 +4898,7 @@ function Gn({ discount: e, onSaved: t }) {
|
|
|
4554
4898
|
children: [
|
|
4555
4899
|
/* @__PURE__ */ C(V, { title: s ? o.editTitle : o.createTitle }),
|
|
4556
4900
|
/* @__PURE__ */ C(q, { error: T.error ?? E.error }),
|
|
4557
|
-
/* @__PURE__ */ C(
|
|
4901
|
+
/* @__PURE__ */ C(nr, {
|
|
4558
4902
|
form: u,
|
|
4559
4903
|
errors: p,
|
|
4560
4904
|
labels: o,
|
|
@@ -4568,7 +4912,7 @@ function Gn({ discount: e, onSaved: t }) {
|
|
|
4568
4912
|
type: "submit",
|
|
4569
4913
|
className: "sfa-btn sfa-btn--primary",
|
|
4570
4914
|
disabled: T.pending,
|
|
4571
|
-
children:
|
|
4915
|
+
children: r.save
|
|
4572
4916
|
}),
|
|
4573
4917
|
s?.active ? /* @__PURE__ */ C("button", {
|
|
4574
4918
|
type: "button",
|
|
@@ -4604,81 +4948,102 @@ function Gn({ discount: e, onSaved: t }) {
|
|
|
4604
4948
|
]
|
|
4605
4949
|
});
|
|
4606
4950
|
}
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
let e = I(), { labels: t, currency: n } = F(), [r, i] = b([]), a = y(0), o = y(Promise.resolve()), s = (e, t) => i((n) => n.map((n) => n.id === e ? {
|
|
4951
|
+
function or({ concurrency: e = 3 } = {}) {
|
|
4952
|
+
let t = I(), { labels: n, currency: r } = F(), [i, a] = b([]), o = y(0), s = y([]), c = y(0), l = (e, t) => a((n) => n.map((n) => n.id === e ? {
|
|
4610
4953
|
...n,
|
|
4611
4954
|
...t
|
|
4612
|
-
} : n)),
|
|
4613
|
-
|
|
4955
|
+
} : n)), u = async (e) => {
|
|
4956
|
+
l(e.id, {
|
|
4614
4957
|
status: "uploading",
|
|
4615
4958
|
error: void 0
|
|
4616
4959
|
});
|
|
4617
|
-
let
|
|
4960
|
+
let n = e.productId;
|
|
4618
4961
|
try {
|
|
4619
|
-
|
|
4620
|
-
let i = await
|
|
4621
|
-
|
|
4962
|
+
n || (n = (await t.createProduct(lt(Ht, r))).id, l(e.id, { productId: n }));
|
|
4963
|
+
let i = await t.uploadProductImage(n, e.file, "");
|
|
4964
|
+
l(e.id, {
|
|
4622
4965
|
status: "done",
|
|
4623
4966
|
product: i
|
|
4624
4967
|
});
|
|
4625
|
-
} catch (
|
|
4626
|
-
|
|
4968
|
+
} catch (t) {
|
|
4969
|
+
l(e.id, {
|
|
4627
4970
|
status: "error",
|
|
4628
|
-
error:
|
|
4971
|
+
error: t
|
|
4972
|
+
});
|
|
4973
|
+
}
|
|
4974
|
+
}, d = () => {
|
|
4975
|
+
for (; c.current < e && s.current.length > 0;) {
|
|
4976
|
+
let e = s.current.shift();
|
|
4977
|
+
c.current += 1, u(e).finally(() => {
|
|
4978
|
+
--c.current, d();
|
|
4629
4979
|
});
|
|
4630
4980
|
}
|
|
4631
|
-
},
|
|
4632
|
-
|
|
4633
|
-
},
|
|
4634
|
-
let
|
|
4635
|
-
let
|
|
4981
|
+
}, f = (e) => {
|
|
4982
|
+
s.current.push(...e), d();
|
|
4983
|
+
}, p = h((e) => {
|
|
4984
|
+
let t = e.map((e) => {
|
|
4985
|
+
let t = Mt(e, n.products.images);
|
|
4636
4986
|
return {
|
|
4637
|
-
id:
|
|
4987
|
+
id: o.current++,
|
|
4638
4988
|
file: e,
|
|
4639
|
-
status:
|
|
4640
|
-
reason:
|
|
4989
|
+
status: t ? "error" : "queued",
|
|
4990
|
+
reason: t ?? void 0
|
|
4641
4991
|
};
|
|
4642
4992
|
});
|
|
4643
|
-
|
|
4993
|
+
a((e) => [...e, ...t]), f(t.filter((e) => e.status === "queued"));
|
|
4644
4994
|
}, [
|
|
4645
|
-
e,
|
|
4646
4995
|
t,
|
|
4647
|
-
n
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4996
|
+
n,
|
|
4997
|
+
r
|
|
4998
|
+
]), m = () => {
|
|
4999
|
+
let e = i.filter((e) => e.status === "error" && !e.reason);
|
|
5000
|
+
a((t) => t.map((t) => e.some((e) => e.id === t.id) ? {
|
|
4651
5001
|
...t,
|
|
4652
5002
|
status: "queued"
|
|
4653
|
-
} : t)),
|
|
4654
|
-
},
|
|
5003
|
+
} : t)), f(e);
|
|
5004
|
+
}, g = i.filter((e) => e.status === "done"), _ = i.filter((e) => e.status === "error");
|
|
4655
5005
|
return {
|
|
4656
|
-
items:
|
|
4657
|
-
add:
|
|
4658
|
-
retry:
|
|
4659
|
-
done:
|
|
4660
|
-
failed:
|
|
4661
|
-
settled:
|
|
4662
|
-
products:
|
|
5006
|
+
items: i,
|
|
5007
|
+
add: p,
|
|
5008
|
+
retry: m,
|
|
5009
|
+
done: g,
|
|
5010
|
+
failed: _,
|
|
5011
|
+
settled: i.length > 0 && g.length + _.length === i.length,
|
|
5012
|
+
products: g.flatMap((e) => e.product ? [e.product] : [])
|
|
4663
5013
|
};
|
|
4664
5014
|
}
|
|
4665
5015
|
// src/views/products/add-several/photo-picker.tsx
|
|
4666
|
-
function
|
|
5016
|
+
function sr({ label: e, onFiles: t, multiple: n = !0, primary: r = !1, zone: i = !1, hint: a }) {
|
|
4667
5017
|
return /* @__PURE__ */ w("label", {
|
|
4668
|
-
className: `sfa-btn${r ? " sfa-btn--primary" : ""}`,
|
|
4669
|
-
children: [
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
5018
|
+
className: i ? "sfa-dropzone" : `sfa-btn${r ? " sfa-btn--primary" : ""}`,
|
|
5019
|
+
children: [
|
|
5020
|
+
i ? /* @__PURE__ */ C("span", {
|
|
5021
|
+
className: "sfa-dropzone__icon",
|
|
5022
|
+
"aria-hidden": "true",
|
|
5023
|
+
children: "+"
|
|
5024
|
+
}) : null,
|
|
5025
|
+
/* @__PURE__ */ C("span", {
|
|
5026
|
+
className: i ? "sfa-dropzone__label" : void 0,
|
|
5027
|
+
children: e
|
|
5028
|
+
}),
|
|
5029
|
+
i && a ? /* @__PURE__ */ C("span", {
|
|
5030
|
+
className: "sfa-dropzone__hint",
|
|
5031
|
+
children: a
|
|
5032
|
+
}) : null,
|
|
5033
|
+
/* @__PURE__ */ C("input", {
|
|
5034
|
+
type: "file",
|
|
5035
|
+
accept: "image/*",
|
|
5036
|
+
multiple: n,
|
|
5037
|
+
className: "sfa-sr-only",
|
|
5038
|
+
onChange: (e) => {
|
|
5039
|
+
t(Array.from(e.target.files ?? [])), e.target.value = "";
|
|
5040
|
+
}
|
|
5041
|
+
})
|
|
5042
|
+
]
|
|
4678
5043
|
});
|
|
4679
5044
|
}
|
|
4680
5045
|
// src/views/products/add-several/admin-add-several.tsx
|
|
4681
|
-
function
|
|
5046
|
+
function cr({ failed: e }) {
|
|
4682
5047
|
return /* @__PURE__ */ C("ul", {
|
|
4683
5048
|
className: "sfa-batch__failed",
|
|
4684
5049
|
children: e.map((e) => /* @__PURE__ */ w("li", { children: [/* @__PURE__ */ C("strong", { children: e.file.name }), e.reason ? /* @__PURE__ */ C(K, {
|
|
@@ -4687,8 +5052,8 @@ function Jn({ failed: e }) {
|
|
|
4687
5052
|
}) : /* @__PURE__ */ C(q, { error: e.error })] }, e.id))
|
|
4688
5053
|
});
|
|
4689
5054
|
}
|
|
4690
|
-
function
|
|
4691
|
-
let { labels: t } = F(), n = t.products.stock.addSeveral, r =
|
|
5055
|
+
function lr({ onDone: e }) {
|
|
5056
|
+
let { labels: t } = F(), n = t.products.stock.addSeveral, r = or(), i = r.items.length, a = r.failed.some((e) => !e.reason), o = r.done.length + r.failed.length;
|
|
4692
5057
|
return /* @__PURE__ */ w("section", {
|
|
4693
5058
|
className: "sfa-batch",
|
|
4694
5059
|
children: [/* @__PURE__ */ C(V, { title: n.title }), /* @__PURE__ */ C("div", {
|
|
@@ -4698,16 +5063,17 @@ function Yn({ onDone: e }) {
|
|
|
4698
5063
|
children: [
|
|
4699
5064
|
/* @__PURE__ */ C("h2", { children: n.introTitle }),
|
|
4700
5065
|
/* @__PURE__ */ C("p", { children: n.introBody }),
|
|
4701
|
-
/* @__PURE__ */ C(
|
|
5066
|
+
/* @__PURE__ */ C(sr, {
|
|
4702
5067
|
label: n.choose,
|
|
5068
|
+
hint: n.dropHint,
|
|
4703
5069
|
onFiles: r.add,
|
|
4704
|
-
|
|
5070
|
+
zone: !0
|
|
4705
5071
|
})
|
|
4706
5072
|
]
|
|
4707
5073
|
}) : r.settled ? r.failed.length === 0 ? /* @__PURE__ */ w("div", {
|
|
4708
5074
|
className: "sfa-batch__result",
|
|
4709
5075
|
children: [
|
|
4710
|
-
/* @__PURE__ */ C("h2", { children:
|
|
5076
|
+
/* @__PURE__ */ C("h2", { children: Y(n.doneTitle, { count: r.done.length }) }),
|
|
4711
5077
|
/* @__PURE__ */ C("p", { children: n.doneBody }),
|
|
4712
5078
|
/* @__PURE__ */ C("button", {
|
|
4713
5079
|
type: "button",
|
|
@@ -4719,8 +5085,8 @@ function Yn({ onDone: e }) {
|
|
|
4719
5085
|
}) : /* @__PURE__ */ w("div", {
|
|
4720
5086
|
className: "sfa-batch__result",
|
|
4721
5087
|
children: [
|
|
4722
|
-
/* @__PURE__ */ C("h2", { children:
|
|
4723
|
-
/* @__PURE__ */ C(
|
|
5088
|
+
/* @__PURE__ */ C("h2", { children: Y(n.failedTitle, { count: r.failed.length }) }),
|
|
5089
|
+
/* @__PURE__ */ C(cr, { failed: r.failed }),
|
|
4724
5090
|
/* @__PURE__ */ w("div", {
|
|
4725
5091
|
className: "sfa-batch__actions",
|
|
4726
5092
|
children: [a ? /* @__PURE__ */ C("button", {
|
|
@@ -4733,7 +5099,7 @@ function Yn({ onDone: e }) {
|
|
|
4733
5099
|
className: "sfa-btn",
|
|
4734
5100
|
onClick: () => e(r.products),
|
|
4735
5101
|
children: n.continueWithout
|
|
4736
|
-
}) : /* @__PURE__ */ C(
|
|
5102
|
+
}) : /* @__PURE__ */ C(sr, {
|
|
4737
5103
|
label: n.choose,
|
|
4738
5104
|
onFiles: r.add
|
|
4739
5105
|
})]
|
|
@@ -4745,7 +5111,7 @@ function Yn({ onDone: e }) {
|
|
|
4745
5111
|
children: [/* @__PURE__ */ C("progress", {
|
|
4746
5112
|
max: i,
|
|
4747
5113
|
value: o
|
|
4748
|
-
}), /* @__PURE__ */ C("p", { children:
|
|
5114
|
+
}), /* @__PURE__ */ C("p", { children: Y(n.progress, {
|
|
4749
5115
|
done: o,
|
|
4750
5116
|
total: i
|
|
4751
5117
|
}) })]
|
|
@@ -4754,7 +5120,7 @@ function Yn({ onDone: e }) {
|
|
|
4754
5120
|
});
|
|
4755
5121
|
}
|
|
4756
5122
|
// src/views/products/finish-drafts/piece-fields.tsx
|
|
4757
|
-
function
|
|
5123
|
+
function ur({ form: e, update: t, categories: n }) {
|
|
4758
5124
|
let { labels: r, locale: i, currency: a } = F(), o = r.products.fields, s = r.products.flow, c = [...n ?? []], l = e.category.trim();
|
|
4759
5125
|
return l && !c.includes(l) && c.push(l), /* @__PURE__ */ w("div", {
|
|
4760
5126
|
className: "sfa-piece__fields",
|
|
@@ -4783,7 +5149,7 @@ function Xn({ form: e, update: t, categories: n }) {
|
|
|
4783
5149
|
className: "sfa-flow__price",
|
|
4784
5150
|
children: [/* @__PURE__ */ C("span", {
|
|
4785
5151
|
"aria-hidden": "true",
|
|
4786
|
-
children:
|
|
5152
|
+
children: _t(i, a)
|
|
4787
5153
|
}), /* @__PURE__ */ C("input", {
|
|
4788
5154
|
id: "sfa-piece-price",
|
|
4789
5155
|
type: "text",
|
|
@@ -4829,14 +5195,14 @@ function Xn({ form: e, update: t, categories: n }) {
|
|
|
4829
5195
|
});
|
|
4830
5196
|
}
|
|
4831
5197
|
// src/views/products/finish-drafts/piece-card.tsx
|
|
4832
|
-
function
|
|
4833
|
-
let { labels: o, renderImage: s } = F(), c = o.products.stock.queue, [l, u] = b(() =>
|
|
5198
|
+
function dr({ product: e, index: t, total: n, categories: r, onAdvance: i, onBack: a }) {
|
|
5199
|
+
let { labels: o, renderImage: s } = F(), c = o.products.stock.queue, [l, u] = b(() => Ut(e)), d = Wt({
|
|
4834
5200
|
initial: e,
|
|
4835
5201
|
form: l
|
|
4836
|
-
}), f =
|
|
5202
|
+
}), f = Nt({
|
|
4837
5203
|
productId: e.id,
|
|
4838
5204
|
onUploaded: d.setProduct
|
|
4839
|
-
}), p =
|
|
5205
|
+
}), p = $(d.product)[0], m = t === n - 1, h = String(t + 1), g = (e, t) => u((n) => ({
|
|
4840
5206
|
...n,
|
|
4841
5207
|
[e]: t
|
|
4842
5208
|
})), _ = async () => {
|
|
@@ -4850,7 +5216,7 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4850
5216
|
/* @__PURE__ */ C("p", {
|
|
4851
5217
|
className: "sfa-piece__count",
|
|
4852
5218
|
id: "sfa-piece-title",
|
|
4853
|
-
children:
|
|
5219
|
+
children: Y(c.pieceOf, {
|
|
4854
5220
|
n: t + 1,
|
|
4855
5221
|
m: n
|
|
4856
5222
|
})
|
|
@@ -4866,9 +5232,9 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4866
5232
|
className: "sfa-piece__photo",
|
|
4867
5233
|
children: [p ? s({
|
|
4868
5234
|
src: p.url,
|
|
4869
|
-
alt: p.alt ||
|
|
5235
|
+
alt: p.alt || Q(c.coverAlt, { n: h }),
|
|
4870
5236
|
sizes: "320px"
|
|
4871
|
-
}) : /* @__PURE__ */ C(
|
|
5237
|
+
}) : /* @__PURE__ */ C(sr, {
|
|
4872
5238
|
label: c.addPhoto,
|
|
4873
5239
|
multiple: !1,
|
|
4874
5240
|
onFiles: (e) => f.upload(e, "")
|
|
@@ -4876,7 +5242,7 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4876
5242
|
variant: "error",
|
|
4877
5243
|
children: e.reason ?? /* @__PURE__ */ C(q, { error: e.error })
|
|
4878
5244
|
}, e.id) : null)]
|
|
4879
|
-
}), /* @__PURE__ */ C(
|
|
5245
|
+
}), /* @__PURE__ */ C(ur, {
|
|
4880
5246
|
form: l,
|
|
4881
5247
|
update: g,
|
|
4882
5248
|
categories: r
|
|
@@ -4884,7 +5250,7 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4884
5250
|
}),
|
|
4885
5251
|
/* @__PURE__ */ C(q, { error: d.error }),
|
|
4886
5252
|
/* @__PURE__ */ w("div", {
|
|
4887
|
-
className: "sfa-
|
|
5253
|
+
className: "sfa-piece__foot",
|
|
4888
5254
|
children: [
|
|
4889
5255
|
a ? /* @__PURE__ */ C("button", {
|
|
4890
5256
|
type: "button",
|
|
@@ -4902,7 +5268,7 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4902
5268
|
/* @__PURE__ */ C("button", {
|
|
4903
5269
|
type: "button",
|
|
4904
5270
|
className: "sfa-btn sfa-btn--primary",
|
|
4905
|
-
disabled: !
|
|
5271
|
+
disabled: !dt(l) || d.state === "saving",
|
|
4906
5272
|
onClick: _,
|
|
4907
5273
|
children: m ? c.review : c.next
|
|
4908
5274
|
})
|
|
@@ -4912,94 +5278,90 @@ function Zn({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
4912
5278
|
});
|
|
4913
5279
|
}
|
|
4914
5280
|
// src/views/products/finish-drafts/piece-summary.tsx
|
|
4915
|
-
function
|
|
4916
|
-
return
|
|
5281
|
+
function fr(e) {
|
|
5282
|
+
return dt(Ut(e));
|
|
4917
5283
|
}
|
|
4918
|
-
function
|
|
4919
|
-
let { labels:
|
|
5284
|
+
function pr({ pieces: e, pending: t, failure: n, onPublish: r, onOpenPiece: i, onKeepDrafts: a }) {
|
|
5285
|
+
let { labels: o, renderImage: s } = F(), c = o.products.stock.summary, l = e.filter(fr), u = e.filter((e) => !fr(e));
|
|
4920
5286
|
return /* @__PURE__ */ w("section", {
|
|
4921
5287
|
className: "sfa-piece",
|
|
4922
5288
|
"aria-labelledby": "sfa-summary-title",
|
|
4923
5289
|
children: [
|
|
4924
5290
|
/* @__PURE__ */ C("h2", {
|
|
4925
5291
|
id: "sfa-summary-title",
|
|
4926
|
-
|
|
5292
|
+
className: "sfa-piece__heading",
|
|
5293
|
+
children: c.title
|
|
4927
5294
|
}),
|
|
4928
|
-
/* @__PURE__ */ C("p", { children:
|
|
5295
|
+
/* @__PURE__ */ C("p", { children: l.length ? c.lede : c.allSkipped }),
|
|
4929
5296
|
/* @__PURE__ */ C("ul", {
|
|
4930
5297
|
className: "sfa-summary__list",
|
|
4931
|
-
children: e.map((e) => {
|
|
4932
|
-
let
|
|
4933
|
-
|
|
5298
|
+
children: e.map((e, t) => {
|
|
5299
|
+
let n = $(e)[0], r = fr(e), a = e.name || c.untitled, o = /* @__PURE__ */ w(S, { children: [
|
|
5300
|
+
/* @__PURE__ */ C("span", {
|
|
5301
|
+
className: "sfa-summary__photo",
|
|
5302
|
+
children: n ? s({
|
|
5303
|
+
src: n.url,
|
|
5304
|
+
alt: "",
|
|
5305
|
+
sizes: "56px"
|
|
5306
|
+
}) : null
|
|
5307
|
+
}),
|
|
5308
|
+
/* @__PURE__ */ C("span", {
|
|
5309
|
+
className: "sfa-summary__name",
|
|
5310
|
+
children: a
|
|
5311
|
+
}),
|
|
5312
|
+
/* @__PURE__ */ C("span", {
|
|
5313
|
+
className: "sfa-summary__price",
|
|
5314
|
+
children: r && e.priceCents !== null ? /* @__PURE__ */ C(W, {
|
|
5315
|
+
cents: e.priceCents,
|
|
5316
|
+
currency: e.currency
|
|
5317
|
+
}) : c.needsDetails
|
|
5318
|
+
})
|
|
5319
|
+
] });
|
|
5320
|
+
return /* @__PURE__ */ C("li", { children: r ? /* @__PURE__ */ C("div", {
|
|
4934
5321
|
className: "sfa-summary__row",
|
|
4935
|
-
children:
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
}),
|
|
4948
|
-
/* @__PURE__ */ C("span", {
|
|
4949
|
-
className: "sfa-summary__price",
|
|
4950
|
-
children: Qn(e) && e.priceCents !== null ? /* @__PURE__ */ C(W, {
|
|
4951
|
-
cents: e.priceCents,
|
|
4952
|
-
currency: e.currency
|
|
4953
|
-
}) : s.needsDetails
|
|
4954
|
-
})
|
|
4955
|
-
]
|
|
4956
|
-
}, e.id);
|
|
5322
|
+
children: o
|
|
5323
|
+
}) : /* @__PURE__ */ w("button", {
|
|
5324
|
+
type: "button",
|
|
5325
|
+
className: "sfa-summary__row sfa-summary__row--open",
|
|
5326
|
+
"aria-label": Q(c.openPiece, { name: a }),
|
|
5327
|
+
onClick: () => i(t),
|
|
5328
|
+
children: [o, /* @__PURE__ */ C("span", {
|
|
5329
|
+
className: "sfa-summary__chevron",
|
|
5330
|
+
"aria-hidden": "true",
|
|
5331
|
+
children: "›"
|
|
5332
|
+
})]
|
|
5333
|
+
}) }, e.id);
|
|
4957
5334
|
})
|
|
4958
5335
|
}),
|
|
4959
5336
|
/* @__PURE__ */ C(q, { error: n }),
|
|
4960
5337
|
/* @__PURE__ */ w("div", {
|
|
4961
|
-
className: "sfa-
|
|
5338
|
+
className: "sfa-piece__foot",
|
|
4962
5339
|
children: [/* @__PURE__ */ C("button", {
|
|
4963
5340
|
type: "button",
|
|
4964
5341
|
className: "sfa-btn",
|
|
4965
5342
|
disabled: t,
|
|
4966
|
-
onClick:
|
|
4967
|
-
children:
|
|
4968
|
-
}),
|
|
5343
|
+
onClick: a,
|
|
5344
|
+
children: c.keepDrafts
|
|
5345
|
+
}), l.length ? /* @__PURE__ */ C("button", {
|
|
4969
5346
|
type: "button",
|
|
4970
5347
|
className: "sfa-btn sfa-btn--primary",
|
|
4971
5348
|
disabled: t,
|
|
4972
|
-
onClick: () => r(
|
|
4973
|
-
children:
|
|
5349
|
+
onClick: () => r(l, u),
|
|
5350
|
+
children: Y(c.publish, { count: l.length })
|
|
4974
5351
|
}) : null]
|
|
4975
5352
|
})
|
|
4976
5353
|
]
|
|
4977
5354
|
});
|
|
4978
5355
|
}
|
|
4979
|
-
// src/lib/fill-alts.ts
|
|
4980
|
-
async function er(e, t, n) {
|
|
4981
|
-
let r = t.name.trim();
|
|
4982
|
-
if (!r) return t;
|
|
4983
|
-
let i = t, a = [...t.images].sort((e, t) => e.position - t.position);
|
|
4984
|
-
for (let [o, s] of a.entries()) {
|
|
4985
|
-
if (s.alt.trim()) continue;
|
|
4986
|
-
let a = Z(n, {
|
|
4987
|
-
name: r,
|
|
4988
|
-
n: String(o + 1)
|
|
4989
|
-
});
|
|
4990
|
-
i = await e.updateProductImage(t.id, s.id, { alt: a });
|
|
4991
|
-
}
|
|
4992
|
-
return i;
|
|
4993
|
-
}
|
|
4994
5356
|
// src/views/products/finish-drafts/use-publish-pieces.ts
|
|
4995
|
-
function
|
|
5357
|
+
function mr() {
|
|
4996
5358
|
let e = I(), { labels: t } = F(), [n, r] = b(!1), [i, a] = b(void 0), [o, s] = b(null);
|
|
4997
5359
|
return {
|
|
4998
5360
|
publish: async (n, i) => {
|
|
4999
5361
|
r(!0), a(void 0);
|
|
5000
5362
|
let o = [], c = [...i];
|
|
5001
5363
|
for (let r of n) try {
|
|
5002
|
-
await
|
|
5364
|
+
await Vt(e, r, t.products.flow.altFallback), o.push(await e.updateProduct(r.id, { status: "active" }));
|
|
5003
5365
|
} catch (e) {
|
|
5004
5366
|
c.push(r), e instanceof u || a(e);
|
|
5005
5367
|
}
|
|
@@ -5016,18 +5378,26 @@ function tr() {
|
|
|
5016
5378
|
};
|
|
5017
5379
|
}
|
|
5018
5380
|
// src/views/products/finish-drafts/admin-finish-drafts.tsx
|
|
5019
|
-
function
|
|
5020
|
-
let { labels: r } = F(), i = r.products.stock, [a, o] = b(e), [s, c] = b(0), l =
|
|
5381
|
+
function hr({ initial: e, categories: t, onDone: n }) {
|
|
5382
|
+
let { labels: r } = F(), i = r.products.stock, [a, o] = b(e), [s, c] = b(0), l = mr();
|
|
5021
5383
|
if (l.outcome) {
|
|
5022
5384
|
let { published: e, drafts: t } = l.outcome;
|
|
5023
5385
|
return /* @__PURE__ */ w("section", {
|
|
5024
|
-
className: "sfa-piece",
|
|
5386
|
+
className: "sfa-piece sfa-piece--celebrate",
|
|
5025
5387
|
children: [
|
|
5026
|
-
/* @__PURE__ */ C("
|
|
5388
|
+
/* @__PURE__ */ C("span", {
|
|
5389
|
+
className: "sfa-piece__badge",
|
|
5390
|
+
"aria-hidden": "true",
|
|
5391
|
+
children: "✓"
|
|
5392
|
+
}),
|
|
5393
|
+
/* @__PURE__ */ C("h2", {
|
|
5394
|
+
className: "sfa-piece__heading",
|
|
5395
|
+
children: Y(i.summary.publishedTitle, { count: e.length })
|
|
5396
|
+
}),
|
|
5027
5397
|
/* @__PURE__ */ C("p", { children: i.summary.publishedBody }),
|
|
5028
|
-
t.length ? /* @__PURE__ */ C("p", { children:
|
|
5398
|
+
t.length ? /* @__PURE__ */ C("p", { children: Y(i.summary.stillIncomplete, { count: t.length }) }) : null,
|
|
5029
5399
|
/* @__PURE__ */ C("div", {
|
|
5030
|
-
className: "sfa-piece__actions",
|
|
5400
|
+
className: "sfa-piece__actions sfa-piece__actions--center",
|
|
5031
5401
|
children: /* @__PURE__ */ C("button", {
|
|
5032
5402
|
type: "button",
|
|
5033
5403
|
className: "sfa-btn sfa-btn--primary",
|
|
@@ -5038,16 +5408,17 @@ function nr({ initial: e, categories: t, onDone: n }) {
|
|
|
5038
5408
|
]
|
|
5039
5409
|
});
|
|
5040
5410
|
}
|
|
5041
|
-
return s >= a.length ? /* @__PURE__ */ C(
|
|
5411
|
+
return s >= a.length ? /* @__PURE__ */ C(pr, {
|
|
5042
5412
|
pieces: a,
|
|
5043
5413
|
pending: l.pending,
|
|
5044
5414
|
failure: l.failure,
|
|
5045
5415
|
onPublish: l.publish,
|
|
5416
|
+
onOpenPiece: c,
|
|
5046
5417
|
onKeepDrafts: () => n({
|
|
5047
5418
|
published: [],
|
|
5048
5419
|
drafts: a
|
|
5049
5420
|
})
|
|
5050
|
-
}) : /* @__PURE__ */ C(
|
|
5421
|
+
}) : /* @__PURE__ */ C(dr, {
|
|
5051
5422
|
product: a[s],
|
|
5052
5423
|
index: s,
|
|
5053
5424
|
total: a.length,
|
|
@@ -5058,7 +5429,7 @@ function nr({ initial: e, categories: t, onDone: n }) {
|
|
|
5058
5429
|
onBack: s > 0 ? () => c(s - 1) : void 0
|
|
5059
5430
|
}, a[s].id);
|
|
5060
5431
|
}
|
|
5061
|
-
function
|
|
5432
|
+
function gr({ productIds: e, categories: t, onDone: n }) {
|
|
5062
5433
|
let r = I(), { labels: i } = F(), a = i.products.stock.queue, o = L(["finish-drafts", e ?? null], () => e ? Promise.all(e.map((e) => r.getProduct(e))) : r.listProducts({
|
|
5063
5434
|
incomplete: "true",
|
|
5064
5435
|
limit: 100
|
|
@@ -5076,7 +5447,7 @@ function rr({ productIds: e, categories: t, onDone: n }) {
|
|
|
5076
5447
|
}),
|
|
5077
5448
|
children: a.done
|
|
5078
5449
|
})]
|
|
5079
|
-
}) : /* @__PURE__ */ C(
|
|
5450
|
+
}) : /* @__PURE__ */ C(hr, {
|
|
5080
5451
|
initial: o.data,
|
|
5081
5452
|
categories: t,
|
|
5082
5453
|
onDone: n
|
|
@@ -5086,6 +5457,6 @@ function rr({ productIds: e, categories: t, onDone: n }) {
|
|
|
5086
5457
|
})]
|
|
5087
5458
|
});
|
|
5088
5459
|
}
|
|
5089
|
-
export {
|
|
5460
|
+
export { lr as AdminAddSeveral, rr as AdminDiscountEditor, Vn as AdminDiscountList, gr as AdminFinishDrafts, me as AdminLayout, Cn as AdminOrderDetail, sn as AdminOrderList, V as AdminPageHeader, Zt as AdminProductEditor, Kt as AdminProductFlow, nn as AdminProductImages, nt as AdminProductList, Ke as AdminProductSheet, oe as AdminProvider, we as AdminSetupChecklist, Fn as AdminShippingRates, H as AdminTable, G as ConfirmDialog, J as EmptyState, q as ErrorMessage, W as Money, K as Notice, vn as OrderActions, U as StatusBadge, rt as Switch, B as adminNavIcons, ve as errorKey, Z as formatMoneyInput, X as parseMoneyInput, F as useAdmin, I as useAdminClient, R as useAdminMutation, L as useAdminQuery };
|
|
5090
5461
|
|
|
5091
5462
|
//# sourceMappingURL=index.js.map
|