@develemit/commerce-admin 0.8.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 +8 -0
- package/README.md +2 -1
- package/dist/index.js +524 -496
- package/dist/index.js.map +1 -1
- package/dist/lib/fill-alts.d.ts +1 -1
- package/dist/lib/order-labels.d.ts +1 -0
- package/dist/lib/product-flow-labels.d.ts +2 -0
- package/dist/lib/product-form.d.ts +2 -1
- package/dist/lib/use-batch-upload.d.ts +6 -1
- package/dist/lib/use-order-pages.d.ts +1 -0
- package/dist/lib/use-product-autosave.d.ts +4 -0
- package/dist/lib/use-product-pages.d.ts +1 -0
- package/dist/views/products/finish-drafts/use-publish-pieces.d.ts +2 -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/use-product-flow.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ var D = {
|
|
|
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.",
|
|
@@ -454,6 +455,8 @@ var D = {
|
|
|
454
455
|
stepCount: "Step {n} of {total}",
|
|
455
456
|
materialsOther: "Or type your own",
|
|
456
457
|
size: "Size",
|
|
458
|
+
taxCode: "Tax category",
|
|
459
|
+
taxCodeDefault: "Default",
|
|
457
460
|
altTitle: "Describe each photo",
|
|
458
461
|
altHelp: "Describe the photo for shoppers who can’t see it. Left blank, it uses the name.",
|
|
459
462
|
altFallback: "{name}, photo {n}",
|
|
@@ -1309,7 +1312,7 @@ var ye = {
|
|
|
1309
1312
|
products: "M4 7h16v13H4V7zm0 0l2-3h12l2 3M9 12h6",
|
|
1310
1313
|
search: "M11 4a7 7 0 100 14 7 7 0 000-14zm9 16l-4-4"
|
|
1311
1314
|
};
|
|
1312
|
-
function
|
|
1315
|
+
function J({ icon: e, title: t, body: n, action: r, children: i }) {
|
|
1313
1316
|
return /* @__PURE__ */ w("div", {
|
|
1314
1317
|
className: "sfa-empty-state",
|
|
1315
1318
|
children: [
|
|
@@ -1344,14 +1347,14 @@ function be({ icon: e, title: t, body: n, action: r, children: i }) {
|
|
|
1344
1347
|
});
|
|
1345
1348
|
}
|
|
1346
1349
|
// src/lib/product-missing.ts
|
|
1347
|
-
function
|
|
1350
|
+
function be(e, t) {
|
|
1348
1351
|
return e.status === "draft" ? e.priceCents === null ? t.needsPrice : e.category ? e.images.length === 0 ? t.needsPhoto : null : t.needsCategory : null;
|
|
1349
1352
|
}
|
|
1350
|
-
function
|
|
1353
|
+
function Y(e, t) {
|
|
1351
1354
|
return e.replace(/\{(\w+)\}/g, (e, n) => String(t[n] ?? ""));
|
|
1352
1355
|
}
|
|
1353
1356
|
// src/components/setup-checklist/setup-checklist.tsx
|
|
1354
|
-
function
|
|
1357
|
+
function xe({ step: e }) {
|
|
1355
1358
|
let t = e.locked ? e.lockedDetail : e.detail;
|
|
1356
1359
|
return /* @__PURE__ */ w(S, { children: [
|
|
1357
1360
|
/* @__PURE__ */ C("span", {
|
|
@@ -1369,40 +1372,40 @@ function Se({ step: e }) {
|
|
|
1369
1372
|
children: t
|
|
1370
1373
|
}) : null]
|
|
1371
1374
|
}),
|
|
1372
|
-
|
|
1375
|
+
Se(e) ? /* @__PURE__ */ C("span", {
|
|
1373
1376
|
className: "sfa-setup__chevron",
|
|
1374
1377
|
"aria-hidden": "true",
|
|
1375
1378
|
children: "›"
|
|
1376
1379
|
}) : null
|
|
1377
1380
|
] });
|
|
1378
1381
|
}
|
|
1379
|
-
function
|
|
1382
|
+
function Se(e) {
|
|
1380
1383
|
return !e.done && !e.locked && !!(e.href || e.onSelect);
|
|
1381
1384
|
}
|
|
1382
|
-
function
|
|
1385
|
+
function Ce({ step: e }) {
|
|
1383
1386
|
let { renderLink: t } = F(), n = `sfa-setup__step${e.done ? " is-done" : ""}${e.locked ? " is-locked" : ""}`, r = !e.done && !e.locked, i;
|
|
1384
1387
|
return i = r && e.href ? t({
|
|
1385
1388
|
href: e.href,
|
|
1386
|
-
children: /* @__PURE__ */ C(
|
|
1389
|
+
children: /* @__PURE__ */ C(xe, { step: e }),
|
|
1387
1390
|
className: "sfa-setup__action"
|
|
1388
1391
|
}) : r && e.onSelect ? /* @__PURE__ */ C("button", {
|
|
1389
1392
|
type: "button",
|
|
1390
1393
|
className: "sfa-setup__action",
|
|
1391
1394
|
onClick: e.onSelect,
|
|
1392
|
-
children: /* @__PURE__ */ C(
|
|
1395
|
+
children: /* @__PURE__ */ C(xe, { step: e })
|
|
1393
1396
|
}) : /* @__PURE__ */ C("span", {
|
|
1394
1397
|
className: "sfa-setup__action",
|
|
1395
|
-
children: /* @__PURE__ */ C(
|
|
1398
|
+
children: /* @__PURE__ */ C(xe, { step: e })
|
|
1396
1399
|
}), /* @__PURE__ */ C("li", {
|
|
1397
1400
|
className: n,
|
|
1398
1401
|
"data-step": e.id,
|
|
1399
1402
|
children: i
|
|
1400
1403
|
});
|
|
1401
1404
|
}
|
|
1402
|
-
function
|
|
1405
|
+
function we({ steps: e, compact: t = !1 }) {
|
|
1403
1406
|
let { labels: n } = F(), r = n.products.setup, [i, a] = b(!0), o = e.filter((e) => e.done).length;
|
|
1404
1407
|
if (e.length === 0 || o === e.length) return null;
|
|
1405
|
-
let s =
|
|
1408
|
+
let s = Y(r.progress, {
|
|
1406
1409
|
done: o,
|
|
1407
1410
|
total: e.length
|
|
1408
1411
|
}), c = !t || i;
|
|
@@ -1441,19 +1444,19 @@ function Te({ steps: e, compact: t = !1 }) {
|
|
|
1441
1444
|
}),
|
|
1442
1445
|
c ? /* @__PURE__ */ C("ul", {
|
|
1443
1446
|
className: "sfa-setup__list",
|
|
1444
|
-
children: e.map((e) => /* @__PURE__ */ C(
|
|
1447
|
+
children: e.map((e) => /* @__PURE__ */ C(Ce, { step: e }, e.id))
|
|
1445
1448
|
}) : null
|
|
1446
1449
|
]
|
|
1447
1450
|
});
|
|
1448
1451
|
}
|
|
1449
1452
|
// src/lib/product-filter.ts
|
|
1450
|
-
function
|
|
1453
|
+
function Te(e) {
|
|
1451
1454
|
return e.status === "active" && e.quantity === 0;
|
|
1452
1455
|
}
|
|
1453
|
-
function
|
|
1454
|
-
return
|
|
1456
|
+
function Ee(e) {
|
|
1457
|
+
return Te(e) ? "sold" : e.status;
|
|
1455
1458
|
}
|
|
1456
|
-
function
|
|
1459
|
+
function De(e) {
|
|
1457
1460
|
switch (e) {
|
|
1458
1461
|
case "live":
|
|
1459
1462
|
case "sold": return "active";
|
|
@@ -1462,12 +1465,12 @@ function Oe(e) {
|
|
|
1462
1465
|
case "all": return;
|
|
1463
1466
|
}
|
|
1464
1467
|
}
|
|
1465
|
-
function
|
|
1468
|
+
function Oe(e) {
|
|
1466
1469
|
if (e === "live") return "in";
|
|
1467
1470
|
if (e === "sold") return "sold";
|
|
1468
1471
|
}
|
|
1469
1472
|
// src/lib/use-debounced.ts
|
|
1470
|
-
function
|
|
1473
|
+
function ke(e, t) {
|
|
1471
1474
|
let [n, r] = b(e);
|
|
1472
1475
|
return _(() => {
|
|
1473
1476
|
let n = setTimeout(() => r(e), t);
|
|
@@ -1475,7 +1478,7 @@ function Ae(e, t) {
|
|
|
1475
1478
|
}, [e, t]), n;
|
|
1476
1479
|
}
|
|
1477
1480
|
// src/lib/use-paged-list.ts
|
|
1478
|
-
function
|
|
1481
|
+
function Ae(e, t) {
|
|
1479
1482
|
let n = L(e, () => t()), [r, i] = b(null), a = R(async (e, n) => {
|
|
1480
1483
|
let r = await t(e);
|
|
1481
1484
|
i((e) => ({
|
|
@@ -1498,21 +1501,21 @@ function je(e, t) {
|
|
|
1498
1501
|
};
|
|
1499
1502
|
}
|
|
1500
1503
|
// src/lib/use-product-pages.ts
|
|
1501
|
-
function
|
|
1504
|
+
function je(e) {
|
|
1502
1505
|
let t = I();
|
|
1503
|
-
return
|
|
1506
|
+
return Ae(["admin-products", e], (n) => t.listProducts(n ? {
|
|
1504
1507
|
...e,
|
|
1505
1508
|
cursor: n
|
|
1506
1509
|
} : e));
|
|
1507
1510
|
}
|
|
1508
1511
|
// src/lib/product-sheet-actions.ts
|
|
1509
|
-
function
|
|
1512
|
+
function Me(e) {
|
|
1510
1513
|
return e.name.trim() !== "" && e.priceCents !== null && !!e.category && e.images.length > 0;
|
|
1511
1514
|
}
|
|
1512
|
-
function
|
|
1513
|
-
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";
|
|
1514
1517
|
}
|
|
1515
|
-
function
|
|
1518
|
+
function Pe(e, t) {
|
|
1516
1519
|
switch (t) {
|
|
1517
1520
|
case "publish": return {
|
|
1518
1521
|
patch: { status: "active" },
|
|
@@ -1533,28 +1536,28 @@ function Fe(e, t) {
|
|
|
1533
1536
|
case "finish": return null;
|
|
1534
1537
|
}
|
|
1535
1538
|
}
|
|
1536
|
-
var
|
|
1539
|
+
var Fe = {
|
|
1537
1540
|
patch: { status: "draft" },
|
|
1538
1541
|
undo: { status: "active" }
|
|
1539
1542
|
};
|
|
1540
|
-
function
|
|
1543
|
+
function Ie(e) {
|
|
1541
1544
|
return {
|
|
1542
1545
|
patch: { status: "archived" },
|
|
1543
1546
|
undo: { status: e.status }
|
|
1544
1547
|
};
|
|
1545
1548
|
}
|
|
1546
|
-
function
|
|
1549
|
+
function Le(e) {
|
|
1547
1550
|
return {
|
|
1548
1551
|
patch: { featured: !e.featured },
|
|
1549
1552
|
undo: { featured: e.featured }
|
|
1550
1553
|
};
|
|
1551
1554
|
}
|
|
1552
|
-
var
|
|
1555
|
+
var Re = (e) => e.status === "active";
|
|
1553
1556
|
// src/views/products/product-sheet/delete-draft-button.tsx
|
|
1554
|
-
function
|
|
1557
|
+
function ze(e) {
|
|
1555
1558
|
return e.status === "draft" && !e.everPublished;
|
|
1556
1559
|
}
|
|
1557
|
-
function
|
|
1560
|
+
function Be({ product: e, disabled: t, onDeleted: n }) {
|
|
1558
1561
|
let r = F().labels.products.sheet, i = I(), [a, o] = b(!1), s = R(async () => (await i.deleteProduct(e.id), !0));
|
|
1559
1562
|
return /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("button", {
|
|
1560
1563
|
type: "button",
|
|
@@ -1578,7 +1581,7 @@ function Ve({ product: e, disabled: t, onDeleted: n }) {
|
|
|
1578
1581
|
})] });
|
|
1579
1582
|
}
|
|
1580
1583
|
// src/views/products/product-sheet/sheet-carousel.tsx
|
|
1581
|
-
function
|
|
1584
|
+
function Ve({ product: e }) {
|
|
1582
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))];
|
|
1583
1586
|
if (!s) return /* @__PURE__ */ C("div", {
|
|
1584
1587
|
className: "sfa-sheet__photo",
|
|
@@ -1588,7 +1591,7 @@ function He({ product: e }) {
|
|
|
1588
1591
|
return /* @__PURE__ */ w("div", {
|
|
1589
1592
|
className: "sfa-sheet__photo",
|
|
1590
1593
|
role: "group",
|
|
1591
|
-
"aria-label":
|
|
1594
|
+
"aria-label": Y(r.photoOf, {
|
|
1592
1595
|
current: i + 1,
|
|
1593
1596
|
total: o
|
|
1594
1597
|
}),
|
|
@@ -1612,7 +1615,7 @@ function He({ product: e }) {
|
|
|
1612
1615
|
});
|
|
1613
1616
|
}
|
|
1614
1617
|
// src/views/products/product-sheet/use-product-change.ts
|
|
1615
|
-
function
|
|
1618
|
+
function He(e, t, n) {
|
|
1616
1619
|
let r = I(), [i, a] = b(null), o = R((t) => r.updateProduct(e.id, t)), s = async (e, r) => {
|
|
1617
1620
|
a(null);
|
|
1618
1621
|
let i = await o.run(e.patch);
|
|
@@ -1637,13 +1640,13 @@ function Ue(e, t, n) {
|
|
|
1637
1640
|
};
|
|
1638
1641
|
}
|
|
1639
1642
|
// src/views/products/product-sheet/sheet-edit-link.tsx
|
|
1640
|
-
function
|
|
1643
|
+
function Ue(e, t) {
|
|
1641
1644
|
return `${e}${e.includes("?") ? "&" : "?"}step=${t}`;
|
|
1642
1645
|
}
|
|
1643
|
-
function
|
|
1646
|
+
function We(e) {
|
|
1644
1647
|
return !e.name || e.priceCents === null || !e.category || e.images.length > 0 ? "basics" : "photos";
|
|
1645
1648
|
}
|
|
1646
|
-
function
|
|
1649
|
+
function Ge({ product: e, step: t, onEdit: n, className: r, children: i }) {
|
|
1647
1650
|
let { hrefs: a, renderLink: o } = F();
|
|
1648
1651
|
return n ? /* @__PURE__ */ C("button", {
|
|
1649
1652
|
type: "button",
|
|
@@ -1651,30 +1654,30 @@ function Ke({ product: e, step: t, onEdit: n, className: r, children: i }) {
|
|
|
1651
1654
|
onClick: () => n(e, t),
|
|
1652
1655
|
children: i
|
|
1653
1656
|
}) : o({
|
|
1654
|
-
href:
|
|
1657
|
+
href: Ue(a.product(e.id), t),
|
|
1655
1658
|
children: i,
|
|
1656
1659
|
className: r
|
|
1657
1660
|
});
|
|
1658
1661
|
}
|
|
1659
1662
|
// src/views/products/product-sheet/admin-product-sheet.tsx
|
|
1660
|
-
function
|
|
1663
|
+
function Ke({ productId: e, onClose: t, onEdit: n, onChanged: r }) {
|
|
1661
1664
|
let i = I(), a = L(["admin-product", e], () => i.getProduct(e)), [o, s] = b(null), c = o && o.id === e ? o : a.data;
|
|
1662
|
-
return /* @__PURE__ */ C(
|
|
1665
|
+
return /* @__PURE__ */ C(Je, {
|
|
1663
1666
|
onClose: t,
|
|
1664
|
-
children: c ? /* @__PURE__ */ C(
|
|
1667
|
+
children: c ? /* @__PURE__ */ C(Ye, {
|
|
1665
1668
|
product: c,
|
|
1666
1669
|
setProduct: s,
|
|
1667
1670
|
onEdit: n,
|
|
1668
1671
|
onChanged: r ?? (() => void 0),
|
|
1669
1672
|
onClose: t
|
|
1670
|
-
}) : /* @__PURE__ */ C(
|
|
1673
|
+
}) : /* @__PURE__ */ C(qe, { error: a.error })
|
|
1671
1674
|
});
|
|
1672
1675
|
}
|
|
1673
|
-
function
|
|
1676
|
+
function qe({ error: e }) {
|
|
1674
1677
|
let { labels: t } = F();
|
|
1675
1678
|
return e ? /* @__PURE__ */ C(q, { error: e }) : /* @__PURE__ */ C("p", { children: t.loading });
|
|
1676
1679
|
}
|
|
1677
|
-
function
|
|
1680
|
+
function Je({ onClose: e, children: t }) {
|
|
1678
1681
|
let { labels: n } = F(), r = y(null), i = ge(r, !0, e);
|
|
1679
1682
|
return /* @__PURE__ */ w("div", {
|
|
1680
1683
|
className: "sfa-sheet-layer",
|
|
@@ -1706,8 +1709,8 @@ function Ye({ onClose: e, children: t }) {
|
|
|
1706
1709
|
})]
|
|
1707
1710
|
});
|
|
1708
1711
|
}
|
|
1709
|
-
function
|
|
1710
|
-
let { labels: a, hrefs: o } = F(), s = a.products.sheet, c =
|
|
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 = {
|
|
1711
1714
|
product: e,
|
|
1712
1715
|
onEdit: n
|
|
1713
1716
|
}, p = async () => {
|
|
@@ -1716,7 +1719,7 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1716
1719
|
return /* @__PURE__ */ w("div", {
|
|
1717
1720
|
className: "sfa-sheet__body",
|
|
1718
1721
|
children: [
|
|
1719
|
-
/* @__PURE__ */ C(
|
|
1722
|
+
/* @__PURE__ */ C(Ve, { product: e }),
|
|
1720
1723
|
/* @__PURE__ */ C("h2", {
|
|
1721
1724
|
className: "sfa-sheet__name",
|
|
1722
1725
|
children: e.name
|
|
@@ -1724,7 +1727,7 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1724
1727
|
/* @__PURE__ */ w("p", {
|
|
1725
1728
|
className: "sfa-sheet__meta",
|
|
1726
1729
|
children: [
|
|
1727
|
-
/* @__PURE__ */ C(U, { status:
|
|
1730
|
+
/* @__PURE__ */ C(U, { status: Ee(e) }),
|
|
1728
1731
|
/* @__PURE__ */ C("span", { children: e.priceCents === null ? "—" : /* @__PURE__ */ C(W, {
|
|
1729
1732
|
cents: e.priceCents,
|
|
1730
1733
|
currency: e.currency
|
|
@@ -1749,9 +1752,9 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1749
1752
|
children: s.primary[l]
|
|
1750
1753
|
}) : /* @__PURE__ */ C("span", {
|
|
1751
1754
|
className: "sfa-sheet__primary",
|
|
1752
|
-
children: /* @__PURE__ */ C(
|
|
1755
|
+
children: /* @__PURE__ */ C(Ge, {
|
|
1753
1756
|
...f,
|
|
1754
|
-
step:
|
|
1757
|
+
step: We(e),
|
|
1755
1758
|
className: "sfa-btn sfa-btn--primary",
|
|
1756
1759
|
children: s.primary.finish
|
|
1757
1760
|
})
|
|
@@ -1759,30 +1762,30 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1759
1762
|
/* @__PURE__ */ w("div", {
|
|
1760
1763
|
className: "sfa-sheet__actions",
|
|
1761
1764
|
children: [
|
|
1762
|
-
/* @__PURE__ */ C(
|
|
1765
|
+
/* @__PURE__ */ C(Ge, {
|
|
1763
1766
|
...f,
|
|
1764
1767
|
step: "basics",
|
|
1765
1768
|
className: "sfa-btn",
|
|
1766
1769
|
children: s.edit
|
|
1767
1770
|
}),
|
|
1768
|
-
/* @__PURE__ */ C(
|
|
1771
|
+
/* @__PURE__ */ C(Ge, {
|
|
1769
1772
|
...f,
|
|
1770
1773
|
step: "photos",
|
|
1771
1774
|
className: "sfa-btn",
|
|
1772
|
-
children:
|
|
1775
|
+
children: Y(s.photos, { count: e.images.length })
|
|
1773
1776
|
}),
|
|
1774
|
-
|
|
1777
|
+
Re(e) ? /* @__PURE__ */ C("button", {
|
|
1775
1778
|
type: "button",
|
|
1776
1779
|
className: "sfa-btn",
|
|
1777
1780
|
disabled: c.pending,
|
|
1778
|
-
onClick: () => c.apply(
|
|
1781
|
+
onClick: () => c.apply(Le(e), s.done.feature),
|
|
1779
1782
|
children: e.featured ? s.featureOff : s.featureOn
|
|
1780
1783
|
}) : null,
|
|
1781
1784
|
e.status === "active" ? /* @__PURE__ */ C("button", {
|
|
1782
1785
|
type: "button",
|
|
1783
1786
|
className: "sfa-btn",
|
|
1784
1787
|
disabled: c.pending,
|
|
1785
|
-
onClick: () => c.apply(
|
|
1788
|
+
onClick: () => c.apply(Fe, s.done.hide),
|
|
1786
1789
|
children: s.hide
|
|
1787
1790
|
}) : null,
|
|
1788
1791
|
d ? /* @__PURE__ */ C("button", {
|
|
@@ -1791,7 +1794,7 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1791
1794
|
onClick: p,
|
|
1792
1795
|
children: s.copyLink
|
|
1793
1796
|
}) : null,
|
|
1794
|
-
|
|
1797
|
+
ze(e) ? /* @__PURE__ */ C(Be, {
|
|
1795
1798
|
product: e,
|
|
1796
1799
|
disabled: c.pending,
|
|
1797
1800
|
onDeleted: () => {
|
|
@@ -1801,7 +1804,7 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1801
1804
|
type: "button",
|
|
1802
1805
|
className: "sfa-btn",
|
|
1803
1806
|
disabled: c.pending,
|
|
1804
|
-
onClick: () => c.apply(
|
|
1807
|
+
onClick: () => c.apply(Ie(e), s.done.archive),
|
|
1805
1808
|
children: s.archive
|
|
1806
1809
|
})
|
|
1807
1810
|
]
|
|
@@ -1821,8 +1824,8 @@ function Xe({ product: e, setProduct: t, onEdit: n, onChanged: r, onClose: i })
|
|
|
1821
1824
|
});
|
|
1822
1825
|
}
|
|
1823
1826
|
// src/views/products/product-card.tsx
|
|
1824
|
-
function
|
|
1825
|
-
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", {
|
|
1826
1829
|
type: "button",
|
|
1827
1830
|
className: "sfa-card__name sfa-link--tap",
|
|
1828
1831
|
onClick: t,
|
|
@@ -1870,17 +1873,17 @@ function Ze({ product: e, onOpen: t }) {
|
|
|
1870
1873
|
});
|
|
1871
1874
|
}
|
|
1872
1875
|
// src/views/products/product-toolbar.tsx
|
|
1873
|
-
var
|
|
1876
|
+
var Ze = [
|
|
1874
1877
|
"all",
|
|
1875
1878
|
"live",
|
|
1876
1879
|
"sold",
|
|
1877
1880
|
"draft",
|
|
1878
1881
|
"archived"
|
|
1879
1882
|
];
|
|
1880
|
-
function
|
|
1883
|
+
function Qe(e, t) {
|
|
1881
1884
|
return t === "all" ? e.all : e[t];
|
|
1882
1885
|
}
|
|
1883
|
-
function
|
|
1886
|
+
function $e({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
1884
1887
|
let { labels: a } = F(), o = a.products, [s, c] = b(!1);
|
|
1885
1888
|
return /* @__PURE__ */ w("div", {
|
|
1886
1889
|
className: "sfa-products__toolbar",
|
|
@@ -1889,14 +1892,14 @@ function et({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
|
1889
1892
|
role: "group",
|
|
1890
1893
|
"aria-label": o.columns.status,
|
|
1891
1894
|
className: "sfa-filter-group",
|
|
1892
|
-
children:
|
|
1895
|
+
children: Ze.map((n) => /* @__PURE__ */ w("button", {
|
|
1893
1896
|
type: "button",
|
|
1894
1897
|
className: "sfa-chip",
|
|
1895
1898
|
"aria-pressed": e === n,
|
|
1896
1899
|
onClick: () => t(n),
|
|
1897
1900
|
children: [o.filters[n], i ? /* @__PURE__ */ C("span", {
|
|
1898
1901
|
className: "sfa-chip__count",
|
|
1899
|
-
children:
|
|
1902
|
+
children: Qe(i, n)
|
|
1900
1903
|
}) : null]
|
|
1901
1904
|
}, n))
|
|
1902
1905
|
}),
|
|
@@ -1919,7 +1922,7 @@ function et({ filter: e, onFilter: t, search: n, onSearch: r, counts: i }) {
|
|
|
1919
1922
|
});
|
|
1920
1923
|
}
|
|
1921
1924
|
// src/views/products/product-welcome.tsx
|
|
1922
|
-
function
|
|
1925
|
+
function et() {
|
|
1923
1926
|
return /* @__PURE__ */ w("svg", {
|
|
1924
1927
|
className: "sfa-welcome__art",
|
|
1925
1928
|
viewBox: "0 0 120 120",
|
|
@@ -1956,14 +1959,14 @@ function tt() {
|
|
|
1956
1959
|
]
|
|
1957
1960
|
});
|
|
1958
1961
|
}
|
|
1959
|
-
function
|
|
1962
|
+
function tt({ art: e, steps: t, onAddMany: n }) {
|
|
1960
1963
|
let { labels: r, hrefs: i, renderLink: a } = F(), o = r.products.welcome;
|
|
1961
1964
|
return /* @__PURE__ */ w("div", {
|
|
1962
1965
|
className: "sfa-welcome",
|
|
1963
1966
|
children: [/* @__PURE__ */ w("div", {
|
|
1964
1967
|
className: "sfa-welcome__hero",
|
|
1965
1968
|
children: [
|
|
1966
|
-
e ?? /* @__PURE__ */ C(
|
|
1969
|
+
e ?? /* @__PURE__ */ C(et, {}),
|
|
1967
1970
|
/* @__PURE__ */ C("h2", {
|
|
1968
1971
|
className: "sfa-welcome__title",
|
|
1969
1972
|
children: o.title
|
|
@@ -1986,12 +1989,12 @@ function nt({ art: e, steps: t, onAddMany: n }) {
|
|
|
1986
1989
|
}) : null]
|
|
1987
1990
|
})
|
|
1988
1991
|
]
|
|
1989
|
-
}), t ? /* @__PURE__ */ C(
|
|
1992
|
+
}), t ? /* @__PURE__ */ C(we, { steps: t }) : null]
|
|
1990
1993
|
});
|
|
1991
1994
|
}
|
|
1992
1995
|
// src/views/products/admin-product-list.tsx
|
|
1993
|
-
function
|
|
1994
|
-
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({
|
|
1995
1998
|
...g ? { status: g } : {},
|
|
1996
1999
|
...d === "all" ? { excludeArchived: "true" } : {},
|
|
1997
2000
|
..._ ? { stock: _ } : {},
|
|
@@ -2011,33 +2014,33 @@ function rt({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
2011
2014
|
floatingAction: O ? void 0 : N
|
|
2012
2015
|
}),
|
|
2013
2016
|
/* @__PURE__ */ C(q, { error: v.error ?? y.error }),
|
|
2014
|
-
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, {
|
|
2015
2018
|
art: e,
|
|
2016
2019
|
steps: t,
|
|
2017
2020
|
onAddMany: n
|
|
2018
2021
|
}) : /* @__PURE__ */ w(S, { children: [
|
|
2019
|
-
t ? /* @__PURE__ */ C(
|
|
2022
|
+
t ? /* @__PURE__ */ C(we, {
|
|
2020
2023
|
steps: t,
|
|
2021
2024
|
compact: !0
|
|
2022
2025
|
}) : null,
|
|
2023
2026
|
M > 0 ? /* @__PURE__ */ w("div", {
|
|
2024
2027
|
className: "sfa-banner",
|
|
2025
2028
|
role: "status",
|
|
2026
|
-
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", {
|
|
2027
2030
|
type: "button",
|
|
2028
2031
|
className: "sfa-btn",
|
|
2029
2032
|
onClick: r,
|
|
2030
2033
|
children: u.draftsBanner.finish
|
|
2031
2034
|
}) : null]
|
|
2032
2035
|
}) : null,
|
|
2033
|
-
/* @__PURE__ */ C(
|
|
2036
|
+
/* @__PURE__ */ C($e, {
|
|
2034
2037
|
filter: d,
|
|
2035
2038
|
onFilter: f,
|
|
2036
2039
|
search: p,
|
|
2037
2040
|
onSearch: m,
|
|
2038
2041
|
counts: D
|
|
2039
2042
|
}),
|
|
2040
|
-
A.length === 0 ? /* @__PURE__ */ C(
|
|
2043
|
+
A.length === 0 ? /* @__PURE__ */ C(J, {
|
|
2041
2044
|
icon: h ? "search" : "products",
|
|
2042
2045
|
title: j,
|
|
2043
2046
|
action: h ? /* @__PURE__ */ C("button", {
|
|
@@ -2057,7 +2060,7 @@ function rt({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
2057
2060
|
}) : null] })
|
|
2058
2061
|
}) : /* @__PURE__ */ C("ul", {
|
|
2059
2062
|
className: "sfa-grid",
|
|
2060
|
-
children: A.map((e) => /* @__PURE__ */ C(
|
|
2063
|
+
children: A.map((e) => /* @__PURE__ */ C(Xe, {
|
|
2061
2064
|
product: e,
|
|
2062
2065
|
onOpen: () => i ? i(e) : T(e.id)
|
|
2063
2066
|
}, e.id))
|
|
@@ -2070,7 +2073,7 @@ function rt({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
2070
2073
|
children: u.loadMore
|
|
2071
2074
|
}) : null
|
|
2072
2075
|
] }),
|
|
2073
|
-
x ? /* @__PURE__ */ C(
|
|
2076
|
+
x ? /* @__PURE__ */ C(Ke, {
|
|
2074
2077
|
productId: x,
|
|
2075
2078
|
onClose: () => T(null),
|
|
2076
2079
|
onEdit: a,
|
|
@@ -2080,7 +2083,7 @@ function rt({ welcome: e, setup: t, onAddMany: n, onFinishDrafts: r, onOpenProdu
|
|
|
2080
2083
|
});
|
|
2081
2084
|
}
|
|
2082
2085
|
// src/components/switch/switch.tsx
|
|
2083
|
-
function
|
|
2086
|
+
function rt({ id: e, label: t, checked: n, onChange: r }) {
|
|
2084
2087
|
return /* @__PURE__ */ w("label", {
|
|
2085
2088
|
className: "sfa-switch",
|
|
2086
2089
|
htmlFor: e,
|
|
@@ -2094,95 +2097,98 @@ function it({ id: e, label: t, checked: n, onChange: r }) {
|
|
|
2094
2097
|
});
|
|
2095
2098
|
}
|
|
2096
2099
|
// src/lib/money-input.ts
|
|
2097
|
-
var
|
|
2098
|
-
function
|
|
2099
|
-
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);
|
|
2100
2103
|
if (!n || !n[1] && !n[2]) return null;
|
|
2101
2104
|
let r = Number((n[1] ?? "0").replace(/,/g, "")), i = Number((n[2] ?? "").padEnd(2, "0")), a = r * 100 + i;
|
|
2102
2105
|
return Number.isSafeInteger(a) ? a : null;
|
|
2103
2106
|
}
|
|
2104
|
-
function
|
|
2107
|
+
function Z(e) {
|
|
2105
2108
|
return `${Math.floor(e / 100)}.${String(e % 100).padStart(2, "0")}`;
|
|
2106
2109
|
}
|
|
2107
2110
|
// src/lib/product-draft.ts
|
|
2108
|
-
function
|
|
2111
|
+
function at(e) {
|
|
2109
2112
|
let t = e.trim();
|
|
2110
2113
|
return t === "" ? null : t;
|
|
2111
2114
|
}
|
|
2112
|
-
function
|
|
2115
|
+
function ot(e) {
|
|
2113
2116
|
return /^\d+$/.test(e.trim()) ? Number(e.trim()) : null;
|
|
2114
2117
|
}
|
|
2115
|
-
function
|
|
2116
|
-
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);
|
|
2117
2120
|
return {
|
|
2118
2121
|
...t ? { name: t } : {},
|
|
2119
2122
|
...n ? { category: n } : {},
|
|
2120
2123
|
...r === null ? {} : { priceCents: r },
|
|
2121
2124
|
...i === null ? {} : { quantity: i },
|
|
2122
2125
|
description: e.description,
|
|
2123
|
-
materials:
|
|
2124
|
-
dimensions:
|
|
2125
|
-
featured: e.featured
|
|
2126
|
+
materials: at(e.materials),
|
|
2127
|
+
dimensions: at(e.dimensions),
|
|
2128
|
+
featured: e.featured,
|
|
2129
|
+
taxCode: at(e.taxCode)
|
|
2126
2130
|
};
|
|
2127
2131
|
}
|
|
2128
|
-
function
|
|
2132
|
+
function ct(e) {
|
|
2129
2133
|
return e.name.trim() !== "";
|
|
2130
2134
|
}
|
|
2131
|
-
function
|
|
2135
|
+
function lt(e, t) {
|
|
2136
|
+
let { taxCode: n, ...r } = st(e);
|
|
2132
2137
|
return {
|
|
2133
|
-
...
|
|
2138
|
+
...r,
|
|
2139
|
+
...n ? { taxCode: n } : {},
|
|
2134
2140
|
...t ? { currency: t } : {},
|
|
2135
2141
|
status: "draft"
|
|
2136
2142
|
};
|
|
2137
2143
|
}
|
|
2138
|
-
function
|
|
2144
|
+
function ut(e, t) {
|
|
2139
2145
|
let n = {};
|
|
2140
|
-
for (let [r, i] of Object.entries(
|
|
2146
|
+
for (let [r, i] of Object.entries(st(t))) i !== (e[r] ?? null) && (n[r] = i);
|
|
2141
2147
|
return n;
|
|
2142
2148
|
}
|
|
2143
|
-
function
|
|
2144
|
-
return e.name.trim() !== "" && e.category.trim() !== "" &&
|
|
2149
|
+
function dt(e) {
|
|
2150
|
+
return e.name.trim() !== "" && e.category.trim() !== "" && X(e.price) !== null;
|
|
2145
2151
|
}
|
|
2146
|
-
function
|
|
2152
|
+
function ft(e) {
|
|
2147
2153
|
let t = [];
|
|
2148
|
-
return e.name.trim() === "" && t.push("name"),
|
|
2154
|
+
return e.name.trim() === "" && t.push("name"), X(e.price) === null && t.push("price"), e.category.trim() === "" && t.push("category"), t;
|
|
2149
2155
|
}
|
|
2150
|
-
function
|
|
2156
|
+
function pt(e) {
|
|
2151
2157
|
return e.replace(/(^|[\s-])(\p{L})/gu, (e, t, n) => t + n.toUpperCase());
|
|
2152
2158
|
}
|
|
2153
|
-
function
|
|
2159
|
+
function mt(e) {
|
|
2154
2160
|
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
2155
2161
|
}
|
|
2156
|
-
function
|
|
2157
|
-
return [...e, ...
|
|
2162
|
+
function ht(e, t) {
|
|
2163
|
+
return [...e, ...mt(t)].join(", ");
|
|
2158
2164
|
}
|
|
2159
|
-
function
|
|
2165
|
+
function gt(e, t) {
|
|
2160
2166
|
let n = e.trimEnd();
|
|
2161
2167
|
return n ? `${n}\n${t}` : t;
|
|
2162
2168
|
}
|
|
2163
|
-
function
|
|
2169
|
+
function _t(e, t) {
|
|
2164
2170
|
return new Intl.NumberFormat(e, {
|
|
2165
2171
|
style: "currency",
|
|
2166
2172
|
currency: t
|
|
2167
2173
|
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? t;
|
|
2168
2174
|
}
|
|
2169
|
-
function
|
|
2175
|
+
function Q(e, t) {
|
|
2170
2176
|
return e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? "");
|
|
2171
2177
|
}
|
|
2172
2178
|
// src/views/products/product-flow/basics-section.tsx
|
|
2173
|
-
function
|
|
2179
|
+
function vt(e, t, n) {
|
|
2174
2180
|
let r = t.trim();
|
|
2175
2181
|
return n || !r || e.includes(r) ? e : [...e, r];
|
|
2176
2182
|
}
|
|
2177
|
-
function
|
|
2178
|
-
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");
|
|
2179
2185
|
return /* @__PURE__ */ w(S, { children: [
|
|
2180
2186
|
/* @__PURE__ */ w("div", {
|
|
2181
2187
|
className: "sfa-field",
|
|
2182
2188
|
children: [/* @__PURE__ */ C("label", {
|
|
2183
2189
|
className: "sfa-field__label",
|
|
2184
2190
|
htmlFor: "sfa-flow-name",
|
|
2185
|
-
children:
|
|
2191
|
+
children: c.name
|
|
2186
2192
|
}), /* @__PURE__ */ C("input", {
|
|
2187
2193
|
id: "sfa-flow-name",
|
|
2188
2194
|
type: "text",
|
|
@@ -2196,23 +2202,23 @@ function bt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2196
2202
|
children: [/* @__PURE__ */ C("label", {
|
|
2197
2203
|
className: "sfa-field__label",
|
|
2198
2204
|
htmlFor: "sfa-flow-price",
|
|
2199
|
-
children:
|
|
2205
|
+
children: c.price
|
|
2200
2206
|
}), /* @__PURE__ */ w("span", {
|
|
2201
2207
|
className: "sfa-flow__price",
|
|
2202
2208
|
children: [/* @__PURE__ */ C("span", {
|
|
2203
2209
|
"aria-hidden": "true",
|
|
2204
|
-
children:
|
|
2210
|
+
children: _t(o, r)
|
|
2205
2211
|
}), /* @__PURE__ */ C("input", {
|
|
2206
2212
|
id: "sfa-flow-price",
|
|
2207
2213
|
type: "text",
|
|
2208
2214
|
inputMode: "decimal",
|
|
2209
|
-
placeholder:
|
|
2215
|
+
placeholder: s.pricePlaceholder,
|
|
2210
2216
|
value: e.price,
|
|
2211
2217
|
onChange: (e) => t("price", e.target.value)
|
|
2212
2218
|
})]
|
|
2213
2219
|
})]
|
|
2214
2220
|
}),
|
|
2215
|
-
|
|
2221
|
+
l.length ? /* @__PURE__ */ w("div", {
|
|
2216
2222
|
className: "sfa-field",
|
|
2217
2223
|
role: "group",
|
|
2218
2224
|
"aria-labelledby": "sfa-flow-category-label",
|
|
@@ -2220,31 +2226,31 @@ function bt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2220
2226
|
/* @__PURE__ */ C("span", {
|
|
2221
2227
|
id: "sfa-flow-category-label",
|
|
2222
2228
|
className: "sfa-field__label",
|
|
2223
|
-
children:
|
|
2229
|
+
children: c.category
|
|
2224
2230
|
}),
|
|
2225
2231
|
/* @__PURE__ */ w("div", {
|
|
2226
2232
|
className: "sfa-flow__chips",
|
|
2227
|
-
children: [
|
|
2233
|
+
children: [f.map((n) => /* @__PURE__ */ C("button", {
|
|
2228
2234
|
type: "button",
|
|
2229
2235
|
className: "sfa-chip",
|
|
2230
|
-
"aria-pressed": !
|
|
2236
|
+
"aria-pressed": !u && e.category.trim() === n,
|
|
2231
2237
|
onClick: () => {
|
|
2232
|
-
|
|
2238
|
+
d(!1), t("category", n);
|
|
2233
2239
|
},
|
|
2234
|
-
children:
|
|
2235
|
-
}, n)),
|
|
2240
|
+
children: pt(n)
|
|
2241
|
+
}, n)), p ? null : /* @__PURE__ */ C("button", {
|
|
2236
2242
|
type: "button",
|
|
2237
2243
|
className: "sfa-chip",
|
|
2238
|
-
"aria-pressed":
|
|
2244
|
+
"aria-pressed": u,
|
|
2239
2245
|
onClick: () => {
|
|
2240
|
-
|
|
2246
|
+
d(!0), t("category", "");
|
|
2241
2247
|
},
|
|
2242
|
-
children:
|
|
2248
|
+
children: s.otherCategory
|
|
2243
2249
|
})]
|
|
2244
2250
|
}),
|
|
2245
|
-
|
|
2251
|
+
u ? /* @__PURE__ */ C("input", {
|
|
2246
2252
|
type: "text",
|
|
2247
|
-
"aria-label":
|
|
2253
|
+
"aria-label": s.newCategory,
|
|
2248
2254
|
value: e.category,
|
|
2249
2255
|
onChange: (e) => t("category", e.target.value)
|
|
2250
2256
|
}) : null
|
|
@@ -2254,7 +2260,7 @@ function bt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2254
2260
|
children: [/* @__PURE__ */ C("label", {
|
|
2255
2261
|
className: "sfa-field__label",
|
|
2256
2262
|
htmlFor: "sfa-flow-category",
|
|
2257
|
-
children:
|
|
2263
|
+
children: c.category
|
|
2258
2264
|
}), /* @__PURE__ */ C("input", {
|
|
2259
2265
|
id: "sfa-flow-category",
|
|
2260
2266
|
type: "text",
|
|
@@ -2262,20 +2268,20 @@ function bt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2262
2268
|
onChange: (e) => t("category", e.target.value)
|
|
2263
2269
|
})]
|
|
2264
2270
|
}),
|
|
2265
|
-
/* @__PURE__ */ C(
|
|
2271
|
+
/* @__PURE__ */ C(rt, {
|
|
2266
2272
|
id: "sfa-flow-one-of-a-kind",
|
|
2267
|
-
label:
|
|
2268
|
-
checked:
|
|
2273
|
+
label: s.oneOfAKind,
|
|
2274
|
+
checked: m,
|
|
2269
2275
|
onChange: (n) => {
|
|
2270
|
-
|
|
2276
|
+
h(n), n ? t("quantity", "1") : e.quantity.trim() === "1" && t("quantity", "2");
|
|
2271
2277
|
}
|
|
2272
2278
|
}),
|
|
2273
|
-
|
|
2279
|
+
m ? null : /* @__PURE__ */ w("div", {
|
|
2274
2280
|
className: "sfa-field",
|
|
2275
2281
|
children: [/* @__PURE__ */ C("label", {
|
|
2276
2282
|
className: "sfa-field__label",
|
|
2277
2283
|
htmlFor: "sfa-flow-quantity",
|
|
2278
|
-
children:
|
|
2284
|
+
children: s.howMany
|
|
2279
2285
|
}), /* @__PURE__ */ C("input", {
|
|
2280
2286
|
id: "sfa-flow-quantity",
|
|
2281
2287
|
type: "text",
|
|
@@ -2283,19 +2289,38 @@ function bt({ form: e, update: t, categories: n, currency: r }) {
|
|
|
2283
2289
|
value: e.quantity,
|
|
2284
2290
|
onChange: (e) => t("quantity", e.target.value)
|
|
2285
2291
|
})]
|
|
2286
|
-
})
|
|
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
|
|
2287
2312
|
] });
|
|
2288
2313
|
}
|
|
2289
2314
|
// src/views/products/product-flow/flow-actions.tsx
|
|
2290
|
-
function
|
|
2315
|
+
function bt(e) {
|
|
2291
2316
|
let t = M.indexOf(e);
|
|
2292
2317
|
return M[Math.min(t + 1, M.length - 1)];
|
|
2293
2318
|
}
|
|
2294
|
-
function
|
|
2319
|
+
function xt(e) {
|
|
2295
2320
|
let t = M.indexOf(e);
|
|
2296
2321
|
return t > 0 ? M[t - 1] : null;
|
|
2297
2322
|
}
|
|
2298
|
-
function
|
|
2323
|
+
function St({ flow: e }) {
|
|
2299
2324
|
let { labels: t } = F(), n = t.products.flow;
|
|
2300
2325
|
return (e.product?.status ?? "draft") === "draft" ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("button", {
|
|
2301
2326
|
type: "button",
|
|
@@ -2317,8 +2342,8 @@ function Ct({ flow: e }) {
|
|
|
2317
2342
|
children: n.saveChanges
|
|
2318
2343
|
});
|
|
2319
2344
|
}
|
|
2320
|
-
function
|
|
2321
|
-
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));
|
|
2322
2347
|
if (e.step === "photos") {
|
|
2323
2348
|
let t = (e.product?.images.length ?? 0) > 0;
|
|
2324
2349
|
return /* @__PURE__ */ C("button", {
|
|
@@ -2331,7 +2356,7 @@ function wt({ flow: e }) {
|
|
|
2331
2356
|
return e.step === "basics" ? /* @__PURE__ */ C("button", {
|
|
2332
2357
|
type: "button",
|
|
2333
2358
|
className: "sfa-btn sfa-btn--primary",
|
|
2334
|
-
disabled: !
|
|
2359
|
+
disabled: !dt(e.form),
|
|
2335
2360
|
"aria-describedby": "sfa-flow-continue-hint",
|
|
2336
2361
|
onClick: r,
|
|
2337
2362
|
children: n.continue
|
|
@@ -2345,12 +2370,12 @@ function wt({ flow: e }) {
|
|
|
2345
2370
|
className: "sfa-btn sfa-btn--primary",
|
|
2346
2371
|
onClick: r,
|
|
2347
2372
|
children: n.continue
|
|
2348
|
-
})] }) : /* @__PURE__ */ C(
|
|
2373
|
+
})] }) : /* @__PURE__ */ C(St, { flow: e });
|
|
2349
2374
|
}
|
|
2350
|
-
function
|
|
2375
|
+
function wt({ flow: e }) {
|
|
2351
2376
|
let { labels: t, locale: n } = F(), r = t.products.flow;
|
|
2352
2377
|
if (e.step !== "basics") return null;
|
|
2353
|
-
let i =
|
|
2378
|
+
let i = ft(e.form);
|
|
2354
2379
|
if (!i.length) return null;
|
|
2355
2380
|
let a = new Intl.ListFormat(n, {
|
|
2356
2381
|
style: "long",
|
|
@@ -2359,11 +2384,11 @@ function Tt({ flow: e }) {
|
|
|
2359
2384
|
return /* @__PURE__ */ C("p", {
|
|
2360
2385
|
id: "sfa-flow-continue-hint",
|
|
2361
2386
|
className: "sfa-flow__hint",
|
|
2362
|
-
children:
|
|
2387
|
+
children: Q(r.continueNeeds, { things: a })
|
|
2363
2388
|
});
|
|
2364
2389
|
}
|
|
2365
2390
|
// src/views/products/product-flow/flow-frame.tsx
|
|
2366
|
-
function
|
|
2391
|
+
function Tt({ title: e, step: t, onBack: n, canGoBack: r, close: i }) {
|
|
2367
2392
|
let { labels: a } = F(), o = a.products.flow;
|
|
2368
2393
|
return /* @__PURE__ */ w("div", {
|
|
2369
2394
|
className: "sfa-flow__head",
|
|
@@ -2390,7 +2415,7 @@ function Et({ title: e, step: t, onBack: n, canGoBack: r, close: i }) {
|
|
|
2390
2415
|
/* @__PURE__ */ w("p", {
|
|
2391
2416
|
className: "sfa-flow__step-count",
|
|
2392
2417
|
children: [
|
|
2393
|
-
|
|
2418
|
+
Q(o.stepCount, {
|
|
2394
2419
|
n: String(M.indexOf(t) + 1),
|
|
2395
2420
|
total: String(M.length)
|
|
2396
2421
|
}),
|
|
@@ -2402,7 +2427,7 @@ function Et({ title: e, step: t, onBack: n, canGoBack: r, close: i }) {
|
|
|
2402
2427
|
]
|
|
2403
2428
|
});
|
|
2404
2429
|
}
|
|
2405
|
-
function
|
|
2430
|
+
function Et({ step: e, allOpen: t, onStep: n }) {
|
|
2406
2431
|
let { labels: r } = F(), i = r.products.flow, a = M.indexOf(e);
|
|
2407
2432
|
return /* @__PURE__ */ C("nav", {
|
|
2408
2433
|
className: "sfa-flow__steps",
|
|
@@ -2417,7 +2442,7 @@ function Dt({ step: e, allOpen: t, onStep: n }) {
|
|
|
2417
2442
|
}) }, e)) })
|
|
2418
2443
|
});
|
|
2419
2444
|
}
|
|
2420
|
-
function
|
|
2445
|
+
function Dt({ state: e, isNew: t, onRetry: n }) {
|
|
2421
2446
|
let { labels: r } = F(), i = r.products.flow;
|
|
2422
2447
|
return e === "idle" ? null : e === "error" ? /* @__PURE__ */ w("div", {
|
|
2423
2448
|
className: "sfa-flow__saved is-error",
|
|
@@ -2438,7 +2463,7 @@ function Ot({ state: e, isNew: t, onRetry: n }) {
|
|
|
2438
2463
|
}), e === "saving" ? i.saving : t ? i.savedNew : i.savedEdit]
|
|
2439
2464
|
});
|
|
2440
2465
|
}
|
|
2441
|
-
function
|
|
2466
|
+
function Ot({ step: e, active: t, live: n, children: r }) {
|
|
2442
2467
|
let { labels: i } = F(), a = i.products.flow;
|
|
2443
2468
|
return /* @__PURE__ */ w("section", {
|
|
2444
2469
|
id: `sfa-flow-${e}`,
|
|
@@ -2459,12 +2484,12 @@ function kt({ step: e, active: t, live: n, children: r }) {
|
|
|
2459
2484
|
});
|
|
2460
2485
|
}
|
|
2461
2486
|
// src/views/products/product-flow/flow-images.ts
|
|
2462
|
-
function
|
|
2487
|
+
function $(e) {
|
|
2463
2488
|
return [...e?.images ?? []].sort((e, t) => e.position - t.position);
|
|
2464
2489
|
}
|
|
2465
2490
|
// src/views/products/product-flow/flow-success.tsx
|
|
2466
|
-
function
|
|
2467
|
-
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);
|
|
2468
2493
|
return /* @__PURE__ */ w("section", {
|
|
2469
2494
|
className: "sfa-flow-success",
|
|
2470
2495
|
"aria-labelledby": "sfa-flow-success",
|
|
@@ -2510,20 +2535,20 @@ function At({ success: e, onAddAnother: t, onDone: n }) {
|
|
|
2510
2535
|
]
|
|
2511
2536
|
});
|
|
2512
2537
|
}
|
|
2513
|
-
var
|
|
2538
|
+
var At = [
|
|
2514
2539
|
"image/jpeg",
|
|
2515
2540
|
"image/png",
|
|
2516
2541
|
"image/webp",
|
|
2517
2542
|
"image/heic"
|
|
2518
2543
|
];
|
|
2519
|
-
function
|
|
2544
|
+
function jt(e, t) {
|
|
2520
2545
|
return e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? "");
|
|
2521
2546
|
}
|
|
2522
|
-
function
|
|
2523
|
-
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 });
|
|
2524
2549
|
}
|
|
2525
2550
|
// src/lib/use-image-upload.ts
|
|
2526
|
-
function
|
|
2551
|
+
function Nt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
2527
2552
|
let r = I(), { labels: i } = F(), [a, o] = b([]), s = y(0), c = y(Promise.resolve()), l = y(n), u = y({
|
|
2528
2553
|
productId: e,
|
|
2529
2554
|
resolveProductId: t
|
|
@@ -2560,7 +2585,7 @@ function Pt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
|
2560
2585
|
let n = e.map((e) => ({
|
|
2561
2586
|
id: s.current++,
|
|
2562
2587
|
file: e,
|
|
2563
|
-
reason:
|
|
2588
|
+
reason: Mt(e, i.products.images)
|
|
2564
2589
|
}));
|
|
2565
2590
|
o((e) => [...e, ...n.map(({ id: e, file: t, reason: n }) => ({
|
|
2566
2591
|
id: e,
|
|
@@ -2574,8 +2599,8 @@ function Pt({ productId: e, resolveProductId: t, onUploaded: n }) {
|
|
|
2574
2599
|
};
|
|
2575
2600
|
}
|
|
2576
2601
|
// src/views/products/product-flow/photos-section.tsx
|
|
2577
|
-
function
|
|
2578
|
-
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({
|
|
2579
2604
|
productId: e?.id,
|
|
2580
2605
|
resolveProductId: async () => (await t()).id,
|
|
2581
2606
|
onUploaded: n
|
|
@@ -2626,7 +2651,7 @@ function Ft({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
|
2626
2651
|
children: [/* @__PURE__ */ w("button", {
|
|
2627
2652
|
type: "button",
|
|
2628
2653
|
className: "sfa-flow__thumb-pick",
|
|
2629
|
-
"aria-label": t === 0 ? `${
|
|
2654
|
+
"aria-label": t === 0 ? `${Q(s.photoN, { n })}, ${s.cover}` : Q(s.makeCover, { n }),
|
|
2630
2655
|
"aria-pressed": t === 0,
|
|
2631
2656
|
disabled: u,
|
|
2632
2657
|
onClick: () => t === 0 ? void 0 : y(e.id),
|
|
@@ -2641,14 +2666,14 @@ function Ft({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
|
2641
2666
|
}), /* @__PURE__ */ C("button", {
|
|
2642
2667
|
type: "button",
|
|
2643
2668
|
className: "sfa-flow__thumb-remove",
|
|
2644
|
-
"aria-label":
|
|
2669
|
+
"aria-label": Q(s.removePhoto, { n }),
|
|
2645
2670
|
disabled: u,
|
|
2646
2671
|
onClick: () => v((t) => i.deleteProductImage(t, e.id)),
|
|
2647
2672
|
children: "✕"
|
|
2648
2673
|
})]
|
|
2649
2674
|
}, e.id);
|
|
2650
2675
|
}),
|
|
2651
|
-
p.map((e) => /* @__PURE__ */ C(
|
|
2676
|
+
p.map((e) => /* @__PURE__ */ C(Ft, {
|
|
2652
2677
|
entry: e,
|
|
2653
2678
|
onDismiss: h
|
|
2654
2679
|
}, e.id)),
|
|
@@ -2664,7 +2689,7 @@ function Ft({ product: e, ensureProduct: t, setProduct: n, imagesSlot: r }) {
|
|
|
2664
2689
|
})
|
|
2665
2690
|
] });
|
|
2666
2691
|
}
|
|
2667
|
-
function
|
|
2692
|
+
function Ft({ entry: e, onDismiss: t }) {
|
|
2668
2693
|
let { labels: n } = F();
|
|
2669
2694
|
return e.status === "error" ? /* @__PURE__ */ w("li", {
|
|
2670
2695
|
className: "sfa-flow__thumb is-failed",
|
|
@@ -2683,13 +2708,13 @@ function It({ entry: e, onDismiss: t }) {
|
|
|
2683
2708
|
children: /* @__PURE__ */ C("span", {
|
|
2684
2709
|
className: "sfa-spinner",
|
|
2685
2710
|
role: "status",
|
|
2686
|
-
children:
|
|
2711
|
+
children: Q(n.products.flow.uploading, { name: e.name })
|
|
2687
2712
|
})
|
|
2688
2713
|
});
|
|
2689
2714
|
}
|
|
2690
2715
|
// src/views/products/product-flow/preview-section.tsx
|
|
2691
|
-
function
|
|
2692
|
-
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);
|
|
2693
2718
|
return /* @__PURE__ */ w(S, { children: [
|
|
2694
2719
|
/* @__PURE__ */ w("div", {
|
|
2695
2720
|
className: "sfa-flow__preview",
|
|
@@ -2731,7 +2756,7 @@ function Lt({ form: e, update: t, product: n, currency: r, missing: i, actions:
|
|
|
2731
2756
|
}) : null
|
|
2732
2757
|
]
|
|
2733
2758
|
}),
|
|
2734
|
-
/* @__PURE__ */ C(
|
|
2759
|
+
/* @__PURE__ */ C(rt, {
|
|
2735
2760
|
id: "sfa-flow-featured",
|
|
2736
2761
|
label: c.featured,
|
|
2737
2762
|
checked: e.featured,
|
|
@@ -2752,19 +2777,19 @@ function Lt({ form: e, update: t, product: n, currency: r, missing: i, actions:
|
|
|
2752
2777
|
] });
|
|
2753
2778
|
}
|
|
2754
2779
|
// src/views/products/product-flow/materials-field.tsx
|
|
2755
|
-
function
|
|
2756
|
-
let n =
|
|
2780
|
+
function Lt(e, t) {
|
|
2781
|
+
let n = mt(e);
|
|
2757
2782
|
return {
|
|
2758
2783
|
picked: n.filter((e) => t.includes(e)),
|
|
2759
2784
|
custom: n.filter((e) => !t.includes(e)).join(", ")
|
|
2760
2785
|
};
|
|
2761
2786
|
}
|
|
2762
|
-
function
|
|
2763
|
-
let { labels: r } = F(), i =
|
|
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) => {
|
|
2764
2789
|
let t = a.includes(e) ? a.filter((t) => t !== e) : [...a, e];
|
|
2765
|
-
o(t), n(
|
|
2790
|
+
o(t), n(ht(t, s));
|
|
2766
2791
|
}, u = (e) => {
|
|
2767
|
-
c(e), n(
|
|
2792
|
+
c(e), n(ht(a, e));
|
|
2768
2793
|
};
|
|
2769
2794
|
return /* @__PURE__ */ w("div", {
|
|
2770
2795
|
className: "sfa-field",
|
|
@@ -2795,8 +2820,8 @@ function zt({ value: e, suggestions: t = [], onChange: n }) {
|
|
|
2795
2820
|
});
|
|
2796
2821
|
}
|
|
2797
2822
|
// src/views/products/product-flow/story-section.tsx
|
|
2798
|
-
function
|
|
2799
|
-
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);
|
|
2800
2825
|
return /* @__PURE__ */ w(S, { children: [
|
|
2801
2826
|
/* @__PURE__ */ w("div", {
|
|
2802
2827
|
className: "sfa-field",
|
|
@@ -2818,13 +2843,13 @@ function Bt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2818
2843
|
children: c.map((n) => /* @__PURE__ */ w("button", {
|
|
2819
2844
|
type: "button",
|
|
2820
2845
|
className: "sfa-chip",
|
|
2821
|
-
onClick: () => t("description",
|
|
2846
|
+
onClick: () => t("description", gt(e.description, n)),
|
|
2822
2847
|
children: ["+ ", n]
|
|
2823
2848
|
}, n))
|
|
2824
2849
|
}) : null
|
|
2825
2850
|
]
|
|
2826
2851
|
}),
|
|
2827
|
-
/* @__PURE__ */ C(
|
|
2852
|
+
/* @__PURE__ */ C(Rt, {
|
|
2828
2853
|
value: e.materials,
|
|
2829
2854
|
suggestions: i,
|
|
2830
2855
|
onChange: (e) => t("materials", e)
|
|
@@ -2854,11 +2879,11 @@ function Bt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2854
2879
|
className: "sfa-field__help",
|
|
2855
2880
|
children: o.altHelp
|
|
2856
2881
|
}),
|
|
2857
|
-
l.map((t, i) => /* @__PURE__ */ C(
|
|
2882
|
+
l.map((t, i) => /* @__PURE__ */ C(Bt, {
|
|
2858
2883
|
productId: n.id,
|
|
2859
2884
|
image: t,
|
|
2860
|
-
label:
|
|
2861
|
-
placeholder: o.altPlaceholder ||
|
|
2885
|
+
label: Q(o.photoN, { n: String(i + 1) }),
|
|
2886
|
+
placeholder: o.altPlaceholder || Q(o.altFallback, {
|
|
2862
2887
|
name: e.name.trim() || o.untitled,
|
|
2863
2888
|
n: String(i + 1)
|
|
2864
2889
|
}),
|
|
@@ -2868,7 +2893,7 @@ function Bt({ form: e, update: t, product: n, setProduct: r, materialSuggestions
|
|
|
2868
2893
|
}) : null
|
|
2869
2894
|
] });
|
|
2870
2895
|
}
|
|
2871
|
-
function
|
|
2896
|
+
function Bt({ productId: e, image: t, label: n, placeholder: r, onSaved: i }) {
|
|
2872
2897
|
let a = I(), [o, s] = b(t.alt), [c, l] = b(void 0), u = `sfa-flow-alt-${t.id}`;
|
|
2873
2898
|
return /* @__PURE__ */ w("div", {
|
|
2874
2899
|
className: "sfa-field",
|
|
@@ -2899,6 +2924,21 @@ function Vt({ productId: e, image: t, label: n, placeholder: r, onSaved: i }) {
|
|
|
2899
2924
|
]
|
|
2900
2925
|
});
|
|
2901
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
|
+
}
|
|
2902
2942
|
// src/lib/product-form.ts
|
|
2903
2943
|
var Ht = {
|
|
2904
2944
|
name: "",
|
|
@@ -2909,7 +2949,8 @@ var Ht = {
|
|
|
2909
2949
|
price: "",
|
|
2910
2950
|
quantity: "1",
|
|
2911
2951
|
status: "draft",
|
|
2912
|
-
featured: !1
|
|
2952
|
+
featured: !1,
|
|
2953
|
+
taxCode: ""
|
|
2913
2954
|
};
|
|
2914
2955
|
function Ut(e) {
|
|
2915
2956
|
return {
|
|
@@ -2918,10 +2959,11 @@ function Ut(e) {
|
|
|
2918
2959
|
description: e.description,
|
|
2919
2960
|
materials: e.materials ?? "",
|
|
2920
2961
|
dimensions: e.dimensions ?? "",
|
|
2921
|
-
price: e.priceCents === null ? "" :
|
|
2962
|
+
price: e.priceCents === null ? "" : Z(e.priceCents),
|
|
2922
2963
|
quantity: String(e.quantity),
|
|
2923
2964
|
status: e.status,
|
|
2924
|
-
featured: e.featured
|
|
2965
|
+
featured: e.featured,
|
|
2966
|
+
taxCode: e.taxCode ?? ""
|
|
2925
2967
|
};
|
|
2926
2968
|
}
|
|
2927
2969
|
// src/lib/use-product-autosave.ts
|
|
@@ -2930,12 +2972,12 @@ function Wt({ initial: e, form: t, currency: n, delayMs: r = 600 }) {
|
|
|
2930
2972
|
d.current = e, o(e);
|
|
2931
2973
|
}, []), v = h(async (e) => {
|
|
2932
2974
|
let t = d.current, r = f.current;
|
|
2933
|
-
if (!t && !e && !
|
|
2934
|
-
let a = t ?
|
|
2975
|
+
if (!t && !e && !ct(r)) return null;
|
|
2976
|
+
let a = t ? ut(t, r) : null;
|
|
2935
2977
|
if (t && a && Object.keys(a).length === 0) return t;
|
|
2936
2978
|
c("saving");
|
|
2937
2979
|
try {
|
|
2938
|
-
let e = t ? await i.updateProduct(t.id, a) : await i.createProduct(
|
|
2980
|
+
let e = t ? await i.updateProduct(t.id, a) : await i.createProduct(lt(r, n)), o = d.current;
|
|
2939
2981
|
return g(t && o && o !== t ? {
|
|
2940
2982
|
...e,
|
|
2941
2983
|
images: o.images
|
|
@@ -2984,18 +3026,8 @@ function Gt({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
2984
3026
|
[e]: t
|
|
2985
3027
|
}));
|
|
2986
3028
|
}, A = async (e) => {
|
|
2987
|
-
let t = c.name
|
|
2988
|
-
|
|
2989
|
-
let n = e, r = [...e.images].sort((e, t) => e.position - t.position);
|
|
2990
|
-
for (let [i, o] of r.entries()) {
|
|
2991
|
-
if (o.alt.trim()) continue;
|
|
2992
|
-
let r = Z(s.altFallback, {
|
|
2993
|
-
name: t,
|
|
2994
|
-
n: String(i + 1)
|
|
2995
|
-
});
|
|
2996
|
-
n = await a.updateProductImage(e.id, o.id, { alt: r });
|
|
2997
|
-
}
|
|
2998
|
-
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;
|
|
2999
3031
|
}, j = async (e) => {
|
|
3000
3032
|
y(!0), _(void 0), h(null);
|
|
3001
3033
|
try {
|
|
@@ -3009,7 +3041,7 @@ function Gt({ initial: e, initialStep: t, isFirstProduct: n, onDone: r, onClose:
|
|
|
3009
3041
|
r ? r(e) : w(o.products.saved);
|
|
3010
3042
|
}, N = () => j(async () => {
|
|
3011
3043
|
let e = await p.flush();
|
|
3012
|
-
e ? M(await A(e)) :
|
|
3044
|
+
e ? M(await A(e)) : ct(c) || await ee();
|
|
3013
3045
|
}), P = () => j(async () => {
|
|
3014
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" });
|
|
3015
3047
|
if (p.setProduct(r), !e) return M(r);
|
|
@@ -3073,46 +3105,46 @@ function qt({ productId: e, ...t }) {
|
|
|
3073
3105
|
initial: i.data
|
|
3074
3106
|
}, i.data.id) : /* @__PURE__ */ C("p", { children: r.loading });
|
|
3075
3107
|
}
|
|
3076
|
-
function Jt({ initial: e, initialStep: t, onDone: n, onClose: r, categories: i, materialSuggestions: a,
|
|
3077
|
-
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({
|
|
3078
3110
|
initial: e,
|
|
3079
3111
|
initialStep: t,
|
|
3080
|
-
isFirstProduct:
|
|
3112
|
+
isFirstProduct: s,
|
|
3081
3113
|
onDone: n,
|
|
3082
3114
|
onClose: r
|
|
3083
|
-
}),
|
|
3084
|
-
form:
|
|
3085
|
-
update:
|
|
3086
|
-
},
|
|
3115
|
+
}), g = h.product?.currency ?? p, v = {
|
|
3116
|
+
form: h.form,
|
|
3117
|
+
update: h.update
|
|
3118
|
+
}, b = y(null), x = y(!0);
|
|
3087
3119
|
if (_(() => {
|
|
3088
|
-
let e = !
|
|
3089
|
-
|
|
3090
|
-
}, [
|
|
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", {
|
|
3091
3123
|
className: "sfa-flow sfa-flow--done",
|
|
3092
|
-
children: /* @__PURE__ */ C(
|
|
3093
|
-
success:
|
|
3094
|
-
onAddAnother:
|
|
3124
|
+
children: /* @__PURE__ */ C(kt, {
|
|
3125
|
+
success: h.success,
|
|
3126
|
+
onAddAnother: l,
|
|
3095
3127
|
onDone: n
|
|
3096
3128
|
})
|
|
3097
3129
|
});
|
|
3098
|
-
let
|
|
3099
|
-
let e =
|
|
3100
|
-
e ?
|
|
3101
|
-
},
|
|
3130
|
+
let T = () => {
|
|
3131
|
+
let e = xt(h.step);
|
|
3132
|
+
e ? h.goTo(e) : r && h.close();
|
|
3133
|
+
}, E = r ? /* @__PURE__ */ w("button", {
|
|
3102
3134
|
type: "button",
|
|
3103
3135
|
className: "sfa-btn sfa-btn--ghost",
|
|
3104
|
-
"aria-label":
|
|
3105
|
-
onClick: () => void
|
|
3136
|
+
"aria-label": m.close,
|
|
3137
|
+
onClick: () => void h.close(),
|
|
3106
3138
|
children: [/* @__PURE__ */ C("span", {
|
|
3107
3139
|
"aria-hidden": "true",
|
|
3108
3140
|
children: "✕"
|
|
3109
3141
|
}), /* @__PURE__ */ C("span", {
|
|
3110
3142
|
className: "sfa-flow__btn-text",
|
|
3111
3143
|
"aria-hidden": "true",
|
|
3112
|
-
children:
|
|
3144
|
+
children: m.close
|
|
3113
3145
|
})]
|
|
3114
|
-
}) :
|
|
3115
|
-
href:
|
|
3146
|
+
}) : f({
|
|
3147
|
+
href: d.products,
|
|
3116
3148
|
className: "sfa-btn sfa-btn--ghost",
|
|
3117
3149
|
children: /* @__PURE__ */ w(S, { children: [
|
|
3118
3150
|
/* @__PURE__ */ C("span", {
|
|
@@ -3121,110 +3153,111 @@ function Jt({ initial: e, initialStep: t, onDone: n, onClose: r, categories: i,
|
|
|
3121
3153
|
}),
|
|
3122
3154
|
/* @__PURE__ */ C("span", {
|
|
3123
3155
|
className: "sfa-sr-only",
|
|
3124
|
-
children:
|
|
3156
|
+
children: m.close
|
|
3125
3157
|
}),
|
|
3126
3158
|
/* @__PURE__ */ C("span", {
|
|
3127
3159
|
className: "sfa-flow__btn-text",
|
|
3128
3160
|
"aria-hidden": "true",
|
|
3129
|
-
children:
|
|
3161
|
+
children: m.close
|
|
3130
3162
|
})
|
|
3131
3163
|
] })
|
|
3132
|
-
}),
|
|
3164
|
+
}), D = (e) => h.step === e;
|
|
3133
3165
|
return /* @__PURE__ */ w("div", {
|
|
3134
|
-
ref:
|
|
3166
|
+
ref: b,
|
|
3135
3167
|
className: "sfa-flow",
|
|
3136
|
-
"data-step":
|
|
3168
|
+
"data-step": h.step,
|
|
3137
3169
|
children: [
|
|
3138
|
-
/* @__PURE__ */ C(
|
|
3139
|
-
title:
|
|
3140
|
-
step:
|
|
3141
|
-
onBack:
|
|
3142
|
-
canGoBack: !!r ||
|
|
3143
|
-
close:
|
|
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
|
|
3144
3176
|
}),
|
|
3145
|
-
/* @__PURE__ */ C(
|
|
3146
|
-
step:
|
|
3147
|
-
allOpen: !
|
|
3148
|
-
onStep:
|
|
3177
|
+
/* @__PURE__ */ C(Et, {
|
|
3178
|
+
step: h.step,
|
|
3179
|
+
allOpen: !h.isNew,
|
|
3180
|
+
onStep: h.goTo
|
|
3149
3181
|
}),
|
|
3150
3182
|
/* @__PURE__ */ w("div", {
|
|
3151
3183
|
className: "sfa-flow__body",
|
|
3152
3184
|
children: [/* @__PURE__ */ w("div", {
|
|
3153
3185
|
className: "sfa-flow__main",
|
|
3154
3186
|
children: [
|
|
3155
|
-
/* @__PURE__ */ C(
|
|
3187
|
+
/* @__PURE__ */ C(Ot, {
|
|
3156
3188
|
step: "photos",
|
|
3157
|
-
active:
|
|
3158
|
-
children: /* @__PURE__ */ C(
|
|
3159
|
-
product:
|
|
3160
|
-
ensureProduct:
|
|
3161
|
-
setProduct:
|
|
3162
|
-
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
|
|
3163
3195
|
})
|
|
3164
3196
|
}),
|
|
3165
|
-
/* @__PURE__ */ C(
|
|
3197
|
+
/* @__PURE__ */ C(Ot, {
|
|
3166
3198
|
step: "basics",
|
|
3167
|
-
active:
|
|
3168
|
-
children: /* @__PURE__ */ C(
|
|
3169
|
-
...
|
|
3199
|
+
active: D("basics"),
|
|
3200
|
+
children: /* @__PURE__ */ C(yt, {
|
|
3201
|
+
...v,
|
|
3170
3202
|
categories: i,
|
|
3171
|
-
currency:
|
|
3203
|
+
currency: g,
|
|
3204
|
+
taxCodes: o
|
|
3172
3205
|
})
|
|
3173
3206
|
}),
|
|
3174
|
-
/* @__PURE__ */ C(
|
|
3207
|
+
/* @__PURE__ */ C(Ot, {
|
|
3175
3208
|
step: "story",
|
|
3176
|
-
active:
|
|
3177
|
-
children: /* @__PURE__ */ C(
|
|
3178
|
-
...
|
|
3179
|
-
product:
|
|
3180
|
-
setProduct:
|
|
3209
|
+
active: D("story"),
|
|
3210
|
+
children: /* @__PURE__ */ C(zt, {
|
|
3211
|
+
...v,
|
|
3212
|
+
product: h.product,
|
|
3213
|
+
setProduct: h.autosave.setProduct,
|
|
3181
3214
|
materialSuggestions: a
|
|
3182
3215
|
})
|
|
3183
3216
|
})
|
|
3184
3217
|
]
|
|
3185
3218
|
}), /* @__PURE__ */ w("aside", {
|
|
3186
3219
|
className: "sfa-flow__aside",
|
|
3187
|
-
children: [/* @__PURE__ */ C(
|
|
3220
|
+
children: [/* @__PURE__ */ C(Ot, {
|
|
3188
3221
|
step: "preview",
|
|
3189
|
-
active:
|
|
3190
|
-
live: (
|
|
3191
|
-
children: /* @__PURE__ */ C(
|
|
3192
|
-
...
|
|
3193
|
-
product:
|
|
3194
|
-
currency:
|
|
3195
|
-
missing:
|
|
3196
|
-
actions: /* @__PURE__ */ C(
|
|
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 })
|
|
3197
3230
|
})
|
|
3198
|
-
}), /* @__PURE__ */ C(q, { error:
|
|
3231
|
+
}), /* @__PURE__ */ C(q, { error: h.failure })]
|
|
3199
3232
|
})]
|
|
3200
3233
|
}),
|
|
3201
3234
|
/* @__PURE__ */ w("div", {
|
|
3202
3235
|
className: "sfa-flow__foot",
|
|
3203
3236
|
children: [
|
|
3204
|
-
/* @__PURE__ */ C(
|
|
3205
|
-
/* @__PURE__ */ C(
|
|
3206
|
-
state:
|
|
3207
|
-
isNew:
|
|
3208
|
-
onRetry: () => void
|
|
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()
|
|
3209
3242
|
}),
|
|
3210
3243
|
/* @__PURE__ */ C("div", {
|
|
3211
3244
|
className: "sfa-flow__foot-actions",
|
|
3212
|
-
children: /* @__PURE__ */ C(
|
|
3245
|
+
children: /* @__PURE__ */ C(Ct, { flow: h })
|
|
3213
3246
|
})
|
|
3214
3247
|
]
|
|
3215
3248
|
}),
|
|
3216
|
-
|
|
3249
|
+
h.notice ? /* @__PURE__ */ C(K, {
|
|
3217
3250
|
variant: "success",
|
|
3218
3251
|
toast: !0,
|
|
3219
|
-
onDismiss:
|
|
3220
|
-
children:
|
|
3252
|
+
onDismiss: h.dismissNotice,
|
|
3253
|
+
children: h.notice
|
|
3221
3254
|
}) : null,
|
|
3222
|
-
|
|
3255
|
+
h.closing ? /* @__PURE__ */ C(K, {
|
|
3223
3256
|
variant: "success",
|
|
3224
3257
|
toast: !0,
|
|
3225
3258
|
duration: 1500,
|
|
3226
|
-
onDismiss:
|
|
3227
|
-
children:
|
|
3259
|
+
onDismiss: h.finishClosing,
|
|
3260
|
+
children: m.savedAsDraft
|
|
3228
3261
|
}) : null
|
|
3229
3262
|
]
|
|
3230
3263
|
});
|
|
@@ -3301,7 +3334,7 @@ function Qt({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
|
|
|
3301
3334
|
}
|
|
3302
3335
|
// src/views/products/image-tile.tsx
|
|
3303
3336
|
function $t({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRemove: o, onSaveAlt: s }) {
|
|
3304
|
-
let { renderImage: c } = F(), l = e.alt ||
|
|
3337
|
+
let { renderImage: c } = F(), l = e.alt || jt(i.photoName, { n: String(t + 1) }), u = (t, n, r) => /* @__PURE__ */ C("button", {
|
|
3305
3338
|
type: "button",
|
|
3306
3339
|
className: "sfa-btn",
|
|
3307
3340
|
"data-image-id": e.id,
|
|
@@ -3384,11 +3417,11 @@ function en({ labels: e, onFiles: t }) {
|
|
|
3384
3417
|
});
|
|
3385
3418
|
}
|
|
3386
3419
|
// src/views/products/admin-product-images.tsx
|
|
3387
|
-
var
|
|
3388
|
-
function
|
|
3389
|
-
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({
|
|
3390
3423
|
productId: e,
|
|
3391
|
-
onUploaded: (e) => o(
|
|
3424
|
+
onUploaded: (e) => o(tn(e.images))
|
|
3392
3425
|
});
|
|
3393
3426
|
_(() => {
|
|
3394
3427
|
let e = T.current;
|
|
@@ -3407,7 +3440,7 @@ function tn({ productId: e, images: t }) {
|
|
|
3407
3440
|
}, o(d), u(!0), c(a[t].id), m(void 0), g(!1);
|
|
3408
3441
|
try {
|
|
3409
3442
|
let t = await n.reorderProductImages(e, d.map((e) => e.id));
|
|
3410
|
-
o(
|
|
3443
|
+
o(tn(t.images));
|
|
3411
3444
|
} catch (e) {
|
|
3412
3445
|
T.current = {
|
|
3413
3446
|
id: a[t].id,
|
|
@@ -3422,7 +3455,7 @@ function tn({ productId: e, images: t }) {
|
|
|
3422
3455
|
x(null), c(t.id), m(void 0), g(!1);
|
|
3423
3456
|
try {
|
|
3424
3457
|
let r = await n.deleteProductImage(e, t.id);
|
|
3425
|
-
o(
|
|
3458
|
+
o(tn(r.images));
|
|
3426
3459
|
} catch (e) {
|
|
3427
3460
|
m(e);
|
|
3428
3461
|
} finally {
|
|
@@ -3430,7 +3463,7 @@ function tn({ productId: e, images: t }) {
|
|
|
3430
3463
|
}
|
|
3431
3464
|
}, M = async (t, r) => {
|
|
3432
3465
|
let i = await n.updateProductImage(e, t, { alt: r });
|
|
3433
|
-
o(
|
|
3466
|
+
o(tn(i.images));
|
|
3434
3467
|
};
|
|
3435
3468
|
return /* @__PURE__ */ w("div", {
|
|
3436
3469
|
className: "sfa-images",
|
|
@@ -3523,27 +3556,27 @@ function tn({ productId: e, images: t }) {
|
|
|
3523
3556
|
});
|
|
3524
3557
|
}
|
|
3525
3558
|
// src/lib/use-order-pages.ts
|
|
3526
|
-
function
|
|
3559
|
+
function rn(e) {
|
|
3527
3560
|
let t = I();
|
|
3528
|
-
return
|
|
3561
|
+
return Ae(["admin-orders", e], (n) => t.listOrders(n ? {
|
|
3529
3562
|
...e,
|
|
3530
3563
|
cursor: n
|
|
3531
3564
|
} : e));
|
|
3532
3565
|
}
|
|
3533
3566
|
// src/views/orders/admin-order-list.tsx
|
|
3534
|
-
var
|
|
3567
|
+
var an = [
|
|
3535
3568
|
"paid",
|
|
3536
3569
|
"shipped",
|
|
3537
3570
|
"needs_attention",
|
|
3538
3571
|
"pending_refund",
|
|
3539
3572
|
"all"
|
|
3540
3573
|
];
|
|
3541
|
-
function
|
|
3574
|
+
function on(e) {
|
|
3542
3575
|
return e === "pending_refund" ? { hasPendingRefund: !0 } : e === "all" ? {} : { status: e };
|
|
3543
3576
|
}
|
|
3544
|
-
function
|
|
3545
|
-
let { labels: e, locale: t, hrefs: n, renderLink: r } = F(), i = e.orders, [a, o] = b("paid"), [s, c] = b(""), l =
|
|
3546
|
-
...
|
|
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),
|
|
3547
3580
|
...l ? { q: l } : {}
|
|
3548
3581
|
}), d = new Intl.DateTimeFormat(t), f = [
|
|
3549
3582
|
{
|
|
@@ -3594,7 +3627,7 @@ function on() {
|
|
|
3594
3627
|
role: "group",
|
|
3595
3628
|
"aria-label": i.columns.status,
|
|
3596
3629
|
className: "sfa-filter-group",
|
|
3597
|
-
children:
|
|
3630
|
+
children: an.map((e) => /* @__PURE__ */ C("button", {
|
|
3598
3631
|
type: "button",
|
|
3599
3632
|
className: "sfa-chip",
|
|
3600
3633
|
"aria-pressed": a === e,
|
|
@@ -3610,7 +3643,7 @@ function on() {
|
|
|
3610
3643
|
})]
|
|
3611
3644
|
}),
|
|
3612
3645
|
/* @__PURE__ */ C(q, { error: u.error }),
|
|
3613
|
-
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, {
|
|
3614
3647
|
icon: l ? "search" : "orders",
|
|
3615
3648
|
title: l ? i.noMatches : i.empty[a],
|
|
3616
3649
|
body: !l && a === "all" ? i.emptyHint : void 0
|
|
@@ -3630,27 +3663,27 @@ function on() {
|
|
|
3630
3663
|
});
|
|
3631
3664
|
}
|
|
3632
3665
|
// src/lib/refund-rules.ts
|
|
3633
|
-
function sn(e) {
|
|
3634
|
-
return e.refunds.filter((e) => e.status === "pending").reduce((e, t) => e + t.amountCents, 0);
|
|
3635
|
-
}
|
|
3636
3666
|
function cn(e) {
|
|
3637
|
-
return e.
|
|
3667
|
+
return e.refunds.filter((e) => e.status === "pending").reduce((e, t) => e + t.amountCents, 0);
|
|
3638
3668
|
}
|
|
3639
3669
|
function ln(e) {
|
|
3670
|
+
return e.totalCents - e.refundedCents - cn(e);
|
|
3671
|
+
}
|
|
3672
|
+
function un(e) {
|
|
3640
3673
|
return e.refunds.some((e) => e.status === "pending");
|
|
3641
3674
|
}
|
|
3642
|
-
function
|
|
3643
|
-
return e.status !== "needs_attention" && t !== null && t ===
|
|
3675
|
+
function dn(e, t) {
|
|
3676
|
+
return e.status !== "needs_attention" && t !== null && t === ln(e);
|
|
3644
3677
|
}
|
|
3645
|
-
function
|
|
3678
|
+
function fn(e) {
|
|
3646
3679
|
return e.status === "paid" || e.status === "shipped";
|
|
3647
3680
|
}
|
|
3648
|
-
function
|
|
3649
|
-
return (
|
|
3681
|
+
function pn(e) {
|
|
3682
|
+
return (fn(e) || e.status === "needs_attention") && ln(e) > 0;
|
|
3650
3683
|
}
|
|
3651
3684
|
// src/views/orders/refund-dialog.tsx
|
|
3652
|
-
function
|
|
3653
|
-
let i = I(), o = F().labels.orders.actions, s = y(crypto.randomUUID()), c =
|
|
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;
|
|
3654
3687
|
return /* @__PURE__ */ w(G, {
|
|
3655
3688
|
open: !0,
|
|
3656
3689
|
title: o.refundTitle,
|
|
@@ -3666,7 +3699,7 @@ function pn({ order: t, onClose: n, onDone: r }) {
|
|
|
3666
3699
|
},
|
|
3667
3700
|
onCancel: n,
|
|
3668
3701
|
children: [
|
|
3669
|
-
|
|
3702
|
+
un(t) ? /* @__PURE__ */ C(K, {
|
|
3670
3703
|
variant: "warning",
|
|
3671
3704
|
children: o.refundPending
|
|
3672
3705
|
}) : null,
|
|
@@ -3732,7 +3765,7 @@ function pn({ order: t, onClose: n, onDone: r }) {
|
|
|
3732
3765
|
});
|
|
3733
3766
|
}
|
|
3734
3767
|
// src/views/orders/resolve-button.tsx
|
|
3735
|
-
function
|
|
3768
|
+
function hn({ order: e, onDone: t, notice: n }) {
|
|
3736
3769
|
let r = I(), { labels: i, hrefs: a, renderLink: o } = F(), s = i.orders.actions, l = R(r.resolveOrder), u = async () => {
|
|
3737
3770
|
await l.run(e.id) && t(s.resolved);
|
|
3738
3771
|
}, d = l.error instanceof c ? l.error : null, f = new Map(e.items.map((e) => [e.productId, e.name]));
|
|
@@ -3760,7 +3793,7 @@ function mn({ order: e, onDone: t, notice: n }) {
|
|
|
3760
3793
|
});
|
|
3761
3794
|
}
|
|
3762
3795
|
// src/views/orders/ship-form.tsx
|
|
3763
|
-
function
|
|
3796
|
+
function gn(e) {
|
|
3764
3797
|
try {
|
|
3765
3798
|
let { protocol: t } = new URL(e);
|
|
3766
3799
|
return t === "http:" || t === "https:";
|
|
@@ -3768,10 +3801,10 @@ function hn(e) {
|
|
|
3768
3801
|
return !1;
|
|
3769
3802
|
}
|
|
3770
3803
|
}
|
|
3771
|
-
function
|
|
3804
|
+
function _n({ order: e, onDone: t, requireTracking: n = !0, notice: r }) {
|
|
3772
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 () => {
|
|
3773
3806
|
let n = d.trim();
|
|
3774
|
-
n && !
|
|
3807
|
+
n && !gn(n) ? m(!0) : (m(!1), await _.run(e.id, {
|
|
3775
3808
|
carrier: s.trim() || void 0,
|
|
3776
3809
|
trackingNumber: l.trim() || void 0,
|
|
3777
3810
|
trackingUrl: n || void 0
|
|
@@ -3782,7 +3815,7 @@ function gn({ order: e, onDone: t, requireTracking: n = !0, notice: r }) {
|
|
|
3782
3815
|
onSubmit: async (e) => {
|
|
3783
3816
|
e.preventDefault();
|
|
3784
3817
|
let t = d.trim();
|
|
3785
|
-
if (t && !
|
|
3818
|
+
if (t && !gn(t)) {
|
|
3786
3819
|
m(!0);
|
|
3787
3820
|
return;
|
|
3788
3821
|
}
|
|
@@ -3862,7 +3895,7 @@ function gn({ order: e, onDone: t, requireTracking: n = !0, notice: r }) {
|
|
|
3862
3895
|
});
|
|
3863
3896
|
}
|
|
3864
3897
|
// src/views/orders/order-actions.tsx
|
|
3865
|
-
function
|
|
3898
|
+
function vn({ order: e, reload: t, requireTracking: n = !0 }) {
|
|
3866
3899
|
let r = F().labels.orders.actions, [i, a] = b(!1), [o, s] = b(null), c = (e) => (n) => {
|
|
3867
3900
|
a(!1), s({
|
|
3868
3901
|
source: e,
|
|
@@ -3876,25 +3909,25 @@ function _n({ order: e, reload: t, requireTracking: n = !0 }) {
|
|
|
3876
3909
|
return /* @__PURE__ */ w("div", {
|
|
3877
3910
|
className: "sfa-order__actions",
|
|
3878
3911
|
children: [
|
|
3879
|
-
|
|
3912
|
+
fn(e) ? /* @__PURE__ */ C(_n, {
|
|
3880
3913
|
order: e,
|
|
3881
3914
|
requireTracking: n,
|
|
3882
3915
|
onDone: c("ship"),
|
|
3883
3916
|
notice: l("ship")
|
|
3884
3917
|
}) : null,
|
|
3885
|
-
e.status === "needs_attention" ? /* @__PURE__ */ C(
|
|
3918
|
+
e.status === "needs_attention" ? /* @__PURE__ */ C(hn, {
|
|
3886
3919
|
order: e,
|
|
3887
3920
|
onDone: c("resolve"),
|
|
3888
3921
|
notice: l("resolve")
|
|
3889
3922
|
}) : null,
|
|
3890
|
-
|
|
3923
|
+
pn(e) ? /* @__PURE__ */ C("button", {
|
|
3891
3924
|
type: "button",
|
|
3892
3925
|
className: "sfa-btn sfa-btn--quiet-danger sfa-order__refund-btn",
|
|
3893
3926
|
onClick: () => a(!0),
|
|
3894
3927
|
children: r.refund
|
|
3895
3928
|
}) : null,
|
|
3896
3929
|
l("refund"),
|
|
3897
|
-
i ? /* @__PURE__ */ C(
|
|
3930
|
+
i ? /* @__PURE__ */ C(mn, {
|
|
3898
3931
|
order: e,
|
|
3899
3932
|
onClose: () => {
|
|
3900
3933
|
a(!1), t();
|
|
@@ -3905,7 +3938,7 @@ function _n({ order: e, reload: t, requireTracking: n = !0 }) {
|
|
|
3905
3938
|
});
|
|
3906
3939
|
}
|
|
3907
3940
|
// src/views/orders/order-fulfillment.tsx
|
|
3908
|
-
function
|
|
3941
|
+
function yn({ order: e }) {
|
|
3909
3942
|
let { labels: t, locale: n, renderLink: r } = F(), i = t.orders, a = e.fulfillment;
|
|
3910
3943
|
return /* @__PURE__ */ w("section", {
|
|
3911
3944
|
className: "sfa-order__section",
|
|
@@ -3923,7 +3956,7 @@ function vn({ order: e }) {
|
|
|
3923
3956
|
});
|
|
3924
3957
|
}
|
|
3925
3958
|
// src/views/orders/order-items.tsx
|
|
3926
|
-
function
|
|
3959
|
+
function bn({ order: e }) {
|
|
3927
3960
|
let { labels: t } = F(), n = t.orders, { currency: r } = e, i = [
|
|
3928
3961
|
{
|
|
3929
3962
|
key: "name",
|
|
@@ -3978,6 +4011,10 @@ function yn({ order: e }) {
|
|
|
3978
4011
|
cents: e.shippingCents,
|
|
3979
4012
|
currency: r
|
|
3980
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,
|
|
3981
4018
|
/* @__PURE__ */ C("dt", { children: n.total }),
|
|
3982
4019
|
/* @__PURE__ */ C("dd", { children: /* @__PURE__ */ C(W, {
|
|
3983
4020
|
cents: e.totalCents,
|
|
@@ -3989,7 +4026,7 @@ function yn({ order: e }) {
|
|
|
3989
4026
|
});
|
|
3990
4027
|
}
|
|
3991
4028
|
// src/views/orders/order-refunds.tsx
|
|
3992
|
-
function
|
|
4029
|
+
function xn({ order: e }) {
|
|
3993
4030
|
let { labels: t, locale: n } = F(), r = t.orders, { currency: i } = e, a = new Intl.DateTimeFormat(n), o = [
|
|
3994
4031
|
{
|
|
3995
4032
|
key: "amount",
|
|
@@ -4053,7 +4090,7 @@ function bn({ order: e }) {
|
|
|
4053
4090
|
});
|
|
4054
4091
|
}
|
|
4055
4092
|
// src/views/orders/admin-order-detail.tsx
|
|
4056
|
-
function
|
|
4093
|
+
function Sn(e) {
|
|
4057
4094
|
let t = e.shippingAddress;
|
|
4058
4095
|
if (!t) return [];
|
|
4059
4096
|
let n = [
|
|
@@ -4069,12 +4106,12 @@ function xn(e) {
|
|
|
4069
4106
|
t.country
|
|
4070
4107
|
].filter((e) => !!e);
|
|
4071
4108
|
}
|
|
4072
|
-
function
|
|
4109
|
+
function Cn({ orderId: e, actions: t, requireTracking: n = !0 }) {
|
|
4073
4110
|
let r = I(), { labels: i, locale: a, hrefs: o, renderLink: s } = F(), c = i.orders, l = L(["admin-order", e], () => r.getOrder(e));
|
|
4074
4111
|
if (l.error) return /* @__PURE__ */ C(q, { error: l.error });
|
|
4075
4112
|
let u = l.data;
|
|
4076
4113
|
if (!u) return /* @__PURE__ */ C("p", { children: i.loading });
|
|
4077
|
-
let d =
|
|
4114
|
+
let d = Sn(u);
|
|
4078
4115
|
return /* @__PURE__ */ w("article", {
|
|
4079
4116
|
className: "sfa-order",
|
|
4080
4117
|
children: [
|
|
@@ -4110,7 +4147,7 @@ function Sn({ orderId: e, actions: t, requireTracking: n = !0 }) {
|
|
|
4110
4147
|
className: "sfa-order__section",
|
|
4111
4148
|
children: [/* @__PURE__ */ C("h2", { children: c.buyer }), /* @__PURE__ */ C("p", { children: u.email ?? i.orders.noEmail })]
|
|
4112
4149
|
}),
|
|
4113
|
-
/* @__PURE__ */ C(
|
|
4150
|
+
/* @__PURE__ */ C(bn, { order: u }),
|
|
4114
4151
|
/* @__PURE__ */ w("section", {
|
|
4115
4152
|
className: "sfa-order__section",
|
|
4116
4153
|
children: [/* @__PURE__ */ C("h2", { children: c.shippingAddress }), d.length === 0 ? /* @__PURE__ */ C("p", { children: c.noAddress }) : /* @__PURE__ */ C("address", {
|
|
@@ -4122,14 +4159,14 @@ function Sn({ orderId: e, actions: t, requireTracking: n = !0 }) {
|
|
|
4122
4159
|
}), /* @__PURE__ */ w("div", {
|
|
4123
4160
|
className: "sfa-order__side",
|
|
4124
4161
|
children: [
|
|
4125
|
-
/* @__PURE__ */ C(
|
|
4126
|
-
/* @__PURE__ */ C(
|
|
4162
|
+
/* @__PURE__ */ C(yn, { order: u }),
|
|
4163
|
+
/* @__PURE__ */ C(xn, { order: u }),
|
|
4127
4164
|
/* @__PURE__ */ C("section", {
|
|
4128
4165
|
className: "sfa-order__section",
|
|
4129
4166
|
children: t ? t({
|
|
4130
4167
|
order: u,
|
|
4131
4168
|
reload: l.reload
|
|
4132
|
-
}) : /* @__PURE__ */ C(
|
|
4169
|
+
}) : /* @__PURE__ */ C(vn, {
|
|
4133
4170
|
order: u,
|
|
4134
4171
|
reload: l.reload,
|
|
4135
4172
|
requireTracking: n
|
|
@@ -4142,21 +4179,21 @@ function Sn({ orderId: e, actions: t, requireTracking: n = !0 }) {
|
|
|
4142
4179
|
});
|
|
4143
4180
|
}
|
|
4144
4181
|
// src/lib/shipping-rates.ts
|
|
4145
|
-
var
|
|
4146
|
-
function
|
|
4182
|
+
var wn = 0, Tn = () => `rate-${++wn}`;
|
|
4183
|
+
function En(e) {
|
|
4147
4184
|
return [...e].sort((e, t) => e.sort - t.sort).map((e) => ({
|
|
4148
|
-
key:
|
|
4185
|
+
key: Tn(),
|
|
4149
4186
|
label: e.label,
|
|
4150
|
-
amount:
|
|
4187
|
+
amount: Z(e.amountCents),
|
|
4151
4188
|
currency: e.currency,
|
|
4152
4189
|
minDays: e.minDays == null ? "" : String(e.minDays),
|
|
4153
4190
|
maxDays: e.maxDays == null ? "" : String(e.maxDays),
|
|
4154
4191
|
active: e.active
|
|
4155
4192
|
}));
|
|
4156
4193
|
}
|
|
4157
|
-
function
|
|
4194
|
+
function Dn(e, t) {
|
|
4158
4195
|
return {
|
|
4159
|
-
key:
|
|
4196
|
+
key: Tn(),
|
|
4160
4197
|
label: t,
|
|
4161
4198
|
amount: "",
|
|
4162
4199
|
currency: e,
|
|
@@ -4165,18 +4202,18 @@ function En(e, t) {
|
|
|
4165
4202
|
active: !0
|
|
4166
4203
|
};
|
|
4167
4204
|
}
|
|
4168
|
-
var
|
|
4169
|
-
function
|
|
4205
|
+
var On = (e) => JSON.stringify(e.map(({ key: e, ...t }) => t));
|
|
4206
|
+
function kn(e) {
|
|
4170
4207
|
let t = e.trim();
|
|
4171
4208
|
return t === "" ? null : /^\d+$/.test(t) ? Number(t) : void 0;
|
|
4172
4209
|
}
|
|
4173
|
-
function
|
|
4210
|
+
function An(e, t) {
|
|
4174
4211
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
4175
4212
|
if (e.forEach((e) => {
|
|
4176
4213
|
let t = e.label.trim();
|
|
4177
4214
|
i.set(t, (i.get(t) ?? 0) + 1);
|
|
4178
4215
|
}), e.forEach((e, a) => {
|
|
4179
|
-
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);
|
|
4180
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({
|
|
4181
4218
|
label: s,
|
|
4182
4219
|
amountCents: c ?? 0,
|
|
@@ -4201,19 +4238,19 @@ function kn(e, t) {
|
|
|
4201
4238
|
valid: Object.keys(n).length === 0 && !a
|
|
4202
4239
|
};
|
|
4203
4240
|
}
|
|
4204
|
-
var
|
|
4241
|
+
var jn = {
|
|
4205
4242
|
label: "label",
|
|
4206
4243
|
amountCents: "amount",
|
|
4207
4244
|
currency: "currency",
|
|
4208
4245
|
minDays: "minDays",
|
|
4209
4246
|
maxDays: "maxDays"
|
|
4210
4247
|
};
|
|
4211
|
-
function
|
|
4248
|
+
function Mn(e, t, n) {
|
|
4212
4249
|
let r = {};
|
|
4213
4250
|
for (let i of e) {
|
|
4214
4251
|
let e = i?.path ?? [], a = e.findIndex((e) => typeof e == "number"), o = a >= 0 ? t[e[a]]?.key : void 0;
|
|
4215
4252
|
if (!o) continue;
|
|
4216
|
-
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;
|
|
4217
4254
|
r[o] = {
|
|
4218
4255
|
...r[o],
|
|
4219
4256
|
[c ?? "row"]: n.rowInvalid
|
|
@@ -4222,7 +4259,7 @@ function jn(e, t, n) {
|
|
|
4222
4259
|
return r;
|
|
4223
4260
|
}
|
|
4224
4261
|
// src/lib/currency-symbol.ts
|
|
4225
|
-
function
|
|
4262
|
+
function Nn(e, t) {
|
|
4226
4263
|
try {
|
|
4227
4264
|
return new Intl.NumberFormat(t, {
|
|
4228
4265
|
style: "currency",
|
|
@@ -4234,8 +4271,8 @@ function Mn(e, t) {
|
|
|
4234
4271
|
}
|
|
4235
4272
|
}
|
|
4236
4273
|
// src/views/shipping/shipping-rate-row.tsx
|
|
4237
|
-
function
|
|
4238
|
-
let u = e.label.trim() ||
|
|
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) => {
|
|
4239
4276
|
let u = r[o], d = `${e.key}-${t}`, f = /* @__PURE__ */ C("input", {
|
|
4240
4277
|
id: d,
|
|
4241
4278
|
value: a,
|
|
@@ -4339,13 +4376,13 @@ function Nn({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, l
|
|
|
4339
4376
|
});
|
|
4340
4377
|
}
|
|
4341
4378
|
// src/views/shipping/admin-shipping-rates.tsx
|
|
4342
|
-
function
|
|
4379
|
+
function Fn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
4343
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);
|
|
4344
4381
|
if (s.data && s.data !== p) {
|
|
4345
|
-
let e =
|
|
4346
|
-
m(s.data), l(e), f(
|
|
4382
|
+
let e = En(s.data);
|
|
4383
|
+
m(s.data), l(e), f(On(e));
|
|
4347
4384
|
}
|
|
4348
|
-
let N = p !== void 0 &&
|
|
4385
|
+
let N = p !== void 0 && On(c) !== u;
|
|
4349
4386
|
_(() => {
|
|
4350
4387
|
j.current !== N && (j.current = N, e?.(N));
|
|
4351
4388
|
}, [N, e]), _(() => {
|
|
@@ -4365,19 +4402,19 @@ function Pn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
|
4365
4402
|
if (n < 0 || n >= c.length) return;
|
|
4366
4403
|
let r = [...c];
|
|
4367
4404
|
[r[e], r[n]] = [r[n], r[e]], P(r);
|
|
4368
|
-
}, ne = () => P([...c,
|
|
4369
|
-
...
|
|
4370
|
-
amount:
|
|
4405
|
+
}, ne = () => P([...c, Dn(i, o.newRateLabel)]), re = (e) => P([...c, {
|
|
4406
|
+
...Dn(i, e.label),
|
|
4407
|
+
amount: Z(e.amountCents)
|
|
4371
4408
|
}]), ie = () => {
|
|
4372
4409
|
h && (P(c.filter((e) => e.key !== h.key)), k(!0), g(null));
|
|
4373
4410
|
}, ae = async () => {
|
|
4374
|
-
let e =
|
|
4411
|
+
let e = An(c, o);
|
|
4375
4412
|
if (x(e.rowErrors), T(e.noActive), !e.valid) return;
|
|
4376
4413
|
let t = await A.run(e.rates);
|
|
4377
4414
|
if (!t) return;
|
|
4378
|
-
let n =
|
|
4379
|
-
l(n), f(
|
|
4380
|
-
}, oe = c.some((e) => e.currency !== i), z = A.error instanceof d ?
|
|
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) : {};
|
|
4381
4418
|
return s.loading && !s.data ? /* @__PURE__ */ C("p", {
|
|
4382
4419
|
role: "status",
|
|
4383
4420
|
children: o.loading
|
|
@@ -4392,13 +4429,13 @@ function Pn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
|
4392
4429
|
}) : null,
|
|
4393
4430
|
oe ? /* @__PURE__ */ C(K, {
|
|
4394
4431
|
variant: "warning",
|
|
4395
|
-
children:
|
|
4432
|
+
children: jt(o.mixedCurrency, { currency: i })
|
|
4396
4433
|
}) : null,
|
|
4397
4434
|
N ? /* @__PURE__ */ C("p", {
|
|
4398
4435
|
className: "sfa-field__help",
|
|
4399
4436
|
children: o.unsaved
|
|
4400
4437
|
}) : null,
|
|
4401
|
-
c.length === 0 ? /* @__PURE__ */ C(
|
|
4438
|
+
c.length === 0 ? /* @__PURE__ */ C(J, {
|
|
4402
4439
|
icon: "shipping",
|
|
4403
4440
|
title: o.emptyTitle,
|
|
4404
4441
|
body: o.empty,
|
|
@@ -4420,7 +4457,7 @@ function Pn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
|
4420
4457
|
}) : null,
|
|
4421
4458
|
/* @__PURE__ */ C("ul", {
|
|
4422
4459
|
className: "sfa-rates",
|
|
4423
|
-
children: c.map((e, t) => /* @__PURE__ */ C(
|
|
4460
|
+
children: c.map((e, t) => /* @__PURE__ */ C(Pn, {
|
|
4424
4461
|
draft: e,
|
|
4425
4462
|
index: t,
|
|
4426
4463
|
total: c.length,
|
|
@@ -4478,36 +4515,36 @@ function Pn({ onDirtyChange: e, suggestedRates: t = [] }) {
|
|
|
4478
4515
|
}) : /* @__PURE__ */ C(q, { error: s.error });
|
|
4479
4516
|
}
|
|
4480
4517
|
// src/lib/discount-status.ts
|
|
4481
|
-
function
|
|
4518
|
+
function In(e, t = /* @__PURE__ */ new Date()) {
|
|
4482
4519
|
return e.active ? e.startsAt && new Date(e.startsAt) > t ? "scheduled" : e.endsAt && new Date(e.endsAt) <= t ? "expired" : "active" : "inactive";
|
|
4483
4520
|
}
|
|
4484
|
-
function
|
|
4521
|
+
function Ln(e, t) {
|
|
4485
4522
|
return e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e);
|
|
4486
4523
|
}
|
|
4487
4524
|
// src/lib/use-discount-pages.ts
|
|
4488
|
-
function
|
|
4525
|
+
function Rn(e) {
|
|
4489
4526
|
let t = I();
|
|
4490
|
-
return
|
|
4527
|
+
return Ae(["admin-discounts", e], (n) => t.listDiscounts(n ? {
|
|
4491
4528
|
...e,
|
|
4492
4529
|
cursor: n
|
|
4493
4530
|
} : e));
|
|
4494
4531
|
}
|
|
4495
4532
|
// src/views/discounts/discount-value.tsx
|
|
4496
|
-
function
|
|
4533
|
+
function zn({ discount: e }) {
|
|
4497
4534
|
return e.type === "percent" ? /* @__PURE__ */ w("span", { children: [e.percentOff, "%"] }) : /* @__PURE__ */ C(W, {
|
|
4498
4535
|
cents: e.amountOffCents ?? 0,
|
|
4499
4536
|
currency: e.currency ?? "USD"
|
|
4500
4537
|
});
|
|
4501
4538
|
}
|
|
4502
4539
|
// src/views/discounts/admin-discount-list.tsx
|
|
4503
|
-
var
|
|
4540
|
+
var Bn = [
|
|
4504
4541
|
"active",
|
|
4505
4542
|
"scheduled",
|
|
4506
4543
|
"expired",
|
|
4507
4544
|
"inactive"
|
|
4508
4545
|
];
|
|
4509
|
-
function
|
|
4510
|
-
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({
|
|
4511
4548
|
status: i,
|
|
4512
4549
|
...c ? { q: c } : {}
|
|
4513
4550
|
}), u = [
|
|
@@ -4523,22 +4560,22 @@ function Bn() {
|
|
|
4523
4560
|
{
|
|
4524
4561
|
key: "value",
|
|
4525
4562
|
header: r.columns.value,
|
|
4526
|
-
render: (e) => /* @__PURE__ */ C(
|
|
4563
|
+
render: (e) => /* @__PURE__ */ C(zn, { discount: e })
|
|
4527
4564
|
},
|
|
4528
4565
|
{
|
|
4529
4566
|
key: "status",
|
|
4530
4567
|
header: r.columns.status,
|
|
4531
|
-
render: (e) => /* @__PURE__ */ C(U, { status:
|
|
4568
|
+
render: (e) => /* @__PURE__ */ C(U, { status: In(e) })
|
|
4532
4569
|
},
|
|
4533
4570
|
{
|
|
4534
4571
|
key: "usage",
|
|
4535
4572
|
header: r.columns.usage,
|
|
4536
4573
|
render: (e) => {
|
|
4537
4574
|
let t = e.redeemedCount + e.reservedCount;
|
|
4538
|
-
return e.maxRedemptions ?
|
|
4575
|
+
return e.maxRedemptions ? Ln(r.usage, {
|
|
4539
4576
|
used: t,
|
|
4540
4577
|
max: e.maxRedemptions
|
|
4541
|
-
}) :
|
|
4578
|
+
}) : Ln(r.usageUnlimited, { used: t });
|
|
4542
4579
|
}
|
|
4543
4580
|
}
|
|
4544
4581
|
];
|
|
@@ -4559,7 +4596,7 @@ function Bn() {
|
|
|
4559
4596
|
role: "group",
|
|
4560
4597
|
"aria-label": r.columns.status,
|
|
4561
4598
|
className: "sfa-filter-group",
|
|
4562
|
-
children:
|
|
4599
|
+
children: Bn.map((e) => /* @__PURE__ */ C("button", {
|
|
4563
4600
|
type: "button",
|
|
4564
4601
|
className: "sfa-chip",
|
|
4565
4602
|
"aria-pressed": i === e,
|
|
@@ -4575,7 +4612,7 @@ function Bn() {
|
|
|
4575
4612
|
})]
|
|
4576
4613
|
}),
|
|
4577
4614
|
/* @__PURE__ */ C(q, { error: l.error }),
|
|
4578
|
-
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, {
|
|
4579
4616
|
icon: c ? "search" : "discounts",
|
|
4580
4617
|
title: c ? r.noMatches : r.empty[i],
|
|
4581
4618
|
body: c ? void 0 : r.emptyHint
|
|
@@ -4595,7 +4632,7 @@ function Bn() {
|
|
|
4595
4632
|
});
|
|
4596
4633
|
}
|
|
4597
4634
|
// src/lib/discount-form.ts
|
|
4598
|
-
var
|
|
4635
|
+
var Hn = {
|
|
4599
4636
|
code: "",
|
|
4600
4637
|
type: "percent",
|
|
4601
4638
|
percentOff: "",
|
|
@@ -4604,43 +4641,43 @@ var Vn = {
|
|
|
4604
4641
|
startsAt: "",
|
|
4605
4642
|
endsAt: "",
|
|
4606
4643
|
maxRedemptions: ""
|
|
4607
|
-
},
|
|
4608
|
-
function
|
|
4644
|
+
}, Un = (e) => String(e).padStart(2, "0");
|
|
4645
|
+
function Wn(e) {
|
|
4609
4646
|
if (!e) return "";
|
|
4610
4647
|
let t = new Date(e);
|
|
4611
|
-
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())}`;
|
|
4612
4649
|
}
|
|
4613
|
-
function
|
|
4650
|
+
function Gn(e) {
|
|
4614
4651
|
if (e.trim() === "") return null;
|
|
4615
4652
|
let t = new Date(e);
|
|
4616
4653
|
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
4617
4654
|
}
|
|
4618
|
-
function
|
|
4655
|
+
function Kn(e) {
|
|
4619
4656
|
return {
|
|
4620
4657
|
code: e.code,
|
|
4621
4658
|
type: e.type,
|
|
4622
4659
|
percentOff: e.percentOff ? String(e.percentOff) : "",
|
|
4623
|
-
amountOff: e.amountOffCents ?
|
|
4624
|
-
minSubtotal: e.minSubtotalCents ?
|
|
4625
|
-
startsAt:
|
|
4626
|
-
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),
|
|
4627
4664
|
maxRedemptions: e.maxRedemptions ? String(e.maxRedemptions) : ""
|
|
4628
4665
|
};
|
|
4629
4666
|
}
|
|
4630
|
-
function
|
|
4667
|
+
function qn(e) {
|
|
4631
4668
|
return !!(e && e.redeemedCount + e.reservedCount > 0);
|
|
4632
4669
|
}
|
|
4633
|
-
var
|
|
4634
|
-
function
|
|
4670
|
+
var Jn = (e) => /^\d+$/.test(e.trim()) && Number(e) > 0 ? Number(e) : null;
|
|
4671
|
+
function Yn(e, t, n, r = 0) {
|
|
4635
4672
|
let i = t.validation, a = {}, o = e.code.trim().toUpperCase();
|
|
4636
4673
|
/^[A-Z0-9_-]{1,40}$/.test(o) || (a.code = i.code);
|
|
4637
|
-
let s =
|
|
4674
|
+
let s = Jn(e.percentOff), c = X(e.amountOff);
|
|
4638
4675
|
e.type === "percent" && (s === null || s > 100) && (a.percentOff = i.percentOff), e.type === "fixed" && !c && (a.amountOff = i.amountOff);
|
|
4639
|
-
let l = e.minSubtotal.trim(), u = l === "" ? null :
|
|
4676
|
+
let l = e.minSubtotal.trim(), u = l === "" ? null : X(l);
|
|
4640
4677
|
l !== "" && !u && (a.minSubtotal = i.minSubtotal);
|
|
4641
|
-
let d = e.maxRedemptions.trim(), f = d === "" ? null :
|
|
4678
|
+
let d = e.maxRedemptions.trim(), f = d === "" ? null : Jn(d);
|
|
4642
4679
|
d !== "" && f === null ? a.maxRedemptions = i.maxRedemptions : f !== null && f < r && (a.maxRedemptions = i.maxRedemptionsBelowUsage);
|
|
4643
|
-
let p =
|
|
4680
|
+
let p = Gn(e.startsAt), m = Gn(e.endsAt);
|
|
4644
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 ? {
|
|
4645
4682
|
ok: !1,
|
|
4646
4683
|
errors: a
|
|
@@ -4660,25 +4697,25 @@ function Jn(e, t, n, r = 0) {
|
|
|
4660
4697
|
}
|
|
4661
4698
|
};
|
|
4662
4699
|
}
|
|
4663
|
-
var
|
|
4700
|
+
var Xn = [
|
|
4664
4701
|
"type",
|
|
4665
4702
|
"percentOff",
|
|
4666
4703
|
"amountOffCents",
|
|
4667
4704
|
"currency"
|
|
4668
|
-
],
|
|
4705
|
+
], Zn = [
|
|
4669
4706
|
"minSubtotalCents",
|
|
4670
4707
|
"startsAt",
|
|
4671
4708
|
"endsAt",
|
|
4672
4709
|
"maxRedemptions"
|
|
4673
4710
|
];
|
|
4674
|
-
function
|
|
4711
|
+
function Qn(e, t, n) {
|
|
4675
4712
|
let r = {}, i = t, a = e, o = (e) => (i[e] ?? null) !== (a[e] ?? null);
|
|
4676
|
-
for (let e of
|
|
4713
|
+
for (let e of Zn) o(e) && (r[e] = i[e]);
|
|
4677
4714
|
if (n) return r;
|
|
4678
|
-
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];
|
|
4679
4716
|
return r;
|
|
4680
4717
|
}
|
|
4681
|
-
function
|
|
4718
|
+
function $n(e, t) {
|
|
4682
4719
|
let n = {
|
|
4683
4720
|
code: "code",
|
|
4684
4721
|
percentOff: "percentOff",
|
|
@@ -4695,7 +4732,7 @@ function Qn(e, t) {
|
|
|
4695
4732
|
return r;
|
|
4696
4733
|
}
|
|
4697
4734
|
// src/views/discounts/discount-fields.tsx
|
|
4698
|
-
function
|
|
4735
|
+
function er({ name: e, label: t, error: n, help: r, disabled: i, children: a }) {
|
|
4699
4736
|
let o = `sfa-field-${e}`, s = [r ? `${o}-help` : "", n ? `${o}-error` : ""].filter(Boolean).join(" ");
|
|
4700
4737
|
return /* @__PURE__ */ w("div", {
|
|
4701
4738
|
className: "sfa-field",
|
|
@@ -4725,9 +4762,9 @@ function $n({ name: e, label: t, error: n, help: r, disabled: i, children: a })
|
|
|
4725
4762
|
]
|
|
4726
4763
|
});
|
|
4727
4764
|
}
|
|
4728
|
-
var
|
|
4729
|
-
function
|
|
4730
|
-
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, {
|
|
4731
4768
|
name: n,
|
|
4732
4769
|
label: r,
|
|
4733
4770
|
error: t[n],
|
|
@@ -4740,7 +4777,7 @@ function tr({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4740
4777
|
value: e[n],
|
|
4741
4778
|
onChange: (e) => i(n, e.target.value)
|
|
4742
4779
|
})
|
|
4743
|
-
}), c = (r) => /* @__PURE__ */ C(
|
|
4780
|
+
}), c = (r) => /* @__PURE__ */ C(er, {
|
|
4744
4781
|
name: r,
|
|
4745
4782
|
label: n.fields[r],
|
|
4746
4783
|
error: t[r],
|
|
@@ -4757,7 +4794,7 @@ function tr({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4757
4794
|
help: o,
|
|
4758
4795
|
locked: a
|
|
4759
4796
|
}),
|
|
4760
|
-
/* @__PURE__ */ C(
|
|
4797
|
+
/* @__PURE__ */ C(er, {
|
|
4761
4798
|
name: "type",
|
|
4762
4799
|
label: n.fields.type,
|
|
4763
4800
|
disabled: a,
|
|
@@ -4765,7 +4802,7 @@ function tr({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4765
4802
|
...t,
|
|
4766
4803
|
value: e.type,
|
|
4767
4804
|
onChange: (e) => i("type", e.target.value),
|
|
4768
|
-
children:
|
|
4805
|
+
children: tr.map((e) => /* @__PURE__ */ C("option", {
|
|
4769
4806
|
value: e,
|
|
4770
4807
|
children: n.types[e]
|
|
4771
4808
|
}, e))
|
|
@@ -4791,33 +4828,33 @@ function tr({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
|
|
|
4791
4828
|
] });
|
|
4792
4829
|
}
|
|
4793
4830
|
// src/views/discounts/admin-discount-editor.tsx
|
|
4794
|
-
function
|
|
4795
|
-
return e ? /* @__PURE__ */ C(
|
|
4831
|
+
function rr({ discountId: e, onSaved: t }) {
|
|
4832
|
+
return e ? /* @__PURE__ */ C(ir, {
|
|
4796
4833
|
discountId: e,
|
|
4797
4834
|
onSaved: t
|
|
4798
|
-
}) : /* @__PURE__ */ C(
|
|
4835
|
+
}) : /* @__PURE__ */ C(ar, {
|
|
4799
4836
|
discount: void 0,
|
|
4800
4837
|
onSaved: t
|
|
4801
4838
|
});
|
|
4802
4839
|
}
|
|
4803
|
-
function
|
|
4840
|
+
function ir({ discountId: e, onSaved: t }) {
|
|
4804
4841
|
let n = I(), { labels: r } = F(), i = L(["admin-discount", e], () => n.getDiscount(e));
|
|
4805
|
-
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, {
|
|
4806
4843
|
discount: i.data,
|
|
4807
4844
|
onSaved: t
|
|
4808
4845
|
}, i.data.id) : /* @__PURE__ */ C("p", { children: r.loading });
|
|
4809
4846
|
}
|
|
4810
|
-
function
|
|
4811
|
-
let n = I(), { labels: r, currency: a } = F(), o = r.discounts, [s, c] = b(e), [u, f] = b(e ?
|
|
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) => {
|
|
4812
4849
|
m(t);
|
|
4813
4850
|
let n = Object.keys(t)[0];
|
|
4814
4851
|
n && e.elements.namedItem(n)?.focus();
|
|
4815
4852
|
}, T = R(async (e) => {
|
|
4816
|
-
let t =
|
|
4853
|
+
let t = Yn(u, o, s?.currency ?? a, y);
|
|
4817
4854
|
if (!t.ok) S(e, t.errors);
|
|
4818
4855
|
else try {
|
|
4819
4856
|
if (!s) return await n.createDiscount(t.input);
|
|
4820
|
-
let e =
|
|
4857
|
+
let e = Qn(s, t.input, x);
|
|
4821
4858
|
return Object.keys(e).length === 0 ? s : await n.updateDiscount(s.id, e);
|
|
4822
4859
|
} catch (t) {
|
|
4823
4860
|
if (t instanceof l) {
|
|
@@ -4829,14 +4866,14 @@ function ir({ discount: e, onSaved: t }) {
|
|
|
4829
4866
|
return;
|
|
4830
4867
|
}
|
|
4831
4868
|
if (!(t instanceof d)) throw t;
|
|
4832
|
-
S(e,
|
|
4869
|
+
S(e, $n(t.issues, o.validation.invalid));
|
|
4833
4870
|
return;
|
|
4834
4871
|
}
|
|
4835
4872
|
}), E = R((e) => {
|
|
4836
4873
|
if (!s) throw Error("Discount has not been created yet.");
|
|
4837
4874
|
return n.updateDiscount(s.id, { active: e });
|
|
4838
4875
|
}), D = (e) => {
|
|
4839
|
-
c(e), f(
|
|
4876
|
+
c(e), f(Kn(e)), g(!0), t?.(e);
|
|
4840
4877
|
}, O = (e, t) => {
|
|
4841
4878
|
f((n) => ({
|
|
4842
4879
|
...n,
|
|
@@ -4861,7 +4898,7 @@ function ir({ discount: e, onSaved: t }) {
|
|
|
4861
4898
|
children: [
|
|
4862
4899
|
/* @__PURE__ */ C(V, { title: s ? o.editTitle : o.createTitle }),
|
|
4863
4900
|
/* @__PURE__ */ C(q, { error: T.error ?? E.error }),
|
|
4864
|
-
/* @__PURE__ */ C(
|
|
4901
|
+
/* @__PURE__ */ C(nr, {
|
|
4865
4902
|
form: u,
|
|
4866
4903
|
errors: p,
|
|
4867
4904
|
labels: o,
|
|
@@ -4911,66 +4948,72 @@ function ir({ discount: e, onSaved: t }) {
|
|
|
4911
4948
|
]
|
|
4912
4949
|
});
|
|
4913
4950
|
}
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
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 ? {
|
|
4917
4953
|
...n,
|
|
4918
4954
|
...t
|
|
4919
|
-
} : n)),
|
|
4920
|
-
|
|
4955
|
+
} : n)), u = async (e) => {
|
|
4956
|
+
l(e.id, {
|
|
4921
4957
|
status: "uploading",
|
|
4922
4958
|
error: void 0
|
|
4923
4959
|
});
|
|
4924
|
-
let
|
|
4960
|
+
let n = e.productId;
|
|
4925
4961
|
try {
|
|
4926
|
-
|
|
4927
|
-
let i = await
|
|
4928
|
-
|
|
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, {
|
|
4929
4965
|
status: "done",
|
|
4930
4966
|
product: i
|
|
4931
4967
|
});
|
|
4932
|
-
} catch (
|
|
4933
|
-
|
|
4968
|
+
} catch (t) {
|
|
4969
|
+
l(e.id, {
|
|
4934
4970
|
status: "error",
|
|
4935
|
-
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();
|
|
4936
4979
|
});
|
|
4937
4980
|
}
|
|
4938
|
-
},
|
|
4939
|
-
|
|
4940
|
-
},
|
|
4941
|
-
let
|
|
4942
|
-
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);
|
|
4943
4986
|
return {
|
|
4944
|
-
id:
|
|
4987
|
+
id: o.current++,
|
|
4945
4988
|
file: e,
|
|
4946
|
-
status:
|
|
4947
|
-
reason:
|
|
4989
|
+
status: t ? "error" : "queued",
|
|
4990
|
+
reason: t ?? void 0
|
|
4948
4991
|
};
|
|
4949
4992
|
});
|
|
4950
|
-
|
|
4993
|
+
a((e) => [...e, ...t]), f(t.filter((e) => e.status === "queued"));
|
|
4951
4994
|
}, [
|
|
4952
|
-
e,
|
|
4953
4995
|
t,
|
|
4954
|
-
n
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
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) ? {
|
|
4958
5001
|
...t,
|
|
4959
5002
|
status: "queued"
|
|
4960
|
-
} : t)),
|
|
4961
|
-
},
|
|
5003
|
+
} : t)), f(e);
|
|
5004
|
+
}, g = i.filter((e) => e.status === "done"), _ = i.filter((e) => e.status === "error");
|
|
4962
5005
|
return {
|
|
4963
|
-
items:
|
|
4964
|
-
add:
|
|
4965
|
-
retry:
|
|
4966
|
-
done:
|
|
4967
|
-
failed:
|
|
4968
|
-
settled:
|
|
4969
|
-
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] : [])
|
|
4970
5013
|
};
|
|
4971
5014
|
}
|
|
4972
5015
|
// src/views/products/add-several/photo-picker.tsx
|
|
4973
|
-
function
|
|
5016
|
+
function sr({ label: e, onFiles: t, multiple: n = !0, primary: r = !1, zone: i = !1, hint: a }) {
|
|
4974
5017
|
return /* @__PURE__ */ w("label", {
|
|
4975
5018
|
className: i ? "sfa-dropzone" : `sfa-btn${r ? " sfa-btn--primary" : ""}`,
|
|
4976
5019
|
children: [
|
|
@@ -5000,7 +5043,7 @@ function or({ label: e, onFiles: t, multiple: n = !0, primary: r = !1, zone: i =
|
|
|
5000
5043
|
});
|
|
5001
5044
|
}
|
|
5002
5045
|
// src/views/products/add-several/admin-add-several.tsx
|
|
5003
|
-
function
|
|
5046
|
+
function cr({ failed: e }) {
|
|
5004
5047
|
return /* @__PURE__ */ C("ul", {
|
|
5005
5048
|
className: "sfa-batch__failed",
|
|
5006
5049
|
children: e.map((e) => /* @__PURE__ */ w("li", { children: [/* @__PURE__ */ C("strong", { children: e.file.name }), e.reason ? /* @__PURE__ */ C(K, {
|
|
@@ -5009,8 +5052,8 @@ function sr({ failed: e }) {
|
|
|
5009
5052
|
}) : /* @__PURE__ */ C(q, { error: e.error })] }, e.id))
|
|
5010
5053
|
});
|
|
5011
5054
|
}
|
|
5012
|
-
function
|
|
5013
|
-
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;
|
|
5014
5057
|
return /* @__PURE__ */ w("section", {
|
|
5015
5058
|
className: "sfa-batch",
|
|
5016
5059
|
children: [/* @__PURE__ */ C(V, { title: n.title }), /* @__PURE__ */ C("div", {
|
|
@@ -5020,7 +5063,7 @@ function cr({ onDone: e }) {
|
|
|
5020
5063
|
children: [
|
|
5021
5064
|
/* @__PURE__ */ C("h2", { children: n.introTitle }),
|
|
5022
5065
|
/* @__PURE__ */ C("p", { children: n.introBody }),
|
|
5023
|
-
/* @__PURE__ */ C(
|
|
5066
|
+
/* @__PURE__ */ C(sr, {
|
|
5024
5067
|
label: n.choose,
|
|
5025
5068
|
hint: n.dropHint,
|
|
5026
5069
|
onFiles: r.add,
|
|
@@ -5030,7 +5073,7 @@ function cr({ onDone: e }) {
|
|
|
5030
5073
|
}) : r.settled ? r.failed.length === 0 ? /* @__PURE__ */ w("div", {
|
|
5031
5074
|
className: "sfa-batch__result",
|
|
5032
5075
|
children: [
|
|
5033
|
-
/* @__PURE__ */ C("h2", { children:
|
|
5076
|
+
/* @__PURE__ */ C("h2", { children: Y(n.doneTitle, { count: r.done.length }) }),
|
|
5034
5077
|
/* @__PURE__ */ C("p", { children: n.doneBody }),
|
|
5035
5078
|
/* @__PURE__ */ C("button", {
|
|
5036
5079
|
type: "button",
|
|
@@ -5042,8 +5085,8 @@ function cr({ onDone: e }) {
|
|
|
5042
5085
|
}) : /* @__PURE__ */ w("div", {
|
|
5043
5086
|
className: "sfa-batch__result",
|
|
5044
5087
|
children: [
|
|
5045
|
-
/* @__PURE__ */ C("h2", { children:
|
|
5046
|
-
/* @__PURE__ */ C(
|
|
5088
|
+
/* @__PURE__ */ C("h2", { children: Y(n.failedTitle, { count: r.failed.length }) }),
|
|
5089
|
+
/* @__PURE__ */ C(cr, { failed: r.failed }),
|
|
5047
5090
|
/* @__PURE__ */ w("div", {
|
|
5048
5091
|
className: "sfa-batch__actions",
|
|
5049
5092
|
children: [a ? /* @__PURE__ */ C("button", {
|
|
@@ -5056,7 +5099,7 @@ function cr({ onDone: e }) {
|
|
|
5056
5099
|
className: "sfa-btn",
|
|
5057
5100
|
onClick: () => e(r.products),
|
|
5058
5101
|
children: n.continueWithout
|
|
5059
|
-
}) : /* @__PURE__ */ C(
|
|
5102
|
+
}) : /* @__PURE__ */ C(sr, {
|
|
5060
5103
|
label: n.choose,
|
|
5061
5104
|
onFiles: r.add
|
|
5062
5105
|
})]
|
|
@@ -5068,7 +5111,7 @@ function cr({ onDone: e }) {
|
|
|
5068
5111
|
children: [/* @__PURE__ */ C("progress", {
|
|
5069
5112
|
max: i,
|
|
5070
5113
|
value: o
|
|
5071
|
-
}), /* @__PURE__ */ C("p", { children:
|
|
5114
|
+
}), /* @__PURE__ */ C("p", { children: Y(n.progress, {
|
|
5072
5115
|
done: o,
|
|
5073
5116
|
total: i
|
|
5074
5117
|
}) })]
|
|
@@ -5077,7 +5120,7 @@ function cr({ onDone: e }) {
|
|
|
5077
5120
|
});
|
|
5078
5121
|
}
|
|
5079
5122
|
// src/views/products/finish-drafts/piece-fields.tsx
|
|
5080
|
-
function
|
|
5123
|
+
function ur({ form: e, update: t, categories: n }) {
|
|
5081
5124
|
let { labels: r, locale: i, currency: a } = F(), o = r.products.fields, s = r.products.flow, c = [...n ?? []], l = e.category.trim();
|
|
5082
5125
|
return l && !c.includes(l) && c.push(l), /* @__PURE__ */ w("div", {
|
|
5083
5126
|
className: "sfa-piece__fields",
|
|
@@ -5106,7 +5149,7 @@ function lr({ form: e, update: t, categories: n }) {
|
|
|
5106
5149
|
className: "sfa-flow__price",
|
|
5107
5150
|
children: [/* @__PURE__ */ C("span", {
|
|
5108
5151
|
"aria-hidden": "true",
|
|
5109
|
-
children:
|
|
5152
|
+
children: _t(i, a)
|
|
5110
5153
|
}), /* @__PURE__ */ C("input", {
|
|
5111
5154
|
id: "sfa-piece-price",
|
|
5112
5155
|
type: "text",
|
|
@@ -5152,14 +5195,14 @@ function lr({ form: e, update: t, categories: n }) {
|
|
|
5152
5195
|
});
|
|
5153
5196
|
}
|
|
5154
5197
|
// src/views/products/finish-drafts/piece-card.tsx
|
|
5155
|
-
function
|
|
5198
|
+
function dr({ product: e, index: t, total: n, categories: r, onAdvance: i, onBack: a }) {
|
|
5156
5199
|
let { labels: o, renderImage: s } = F(), c = o.products.stock.queue, [l, u] = b(() => Ut(e)), d = Wt({
|
|
5157
5200
|
initial: e,
|
|
5158
5201
|
form: l
|
|
5159
|
-
}), f =
|
|
5202
|
+
}), f = Nt({
|
|
5160
5203
|
productId: e.id,
|
|
5161
5204
|
onUploaded: d.setProduct
|
|
5162
|
-
}), p =
|
|
5205
|
+
}), p = $(d.product)[0], m = t === n - 1, h = String(t + 1), g = (e, t) => u((n) => ({
|
|
5163
5206
|
...n,
|
|
5164
5207
|
[e]: t
|
|
5165
5208
|
})), _ = async () => {
|
|
@@ -5173,7 +5216,7 @@ function ur({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
5173
5216
|
/* @__PURE__ */ C("p", {
|
|
5174
5217
|
className: "sfa-piece__count",
|
|
5175
5218
|
id: "sfa-piece-title",
|
|
5176
|
-
children:
|
|
5219
|
+
children: Y(c.pieceOf, {
|
|
5177
5220
|
n: t + 1,
|
|
5178
5221
|
m: n
|
|
5179
5222
|
})
|
|
@@ -5189,9 +5232,9 @@ function ur({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
5189
5232
|
className: "sfa-piece__photo",
|
|
5190
5233
|
children: [p ? s({
|
|
5191
5234
|
src: p.url,
|
|
5192
|
-
alt: p.alt ||
|
|
5235
|
+
alt: p.alt || Q(c.coverAlt, { n: h }),
|
|
5193
5236
|
sizes: "320px"
|
|
5194
|
-
}) : /* @__PURE__ */ C(
|
|
5237
|
+
}) : /* @__PURE__ */ C(sr, {
|
|
5195
5238
|
label: c.addPhoto,
|
|
5196
5239
|
multiple: !1,
|
|
5197
5240
|
onFiles: (e) => f.upload(e, "")
|
|
@@ -5199,7 +5242,7 @@ function ur({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
5199
5242
|
variant: "error",
|
|
5200
5243
|
children: e.reason ?? /* @__PURE__ */ C(q, { error: e.error })
|
|
5201
5244
|
}, e.id) : null)]
|
|
5202
|
-
}), /* @__PURE__ */ C(
|
|
5245
|
+
}), /* @__PURE__ */ C(ur, {
|
|
5203
5246
|
form: l,
|
|
5204
5247
|
update: g,
|
|
5205
5248
|
categories: r
|
|
@@ -5225,7 +5268,7 @@ function ur({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
5225
5268
|
/* @__PURE__ */ C("button", {
|
|
5226
5269
|
type: "button",
|
|
5227
5270
|
className: "sfa-btn sfa-btn--primary",
|
|
5228
|
-
disabled: !
|
|
5271
|
+
disabled: !dt(l) || d.state === "saving",
|
|
5229
5272
|
onClick: _,
|
|
5230
5273
|
children: m ? c.review : c.next
|
|
5231
5274
|
})
|
|
@@ -5235,11 +5278,11 @@ function ur({ product: e, index: t, total: n, categories: r, onAdvance: i, onBac
|
|
|
5235
5278
|
});
|
|
5236
5279
|
}
|
|
5237
5280
|
// src/views/products/finish-drafts/piece-summary.tsx
|
|
5238
|
-
function
|
|
5239
|
-
return
|
|
5281
|
+
function fr(e) {
|
|
5282
|
+
return dt(Ut(e));
|
|
5240
5283
|
}
|
|
5241
|
-
function
|
|
5242
|
-
let { labels: o, renderImage: s } = F(), c = o.products.stock.summary, l = e.filter(
|
|
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));
|
|
5243
5286
|
return /* @__PURE__ */ w("section", {
|
|
5244
5287
|
className: "sfa-piece",
|
|
5245
5288
|
"aria-labelledby": "sfa-summary-title",
|
|
@@ -5253,7 +5296,7 @@ function fr({ pieces: e, pending: t, failure: n, onPublish: r, onOpenPiece: i, o
|
|
|
5253
5296
|
/* @__PURE__ */ C("ul", {
|
|
5254
5297
|
className: "sfa-summary__list",
|
|
5255
5298
|
children: e.map((e, t) => {
|
|
5256
|
-
let n =
|
|
5299
|
+
let n = $(e)[0], r = fr(e), a = e.name || c.untitled, o = /* @__PURE__ */ w(S, { children: [
|
|
5257
5300
|
/* @__PURE__ */ C("span", {
|
|
5258
5301
|
className: "sfa-summary__photo",
|
|
5259
5302
|
children: n ? s({
|
|
@@ -5280,7 +5323,7 @@ function fr({ pieces: e, pending: t, failure: n, onPublish: r, onOpenPiece: i, o
|
|
|
5280
5323
|
}) : /* @__PURE__ */ w("button", {
|
|
5281
5324
|
type: "button",
|
|
5282
5325
|
className: "sfa-summary__row sfa-summary__row--open",
|
|
5283
|
-
"aria-label":
|
|
5326
|
+
"aria-label": Q(c.openPiece, { name: a }),
|
|
5284
5327
|
onClick: () => i(t),
|
|
5285
5328
|
children: [o, /* @__PURE__ */ C("span", {
|
|
5286
5329
|
className: "sfa-summary__chevron",
|
|
@@ -5304,27 +5347,12 @@ function fr({ pieces: e, pending: t, failure: n, onPublish: r, onOpenPiece: i, o
|
|
|
5304
5347
|
className: "sfa-btn sfa-btn--primary",
|
|
5305
5348
|
disabled: t,
|
|
5306
5349
|
onClick: () => r(l, u),
|
|
5307
|
-
children:
|
|
5350
|
+
children: Y(c.publish, { count: l.length })
|
|
5308
5351
|
}) : null]
|
|
5309
5352
|
})
|
|
5310
5353
|
]
|
|
5311
5354
|
});
|
|
5312
5355
|
}
|
|
5313
|
-
// src/lib/fill-alts.ts
|
|
5314
|
-
async function pr(e, t, n) {
|
|
5315
|
-
let r = t.name.trim();
|
|
5316
|
-
if (!r) return t;
|
|
5317
|
-
let i = t, a = [...t.images].sort((e, t) => e.position - t.position);
|
|
5318
|
-
for (let [o, s] of a.entries()) {
|
|
5319
|
-
if (s.alt.trim()) continue;
|
|
5320
|
-
let a = Z(n, {
|
|
5321
|
-
name: r,
|
|
5322
|
-
n: String(o + 1)
|
|
5323
|
-
});
|
|
5324
|
-
i = await e.updateProductImage(t.id, s.id, { alt: a });
|
|
5325
|
-
}
|
|
5326
|
-
return i;
|
|
5327
|
-
}
|
|
5328
5356
|
// src/views/products/finish-drafts/use-publish-pieces.ts
|
|
5329
5357
|
function mr() {
|
|
5330
5358
|
let e = I(), { labels: t } = F(), [n, r] = b(!1), [i, a] = b(void 0), [o, s] = b(null);
|
|
@@ -5333,7 +5361,7 @@ function mr() {
|
|
|
5333
5361
|
r(!0), a(void 0);
|
|
5334
5362
|
let o = [], c = [...i];
|
|
5335
5363
|
for (let r of n) try {
|
|
5336
|
-
await
|
|
5364
|
+
await Vt(e, r, t.products.flow.altFallback), o.push(await e.updateProduct(r.id, { status: "active" }));
|
|
5337
5365
|
} catch (e) {
|
|
5338
5366
|
c.push(r), e instanceof u || a(e);
|
|
5339
5367
|
}
|
|
@@ -5364,10 +5392,10 @@ function hr({ initial: e, categories: t, onDone: n }) {
|
|
|
5364
5392
|
}),
|
|
5365
5393
|
/* @__PURE__ */ C("h2", {
|
|
5366
5394
|
className: "sfa-piece__heading",
|
|
5367
|
-
children:
|
|
5395
|
+
children: Y(i.summary.publishedTitle, { count: e.length })
|
|
5368
5396
|
}),
|
|
5369
5397
|
/* @__PURE__ */ C("p", { children: i.summary.publishedBody }),
|
|
5370
|
-
t.length ? /* @__PURE__ */ C("p", { children:
|
|
5398
|
+
t.length ? /* @__PURE__ */ C("p", { children: Y(i.summary.stillIncomplete, { count: t.length }) }) : null,
|
|
5371
5399
|
/* @__PURE__ */ C("div", {
|
|
5372
5400
|
className: "sfa-piece__actions sfa-piece__actions--center",
|
|
5373
5401
|
children: /* @__PURE__ */ C("button", {
|
|
@@ -5380,7 +5408,7 @@ function hr({ initial: e, categories: t, onDone: n }) {
|
|
|
5380
5408
|
]
|
|
5381
5409
|
});
|
|
5382
5410
|
}
|
|
5383
|
-
return s >= a.length ? /* @__PURE__ */ C(
|
|
5411
|
+
return s >= a.length ? /* @__PURE__ */ C(pr, {
|
|
5384
5412
|
pieces: a,
|
|
5385
5413
|
pending: l.pending,
|
|
5386
5414
|
failure: l.failure,
|
|
@@ -5390,7 +5418,7 @@ function hr({ initial: e, categories: t, onDone: n }) {
|
|
|
5390
5418
|
published: [],
|
|
5391
5419
|
drafts: a
|
|
5392
5420
|
})
|
|
5393
|
-
}) : /* @__PURE__ */ C(
|
|
5421
|
+
}) : /* @__PURE__ */ C(dr, {
|
|
5394
5422
|
product: a[s],
|
|
5395
5423
|
index: s,
|
|
5396
5424
|
total: a.length,
|
|
@@ -5429,6 +5457,6 @@ function gr({ productIds: e, categories: t, onDone: n }) {
|
|
|
5429
5457
|
})]
|
|
5430
5458
|
});
|
|
5431
5459
|
}
|
|
5432
|
-
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 };
|
|
5433
5461
|
|
|
5434
5462
|
//# sourceMappingURL=index.js.map
|