@mercurjs/vendor 2.0.0-canary.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/dist/[id]-23D3HY3G.js +444 -0
- package/dist/[id]-2VBOAZM4.js +1215 -0
- package/dist/[id]-A4FSDRER.js +325 -0
- package/dist/[id]-E45G2SDA.js +213 -0
- package/dist/[id]-FXKSI52D.js +477 -0
- package/dist/[id]-HHZ3BSXV.js +1166 -0
- package/dist/[id]-MIV4U5UW.js +137 -0
- package/dist/[id]-QSRIPPIP.js +612 -0
- package/dist/[id]-RGDXOC7T.js +499 -0
- package/dist/[id]-TI2MOR2C.js +377 -0
- package/dist/[id]-U5DT2ZLS.js +301 -0
- package/dist/[id]-UMFGLDM2.js +354 -0
- package/dist/[id]-VTFOP3BF.js +97 -0
- package/dist/[id]-ZYF75L6G.js +479 -0
- package/dist/[location_id]-4UIEW5KM.js +685 -0
- package/dist/[province_id]-ZCHPXXQN.js +205 -0
- package/dist/add-KNDQL6YN.js +660 -0
- package/dist/add-customer-groups-JA346MTF.js +275 -0
- package/dist/add-products-2VB57KXV.js +273 -0
- package/dist/add-promotions-KVKEP6EO.js +260 -0
- package/dist/add-to-campaign-V6D7JKRS.js +44 -0
- package/dist/additional-attributes-E36EZX4V.js +219 -0
- package/dist/adjust-inventory-P7AB7VIB.js +228 -0
- package/dist/allocate-items-QAS5PZLR.js +529 -0
- package/dist/areas-Y7VDWH7G.js +151 -0
- package/dist/attributes-UEM2VJKV.js +277 -0
- package/dist/breadcrumb-3QTVWXZB.js +27 -0
- package/dist/breadcrumb-5OTOCYNL.js +38 -0
- package/dist/breadcrumb-6NAAOPIY.js +11 -0
- package/dist/breadcrumb-ASB2YCNV.js +25 -0
- package/dist/breadcrumb-CIGKLKKS.js +28 -0
- package/dist/breadcrumb-EOYLR3IQ.js +22 -0
- package/dist/breadcrumb-LENACUAA.js +22 -0
- package/dist/breadcrumb-LIXGWUQF.js +44 -0
- package/dist/breadcrumb-MOQ7GI3Z.js +27 -0
- package/dist/breadcrumb-NCBGPQML.js +23 -0
- package/dist/breadcrumb-OVMEC5OZ.js +33 -0
- package/dist/breadcrumb-RIXJ5QSX.js +45 -0
- package/dist/breadcrumb-TZB6EWNC.js +31 -0
- package/dist/breadcrumb-WP34OXGQ.js +23 -0
- package/dist/campaigns-PMVKUFEA.js +28 -0
- package/dist/categories-CKKIUMYG.js +27 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2C3HUJ3Z.js +222 -0
- package/dist/chunk-2F3H6ORE.js +36 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-3CK6OINO.js +448 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3LPVUPZZ.js +74 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3SIDRPKT.js +185 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-4MFMCZEJ.js +70 -0
- package/dist/chunk-4TBDDMFP.js +425 -0
- package/dist/chunk-4TLP3TAA.js +34 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5NF4OTVV.js +169 -0
- package/dist/chunk-66V3GFSW.js +138 -0
- package/dist/chunk-6EYGH3TB.js +26 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6YA3C4NB.js +55 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-A2SY5L5G.js +183 -0
- package/dist/chunk-A5DJIOHN.js +4 -0
- package/dist/chunk-AIFLEWO2.js +56 -0
- package/dist/chunk-ASVMGV2B.js +80 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AYUG34XF.js +84 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-B2RVONU7.js +160 -0
- package/dist/chunk-BCU3FKP2.js +18 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BDZOSMAX.js +23 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CDIZEXFJ.js +145 -0
- package/dist/chunk-CFETU5BI.js +261 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-CUO22GTM.js +96 -0
- package/dist/chunk-CVVYQI5F.js +41 -0
- package/dist/chunk-DARJTN4I.js +60 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DC2K6CFQ.js +86 -0
- package/dist/chunk-DDEIH66R.js +123 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-DYUTYBAQ.js +67 -0
- package/dist/chunk-E3MNEQID.js +24 -0
- package/dist/chunk-FBZHM2QZ.js +247 -0
- package/dist/chunk-FDZC3TFZ.js +717 -0
- package/dist/chunk-FGCKXH45.js +263 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FOMEBUX6.js +89 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-GC33DBKG.js +143 -0
- package/dist/chunk-GDMNHL7E.js +144 -0
- package/dist/chunk-GTUR4HSV.js +53 -0
- package/dist/chunk-H35HHFTB.js +225 -0
- package/dist/chunk-HB3BP55W.js +25 -0
- package/dist/chunk-HHD2VUED.js +29 -0
- package/dist/chunk-HUNGNEPY.js +312 -0
- package/dist/chunk-HUZG6A3X.js +127 -0
- package/dist/chunk-INNFZYX2.js +183 -0
- package/dist/chunk-IQPN4PZJ.js +749 -0
- package/dist/chunk-IZ5RG5XI.js +72 -0
- package/dist/chunk-J2XP7VRG.js +1080 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JKXAL7WR.js +92 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-JVBLYMY2.js +268 -0
- package/dist/chunk-JXP5YZ77.js +86 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KHHY7EEM.js +267 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LWVBKUUL.js +77 -0
- package/dist/chunk-LYUCDASZ.js +115 -0
- package/dist/chunk-LZ7QV42C.js +37 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N3T24SEK.js +32 -0
- package/dist/chunk-NANYVBFI.js +106 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NX26QE2O.js +47 -0
- package/dist/chunk-NYDJTWRL.js +389 -0
- package/dist/chunk-O5LRZEG6.js +253 -0
- package/dist/chunk-O6PRBSFL.js +115 -0
- package/dist/chunk-OJCDB3N5.js +539 -0
- package/dist/chunk-OSFOX7MG.js +176 -0
- package/dist/chunk-OVPAOBZB.js +110 -0
- package/dist/chunk-PADOWAXM.js +118 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-PLSJ74T2.js +298 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PWZKFTJS.js +247 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-PYQJ5N25.js +191 -0
- package/dist/chunk-Q4UVXS46.js +14 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-QUNDGPF7.js +92801 -0
- package/dist/chunk-R65A4P4H.js +136 -0
- package/dist/chunk-RE7YXVFG.js +128 -0
- package/dist/chunk-RETT6WME.js +37 -0
- package/dist/chunk-RHKRREUU.js +15 -0
- package/dist/chunk-RIILGKYR.js +32 -0
- package/dist/chunk-RM5RSDYP.js +353 -0
- package/dist/chunk-RNC4NFVK.js +170 -0
- package/dist/chunk-RSMZHZI2.js +2078 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S3PQKKNV.js +49 -0
- package/dist/chunk-S5GQ2SES.js +276 -0
- package/dist/chunk-SECZTXSU.js +31 -0
- package/dist/chunk-SI4ALL7W.js +180 -0
- package/dist/chunk-SID3COTK.js +21 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-SOZMJA7V.js +61 -0
- package/dist/chunk-TG3TCIL6.js +207 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TTFCO5HU.js +173 -0
- package/dist/chunk-TXEPCJEQ.js +430 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U3X4DNV6.js +179 -0
- package/dist/chunk-UXKKD4AD.js +437 -0
- package/dist/chunk-UYJ65N46.js +261 -0
- package/dist/chunk-VDWGP2U6.js +71 -0
- package/dist/chunk-VGJTARSA.js +89 -0
- package/dist/chunk-VHMGJUYN.js +28 -0
- package/dist/chunk-VKC3XKFF.js +283 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-W4KHJ4D6.js +74 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-W6ZVQJYB.js +311 -0
- package/dist/chunk-WA3IVAUC.js +123 -0
- package/dist/chunk-WHTS4G5K.js +1551 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WPFTRRWV.js +455 -0
- package/dist/chunk-WQZ4ONQV.js +6 -0
- package/dist/chunk-WS652CCV.js +893 -0
- package/dist/chunk-XG4PTPRM.js +0 -0
- package/dist/chunk-XRNDVICA.js +85 -0
- package/dist/chunk-XXZJISPX.js +48 -0
- package/dist/chunk-Y224F4UU.js +81 -0
- package/dist/chunk-Y3FR5JC7.js +437 -0
- package/dist/chunk-Y4VBOHAP.js +111 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-Z2WPXJ6J.js +146 -0
- package/dist/chunk-ZA2KFUFR.js +19 -0
- package/dist/chunk-ZEKV7LGF.js +6 -0
- package/dist/chunk-ZFFA36DB.js +186 -0
- package/dist/chunk-ZPGWTLF2.js +499 -0
- package/dist/chunk-ZVT2QSWR.js +263 -0
- package/dist/chunk-ZZ7VKT2S.js +4113 -0
- package/dist/collections-TREF67TO.js +63 -0
- package/dist/configuration-KWAL2QZ5.js +152 -0
- package/dist/configuration-RNWBTRAH.js +205 -0
- package/dist/create-7UEEO5TM.js +125 -0
- package/dist/create-DTCDJMIT.js +634 -0
- package/dist/create-DYDRAY6V.js +622 -0
- package/dist/create-EJM5C2XP.js +27 -0
- package/dist/create-F7OMPGZV.js +853 -0
- package/dist/create-G4UJOJJ6.js +69 -0
- package/dist/create-IE6MYOIY.js +170 -0
- package/dist/create-L23TGTBH.js +225 -0
- package/dist/create-LOBCFTCT.js +583 -0
- package/dist/create-MKBBF2V3.js +150 -0
- package/dist/create-TFDUNJSI.js +163 -0
- package/dist/create-TMTZDKII.js +711 -0
- package/dist/create-XGF6DB5F.js +239 -0
- package/dist/create-YAAK7JQ3.js +1052 -0
- package/dist/create-YPCVTXAK.js +194 -0
- package/dist/create-ZU362U3B.js +310 -0
- package/dist/customers-4QWR5UOL.js +27 -0
- package/dist/edit-2QA5BVOY.js +735 -0
- package/dist/edit-47I7VVNB.js +167 -0
- package/dist/edit-5BUGSOTL.js +255 -0
- package/dist/edit-7LQATDUD.js +193 -0
- package/dist/edit-AQAPYMDY.js +260 -0
- package/dist/edit-BQLSTFTQ.js +138 -0
- package/dist/edit-BYXHU3IG.js +308 -0
- package/dist/edit-DG3MY3ZH.js +244 -0
- package/dist/edit-J3LD76JS.js +192 -0
- package/dist/edit-J6WCPHDS.js +205 -0
- package/dist/edit-KCZVZLSZ.js +131 -0
- package/dist/edit-LOKLQGM2.js +181 -0
- package/dist/edit-MDTTTB33.js +104 -0
- package/dist/edit-NFSU2K3O.js +413 -0
- package/dist/edit-RHNZWNXD.js +89 -0
- package/dist/edit-XU33IVZH.js +204 -0
- package/dist/edit-ZMINDMGM.js +116 -0
- package/dist/edit-budget-Z5USV462.js +145 -0
- package/dist/edit-inventory-item-YFW2AFRD.js +128 -0
- package/dist/edit-inventory-item-attributes-IYAMJDTB.js +278 -0
- package/dist/fulfillment-SKXAF3BZ.js +545 -0
- package/dist/fulfillment-providers-ACERVITQ.js +279 -0
- package/dist/home-PP7YYCSB.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +3656 -0
- package/dist/inventory-AIRQ2KNS.js +26 -0
- package/dist/locations-SQKM7JWN.js +23 -0
- package/dist/login-LKFCRHXN.js +35 -0
- package/dist/manage-locations-4PQS4QY7.js +195 -0
- package/dist/media-PL477QJO.js +703 -0
- package/dist/metadata-42MU3H7T.js +60 -0
- package/dist/metadata-DIJTVDF7.js +45 -0
- package/dist/metadata-NX3LEEB3.js +64 -0
- package/dist/metadata-RBDSM567.js +65 -0
- package/dist/metadata-VZTWNZPG.js +66 -0
- package/dist/metadata-X3XGQ563.js +67 -0
- package/dist/no-match-BO2NNLCM.js +33 -0
- package/dist/orders-2KHCHNO5.js +59 -0
- package/dist/organization-VQXCKHCN.js +233 -0
- package/dist/organize-3F5ZUIGB.js +23 -0
- package/dist/organize-WPWEPCF7.js +23 -0
- package/dist/pages/index.d.ts +1153 -0
- package/dist/pages/index.js +198 -0
- package/dist/payouts-3BY73LZ3.js +27 -0
- package/dist/price-lists-G256JJN7.js +34 -0
- package/dist/prices-EW7KBY6R.js +269 -0
- package/dist/pricing-3PUJDOZN.js +313 -0
- package/dist/product-tags-PI3RENEX.js +80 -0
- package/dist/product-types-WJPLJI7H.js +32 -0
- package/dist/product-variant-detail-EYTE7PHL.js +377 -0
- package/dist/product-variant-edit-PW7W5J5E.js +402 -0
- package/dist/products-GSN4I7BT.js +272 -0
- package/dist/products-RFYNEY57.js +85 -0
- package/dist/promotions-CIZIDQ64.js +31 -0
- package/dist/reset-password-OFUSH363.js +299 -0
- package/dist/return-reasons-4V2KVSRI.js +52 -0
- package/dist/sales-channels-MBWVM3X2.js +184 -0
- package/dist/sales-channels-ZKA62EAW.js +156 -0
- package/dist/seller-ZFDLKF5Y.js +36 -0
- package/dist/settings-NP2IAID5.js +111 -0
- package/dist/shipping-profile-7FTHSPY2.js +145 -0
- package/dist/shipping-profiles-7R6L65WG.js +43 -0
- package/dist/stock-ENMBCZRY.js +502 -0
- package/dist/stock-VYDJY46S.js +278 -0
- package/dist/tax-regions-V6G6244H.js +87 -0
- package/package.json +87 -0
|
File without changes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
castNumber
|
|
3
|
+
} from "./chunk-SMQT3ZNO.js";
|
|
4
|
+
|
|
5
|
+
// src/pages/price-lists/common/utils.ts
|
|
6
|
+
import { json } from "react-router-dom";
|
|
7
|
+
var getValues = (priceList) => {
|
|
8
|
+
const startsAt = priceList.starts_at;
|
|
9
|
+
const endsAt = priceList.ends_at;
|
|
10
|
+
const isExpired = endsAt ? new Date(endsAt) < /* @__PURE__ */ new Date() : false;
|
|
11
|
+
const isScheduled = startsAt ? new Date(startsAt) > /* @__PURE__ */ new Date() : false;
|
|
12
|
+
const isDraft = priceList.status === "draft" /* DRAFT */;
|
|
13
|
+
return {
|
|
14
|
+
isExpired,
|
|
15
|
+
isScheduled,
|
|
16
|
+
isDraft
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
var getPriceListStatus = (t, priceList) => {
|
|
20
|
+
const { isExpired, isScheduled, isDraft } = getValues(priceList);
|
|
21
|
+
let text = t("priceLists.fields.status.options.active");
|
|
22
|
+
let color = "green";
|
|
23
|
+
let status = "active" /* ACTIVE */;
|
|
24
|
+
if (isDraft) {
|
|
25
|
+
color = "grey";
|
|
26
|
+
text = t("priceLists.fields.status.options.draft");
|
|
27
|
+
status = "draft" /* DRAFT */;
|
|
28
|
+
}
|
|
29
|
+
if (isExpired) {
|
|
30
|
+
color = "red";
|
|
31
|
+
text = t("priceLists.fields.status.options.expired");
|
|
32
|
+
status = "expired" /* EXPIRED */;
|
|
33
|
+
}
|
|
34
|
+
if (isScheduled) {
|
|
35
|
+
color = "orange";
|
|
36
|
+
text = t("priceLists.fields.status.options.scheduled");
|
|
37
|
+
status = "scheduled" /* SCHEDULED */;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
color,
|
|
41
|
+
text,
|
|
42
|
+
status
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var isProductRow = (row) => {
|
|
46
|
+
return "variants" in row;
|
|
47
|
+
};
|
|
48
|
+
var extractPricesFromVariants = (variantId, variant, regions) => {
|
|
49
|
+
const extractPriceDetails = (price, priceType, id) => {
|
|
50
|
+
const currencyCode = priceType === "currency" ? id : regions.find((r) => r.id === id)?.currency_code;
|
|
51
|
+
if (!currencyCode) {
|
|
52
|
+
throw json({ message: "Currency code not found" }, 400);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
amount: castNumber(price.amount),
|
|
56
|
+
...priceType === "region" ? { rules: { region_id: id } } : {},
|
|
57
|
+
currency_code: currencyCode,
|
|
58
|
+
variant_id: variantId
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const currencyPrices = Object.entries(variant.currency_prices || {}).flatMap(
|
|
62
|
+
([currencyCode, currencyPrice]) => {
|
|
63
|
+
return currencyPrice?.amount ? [extractPriceDetails(currencyPrice, "currency", currencyCode)] : [];
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const regionPrices = Object.entries(variant.region_prices || {}).flatMap(
|
|
67
|
+
([regionId, regionPrice]) => {
|
|
68
|
+
return regionPrice?.amount ? [extractPriceDetails(regionPrice, "region", regionId)] : [];
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
return [...currencyPrices, ...regionPrices];
|
|
72
|
+
};
|
|
73
|
+
var exctractPricesFromProducts = (products, regions) => {
|
|
74
|
+
return Object.values(products).flatMap(
|
|
75
|
+
({ variants }) => Object.entries(variants).flatMap(
|
|
76
|
+
([variantId, variant]) => extractPricesFromVariants(variantId, variant, regions)
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
getPriceListStatus,
|
|
83
|
+
isProductRow,
|
|
84
|
+
exctractPricesFromProducts
|
|
85
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StatusCell
|
|
3
|
+
} from "./chunk-DB6ANJBO.js";
|
|
4
|
+
import {
|
|
5
|
+
i18n
|
|
6
|
+
} from "./chunk-QUNDGPF7.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/promotions.ts
|
|
9
|
+
var promotionStatusMap = {
|
|
10
|
+
["ACTIVE" /* ACTIVE */]: ["green", i18n.t("statuses.active")],
|
|
11
|
+
["INACTIVE" /* INACTIVE */]: ["red", i18n.t("statuses.inactive")],
|
|
12
|
+
["DRAFT" /* DRAFT */]: ["grey", i18n.t("statuses.draft")],
|
|
13
|
+
["SCHEDULED" /* SCHEDULED */]: [
|
|
14
|
+
"orange",
|
|
15
|
+
`${i18n.t("promotions.fields.campaign")} ${i18n.t("statuses.scheduled")?.toLowerCase()}`
|
|
16
|
+
],
|
|
17
|
+
["EXPIRED" /* EXPIRED */]: [
|
|
18
|
+
"red",
|
|
19
|
+
`${i18n.t("promotions.fields.campaign")} ${i18n.t("statuses.expired")?.toLowerCase()}`
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
var getPromotionStatus = (promotion) => {
|
|
23
|
+
const date = /* @__PURE__ */ new Date();
|
|
24
|
+
const campaign = promotion.campaign;
|
|
25
|
+
if (!campaign) {
|
|
26
|
+
return promotionStatusMap[promotion.status.toUpperCase()];
|
|
27
|
+
}
|
|
28
|
+
if (campaign.starts_at && new Date(campaign.starts_at) > date) {
|
|
29
|
+
return promotionStatusMap["SCHEDULED" /* SCHEDULED */];
|
|
30
|
+
}
|
|
31
|
+
const campaignBudget = campaign.budget;
|
|
32
|
+
const overBudget = campaignBudget && campaignBudget.limit && campaignBudget.used > campaignBudget.limit;
|
|
33
|
+
if (campaign.ends_at && new Date(campaign.ends_at) < date || overBudget) {
|
|
34
|
+
return promotionStatusMap["EXPIRED" /* EXPIRED */];
|
|
35
|
+
}
|
|
36
|
+
return promotionStatusMap[promotion.status.toUpperCase()];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/components/table/table-cells/promotion/status-cell/status-cell.tsx
|
|
40
|
+
import { jsx } from "react/jsx-runtime";
|
|
41
|
+
var StatusCell2 = ({ promotion }) => {
|
|
42
|
+
const [color, text] = getPromotionStatus(promotion);
|
|
43
|
+
return /* @__PURE__ */ jsx(StatusCell, { color, children: text });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
StatusCell2 as StatusCell
|
|
48
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/lib/client/client.ts
|
|
2
|
+
import { createClient } from "@mercurjs/client";
|
|
3
|
+
import config from "virtual:mercur/config";
|
|
4
|
+
var backendUrl = config.backendUrl ?? "http://localhost:9000";
|
|
5
|
+
var sdk = createClient({
|
|
6
|
+
baseUrl: backendUrl,
|
|
7
|
+
fetchOptions: {
|
|
8
|
+
credentials: "include"
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var fetchQuery = async (url, {
|
|
12
|
+
method,
|
|
13
|
+
body,
|
|
14
|
+
query,
|
|
15
|
+
headers
|
|
16
|
+
}) => {
|
|
17
|
+
const params = Object.entries(query || {}).reduce((acc, [key, value]) => {
|
|
18
|
+
if (value !== null && value !== void 0 && value !== "") {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
const arrayParams = value.map(
|
|
21
|
+
(item) => `${encodeURIComponent(key)}[]=${encodeURIComponent(item)}`
|
|
22
|
+
).join("&");
|
|
23
|
+
if (acc) {
|
|
24
|
+
acc += "&" + arrayParams;
|
|
25
|
+
} else {
|
|
26
|
+
acc = arrayParams;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
const separator = acc ? "&" : "";
|
|
30
|
+
const serializedValue = typeof value === "object" ? JSON.stringify(value) : value;
|
|
31
|
+
acc += `${separator}${encodeURIComponent(key)}=${encodeURIComponent(serializedValue)}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, "");
|
|
36
|
+
const response = await fetch(
|
|
37
|
+
`${backendUrl}${url}${params ? `?${params}` : ""}`,
|
|
38
|
+
{
|
|
39
|
+
method,
|
|
40
|
+
credentials: "include",
|
|
41
|
+
headers: {
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
...headers
|
|
44
|
+
},
|
|
45
|
+
body: body ? JSON.stringify(body) : null
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const errorData = await response.json();
|
|
50
|
+
if (response.status === 401) {
|
|
51
|
+
window.location.href = "/login?reason=Unauthorized";
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const error = new Error(errorData.message || "Server error");
|
|
55
|
+
error.status = response.status;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
return response.json();
|
|
59
|
+
};
|
|
60
|
+
var uploadFilesQuery = async (files) => {
|
|
61
|
+
const formData = new FormData();
|
|
62
|
+
for (const { file } of files) {
|
|
63
|
+
formData.append("files", file);
|
|
64
|
+
}
|
|
65
|
+
const response = await fetch(`${backendUrl}/vendor/uploads`, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
credentials: "include",
|
|
68
|
+
body: formData
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return response.json();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
backendUrl,
|
|
78
|
+
sdk,
|
|
79
|
+
fetchQuery,
|
|
80
|
+
uploadFilesQuery
|
|
81
|
+
};
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useQueryParams
|
|
3
|
+
} from "./chunk-THHRRYRS.js";
|
|
4
|
+
import {
|
|
5
|
+
ActionMenu
|
|
6
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
7
|
+
import {
|
|
8
|
+
useDate
|
|
9
|
+
} from "./chunk-CFETU5BI.js";
|
|
10
|
+
|
|
11
|
+
// src/components/data-table/data-table.tsx
|
|
12
|
+
import {
|
|
13
|
+
DataTable as UiDataTable,
|
|
14
|
+
useDataTable,
|
|
15
|
+
Heading,
|
|
16
|
+
Text,
|
|
17
|
+
Button
|
|
18
|
+
} from "@medusajs/ui";
|
|
19
|
+
import React, { useCallback, useMemo } from "react";
|
|
20
|
+
import { useTranslation } from "react-i18next";
|
|
21
|
+
import { Link, useNavigate, useSearchParams } from "react-router-dom";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var DataTable = ({
|
|
24
|
+
data = [],
|
|
25
|
+
columns,
|
|
26
|
+
filters,
|
|
27
|
+
commands,
|
|
28
|
+
action,
|
|
29
|
+
actions,
|
|
30
|
+
actionMenu,
|
|
31
|
+
getRowId,
|
|
32
|
+
rowCount = 0,
|
|
33
|
+
enablePagination = true,
|
|
34
|
+
enableSearch = true,
|
|
35
|
+
autoFocusSearch = false,
|
|
36
|
+
enableFilterMenu,
|
|
37
|
+
rowHref,
|
|
38
|
+
heading,
|
|
39
|
+
headingLevel = "h1",
|
|
40
|
+
subHeading,
|
|
41
|
+
prefix,
|
|
42
|
+
pageSize = 10,
|
|
43
|
+
emptyState,
|
|
44
|
+
rowSelection,
|
|
45
|
+
isLoading = false,
|
|
46
|
+
layout = "auto",
|
|
47
|
+
enableColumnVisibility = false,
|
|
48
|
+
initialColumnVisibility = {},
|
|
49
|
+
onColumnVisibilityChange,
|
|
50
|
+
columnOrder,
|
|
51
|
+
onColumnOrderChange,
|
|
52
|
+
enableViewSelector = false,
|
|
53
|
+
entity,
|
|
54
|
+
currentColumns,
|
|
55
|
+
filterBarContent
|
|
56
|
+
}) => {
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const enableFiltering = filters && filters.length > 0;
|
|
59
|
+
const showFilterMenu = enableFilterMenu !== void 0 ? enableFilterMenu : enableFiltering;
|
|
60
|
+
const enableCommands = commands && commands.length > 0;
|
|
61
|
+
const enableSorting = columns.some((column) => column.enableSorting);
|
|
62
|
+
const [columnVisibility, setColumnVisibility] = React.useState(initialColumnVisibility);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
const currentKeys = Object.keys(columnVisibility).sort();
|
|
65
|
+
const newKeys = Object.keys(initialColumnVisibility).sort();
|
|
66
|
+
const hasChanged = currentKeys.length !== newKeys.length || currentKeys.some((key, index) => key !== newKeys[index]) || Object.entries(initialColumnVisibility).some(
|
|
67
|
+
([key, value]) => columnVisibility[key] !== value
|
|
68
|
+
);
|
|
69
|
+
if (hasChanged) {
|
|
70
|
+
setColumnVisibility(initialColumnVisibility);
|
|
71
|
+
}
|
|
72
|
+
}, [initialColumnVisibility]);
|
|
73
|
+
const handleColumnVisibilityChange = React.useCallback(
|
|
74
|
+
(visibility) => {
|
|
75
|
+
setColumnVisibility(visibility);
|
|
76
|
+
onColumnVisibilityChange?.(visibility);
|
|
77
|
+
},
|
|
78
|
+
[onColumnVisibilityChange]
|
|
79
|
+
);
|
|
80
|
+
const filterIds = useMemo(() => filters?.map((f) => f.id) ?? [], [filters]);
|
|
81
|
+
const prefixedFilterIds = filterIds.map((id) => getQueryParamKey(id, prefix));
|
|
82
|
+
const { offset, order, q, ...filterParams } = useQueryParams(
|
|
83
|
+
[
|
|
84
|
+
...filterIds,
|
|
85
|
+
...enableSorting ? ["order"] : [],
|
|
86
|
+
...enableSearch ? ["q"] : [],
|
|
87
|
+
...enablePagination ? ["offset"] : []
|
|
88
|
+
],
|
|
89
|
+
prefix
|
|
90
|
+
);
|
|
91
|
+
const [_, setSearchParams] = useSearchParams();
|
|
92
|
+
const search = useMemo(() => {
|
|
93
|
+
return q ?? "";
|
|
94
|
+
}, [q]);
|
|
95
|
+
const handleSearchChange = (value) => {
|
|
96
|
+
setSearchParams((prev) => {
|
|
97
|
+
if (value) {
|
|
98
|
+
prev.set(getQueryParamKey("q", prefix), value);
|
|
99
|
+
} else {
|
|
100
|
+
prev.delete(getQueryParamKey("q", prefix));
|
|
101
|
+
}
|
|
102
|
+
return prev;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const pagination = useMemo(() => {
|
|
106
|
+
return offset ? parsePaginationState(offset, pageSize) : { pageIndex: 0, pageSize };
|
|
107
|
+
}, [offset, pageSize]);
|
|
108
|
+
const handlePaginationChange = (value) => {
|
|
109
|
+
setSearchParams((prev) => {
|
|
110
|
+
if (value.pageIndex === 0) {
|
|
111
|
+
prev.delete(getQueryParamKey("offset", prefix));
|
|
112
|
+
} else {
|
|
113
|
+
prev.set(
|
|
114
|
+
getQueryParamKey("offset", prefix),
|
|
115
|
+
transformPaginationState(value).toString()
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return prev;
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const filtering = useMemo(
|
|
122
|
+
() => parseFilterState(filterIds, filterParams),
|
|
123
|
+
[filterIds, filterParams]
|
|
124
|
+
);
|
|
125
|
+
const handleFilteringChange = (value) => {
|
|
126
|
+
setSearchParams((prev) => {
|
|
127
|
+
Array.from(prev.keys()).forEach((key) => {
|
|
128
|
+
if (prefixedFilterIds.includes(key)) {
|
|
129
|
+
const unprefixedKey = prefix ? key.replace(`${prefix}_`, "") : key;
|
|
130
|
+
if (!(unprefixedKey in value)) {
|
|
131
|
+
prev.delete(key);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.entries(value).forEach(([key, filter]) => {
|
|
136
|
+
const prefixedKey = getQueryParamKey(key, prefix);
|
|
137
|
+
if (filter !== void 0) {
|
|
138
|
+
prev.set(prefixedKey, JSON.stringify(filter));
|
|
139
|
+
} else {
|
|
140
|
+
prev.delete(prefixedKey);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return prev;
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const sorting = useMemo(() => {
|
|
147
|
+
return order ? parseSortingState(order) : null;
|
|
148
|
+
}, [order]);
|
|
149
|
+
const currentConfiguration = useMemo(
|
|
150
|
+
() => ({
|
|
151
|
+
filters: filtering,
|
|
152
|
+
sorting,
|
|
153
|
+
search
|
|
154
|
+
}),
|
|
155
|
+
[filtering, sorting, search]
|
|
156
|
+
);
|
|
157
|
+
const handleSortingChange = (value) => {
|
|
158
|
+
setSearchParams((prev) => {
|
|
159
|
+
if (value) {
|
|
160
|
+
const valueToStore = transformSortingState(value);
|
|
161
|
+
prev.set(getQueryParamKey("order", prefix), valueToStore);
|
|
162
|
+
} else {
|
|
163
|
+
prev.delete(getQueryParamKey("order", prefix));
|
|
164
|
+
}
|
|
165
|
+
return prev;
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const { pagination: paginationTranslations, toolbar: toolbarTranslations } = useDataTableTranslations();
|
|
169
|
+
const navigate = useNavigate();
|
|
170
|
+
const onRowClick = useCallback(
|
|
171
|
+
(event, row) => {
|
|
172
|
+
if (!rowHref) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const href = rowHref(row);
|
|
176
|
+
const basePath = "/";
|
|
177
|
+
const hrefWithBasePath = `${basePath === "/" ? "" : basePath}${href}`;
|
|
178
|
+
if (event.metaKey || event.ctrlKey || event.button === 1) {
|
|
179
|
+
window.open(hrefWithBasePath, "_blank", "noreferrer");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (event.shiftKey) {
|
|
183
|
+
window.open(hrefWithBasePath, void 0, "noreferrer");
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
navigate(href);
|
|
187
|
+
},
|
|
188
|
+
[navigate, rowHref]
|
|
189
|
+
);
|
|
190
|
+
const instance = useDataTable({
|
|
191
|
+
data,
|
|
192
|
+
columns,
|
|
193
|
+
filters,
|
|
194
|
+
commands,
|
|
195
|
+
rowCount,
|
|
196
|
+
getRowId,
|
|
197
|
+
onRowClick: rowHref ? onRowClick : void 0,
|
|
198
|
+
pagination: enablePagination ? {
|
|
199
|
+
state: pagination,
|
|
200
|
+
onPaginationChange: handlePaginationChange
|
|
201
|
+
} : void 0,
|
|
202
|
+
filtering: enableFiltering ? {
|
|
203
|
+
state: filtering,
|
|
204
|
+
onFilteringChange: handleFilteringChange
|
|
205
|
+
} : void 0,
|
|
206
|
+
sorting: enableSorting ? {
|
|
207
|
+
state: sorting,
|
|
208
|
+
onSortingChange: handleSortingChange
|
|
209
|
+
} : void 0,
|
|
210
|
+
search: enableSearch ? {
|
|
211
|
+
state: search,
|
|
212
|
+
onSearchChange: handleSearchChange
|
|
213
|
+
} : void 0,
|
|
214
|
+
rowSelection,
|
|
215
|
+
isLoading,
|
|
216
|
+
columnVisibility: enableColumnVisibility ? {
|
|
217
|
+
state: columnVisibility,
|
|
218
|
+
onColumnVisibilityChange: handleColumnVisibilityChange
|
|
219
|
+
} : void 0,
|
|
220
|
+
columnOrder: columnOrder && onColumnOrderChange ? {
|
|
221
|
+
state: columnOrder,
|
|
222
|
+
onColumnOrderChange
|
|
223
|
+
} : void 0
|
|
224
|
+
});
|
|
225
|
+
const shouldRenderHeading = heading || subHeading;
|
|
226
|
+
return /* @__PURE__ */ jsxs(
|
|
227
|
+
UiDataTable,
|
|
228
|
+
{
|
|
229
|
+
instance,
|
|
230
|
+
className: layout === "fill" ? "h-full [&_tr]:last-of-type:!border-b" : void 0,
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
UiDataTable.Toolbar,
|
|
234
|
+
{
|
|
235
|
+
className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center",
|
|
236
|
+
translations: toolbarTranslations,
|
|
237
|
+
filterBarContent,
|
|
238
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
239
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-4", children: shouldRenderHeading && /* @__PURE__ */ jsxs("div", { children: [
|
|
240
|
+
heading && /* @__PURE__ */ jsx(Heading, { level: headingLevel, children: heading }),
|
|
241
|
+
subHeading && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: subHeading })
|
|
242
|
+
] }) }),
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
244
|
+
showFilterMenu && /* @__PURE__ */ jsx(UiDataTable.FilterMenu, {}),
|
|
245
|
+
enableSorting && /* @__PURE__ */ jsx(UiDataTable.SortingMenu, {}),
|
|
246
|
+
enableSearch && /* @__PURE__ */ jsx("div", { className: "w-full md:w-auto", children: /* @__PURE__ */ jsx(
|
|
247
|
+
UiDataTable.Search,
|
|
248
|
+
{
|
|
249
|
+
placeholder: t("filters.searchLabel"),
|
|
250
|
+
autoFocus: autoFocusSearch
|
|
251
|
+
}
|
|
252
|
+
) }),
|
|
253
|
+
actionMenu && /* @__PURE__ */ jsx(ActionMenu, { variant: "primary", ...actionMenu }),
|
|
254
|
+
actions && actions.length > 0 && /* @__PURE__ */ jsx(DataTableActions, { actions }),
|
|
255
|
+
!actions && action && /* @__PURE__ */ jsx(DataTableAction, { ...action })
|
|
256
|
+
] })
|
|
257
|
+
] })
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx(UiDataTable.Table, { emptyState }),
|
|
261
|
+
enablePagination && /* @__PURE__ */ jsx(UiDataTable.Pagination, { translations: paginationTranslations }),
|
|
262
|
+
enableCommands && /* @__PURE__ */ jsx(
|
|
263
|
+
UiDataTable.CommandBar,
|
|
264
|
+
{
|
|
265
|
+
selectedLabel: (count) => `${count} selected`
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
function transformSortingState(value) {
|
|
273
|
+
return value.desc ? `-${value.id}` : value.id;
|
|
274
|
+
}
|
|
275
|
+
function parseSortingState(value) {
|
|
276
|
+
return value.startsWith("-") ? { id: value.slice(1), desc: true } : { id: value, desc: false };
|
|
277
|
+
}
|
|
278
|
+
function transformPaginationState(value) {
|
|
279
|
+
return value.pageIndex * value.pageSize;
|
|
280
|
+
}
|
|
281
|
+
function parsePaginationState(value, pageSize) {
|
|
282
|
+
const offset = parseInt(value);
|
|
283
|
+
return {
|
|
284
|
+
pageIndex: Math.floor(offset / pageSize),
|
|
285
|
+
pageSize
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function parseFilterState(filterIds, value) {
|
|
289
|
+
if (!value) {
|
|
290
|
+
return {};
|
|
291
|
+
}
|
|
292
|
+
const filters = {};
|
|
293
|
+
for (const id of filterIds) {
|
|
294
|
+
const filterValue = value[id];
|
|
295
|
+
if (filterValue !== void 0) {
|
|
296
|
+
filters[id] = JSON.parse(filterValue);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return filters;
|
|
300
|
+
}
|
|
301
|
+
function getQueryParamKey(key, prefix) {
|
|
302
|
+
return prefix ? `${prefix}_${key}` : key;
|
|
303
|
+
}
|
|
304
|
+
var useDataTableTranslations = () => {
|
|
305
|
+
const { t } = useTranslation();
|
|
306
|
+
const paginationTranslations = {
|
|
307
|
+
of: t("general.of"),
|
|
308
|
+
results: t("general.results"),
|
|
309
|
+
pages: t("general.pages"),
|
|
310
|
+
prev: t("general.prev"),
|
|
311
|
+
next: t("general.next")
|
|
312
|
+
};
|
|
313
|
+
const toolbarTranslations = {
|
|
314
|
+
clearAll: t("actions.clearAll"),
|
|
315
|
+
sort: t("filters.sortLabel"),
|
|
316
|
+
columns: "Columns"
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
pagination: paginationTranslations,
|
|
320
|
+
toolbar: toolbarTranslations
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
var DataTableAction = ({
|
|
324
|
+
label,
|
|
325
|
+
disabled,
|
|
326
|
+
...props
|
|
327
|
+
}) => {
|
|
328
|
+
const buttonProps = {
|
|
329
|
+
size: "small",
|
|
330
|
+
disabled: disabled ?? false,
|
|
331
|
+
type: "button",
|
|
332
|
+
variant: "secondary"
|
|
333
|
+
};
|
|
334
|
+
if ("to" in props) {
|
|
335
|
+
return /* @__PURE__ */ jsx(Button, { ...buttonProps, asChild: true, children: /* @__PURE__ */ jsx(Link, { to: props.to, children: label }) });
|
|
336
|
+
}
|
|
337
|
+
return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
|
|
338
|
+
};
|
|
339
|
+
var DataTableActions = ({ actions }) => {
|
|
340
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2", children: actions.map((action, index) => /* @__PURE__ */ jsx(DataTableAction, { ...action }, index)) });
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// src/components/data-table/helpers/general/use-data-table-date-filters.tsx
|
|
344
|
+
import { createDataTableFilterHelper } from "@medusajs/ui";
|
|
345
|
+
import { subDays, subMonths } from "date-fns";
|
|
346
|
+
import { useMemo as useMemo2 } from "react";
|
|
347
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
348
|
+
var filterHelper = createDataTableFilterHelper();
|
|
349
|
+
var useDateFilterOptions = () => {
|
|
350
|
+
const { t } = useTranslation2();
|
|
351
|
+
const today = useMemo2(() => {
|
|
352
|
+
const date = /* @__PURE__ */ new Date();
|
|
353
|
+
date.setHours(0, 0, 0, 0);
|
|
354
|
+
return date;
|
|
355
|
+
}, []);
|
|
356
|
+
return useMemo2(() => {
|
|
357
|
+
return [
|
|
358
|
+
{
|
|
359
|
+
label: t("filters.date.today"),
|
|
360
|
+
value: {
|
|
361
|
+
$gte: today.toISOString()
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
label: t("filters.date.lastSevenDays"),
|
|
366
|
+
value: {
|
|
367
|
+
$gte: subDays(today, 7).toISOString()
|
|
368
|
+
// 7 days ago
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
label: t("filters.date.lastThirtyDays"),
|
|
373
|
+
value: {
|
|
374
|
+
$gte: subDays(today, 30).toISOString()
|
|
375
|
+
// 30 days ago
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
label: t("filters.date.lastNinetyDays"),
|
|
380
|
+
value: {
|
|
381
|
+
$gte: subDays(today, 90).toISOString()
|
|
382
|
+
// 90 days ago
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
label: t("filters.date.lastTwelveMonths"),
|
|
387
|
+
value: {
|
|
388
|
+
$gte: subMonths(today, 12).toISOString()
|
|
389
|
+
// 12 months ago
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
];
|
|
393
|
+
}, [today, t]);
|
|
394
|
+
};
|
|
395
|
+
var useDataTableDateFilters = (disableRangeOption) => {
|
|
396
|
+
const { t } = useTranslation2();
|
|
397
|
+
const { getFullDate } = useDate();
|
|
398
|
+
const dateFilterOptions = useDateFilterOptions();
|
|
399
|
+
const rangeOptions = useMemo2(() => {
|
|
400
|
+
if (disableRangeOption) {
|
|
401
|
+
return {
|
|
402
|
+
disableRangeOption: true
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
return {
|
|
406
|
+
rangeOptionStartLabel: t("filters.date.starting"),
|
|
407
|
+
rangeOptionEndLabel: t("filters.date.ending"),
|
|
408
|
+
rangeOptionLabel: t("filters.date.custom"),
|
|
409
|
+
options: dateFilterOptions
|
|
410
|
+
};
|
|
411
|
+
}, [disableRangeOption, t, dateFilterOptions]);
|
|
412
|
+
return useMemo2(() => {
|
|
413
|
+
return [
|
|
414
|
+
filterHelper.accessor("created_at", {
|
|
415
|
+
type: "date",
|
|
416
|
+
label: t("fields.createdAt"),
|
|
417
|
+
format: "date",
|
|
418
|
+
formatDateValue: (date) => getFullDate({ date }),
|
|
419
|
+
options: dateFilterOptions,
|
|
420
|
+
...rangeOptions
|
|
421
|
+
}),
|
|
422
|
+
filterHelper.accessor("updated_at", {
|
|
423
|
+
type: "date",
|
|
424
|
+
label: t("fields.updatedAt"),
|
|
425
|
+
format: "date",
|
|
426
|
+
formatDateValue: (date) => getFullDate({ date }),
|
|
427
|
+
options: dateFilterOptions,
|
|
428
|
+
...rangeOptions
|
|
429
|
+
})
|
|
430
|
+
];
|
|
431
|
+
}, [t, dateFilterOptions, getFullDate, rangeOptions]);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export {
|
|
435
|
+
DataTable,
|
|
436
|
+
useDataTableDateFilters
|
|
437
|
+
};
|