@mercurjs/admin 2.0.0-canary.24
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/add-campaign-promotions-JDC36EOE.js +265 -0
- package/dist/adjust-inventory-2YLC4O4I.js +262 -0
- package/dist/api-key-management-create-KERROZ6Z.js +282 -0
- package/dist/api-key-management-detail-PXY2ZH4V.js +481 -0
- package/dist/api-key-management-edit-7IPPTW37.js +106 -0
- package/dist/api-key-management-list-QQHOCVV4.js +350 -0
- package/dist/api-key-management-sales-channels-AO6SRCAW.js +201 -0
- package/dist/campaign-budget-edit-C5PCVES3.js +147 -0
- package/dist/campaign-configuration-ONC2CL7Q.js +154 -0
- package/dist/campaign-create-J2PN77A6.js +29 -0
- package/dist/campaign-detail-2XJ7PXOQ.js +666 -0
- package/dist/campaign-edit-MU4TVOEC.js +206 -0
- package/dist/campaign-list-BWYHTJL2.js +187 -0
- package/dist/categories-metadata-UC3N6YSC.js +83 -0
- package/dist/category-create-DRJZI3EM.js +427 -0
- package/dist/category-detail-DEGYVUXB.js +544 -0
- package/dist/category-edit-PTYOK7VV.js +220 -0
- package/dist/category-list-T4GPTLOA.js +286 -0
- package/dist/category-organize-MLBY54BT.js +110 -0
- package/dist/category-products-W7U2VZTZ.js +281 -0
- package/dist/chunk-25LYVP3C.js +37 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2I3BDP2Z.js +61 -0
- package/dist/chunk-2KCF3ZIB.js +32 -0
- package/dist/chunk-2MKZ4HD4.js +175 -0
- package/dist/chunk-2PZGY332.js +88 -0
- package/dist/chunk-2QKPRGNK.js +107 -0
- package/dist/chunk-2Y3WMGN6.js +39 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-33XUAKRP.js +6 -0
- package/dist/chunk-362QMJZM.js +77 -0
- package/dist/chunk-3CKTAFTR.js +143 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3KOTDGC2.js +18 -0
- package/dist/chunk-3LDJURK5.js +296 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3XPXUIK3.js +34 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-54EPH67T.js +34 -0
- package/dist/chunk-54RTJBYO.js +153 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5LZ2G4ZX.js +422 -0
- package/dist/chunk-5S6J5PG5.js +182 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6KI3GDYH.js +46 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-7SVLKK6Q.js +31 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AWZFIP25.js +117 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BMNW3AEU.js +373 -0
- package/dist/chunk-BRUOBAPY.js +234 -0
- package/dist/chunk-BYZIWSBB.js +185 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CBRSGM3X.js +342 -0
- package/dist/chunk-CI5Z6FGV.js +87 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-D3KDXELJ.js +110 -0
- package/dist/chunk-D6IERBVW.js +43 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DLKKSPFE.js +50 -0
- package/dist/chunk-DV73MHTN.js +457 -0
- package/dist/chunk-DXZOR4AG.js +69 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-EOZUAYQL.js +6 -0
- package/dist/chunk-ERTSYQAI.js +121 -0
- package/dist/chunk-EZIB4NST.js +94 -0
- package/dist/chunk-FGZCSG7T.js +232 -0
- package/dist/chunk-FI474ADU.js +0 -0
- package/dist/chunk-FLCYR7E5.js +467 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FODCCP6C.js +76 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-FWPGOIFA.js +22 -0
- package/dist/chunk-G5OVX555.js +26 -0
- package/dist/chunk-GUIDZSDY.js +41 -0
- package/dist/chunk-H22XDSXD.js +47 -0
- package/dist/chunk-HC25LNX7.js +45 -0
- package/dist/chunk-HINXQTCW.js +97 -0
- package/dist/chunk-HYUGYB23.js +161 -0
- package/dist/chunk-I43SCBL3.js +106 -0
- package/dist/chunk-IGTRIAUC.js +84 -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-JDGE23BZ.js +332 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JISYRXUS.js +389 -0
- package/dist/chunk-JJVGCTKT.js +243 -0
- package/dist/chunk-JQV7CXEC.js +37 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KBYZLKI4.js +1093 -0
- package/dist/chunk-KTKL7M34.js +90 -0
- package/dist/chunk-KUWNYCGL.js +4113 -0
- package/dist/chunk-KW56S7WF.js +67 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LCZXAT4Q.js +58 -0
- package/dist/chunk-LFKTHNWI.js +83 -0
- package/dist/chunk-LGJWR5LX.js +164 -0
- package/dist/chunk-LLWK3OR6.js +169 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LR4ACD6E.js +86676 -0
- package/dist/chunk-LTBX54CI.js +11 -0
- package/dist/chunk-LXP7K6HL.js +817 -0
- package/dist/chunk-LXSBG6LK.js +18 -0
- package/dist/chunk-LZALOVO3.js +372 -0
- package/dist/chunk-M6SOYQJ6.js +39 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-MWOKFNRO.js +446 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N5IUYCUZ.js +31 -0
- package/dist/chunk-NBMM2TZK.js +33 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NIRWGTM3.js +1104 -0
- package/dist/chunk-NS5CHWOH.js +80 -0
- package/dist/chunk-NWQRHWE5.js +9461 -0
- package/dist/chunk-NXDFDEKP.js +0 -0
- package/dist/chunk-NZJGUN67.js +266 -0
- package/dist/chunk-NZN7PFPB.js +169 -0
- package/dist/chunk-O5HZRJPB.js +55 -0
- package/dist/chunk-O5VKW5FL.js +41 -0
- package/dist/chunk-O67KME6D.js +110 -0
- package/dist/chunk-ODBDAABQ.js +88 -0
- package/dist/chunk-OGYWOPHZ.js +96 -0
- package/dist/chunk-ORW4HNX5.js +357 -0
- package/dist/chunk-P3IZB24Y.js +109 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PX675AEP.js +129 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QG6PLWNH.js +106 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-RK5N3XIX.js +56 -0
- package/dist/chunk-RLMLYJDI.js +38 -0
- package/dist/chunk-RMXYSYK4.js +50 -0
- package/dist/chunk-RPIJY6TT.js +637 -0
- package/dist/chunk-RSBZREKG.js +144 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S4SVK5DE.js +39 -0
- package/dist/chunk-S6LPCNXQ.js +29 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-T435NFHC.js +490 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TLE6YHGH.js +26 -0
- package/dist/chunk-TN4TIT7O.js +116 -0
- package/dist/chunk-TUJIAA5O.js +101 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2L77ZDR.js +17 -0
- package/dist/chunk-U2UCL2VG.js +369 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U5MJIHLY.js +87 -0
- package/dist/chunk-U62GYN4A.js +227 -0
- package/dist/chunk-UM7ZR3VU.js +14 -0
- package/dist/chunk-UQITHKTH.js +342 -0
- package/dist/chunk-UZJ2NQSN.js +257 -0
- package/dist/chunk-UZWFZMOX.js +40 -0
- package/dist/chunk-V74Y5NIV.js +49 -0
- package/dist/chunk-VBMMWVB5.js +49 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VVTSF42Z.js +52 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-VWGKHDZ6.js +528 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-WCEMRNW4.js +6 -0
- package/dist/chunk-WDZFLCSQ.js +77 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WMA3WTCM.js +117 -0
- package/dist/chunk-WWANSDFM.js +175 -0
- package/dist/chunk-XBMLI2YI.js +85 -0
- package/dist/chunk-XBVIP2BA.js +609 -0
- package/dist/chunk-XCMR2HTV.js +102 -0
- package/dist/chunk-XFR5JLNF.js +44 -0
- package/dist/chunk-XL52SYWY.js +23 -0
- package/dist/chunk-XQNVC4Q7.js +212 -0
- package/dist/chunk-XSX255FK.js +12 -0
- package/dist/chunk-Y2M536WR.js +67 -0
- package/dist/chunk-Y456KVIN.js +116 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YBZWO4ZV.js +57 -0
- package/dist/chunk-YGQUBTKR.js +81 -0
- package/dist/chunk-YGSM5PVN.js +170 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-YWWUOGJA.js +62 -0
- package/dist/chunk-YXFG3M2D.js +792 -0
- package/dist/chunk-ZAUMHCIL.js +42 -0
- package/dist/chunk-ZDJWCSZ4.js +85 -0
- package/dist/chunk-ZQZHFMD7.js +19 -0
- package/dist/chunk-ZYNBKBY3.js +14 -0
- package/dist/collection-add-products-IUDEIUM5.js +284 -0
- package/dist/collection-create-AQ3GUG3G.js +133 -0
- package/dist/collection-detail-SDFALX6M.js +444 -0
- package/dist/collection-edit-AAHL2WFH.js +121 -0
- package/dist/collection-list-JGKC5EVM.js +228 -0
- package/dist/collection-metadata-YQWA2JTU.js +80 -0
- package/dist/customer-create-5VT2TB6S.js +183 -0
- package/dist/customer-create-address-ICEFEFD2.js +299 -0
- package/dist/customer-detail-CDELSJ77.js +695 -0
- package/dist/customer-edit-DZAD53JC.js +192 -0
- package/dist/customer-list-EIQP23FQ.js +152 -0
- package/dist/customer-metadata-ATAORBRN.js +81 -0
- package/dist/customers-add-customer-group-542PUCCT.js +308 -0
- package/dist/edit-inventory-item-P2HVULPA.js +152 -0
- package/dist/edit-inventory-item-attributes-V2HK3WTQ.js +323 -0
- package/dist/edit-reservation-LX2Z6KVD.js +246 -0
- package/dist/edit-rules-Q5UNWAUD.js +316 -0
- package/dist/home-I3OILW5Z.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +4824 -0
- package/dist/inventory-create-FT7GL4RK.js +616 -0
- package/dist/inventory-detail-LNZ5QC67.js +771 -0
- package/dist/inventory-list-UXY7PU3N.js +432 -0
- package/dist/inventory-metadata-OYETRH5X.js +83 -0
- package/dist/inventory-stock-3MBERL3K.js +288 -0
- package/dist/invite-HJ7BRO6H.js +372 -0
- package/dist/location-create-ZVVQT2KP.js +238 -0
- package/dist/location-detail-A5SHPUQN.js +823 -0
- package/dist/location-edit-QSRHHDQ2.js +253 -0
- package/dist/location-fulfillment-providers-4HMT5L7L.js +289 -0
- package/dist/location-list-TC5FEN5R.js +346 -0
- package/dist/location-sales-channels-STDHWQSC.js +215 -0
- package/dist/location-service-zone-create-63LUYCJI.js +173 -0
- package/dist/location-service-zone-edit-UNXI5BQV.js +134 -0
- package/dist/location-service-zone-manage-areas-UMD6CZDZ.js +154 -0
- package/dist/location-service-zone-shipping-option-create-5L73SAGE.js +807 -0
- package/dist/location-service-zone-shipping-option-edit-2FEWQD6Y.js +362 -0
- package/dist/location-service-zone-shipping-option-pricing-QSB56QZD.js +362 -0
- package/dist/login-V4HZQTCQ.js +254 -0
- package/dist/manage-locations-NVHONEZE.js +249 -0
- package/dist/no-match-JLVLPCRH.js +33 -0
- package/dist/order-allocate-items-F7CXZQGX.js +558 -0
- package/dist/order-create-claim-GDVWGZJA.js +2203 -0
- package/dist/order-create-edit-6YYKYT66.js +936 -0
- package/dist/order-create-exchange-NLDIMGBG.js +2190 -0
- package/dist/order-create-fulfillment-EIYGSKXP.js +621 -0
- package/dist/order-create-refund-BBXEZNWA.js +403 -0
- package/dist/order-create-return-6TA5J3AW.js +1292 -0
- package/dist/order-create-shipment-T4C6UE2K.js +208 -0
- package/dist/order-detail-Y4EG3P5F.js +3846 -0
- package/dist/order-edit-billing-address-NNIFUC5C.js +400 -0
- package/dist/order-edit-email-VXOX62P6.js +171 -0
- package/dist/order-edit-shipping-address-WDKCQRRG.js +397 -0
- package/dist/order-list-XDOAXZXN.js +231 -0
- package/dist/order-metadata-S6N3GDOA.js +82 -0
- package/dist/order-receive-return-5VWUPWZJ.js +549 -0
- package/dist/order-request-transfer-VFSY5IFF.js +571 -0
- package/dist/price-list-configuration-GH67LL2N.js +356 -0
- package/dist/price-list-create-INX5HG7G.js +973 -0
- package/dist/price-list-detail-5LGPE67O.js +540 -0
- package/dist/price-list-edit-HRWPEIZI.js +227 -0
- package/dist/price-list-list-IXZVTXU5.js +228 -0
- package/dist/price-list-prices-add-QHE3TUTV.js +614 -0
- package/dist/price-list-prices-edit-TMVJ7S7J.js +326 -0
- package/dist/product-attributes-P7WFH4I2.js +358 -0
- package/dist/product-create-YC6MCJ2M.js +2305 -0
- package/dist/product-create-option-BNF2KKJM.js +144 -0
- package/dist/product-create-variant-SIJX7AE3.js +837 -0
- package/dist/product-detail-2GJ3PGHW.js +1638 -0
- package/dist/product-edit-YOGTWZ4I.js +397 -0
- package/dist/product-edit-option-4MUSMFS7.js +152 -0
- package/dist/product-export-5L4HNM3W.js +127 -0
- package/dist/product-import-Y54VG4AC.js +261 -0
- package/dist/product-list-EV2TS3Y4.js +313 -0
- package/dist/product-media-ZSMGHCNP.js +879 -0
- package/dist/product-metadata-572YVJH3.js +80 -0
- package/dist/product-organization-LVKRBJOQ.js +312 -0
- package/dist/product-prices-K5YM2TL6.js +266 -0
- package/dist/product-sales-channels-J3OH4NWX.js +157 -0
- package/dist/product-shipping-profile-NOOFEUBZ.js +146 -0
- package/dist/product-stock-J4LTIX64.js +540 -0
- package/dist/product-tag-create-5JJPPELP.js +122 -0
- package/dist/product-tag-detail-CGLCH3BJ.js +281 -0
- package/dist/product-tag-edit-OR7KSC7I.js +134 -0
- package/dist/product-tag-list-DY7GJUJQ.js +259 -0
- package/dist/product-tag-metadata-BFGPRMME.js +80 -0
- package/dist/product-type-create-FPVSGIKL.js +101 -0
- package/dist/product-type-detail-JYW2DAM4.js +242 -0
- package/dist/product-type-edit-FBT4Z4ZJ.js +113 -0
- package/dist/product-type-list-FK237DSQ.js +175 -0
- package/dist/product-type-metadata-SFJR5OQN.js +80 -0
- package/dist/product-variant-detail-6KPB3HL7.js +485 -0
- package/dist/product-variant-edit-QFHGNDW7.js +538 -0
- package/dist/product-variant-manage-inventory-items-ZEX2IW53.js +340 -0
- package/dist/product-variant-metadata-F45CSWU6.js +86 -0
- package/dist/profile-detail-LLXUNQOT.js +89 -0
- package/dist/profile-edit-UDYMDQLT.js +176 -0
- package/dist/promotion-add-campaign-U6X2FNWZ.js +43 -0
- package/dist/promotion-create-QB7E277L.js +1258 -0
- package/dist/promotion-detail-7D6D6PQ7.js +486 -0
- package/dist/promotion-edit-details-HYQJAZDF.js +512 -0
- package/dist/promotion-list-HTJ5GIWG.js +206 -0
- package/dist/refund-reason-create-LZCL6QJI.js +192 -0
- package/dist/refund-reason-edit-QNGFKZMN.js +192 -0
- package/dist/refund-reason-list-ZEKWYQ45.js +233 -0
- package/dist/region-add-countries-CWJ62VPK.js +226 -0
- package/dist/region-create-Z3JQFIKN.js +507 -0
- package/dist/region-detail-46R3HACJ.js +508 -0
- package/dist/region-edit-W5IVVP7Z.js +380 -0
- package/dist/region-list-DCU6NQFA.js +205 -0
- package/dist/region-metadata-VG5DLCOK.js +83 -0
- package/dist/reservation-create-VG5FSV3F.js +309 -0
- package/dist/reservation-detail-36BA3V2F.js +221 -0
- package/dist/reservation-list-R5UBPNI4.js +298 -0
- package/dist/reservation-metadata-KR4HOHTH.js +83 -0
- package/dist/reset-password-VZPICVMM.js +458 -0
- package/dist/return-reason-create-KTKI6NJE.js +165 -0
- package/dist/return-reason-edit-5KU7WKJF.js +168 -0
- package/dist/return-reason-list-HBSKNIMW.js +240 -0
- package/dist/sales-channel-add-products-6TUDLE4D.js +274 -0
- package/dist/sales-channel-create-2BTWSYIK.js +154 -0
- package/dist/sales-channel-detail-IQIQDN3L.js +437 -0
- package/dist/sales-channel-edit-YBNPALFT.js +163 -0
- package/dist/sales-channel-list-5KNN734B.js +193 -0
- package/dist/sales-channel-metadata-SVW6FYSV.js +88 -0
- package/dist/seller-details-HBVN4GGD.js +77 -0
- package/dist/seller-edit-OXDARXYJ.js +387 -0
- package/dist/seller-list-HG2VXA6V.js +192 -0
- package/dist/settings-D43GVDOO.js +19 -0
- package/dist/shipping-option-type-create-7KYU5NNF.js +195 -0
- package/dist/shipping-option-type-detail-4CNTT3MO.js +169 -0
- package/dist/shipping-option-type-edit-AN6IPVI6.js +191 -0
- package/dist/shipping-option-type-list-36ZS2QZO.js +266 -0
- package/dist/shipping-profile-create-3OWHNAOB.js +123 -0
- package/dist/shipping-profile-detail-WW7IVUVV.js +157 -0
- package/dist/shipping-profile-metadata-AD3DSZLR.js +84 -0
- package/dist/shipping-profiles-list-WOGGP7IT.js +241 -0
- package/dist/store-add-currencies-PIGEOZ4G.js +304 -0
- package/dist/store-detail-MFHPXBIN.js +525 -0
- package/dist/store-edit-WBF6EL5N.js +246 -0
- package/dist/store-metadata-LSK7UVSC.js +85 -0
- package/dist/tax-region-create-XTX4YWRA.js +300 -0
- package/dist/tax-region-detail-XUYJHBHI.js +320 -0
- package/dist/tax-region-edit-AC64YA64.js +162 -0
- package/dist/tax-region-list-XRAYDYK3.js +91 -0
- package/dist/tax-region-metadata-YDQX3Y4X.js +83 -0
- package/dist/tax-region-province-create-GDL65SQF.js +315 -0
- package/dist/tax-region-province-detail-QMPIKT7K.js +215 -0
- package/dist/tax-region-tax-override-create-X2QWOHSU.js +679 -0
- package/dist/tax-region-tax-override-edit-VZJ6EPSU.js +788 -0
- package/dist/tax-region-tax-rate-create-VC2WDVJJ.js +193 -0
- package/dist/tax-region-tax-rate-edit-SDW36H6I.js +192 -0
- package/dist/user-detail-IEIX24PZ.js +163 -0
- package/dist/user-edit-CJ7TNY3H.js +115 -0
- package/dist/user-invite-OTBYWV4L.js +389 -0
- package/dist/user-list-BJXFPTJ7.js +341 -0
- package/dist/user-metadata-ZLC6T6XH.js +83 -0
- package/package.json +87 -0
|
@@ -0,0 +1,3846 @@
|
|
|
1
|
+
import {
|
|
2
|
+
By
|
|
3
|
+
} from "./chunk-ZAUMHCIL.js";
|
|
4
|
+
import "./chunk-LXSBG6LK.js";
|
|
5
|
+
import {
|
|
6
|
+
formatPercentage
|
|
7
|
+
} from "./chunk-QDPLZDMX.js";
|
|
8
|
+
import {
|
|
9
|
+
useCancelOrderEdit,
|
|
10
|
+
useConfirmOrderEdit
|
|
11
|
+
} from "./chunk-BYZIWSBB.js";
|
|
12
|
+
import {
|
|
13
|
+
formatCurrency
|
|
14
|
+
} from "./chunk-XSX255FK.js";
|
|
15
|
+
import {
|
|
16
|
+
getPaymentsFromOrder,
|
|
17
|
+
getReservationsLimitCount
|
|
18
|
+
} from "./chunk-3KOTDGC2.js";
|
|
19
|
+
import {
|
|
20
|
+
useCancelClaim,
|
|
21
|
+
useCancelClaimRequest,
|
|
22
|
+
useClaims
|
|
23
|
+
} from "./chunk-LZALOVO3.js";
|
|
24
|
+
import {
|
|
25
|
+
useCancelExchange,
|
|
26
|
+
useCancelExchangeRequest,
|
|
27
|
+
useExchanges
|
|
28
|
+
} from "./chunk-CBRSGM3X.js";
|
|
29
|
+
import {
|
|
30
|
+
getReturnableQuantity
|
|
31
|
+
} from "./chunk-UM7ZR3VU.js";
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_FIELDS
|
|
34
|
+
} from "./chunk-Y2M536WR.js";
|
|
35
|
+
import {
|
|
36
|
+
useCancelReturn,
|
|
37
|
+
useCancelReturnRequest,
|
|
38
|
+
useReturns
|
|
39
|
+
} from "./chunk-DV73MHTN.js";
|
|
40
|
+
import {
|
|
41
|
+
getCanceledOrderStatus,
|
|
42
|
+
getOrderFulfillmentStatus,
|
|
43
|
+
getOrderPaymentStatus
|
|
44
|
+
} from "./chunk-LQSLDDPT.js";
|
|
45
|
+
import {
|
|
46
|
+
formatProvider
|
|
47
|
+
} from "./chunk-VW56KWO2.js";
|
|
48
|
+
import {
|
|
49
|
+
getLocaleAmount,
|
|
50
|
+
getStylizedAmount,
|
|
51
|
+
isAmountLessThenRoundingError
|
|
52
|
+
} from "./chunk-PXYDR7WQ.js";
|
|
53
|
+
import {
|
|
54
|
+
Thumbnail
|
|
55
|
+
} from "./chunk-WIYFXWRI.js";
|
|
56
|
+
import "./chunk-IQPN4PZJ.js";
|
|
57
|
+
import {
|
|
58
|
+
getFormattedAddress,
|
|
59
|
+
isSameAddress
|
|
60
|
+
} from "./chunk-W6Y3PPU5.js";
|
|
61
|
+
import "./chunk-JRTZWK77.js";
|
|
62
|
+
import {
|
|
63
|
+
TwoColumnPage
|
|
64
|
+
} from "./chunk-U2UCL2VG.js";
|
|
65
|
+
import {
|
|
66
|
+
Skeleton,
|
|
67
|
+
TwoColumnPageSkeleton
|
|
68
|
+
} from "./chunk-INNFZYX2.js";
|
|
69
|
+
import {
|
|
70
|
+
ActionMenu
|
|
71
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
72
|
+
import "./chunk-LAVHRER2.js";
|
|
73
|
+
import "./chunk-Y7QKP6QU.js";
|
|
74
|
+
import {
|
|
75
|
+
useDate
|
|
76
|
+
} from "./chunk-UZWFZMOX.js";
|
|
77
|
+
import "./chunk-XQNVC4Q7.js";
|
|
78
|
+
import {
|
|
79
|
+
useCapturePayment,
|
|
80
|
+
useMarkPaymentCollectionAsPaid,
|
|
81
|
+
useOrderGroup
|
|
82
|
+
} from "./chunk-ORW4HNX5.js";
|
|
83
|
+
import "./chunk-ODBDAABQ.js";
|
|
84
|
+
import "./chunk-YGQUBTKR.js";
|
|
85
|
+
import "./chunk-362QMJZM.js";
|
|
86
|
+
import "./chunk-FODCCP6C.js";
|
|
87
|
+
import "./chunk-AWZFIP25.js";
|
|
88
|
+
import "./chunk-2QKPRGNK.js";
|
|
89
|
+
import "./chunk-XBMLI2YI.js";
|
|
90
|
+
import "./chunk-XL52SYWY.js";
|
|
91
|
+
import "./chunk-NS5CHWOH.js";
|
|
92
|
+
import "./chunk-WDZFLCSQ.js";
|
|
93
|
+
import "./chunk-VVTSF42Z.js";
|
|
94
|
+
import "./chunk-D3KDXELJ.js";
|
|
95
|
+
import {
|
|
96
|
+
useCustomer
|
|
97
|
+
} from "./chunk-2MKZ4HD4.js";
|
|
98
|
+
import "./chunk-OGYWOPHZ.js";
|
|
99
|
+
import "./chunk-U62GYN4A.js";
|
|
100
|
+
import "./chunk-KTKL7M34.js";
|
|
101
|
+
import {
|
|
102
|
+
ordersQueryKeys,
|
|
103
|
+
useCancelOrder,
|
|
104
|
+
useCancelOrderFulfillment,
|
|
105
|
+
useCancelOrderTransfer,
|
|
106
|
+
useMarkOrderFulfillmentAsDelivered,
|
|
107
|
+
useOrder,
|
|
108
|
+
useOrderChanges,
|
|
109
|
+
useOrderLineItems,
|
|
110
|
+
useOrderPreview
|
|
111
|
+
} from "./chunk-JJVGCTKT.js";
|
|
112
|
+
import {
|
|
113
|
+
useReservationItems
|
|
114
|
+
} from "./chunk-I43SCBL3.js";
|
|
115
|
+
import {
|
|
116
|
+
useStockLocation
|
|
117
|
+
} from "./chunk-LLWK3OR6.js";
|
|
118
|
+
import "./chunk-HYUGYB23.js";
|
|
119
|
+
import "./chunk-XCMR2HTV.js";
|
|
120
|
+
import "./chunk-CI5Z6FGV.js";
|
|
121
|
+
import "./chunk-LCZXAT4Q.js";
|
|
122
|
+
import "./chunk-S6LPCNXQ.js";
|
|
123
|
+
import "./chunk-T435NFHC.js";
|
|
124
|
+
import {
|
|
125
|
+
queryClient
|
|
126
|
+
} from "./chunk-2KCF3ZIB.js";
|
|
127
|
+
import {
|
|
128
|
+
sdk
|
|
129
|
+
} from "./chunk-ZYNBKBY3.js";
|
|
130
|
+
import "./chunk-NBMM2TZK.js";
|
|
131
|
+
|
|
132
|
+
// src/pages/orders/order-detail/breadcrumb.tsx
|
|
133
|
+
import { jsxs } from "react/jsx-runtime";
|
|
134
|
+
var OrderDetailBreadcrumb = (props) => {
|
|
135
|
+
const { id } = props.params || {};
|
|
136
|
+
const { order } = useOrder(
|
|
137
|
+
id,
|
|
138
|
+
{
|
|
139
|
+
fields: DEFAULT_FIELDS
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
initialData: props.data,
|
|
143
|
+
enabled: Boolean(id)
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
if (!order) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
150
|
+
"#",
|
|
151
|
+
order.display_id
|
|
152
|
+
] });
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/pages/orders/order-detail/loader.ts
|
|
156
|
+
var orderDetailQuery = (id) => ({
|
|
157
|
+
queryKey: ordersQueryKeys.detail(id),
|
|
158
|
+
queryFn: async () => sdk.admin.order.retrieve(id, {
|
|
159
|
+
fields: DEFAULT_FIELDS
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
var orderLoader = async ({ params }) => {
|
|
163
|
+
const id = params.id;
|
|
164
|
+
const query = orderDetailQuery(id);
|
|
165
|
+
return queryClient.ensureQueryData(query);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/pages/orders/order-detail/order-detail.tsx
|
|
169
|
+
import { useLoaderData, useParams as useParams2 } from "react-router-dom";
|
|
170
|
+
|
|
171
|
+
// src/pages/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx
|
|
172
|
+
import { ExclamationCircle } from "@medusajs/icons";
|
|
173
|
+
import { Button, Container, Heading, Text, toast } from "@medusajs/ui";
|
|
174
|
+
import { useTranslation } from "react-i18next";
|
|
175
|
+
import { useNavigate } from "react-router-dom";
|
|
176
|
+
import { jsx, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
177
|
+
var ActiveOrderClaimSection = ({
|
|
178
|
+
orderPreview
|
|
179
|
+
}) => {
|
|
180
|
+
const { t } = useTranslation();
|
|
181
|
+
const claimId = orderPreview?.order_change?.claim_id;
|
|
182
|
+
const { mutateAsync: cancelClaim } = useCancelClaimRequest(
|
|
183
|
+
claimId,
|
|
184
|
+
orderPreview.id
|
|
185
|
+
);
|
|
186
|
+
const navigate = useNavigate();
|
|
187
|
+
const onContinueClaim = async () => {
|
|
188
|
+
navigate(`/orders/${orderPreview.id}/claims`);
|
|
189
|
+
};
|
|
190
|
+
const onCancelClaim = async () => {
|
|
191
|
+
await cancelClaim(void 0, {
|
|
192
|
+
onSuccess: () => {
|
|
193
|
+
toast.success(t("orders.claims.toast.canceledSuccessfully"));
|
|
194
|
+
},
|
|
195
|
+
onError: (error) => {
|
|
196
|
+
toast.error(error.message);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
if (!claimId) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
return /* @__PURE__ */ jsx(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
style: {
|
|
207
|
+
background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
|
|
208
|
+
},
|
|
209
|
+
className: "-m-4 mb-1 border-b border-l p-4",
|
|
210
|
+
"data-testid": "active-order-claim-section",
|
|
211
|
+
children: /* @__PURE__ */ jsx(Container, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-row justify-between", children: [
|
|
212
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
213
|
+
/* @__PURE__ */ jsxs2("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-claim-header", children: [
|
|
214
|
+
/* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-subtle" }),
|
|
215
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", "data-testid": "active-order-claim-heading", children: t("orders.claims.panel.title") })
|
|
216
|
+
] }),
|
|
217
|
+
/* @__PURE__ */ jsx("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-claim-description", children: /* @__PURE__ */ jsx(Text, { children: t("orders.claims.panel.description") }) })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-claim-actions", children: [
|
|
220
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onCancelClaim, "data-testid": "active-order-claim-cancel-button", children: t("orders.claims.cancel.title") }),
|
|
221
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onContinueClaim, "data-testid": "active-order-claim-continue-button", children: t("actions.continue") })
|
|
222
|
+
] })
|
|
223
|
+
] }) })
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/pages/orders/order-detail/components/active-order-exchange-section/active-order-exchange-section.tsx
|
|
229
|
+
import { ArrowPath } from "@medusajs/icons";
|
|
230
|
+
import { Button as Button2, Container as Container2, Heading as Heading2, Text as Text2, toast as toast2 } from "@medusajs/ui";
|
|
231
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
232
|
+
import { useNavigate as useNavigate2 } from "react-router-dom";
|
|
233
|
+
import { jsx as jsx2, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
234
|
+
var ActiveOrderExchangeSection = ({
|
|
235
|
+
orderPreview
|
|
236
|
+
}) => {
|
|
237
|
+
const { t } = useTranslation2();
|
|
238
|
+
const exchangeId = orderPreview?.order_change?.exchange_id;
|
|
239
|
+
const { mutateAsync: cancelExchange } = useCancelExchangeRequest(
|
|
240
|
+
exchangeId,
|
|
241
|
+
orderPreview.id
|
|
242
|
+
);
|
|
243
|
+
const navigate = useNavigate2();
|
|
244
|
+
const onContinueExchange = async () => {
|
|
245
|
+
navigate(`/orders/${orderPreview.id}/exchanges`);
|
|
246
|
+
};
|
|
247
|
+
const onCancelExchange = async () => {
|
|
248
|
+
await cancelExchange(void 0, {
|
|
249
|
+
onSuccess: () => {
|
|
250
|
+
toast2.success(t("orders.exchanges.toast.canceledSuccessfully"));
|
|
251
|
+
},
|
|
252
|
+
onError: (error) => {
|
|
253
|
+
toast2.error(error.message);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
if (!exchangeId) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
return /* @__PURE__ */ jsx2(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
style: {
|
|
264
|
+
background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
|
|
265
|
+
},
|
|
266
|
+
className: "-m-4 mb-1 border-b border-l p-4",
|
|
267
|
+
"data-testid": "active-order-exchange-section",
|
|
268
|
+
children: /* @__PURE__ */ jsx2(Container2, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs3("div", { className: "flex w-full flex-row justify-between", children: [
|
|
269
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
270
|
+
/* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-exchange-header", children: [
|
|
271
|
+
/* @__PURE__ */ jsx2(ArrowPath, { className: "text-ui-fg-subtle" }),
|
|
272
|
+
/* @__PURE__ */ jsx2(Heading2, { level: "h2", "data-testid": "active-order-exchange-heading", children: t("orders.exchanges.panel.title") })
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ jsx2("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-exchange-description", children: /* @__PURE__ */ jsx2(Text2, { children: t("orders.exchanges.panel.description") }) })
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-exchange-actions", children: [
|
|
277
|
+
/* @__PURE__ */ jsx2(Button2, { size: "small", variant: "secondary", onClick: onCancelExchange, "data-testid": "active-order-exchange-cancel-button", children: t("orders.exchanges.cancel.title") }),
|
|
278
|
+
/* @__PURE__ */ jsx2(
|
|
279
|
+
Button2,
|
|
280
|
+
{
|
|
281
|
+
size: "small",
|
|
282
|
+
variant: "secondary",
|
|
283
|
+
onClick: onContinueExchange,
|
|
284
|
+
"data-testid": "active-order-exchange-continue-button",
|
|
285
|
+
children: t("actions.continue")
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
] })
|
|
289
|
+
] }) })
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// src/pages/orders/order-detail/components/active-order-return-section/active-order-return-section.tsx
|
|
295
|
+
import { ArrowUturnLeft } from "@medusajs/icons";
|
|
296
|
+
import { Button as Button3, Container as Container3, Heading as Heading3, Text as Text3, toast as toast3 } from "@medusajs/ui";
|
|
297
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
298
|
+
import { useNavigate as useNavigate3 } from "react-router-dom";
|
|
299
|
+
import { jsx as jsx3, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
300
|
+
var ActiveOrderReturnSection = ({
|
|
301
|
+
orderPreview
|
|
302
|
+
}) => {
|
|
303
|
+
const { t } = useTranslation3();
|
|
304
|
+
const orderChange = orderPreview?.order_change;
|
|
305
|
+
const returnId = orderChange?.return_id;
|
|
306
|
+
const isReturnRequest = orderChange?.change_type === "return_request" && !!orderChange.return_id;
|
|
307
|
+
const { mutateAsync: cancelReturn } = useCancelReturnRequest(
|
|
308
|
+
returnId,
|
|
309
|
+
orderPreview.id
|
|
310
|
+
);
|
|
311
|
+
const navigate = useNavigate3();
|
|
312
|
+
const onContinueReturn = async () => {
|
|
313
|
+
navigate(`/orders/${orderPreview.id}/returns`);
|
|
314
|
+
};
|
|
315
|
+
const onCancelReturn = async () => {
|
|
316
|
+
await cancelReturn(void 0, {
|
|
317
|
+
onSuccess: () => {
|
|
318
|
+
toast3.success(t("orders.returns.toast.canceledSuccessfully"));
|
|
319
|
+
},
|
|
320
|
+
onError: (error) => {
|
|
321
|
+
toast3.error(error.message);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
if (!returnId || !isReturnRequest) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
return /* @__PURE__ */ jsx3(
|
|
329
|
+
"div",
|
|
330
|
+
{
|
|
331
|
+
style: {
|
|
332
|
+
background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
|
|
333
|
+
},
|
|
334
|
+
className: "-m-4 mb-1 border-b border-l p-4",
|
|
335
|
+
"data-testid": "active-order-return-section",
|
|
336
|
+
children: /* @__PURE__ */ jsx3(Container3, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-row justify-between", children: [
|
|
337
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
338
|
+
/* @__PURE__ */ jsxs4("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-return-header", children: [
|
|
339
|
+
/* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-subtle" }),
|
|
340
|
+
/* @__PURE__ */ jsx3(Heading3, { level: "h2", "data-testid": "active-order-return-heading", children: t("orders.returns.panel.title") })
|
|
341
|
+
] }),
|
|
342
|
+
/* @__PURE__ */ jsx3("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-return-description", children: /* @__PURE__ */ jsx3(Text3, { children: t("orders.returns.panel.description") }) })
|
|
343
|
+
] }),
|
|
344
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-return-actions", children: [
|
|
345
|
+
/* @__PURE__ */ jsx3(Button3, { size: "small", variant: "secondary", onClick: onCancelReturn, "data-testid": "active-order-return-cancel-button", children: t("orders.returns.cancel.title") }),
|
|
346
|
+
/* @__PURE__ */ jsx3(Button3, { size: "small", variant: "secondary", onClick: onContinueReturn, "data-testid": "active-order-return-continue-button", children: t("actions.continue") })
|
|
347
|
+
] })
|
|
348
|
+
] }) })
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// src/pages/orders/order-detail/components/order-active-edit-section/order-active-edit-section.tsx
|
|
354
|
+
import { Button as Button4, Container as Container4, Copy, Heading as Heading4, toast as toast4 } from "@medusajs/ui";
|
|
355
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
356
|
+
import { ExclamationCircleSolid } from "@medusajs/icons";
|
|
357
|
+
import { useMemo } from "react";
|
|
358
|
+
import { useNavigate as useNavigate4 } from "react-router-dom";
|
|
359
|
+
import { jsx as jsx4, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
360
|
+
function EditItem({
|
|
361
|
+
item,
|
|
362
|
+
quantity
|
|
363
|
+
}) {
|
|
364
|
+
return /* @__PURE__ */ jsx4("div", { className: "text-ui-fg-subtle items-center gap-x-2", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-2", children: [
|
|
365
|
+
/* @__PURE__ */ jsxs5("div", { className: "w-fit min-w-[27px]", children: [
|
|
366
|
+
/* @__PURE__ */ jsx4("span", { className: "txt-small tabular-nums", children: quantity }),
|
|
367
|
+
"x"
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ jsx4(Thumbnail, { src: item.thumbnail }),
|
|
370
|
+
/* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle font-medium", children: item.title }),
|
|
371
|
+
item.variant_sku && " \xB7 ",
|
|
372
|
+
item.variant_sku && /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-1", children: [
|
|
373
|
+
/* @__PURE__ */ jsx4("span", { className: "txt-small", children: item.variant_sku }),
|
|
374
|
+
/* @__PURE__ */ jsx4(Copy, { content: item.variant_sku, className: "text-ui-fg-muted" })
|
|
375
|
+
] })
|
|
376
|
+
] }) }, item.id);
|
|
377
|
+
}
|
|
378
|
+
var OrderActiveEditSection = ({
|
|
379
|
+
order
|
|
380
|
+
}) => {
|
|
381
|
+
const { t } = useTranslation4();
|
|
382
|
+
const navigate = useNavigate4();
|
|
383
|
+
const { order: orderPreview } = useOrderPreview(order.id);
|
|
384
|
+
const { mutateAsync: cancelOrderEdit } = useCancelOrderEdit(order.id);
|
|
385
|
+
const { mutateAsync: confirmOrderEdit } = useConfirmOrderEdit(order.id);
|
|
386
|
+
const isPending = orderPreview.order_change?.status === "pending";
|
|
387
|
+
const [addedItems, removedItems] = useMemo(() => {
|
|
388
|
+
const added = [];
|
|
389
|
+
const removed = [];
|
|
390
|
+
const orderLookupMap = new Map(order.items.map((i) => [i.id, i]));
|
|
391
|
+
(orderPreview?.items || []).forEach((currentItem) => {
|
|
392
|
+
const originalItem = orderLookupMap.get(currentItem.id);
|
|
393
|
+
if (!originalItem) {
|
|
394
|
+
added.push({ item: currentItem, quantity: currentItem.quantity });
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (originalItem.quantity > currentItem.quantity) {
|
|
398
|
+
removed.push({
|
|
399
|
+
item: currentItem,
|
|
400
|
+
quantity: originalItem.quantity - currentItem.quantity
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (originalItem.quantity < currentItem.quantity) {
|
|
404
|
+
added.push({
|
|
405
|
+
item: currentItem,
|
|
406
|
+
quantity: currentItem.quantity - originalItem.quantity
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
return [added, removed];
|
|
411
|
+
}, [orderPreview]);
|
|
412
|
+
const onConfirmOrderEdit = async () => {
|
|
413
|
+
try {
|
|
414
|
+
await confirmOrderEdit();
|
|
415
|
+
toast4.success(t("orders.edits.toast.confirmedSuccessfully"));
|
|
416
|
+
} catch (e) {
|
|
417
|
+
toast4.error(e.message);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
const onCancelOrderEdit = async () => {
|
|
421
|
+
try {
|
|
422
|
+
await cancelOrderEdit();
|
|
423
|
+
toast4.success(t("orders.edits.toast.canceledSuccessfully"));
|
|
424
|
+
} catch (e) {
|
|
425
|
+
toast4.error(e.message);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
if (!orderPreview || orderPreview.order_change?.change_type !== "edit") {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
return /* @__PURE__ */ jsx4(
|
|
432
|
+
"div",
|
|
433
|
+
{
|
|
434
|
+
style: {
|
|
435
|
+
background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
|
|
436
|
+
},
|
|
437
|
+
className: "-m-4 mb-1 border-b border-l p-4",
|
|
438
|
+
"data-testid": "order-active-edit-section",
|
|
439
|
+
children: /* @__PURE__ */ jsx4(Container4, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-col divide-y divide-dashed", children: [
|
|
440
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 px-6 py-4", "data-testid": "order-active-edit-header", children: [
|
|
441
|
+
/* @__PURE__ */ jsx4(ExclamationCircleSolid, { className: "text-blue-500" }),
|
|
442
|
+
/* @__PURE__ */ jsx4(Heading4, { level: "h2", "data-testid": "order-active-edit-heading", children: t(
|
|
443
|
+
isPending ? "orders.edits.panel.titlePending" : "orders.edits.panel.title"
|
|
444
|
+
) })
|
|
445
|
+
] }),
|
|
446
|
+
!!addedItems.length && /* @__PURE__ */ jsxs5("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
|
|
447
|
+
/* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.added") }),
|
|
448
|
+
/* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: addedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
|
|
449
|
+
] }),
|
|
450
|
+
!!removedItems.length && /* @__PURE__ */ jsxs5("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
|
|
451
|
+
/* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.removed") }),
|
|
452
|
+
/* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: removedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
|
|
453
|
+
] }),
|
|
454
|
+
/* @__PURE__ */ jsxs5("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "order-active-edit-actions", children: [
|
|
455
|
+
isPending ? /* @__PURE__ */ jsx4(
|
|
456
|
+
Button4,
|
|
457
|
+
{
|
|
458
|
+
size: "small",
|
|
459
|
+
variant: "secondary",
|
|
460
|
+
onClick: () => navigate(`/orders/${order.id}/edits`),
|
|
461
|
+
"data-testid": "order-active-edit-continue-button",
|
|
462
|
+
children: t("actions.continueEdit")
|
|
463
|
+
}
|
|
464
|
+
) : /* @__PURE__ */ jsx4(
|
|
465
|
+
Button4,
|
|
466
|
+
{
|
|
467
|
+
size: "small",
|
|
468
|
+
variant: "secondary",
|
|
469
|
+
onClick: onConfirmOrderEdit,
|
|
470
|
+
"data-testid": "order-active-edit-confirm-button",
|
|
471
|
+
children: t("actions.forceConfirm")
|
|
472
|
+
}
|
|
473
|
+
),
|
|
474
|
+
/* @__PURE__ */ jsx4(
|
|
475
|
+
Button4,
|
|
476
|
+
{
|
|
477
|
+
size: "small",
|
|
478
|
+
variant: "secondary",
|
|
479
|
+
onClick: onCancelOrderEdit,
|
|
480
|
+
"data-testid": "order-active-edit-cancel-button",
|
|
481
|
+
children: t("actions.cancel")
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
] })
|
|
485
|
+
] }) })
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/pages/orders/order-detail/components/order-activity-section/order-activity-section.tsx
|
|
491
|
+
import { Container as Container5, Heading as Heading5 } from "@medusajs/ui";
|
|
492
|
+
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
493
|
+
|
|
494
|
+
// src/pages/orders/order-detail/components/order-activity-section/order-timeline.tsx
|
|
495
|
+
import { Button as Button5, Text as Text6, Tooltip, clx, toast as toast5, usePrompt } from "@medusajs/ui";
|
|
496
|
+
import { Collapsible as RadixCollapsible } from "radix-ui";
|
|
497
|
+
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
498
|
+
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
499
|
+
|
|
500
|
+
// src/pages/orders/order-detail/components/order-activity-section/activity-items.tsx
|
|
501
|
+
import { Popover, Text as Text4 } from "@medusajs/ui";
|
|
502
|
+
import { useState } from "react";
|
|
503
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
504
|
+
import { jsx as jsx5, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
505
|
+
function ActivityItems(props) {
|
|
506
|
+
const { t } = useTranslation5();
|
|
507
|
+
const [open, setOpen] = useState(false);
|
|
508
|
+
const itemsToSend = props.itemsToSend;
|
|
509
|
+
const itemsToReturn = props.itemsToReturn;
|
|
510
|
+
const itemsMap = props.itemsMap;
|
|
511
|
+
const title = props.title;
|
|
512
|
+
const handleMouseEnter = () => {
|
|
513
|
+
setOpen(true);
|
|
514
|
+
};
|
|
515
|
+
const handleMouseLeave = () => {
|
|
516
|
+
setOpen(false);
|
|
517
|
+
};
|
|
518
|
+
if (!itemsToSend?.length && !itemsToReturn?.length) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
return /* @__PURE__ */ jsxs6(Popover, { open, children: [
|
|
522
|
+
/* @__PURE__ */ jsx5(
|
|
523
|
+
Popover.Trigger,
|
|
524
|
+
{
|
|
525
|
+
onMouseEnter: handleMouseEnter,
|
|
526
|
+
onMouseLeave: handleMouseLeave,
|
|
527
|
+
autoFocus: false,
|
|
528
|
+
className: "focus-visible:outline-none",
|
|
529
|
+
children: /* @__PURE__ */ jsx5(Text4, { size: "small", leading: "compact", weight: "plus", children: title })
|
|
530
|
+
}
|
|
531
|
+
),
|
|
532
|
+
/* @__PURE__ */ jsx5(
|
|
533
|
+
Popover.Content,
|
|
534
|
+
{
|
|
535
|
+
align: "center",
|
|
536
|
+
side: "top",
|
|
537
|
+
className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
|
|
538
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
|
|
539
|
+
!!itemsToSend?.length && /* @__PURE__ */ jsxs6("div", { className: "p-3", children: [
|
|
540
|
+
/* @__PURE__ */ jsx5("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toSend") }),
|
|
541
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
|
|
542
|
+
itemsToSend?.map((item) => {
|
|
543
|
+
const originalItem = itemsMap?.get(item.item_id);
|
|
544
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-3", children: [
|
|
545
|
+
/* @__PURE__ */ jsxs6(Text4, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
546
|
+
item.quantity,
|
|
547
|
+
"x"
|
|
548
|
+
] }),
|
|
549
|
+
/* @__PURE__ */ jsx5(Thumbnail, { src: originalItem?.thumbnail }),
|
|
550
|
+
/* @__PURE__ */ jsx5(Text4, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
|
|
551
|
+
] }, item.id);
|
|
552
|
+
}),
|
|
553
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-1 flex-row items-center gap-2" })
|
|
554
|
+
] })
|
|
555
|
+
] }),
|
|
556
|
+
!!itemsToReturn?.length && /* @__PURE__ */ jsxs6("div", { className: "border-t-2 border-dotted p-3", children: [
|
|
557
|
+
/* @__PURE__ */ jsx5("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toReturn") }),
|
|
558
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
|
|
559
|
+
itemsToReturn?.map((item) => {
|
|
560
|
+
const originalItem = itemsMap?.get(item.item_id);
|
|
561
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-3", children: [
|
|
562
|
+
/* @__PURE__ */ jsxs6(Text4, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
563
|
+
item.quantity,
|
|
564
|
+
"x"
|
|
565
|
+
] }),
|
|
566
|
+
/* @__PURE__ */ jsx5(Thumbnail, { src: originalItem?.thumbnail }),
|
|
567
|
+
/* @__PURE__ */ jsx5(Text4, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
|
|
568
|
+
] }, item.id);
|
|
569
|
+
}),
|
|
570
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-1 flex-row items-center gap-2" })
|
|
571
|
+
] })
|
|
572
|
+
] })
|
|
573
|
+
] })
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
] });
|
|
577
|
+
}
|
|
578
|
+
var activity_items_default = ActivityItems;
|
|
579
|
+
|
|
580
|
+
// src/pages/orders/order-detail/components/order-activity-section/change-details-tooltip.tsx
|
|
581
|
+
import { Popover as Popover2, Text as Text5 } from "@medusajs/ui";
|
|
582
|
+
import { useState as useState2 } from "react";
|
|
583
|
+
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
584
|
+
import { jsx as jsx6, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
585
|
+
function ChangeDetailsTooltip(props) {
|
|
586
|
+
const { t } = useTranslation6();
|
|
587
|
+
const [open, setOpen] = useState2(false);
|
|
588
|
+
const previous = props.previous;
|
|
589
|
+
const next = props.next;
|
|
590
|
+
const title = props.title;
|
|
591
|
+
const handleMouseEnter = () => {
|
|
592
|
+
setOpen(true);
|
|
593
|
+
};
|
|
594
|
+
const handleMouseLeave = () => {
|
|
595
|
+
setOpen(false);
|
|
596
|
+
};
|
|
597
|
+
if (!previous && !next) {
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
return /* @__PURE__ */ jsxs7(Popover2, { open, children: [
|
|
601
|
+
/* @__PURE__ */ jsx6(
|
|
602
|
+
Popover2.Trigger,
|
|
603
|
+
{
|
|
604
|
+
onMouseEnter: handleMouseEnter,
|
|
605
|
+
onMouseLeave: handleMouseLeave,
|
|
606
|
+
autoFocus: false,
|
|
607
|
+
className: "focus-visible:outline-none",
|
|
608
|
+
children: /* @__PURE__ */ jsx6(Text5, { size: "small", leading: "compact", weight: "plus", children: title })
|
|
609
|
+
}
|
|
610
|
+
),
|
|
611
|
+
/* @__PURE__ */ jsx6(
|
|
612
|
+
Popover2.Content,
|
|
613
|
+
{
|
|
614
|
+
align: "center",
|
|
615
|
+
side: "top",
|
|
616
|
+
className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
|
|
617
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
|
|
618
|
+
!!previous && /* @__PURE__ */ jsxs7("div", { className: "p-3", children: [
|
|
619
|
+
/* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.from") }),
|
|
620
|
+
/* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: previous })
|
|
621
|
+
] }),
|
|
622
|
+
!!next && /* @__PURE__ */ jsxs7("div", { className: "border-t-2 border-dotted p-3", children: [
|
|
623
|
+
/* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.to") }),
|
|
624
|
+
/* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: next })
|
|
625
|
+
] })
|
|
626
|
+
] })
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
] });
|
|
630
|
+
}
|
|
631
|
+
var change_details_tooltip_default = ChangeDetailsTooltip;
|
|
632
|
+
|
|
633
|
+
// src/pages/orders/order-detail/components/order-activity-section/order-timeline.tsx
|
|
634
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
635
|
+
var NON_RMA_CHANGE_TYPES = ["transfer", "update_order"];
|
|
636
|
+
var OrderTimeline = ({ order }) => {
|
|
637
|
+
const items = useActivityItems(order);
|
|
638
|
+
if (items.length <= 3) {
|
|
639
|
+
return /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-y-0.5", "data-testid": "order-timeline", children: items.map((item, index) => {
|
|
640
|
+
return /* @__PURE__ */ jsx7(
|
|
641
|
+
OrderActivityItem,
|
|
642
|
+
{
|
|
643
|
+
title: item.title,
|
|
644
|
+
timestamp: item.timestamp,
|
|
645
|
+
isFirst: index === items.length - 1,
|
|
646
|
+
itemsToSend: item.itemsToSend,
|
|
647
|
+
itemsToReturn: item.itemsToReturn,
|
|
648
|
+
itemsMap: item.itemsMap,
|
|
649
|
+
children: item.children
|
|
650
|
+
},
|
|
651
|
+
index
|
|
652
|
+
);
|
|
653
|
+
}) });
|
|
654
|
+
}
|
|
655
|
+
const lastItems = items.slice(0, 2);
|
|
656
|
+
const collapsibleItems = items.slice(2, items.length - 1);
|
|
657
|
+
const firstItem = items[items.length - 1];
|
|
658
|
+
return /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-y-0.5", "data-testid": "order-timeline", children: [
|
|
659
|
+
lastItems.map((item, index) => {
|
|
660
|
+
return /* @__PURE__ */ jsx7(
|
|
661
|
+
OrderActivityItem,
|
|
662
|
+
{
|
|
663
|
+
title: item.title,
|
|
664
|
+
timestamp: item.timestamp,
|
|
665
|
+
itemsToSend: item.itemsToSend,
|
|
666
|
+
itemsToReturn: item.itemsToReturn,
|
|
667
|
+
itemsMap: item.itemsMap,
|
|
668
|
+
children: item.children
|
|
669
|
+
},
|
|
670
|
+
index
|
|
671
|
+
);
|
|
672
|
+
}),
|
|
673
|
+
/* @__PURE__ */ jsx7(OrderActivityCollapsible, { activities: collapsibleItems }),
|
|
674
|
+
/* @__PURE__ */ jsx7(
|
|
675
|
+
OrderActivityItem,
|
|
676
|
+
{
|
|
677
|
+
title: firstItem.title,
|
|
678
|
+
timestamp: firstItem.timestamp,
|
|
679
|
+
isFirst: true,
|
|
680
|
+
itemsToSend: firstItem.itemsToSend,
|
|
681
|
+
itemsToReturn: firstItem.itemsToReturn,
|
|
682
|
+
itemsMap: firstItem.itemsMap,
|
|
683
|
+
children: firstItem.children
|
|
684
|
+
}
|
|
685
|
+
)
|
|
686
|
+
] });
|
|
687
|
+
};
|
|
688
|
+
var useActivityItems = (order) => {
|
|
689
|
+
const { t } = useTranslation7();
|
|
690
|
+
const { order_changes: orderChanges = [] } = useOrderChanges(order.id, {
|
|
691
|
+
change_type: [
|
|
692
|
+
"edit",
|
|
693
|
+
"claim",
|
|
694
|
+
"exchange",
|
|
695
|
+
"return",
|
|
696
|
+
"transfer",
|
|
697
|
+
"update_order"
|
|
698
|
+
]
|
|
699
|
+
});
|
|
700
|
+
const rmaChanges = orderChanges.filter(
|
|
701
|
+
(oc) => !NON_RMA_CHANGE_TYPES.includes(oc.change_type)
|
|
702
|
+
);
|
|
703
|
+
const missingLineItemIds = getMissingLineItemIds(order, rmaChanges);
|
|
704
|
+
const { order_items: removedLineItems = [] } = useOrderLineItems(
|
|
705
|
+
order.id,
|
|
706
|
+
{
|
|
707
|
+
fields: "+quantity",
|
|
708
|
+
item_id: missingLineItemIds
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
enabled: !!rmaChanges.length
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
const itemsMap = useMemo2(() => {
|
|
715
|
+
const _itemsMap = new Map(order?.items?.map((i) => [i.id, i]));
|
|
716
|
+
for (const id of missingLineItemIds) {
|
|
717
|
+
const i = removedLineItems.find((i2) => i2.item.id === id);
|
|
718
|
+
if (i) {
|
|
719
|
+
_itemsMap.set(id, { ...i.item, quantity: i.quantity });
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return _itemsMap;
|
|
723
|
+
}, [order.items, removedLineItems, missingLineItemIds]);
|
|
724
|
+
const { returns = [] } = useReturns({
|
|
725
|
+
order_id: order.id,
|
|
726
|
+
fields: "+received_at,*items"
|
|
727
|
+
});
|
|
728
|
+
const { claims = [] } = useClaims({
|
|
729
|
+
order_id: order.id,
|
|
730
|
+
fields: "*additional_items"
|
|
731
|
+
});
|
|
732
|
+
const { exchanges = [] } = useExchanges({
|
|
733
|
+
order_id: order.id,
|
|
734
|
+
fields: "*additional_items"
|
|
735
|
+
});
|
|
736
|
+
const payments = getPaymentsFromOrder(order);
|
|
737
|
+
const notes = [];
|
|
738
|
+
const isLoading = false;
|
|
739
|
+
return useMemo2(() => {
|
|
740
|
+
if (isLoading) {
|
|
741
|
+
return [];
|
|
742
|
+
}
|
|
743
|
+
const items = [];
|
|
744
|
+
for (const payment of payments) {
|
|
745
|
+
const amount = payment.amount;
|
|
746
|
+
items.push({
|
|
747
|
+
title: t("orders.activity.events.payment.awaiting"),
|
|
748
|
+
timestamp: payment.created_at,
|
|
749
|
+
children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
|
|
750
|
+
});
|
|
751
|
+
if (payment.canceled_at) {
|
|
752
|
+
items.push({
|
|
753
|
+
title: t("orders.activity.events.payment.canceled"),
|
|
754
|
+
timestamp: payment.canceled_at,
|
|
755
|
+
children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
if (payment.captured_at) {
|
|
759
|
+
items.push({
|
|
760
|
+
title: t("orders.activity.events.payment.captured"),
|
|
761
|
+
timestamp: payment.captured_at,
|
|
762
|
+
children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
for (const refund of payment.refunds || []) {
|
|
766
|
+
items.push({
|
|
767
|
+
title: t("orders.activity.events.payment.refunded"),
|
|
768
|
+
timestamp: refund.created_at,
|
|
769
|
+
children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(
|
|
770
|
+
refund.amount,
|
|
771
|
+
payment.currency_code
|
|
772
|
+
) })
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
for (const fulfillment of order.fulfillments || []) {
|
|
777
|
+
items.push({
|
|
778
|
+
title: t("orders.activity.events.fulfillment.created"),
|
|
779
|
+
timestamp: fulfillment.created_at,
|
|
780
|
+
children: /* @__PURE__ */ jsx7(FulfillmentCreatedBody, { fulfillment })
|
|
781
|
+
});
|
|
782
|
+
if (fulfillment.delivered_at) {
|
|
783
|
+
items.push({
|
|
784
|
+
title: t("orders.activity.events.fulfillment.delivered"),
|
|
785
|
+
timestamp: fulfillment.delivered_at,
|
|
786
|
+
children: /* @__PURE__ */ jsx7(FulfillmentCreatedBody, { fulfillment })
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
if (fulfillment.shipped_at) {
|
|
790
|
+
items.push({
|
|
791
|
+
title: t("orders.activity.events.fulfillment.shipped"),
|
|
792
|
+
timestamp: fulfillment.shipped_at,
|
|
793
|
+
children: /* @__PURE__ */ jsx7(FulfillmentCreatedBody, { fulfillment, isShipment: true })
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
if (fulfillment.canceled_at) {
|
|
797
|
+
items.push({
|
|
798
|
+
title: t("orders.activity.events.fulfillment.canceled"),
|
|
799
|
+
timestamp: fulfillment.canceled_at
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const returnMap = /* @__PURE__ */ new Map();
|
|
804
|
+
for (const ret of returns) {
|
|
805
|
+
returnMap.set(ret.id, ret);
|
|
806
|
+
if (ret.claim_id || ret.exchange_id) {
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
items.push({
|
|
810
|
+
title: t("orders.activity.events.return.created", {
|
|
811
|
+
returnId: ret.id.slice(-7)
|
|
812
|
+
}),
|
|
813
|
+
timestamp: ret.created_at,
|
|
814
|
+
itemsToReturn: ret?.items,
|
|
815
|
+
itemsMap,
|
|
816
|
+
children: /* @__PURE__ */ jsx7(ReturnBody, { orderReturn: ret, isCreated: !ret.canceled_at })
|
|
817
|
+
});
|
|
818
|
+
if (ret.canceled_at) {
|
|
819
|
+
items.push({
|
|
820
|
+
title: t("orders.activity.events.return.canceled", {
|
|
821
|
+
returnId: ret.id.slice(-7)
|
|
822
|
+
}),
|
|
823
|
+
timestamp: ret.canceled_at
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
if (ret.status === "received" || ret.status === "partially_received") {
|
|
827
|
+
items.push({
|
|
828
|
+
title: t("orders.activity.events.return.received", {
|
|
829
|
+
returnId: ret.id.slice(-7)
|
|
830
|
+
}),
|
|
831
|
+
timestamp: ret.received_at,
|
|
832
|
+
itemsToReturn: ret?.items,
|
|
833
|
+
itemsMap,
|
|
834
|
+
children: /* @__PURE__ */ jsx7(ReturnBody, { orderReturn: ret, isReceived: true })
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
for (const claim of claims) {
|
|
839
|
+
const claimReturn = returnMap.get(claim.return_id);
|
|
840
|
+
items.push({
|
|
841
|
+
title: t(
|
|
842
|
+
claim.canceled_at ? "orders.activity.events.claim.canceled" : "orders.activity.events.claim.created",
|
|
843
|
+
{
|
|
844
|
+
claimId: claim.id.slice(-7)
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
timestamp: claim.canceled_at || claim.created_at,
|
|
848
|
+
itemsToSend: claim.additional_items,
|
|
849
|
+
itemsToReturn: claimReturn?.items,
|
|
850
|
+
itemsMap,
|
|
851
|
+
children: /* @__PURE__ */ jsx7(ClaimBody, { claim, claimReturn })
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
for (const exchange of exchanges) {
|
|
855
|
+
const exchangeReturn = returnMap.get(exchange.return_id);
|
|
856
|
+
items.push({
|
|
857
|
+
title: t(
|
|
858
|
+
exchange.canceled_at ? "orders.activity.events.exchange.canceled" : "orders.activity.events.exchange.created",
|
|
859
|
+
{
|
|
860
|
+
exchangeId: exchange.id.slice(-7)
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
timestamp: exchange.canceled_at || exchange.created_at,
|
|
864
|
+
itemsToSend: exchange.additional_items,
|
|
865
|
+
itemsToReturn: exchangeReturn?.items,
|
|
866
|
+
itemsMap,
|
|
867
|
+
children: /* @__PURE__ */ jsx7(ExchangeBody, { exchange, exchangeReturn })
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
for (const edit of orderChanges.filter((oc) => oc.change_type === "edit")) {
|
|
871
|
+
const isConfirmed = edit.status === "confirmed";
|
|
872
|
+
const isPending = edit.status === "pending";
|
|
873
|
+
if (isPending) {
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
items.push({
|
|
877
|
+
title: t(`orders.activity.events.edit.${edit.status}`, {
|
|
878
|
+
editId: edit.id.slice(-7)
|
|
879
|
+
}),
|
|
880
|
+
timestamp: edit.status === "requested" ? edit.requested_at : edit.status === "confirmed" ? edit.confirmed_at : edit.status === "declined" ? edit.declined_at : edit.status === "canceled" ? edit.canceled_at : edit.created_at,
|
|
881
|
+
children: isConfirmed ? /* @__PURE__ */ jsx7(OrderEditBody, { edit }) : null
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
for (const transfer of orderChanges.filter(
|
|
885
|
+
(oc) => oc.change_type === "transfer"
|
|
886
|
+
)) {
|
|
887
|
+
if (transfer.requested_at) {
|
|
888
|
+
items.push({
|
|
889
|
+
title: t(`orders.activity.events.transfer.requested`, {
|
|
890
|
+
transferId: transfer.id.slice(-7)
|
|
891
|
+
}),
|
|
892
|
+
timestamp: transfer.requested_at,
|
|
893
|
+
children: /* @__PURE__ */ jsx7(TransferOrderRequestBody, { transfer })
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
if (transfer.confirmed_at) {
|
|
897
|
+
items.push({
|
|
898
|
+
title: t(`orders.activity.events.transfer.confirmed`, {
|
|
899
|
+
transferId: transfer.id.slice(-7)
|
|
900
|
+
}),
|
|
901
|
+
timestamp: transfer.confirmed_at
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
if (transfer.declined_at) {
|
|
905
|
+
items.push({
|
|
906
|
+
title: t(`orders.activity.events.transfer.declined`, {
|
|
907
|
+
transferId: transfer.id.slice(-7)
|
|
908
|
+
}),
|
|
909
|
+
timestamp: transfer.declined_at
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
for (const update of orderChanges.filter(
|
|
914
|
+
(oc) => oc.change_type === "update_order"
|
|
915
|
+
)) {
|
|
916
|
+
const updateType = update.actions[0]?.details?.type;
|
|
917
|
+
if (updateType === "shipping_address") {
|
|
918
|
+
items.push({
|
|
919
|
+
title: /* @__PURE__ */ jsx7(
|
|
920
|
+
change_details_tooltip_default,
|
|
921
|
+
{
|
|
922
|
+
title: t(`orders.activity.events.update_order.shipping_address`),
|
|
923
|
+
previous: getFormattedAddress({
|
|
924
|
+
address: update.actions[0].details.old
|
|
925
|
+
}).join(", "),
|
|
926
|
+
next: getFormattedAddress({
|
|
927
|
+
address: update.actions[0].details.new
|
|
928
|
+
}).join(", ")
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
timestamp: update.created_at,
|
|
932
|
+
children: /* @__PURE__ */ jsxs8("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
|
|
933
|
+
t("fields.by"),
|
|
934
|
+
" ",
|
|
935
|
+
/* @__PURE__ */ jsx7(By, { id: update.created_by })
|
|
936
|
+
] })
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
if (updateType === "billing_address") {
|
|
940
|
+
items.push({
|
|
941
|
+
title: /* @__PURE__ */ jsx7(
|
|
942
|
+
change_details_tooltip_default,
|
|
943
|
+
{
|
|
944
|
+
title: t(`orders.activity.events.update_order.billing_address`),
|
|
945
|
+
previous: getFormattedAddress({
|
|
946
|
+
address: update.actions[0].details.old
|
|
947
|
+
}).join(", "),
|
|
948
|
+
next: getFormattedAddress({
|
|
949
|
+
address: update.actions[0].details.new
|
|
950
|
+
}).join(", ")
|
|
951
|
+
}
|
|
952
|
+
),
|
|
953
|
+
timestamp: update.created_at,
|
|
954
|
+
children: /* @__PURE__ */ jsxs8("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
|
|
955
|
+
t("fields.by"),
|
|
956
|
+
" ",
|
|
957
|
+
/* @__PURE__ */ jsx7(By, { id: update.created_by })
|
|
958
|
+
] })
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
if (updateType === "email") {
|
|
962
|
+
items.push({
|
|
963
|
+
title: /* @__PURE__ */ jsx7(
|
|
964
|
+
change_details_tooltip_default,
|
|
965
|
+
{
|
|
966
|
+
title: t(`orders.activity.events.update_order.email`),
|
|
967
|
+
previous: update.actions[0].details.old,
|
|
968
|
+
next: update.actions[0].details.new
|
|
969
|
+
}
|
|
970
|
+
),
|
|
971
|
+
timestamp: update.created_at,
|
|
972
|
+
children: /* @__PURE__ */ jsxs8("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
|
|
973
|
+
t("fields.by"),
|
|
974
|
+
" ",
|
|
975
|
+
/* @__PURE__ */ jsx7(By, { id: update.created_by })
|
|
976
|
+
] })
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (order.canceled_at) {
|
|
981
|
+
items.push({
|
|
982
|
+
title: t("orders.activity.events.canceled.title"),
|
|
983
|
+
timestamp: order.canceled_at
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
const sortedActivities = items.sort((a, b) => {
|
|
987
|
+
return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
|
|
988
|
+
});
|
|
989
|
+
const createdAt = {
|
|
990
|
+
title: t("orders.activity.events.placed.title"),
|
|
991
|
+
timestamp: order.created_at,
|
|
992
|
+
children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(order.total, order.currency_code) })
|
|
993
|
+
};
|
|
994
|
+
return [...sortedActivities, createdAt];
|
|
995
|
+
}, [
|
|
996
|
+
order,
|
|
997
|
+
payments,
|
|
998
|
+
returns,
|
|
999
|
+
exchanges,
|
|
1000
|
+
orderChanges,
|
|
1001
|
+
notes,
|
|
1002
|
+
isLoading,
|
|
1003
|
+
itemsMap
|
|
1004
|
+
]);
|
|
1005
|
+
};
|
|
1006
|
+
var OrderActivityItem = ({
|
|
1007
|
+
title,
|
|
1008
|
+
timestamp,
|
|
1009
|
+
isFirst = false,
|
|
1010
|
+
children,
|
|
1011
|
+
itemsToSend,
|
|
1012
|
+
itemsToReturn,
|
|
1013
|
+
itemsMap
|
|
1014
|
+
}) => {
|
|
1015
|
+
const { getFullDate, getRelativeDate } = useDate();
|
|
1016
|
+
return /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", "data-testid": "order-activity-item", children: [
|
|
1017
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex size-full flex-col items-center gap-y-0.5", "data-testid": "order-activity-item-indicator", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx7("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx7("div", { className: "bg-ui-bg-base shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx7("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
|
|
1019
|
+
!isFirst && /* @__PURE__ */ jsx7("div", { className: "bg-ui-border-base w-px flex-1" })
|
|
1020
|
+
] }),
|
|
1021
|
+
/* @__PURE__ */ jsxs8(
|
|
1022
|
+
"div",
|
|
1023
|
+
{
|
|
1024
|
+
className: clx({
|
|
1025
|
+
"pb-4": !isFirst
|
|
1026
|
+
}),
|
|
1027
|
+
"data-testid": "order-activity-item-content",
|
|
1028
|
+
children: [
|
|
1029
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
1030
|
+
itemsToSend?.length || itemsToReturn?.length ? /* @__PURE__ */ jsx7(
|
|
1031
|
+
activity_items_default,
|
|
1032
|
+
{
|
|
1033
|
+
title,
|
|
1034
|
+
itemsToSend,
|
|
1035
|
+
itemsToReturn,
|
|
1036
|
+
itemsMap
|
|
1037
|
+
},
|
|
1038
|
+
title
|
|
1039
|
+
) : /* @__PURE__ */ jsx7(Text6, { size: "small", leading: "compact", weight: "plus", "data-testid": "order-activity-item-title", children: title }),
|
|
1040
|
+
timestamp && /* @__PURE__ */ jsx7(
|
|
1041
|
+
Tooltip,
|
|
1042
|
+
{
|
|
1043
|
+
content: getFullDate({ date: timestamp, includeTime: true }),
|
|
1044
|
+
children: /* @__PURE__ */ jsx7(
|
|
1045
|
+
Text6,
|
|
1046
|
+
{
|
|
1047
|
+
size: "small",
|
|
1048
|
+
leading: "compact",
|
|
1049
|
+
className: "text-ui-fg-subtle text-right",
|
|
1050
|
+
"data-testid": "order-activity-item-timestamp",
|
|
1051
|
+
children: getRelativeDate(timestamp)
|
|
1052
|
+
}
|
|
1053
|
+
)
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
1056
|
+
] }),
|
|
1057
|
+
/* @__PURE__ */ jsx7("div", { children })
|
|
1058
|
+
]
|
|
1059
|
+
}
|
|
1060
|
+
)
|
|
1061
|
+
] });
|
|
1062
|
+
};
|
|
1063
|
+
var OrderActivityCollapsible = ({
|
|
1064
|
+
activities
|
|
1065
|
+
}) => {
|
|
1066
|
+
const [open, setOpen] = useState3(false);
|
|
1067
|
+
const { t } = useTranslation7();
|
|
1068
|
+
if (!activities.length) {
|
|
1069
|
+
return null;
|
|
1070
|
+
}
|
|
1071
|
+
return /* @__PURE__ */ jsxs8(RadixCollapsible.Root, { open, onOpenChange: setOpen, children: [
|
|
1072
|
+
!open && /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
|
|
1073
|
+
/* @__PURE__ */ jsx7("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx7("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y" }) }),
|
|
1074
|
+
/* @__PURE__ */ jsx7("div", { className: "pb-4", children: /* @__PURE__ */ jsx7(RadixCollapsible.Trigger, { className: "text-left", children: /* @__PURE__ */ jsx7(
|
|
1075
|
+
Text6,
|
|
1076
|
+
{
|
|
1077
|
+
size: "small",
|
|
1078
|
+
leading: "compact",
|
|
1079
|
+
weight: "plus",
|
|
1080
|
+
className: "text-ui-fg-muted",
|
|
1081
|
+
children: t("orders.activity.showMoreActivities", {
|
|
1082
|
+
count: activities.length
|
|
1083
|
+
})
|
|
1084
|
+
}
|
|
1085
|
+
) }) })
|
|
1086
|
+
] }),
|
|
1087
|
+
/* @__PURE__ */ jsx7(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-y-0.5", children: activities.map((item, index) => {
|
|
1088
|
+
return /* @__PURE__ */ jsx7(
|
|
1089
|
+
OrderActivityItem,
|
|
1090
|
+
{
|
|
1091
|
+
title: item.title,
|
|
1092
|
+
timestamp: item.timestamp,
|
|
1093
|
+
itemsToSend: item.itemsToSend,
|
|
1094
|
+
itemsToReturn: item.itemsToReturn,
|
|
1095
|
+
itemsMap: item.itemsMap,
|
|
1096
|
+
children: item.children
|
|
1097
|
+
},
|
|
1098
|
+
index
|
|
1099
|
+
);
|
|
1100
|
+
}) }) })
|
|
1101
|
+
] });
|
|
1102
|
+
};
|
|
1103
|
+
var FulfillmentCreatedBody = ({
|
|
1104
|
+
fulfillment
|
|
1105
|
+
}) => {
|
|
1106
|
+
const { t } = useTranslation7();
|
|
1107
|
+
const numberOfItems = fulfillment.items.reduce((acc, item) => {
|
|
1108
|
+
return acc + item.quantity;
|
|
1109
|
+
}, 0);
|
|
1110
|
+
return /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.fulfillment.items", {
|
|
1111
|
+
count: numberOfItems
|
|
1112
|
+
}) }) });
|
|
1113
|
+
};
|
|
1114
|
+
var ReturnBody = ({
|
|
1115
|
+
orderReturn,
|
|
1116
|
+
isCreated,
|
|
1117
|
+
isReceived
|
|
1118
|
+
}) => {
|
|
1119
|
+
const prompt = usePrompt();
|
|
1120
|
+
const { t } = useTranslation7();
|
|
1121
|
+
const { mutateAsync: cancelReturnRequest } = useCancelReturn(
|
|
1122
|
+
orderReturn.id,
|
|
1123
|
+
orderReturn.order_id
|
|
1124
|
+
);
|
|
1125
|
+
const onCancel = async () => {
|
|
1126
|
+
const res = await prompt({
|
|
1127
|
+
title: t("orders.returns.cancel.title"),
|
|
1128
|
+
description: t("orders.returns.cancel.description"),
|
|
1129
|
+
confirmText: t("actions.confirm"),
|
|
1130
|
+
cancelText: t("actions.cancel")
|
|
1131
|
+
});
|
|
1132
|
+
if (!res) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
await cancelReturnRequest().catch((error) => {
|
|
1136
|
+
toast5.error(error.message);
|
|
1137
|
+
});
|
|
1138
|
+
};
|
|
1139
|
+
const numberOfItems = orderReturn.items.reduce((acc, item) => {
|
|
1140
|
+
return acc + (isReceived ? item.received_quantity : item.quantity);
|
|
1141
|
+
}, 0);
|
|
1142
|
+
return /* @__PURE__ */ jsxs8("div", { className: "flex items-start gap-1", children: [
|
|
1143
|
+
/* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.return.items", {
|
|
1144
|
+
count: numberOfItems
|
|
1145
|
+
}) }),
|
|
1146
|
+
isCreated && /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
1147
|
+
/* @__PURE__ */ jsx7("div", { className: "mt-[2px] flex items-center leading-none", children: "\u22C5" }),
|
|
1148
|
+
/* @__PURE__ */ jsx7(
|
|
1149
|
+
Button5,
|
|
1150
|
+
{
|
|
1151
|
+
onClick: onCancel,
|
|
1152
|
+
className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
|
|
1153
|
+
variant: "transparent",
|
|
1154
|
+
size: "small",
|
|
1155
|
+
children: t("actions.cancel")
|
|
1156
|
+
}
|
|
1157
|
+
)
|
|
1158
|
+
] })
|
|
1159
|
+
] });
|
|
1160
|
+
};
|
|
1161
|
+
var ClaimBody = ({
|
|
1162
|
+
claim,
|
|
1163
|
+
claimReturn
|
|
1164
|
+
}) => {
|
|
1165
|
+
const prompt = usePrompt();
|
|
1166
|
+
const { t } = useTranslation7();
|
|
1167
|
+
const isCanceled = !!claim.created_at;
|
|
1168
|
+
const { mutateAsync: cancelClaim } = useCancelClaim(claim.id, claim.order_id);
|
|
1169
|
+
const onCancel = async () => {
|
|
1170
|
+
const res = await prompt({
|
|
1171
|
+
title: t("orders.claims.cancel.title"),
|
|
1172
|
+
description: t("orders.claims.cancel.description"),
|
|
1173
|
+
confirmText: t("actions.confirm"),
|
|
1174
|
+
cancelText: t("actions.cancel")
|
|
1175
|
+
});
|
|
1176
|
+
if (!res) {
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
await cancelClaim().catch((error) => {
|
|
1180
|
+
toast5.error(error.message);
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
const outboundItems = (claim.additional_items || []).reduce(
|
|
1184
|
+
(acc, item) => acc + item.quantity,
|
|
1185
|
+
0
|
|
1186
|
+
);
|
|
1187
|
+
const inboundItems = (claimReturn?.items || []).reduce(
|
|
1188
|
+
(acc, item) => acc + item.quantity,
|
|
1189
|
+
0
|
|
1190
|
+
);
|
|
1191
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
1192
|
+
outboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsInbound", {
|
|
1193
|
+
count: outboundItems
|
|
1194
|
+
}) }),
|
|
1195
|
+
inboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsOutbound", {
|
|
1196
|
+
count: inboundItems
|
|
1197
|
+
}) }),
|
|
1198
|
+
!isCanceled && /* @__PURE__ */ jsx7(
|
|
1199
|
+
Button5,
|
|
1200
|
+
{
|
|
1201
|
+
onClick: onCancel,
|
|
1202
|
+
className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
|
|
1203
|
+
variant: "transparent",
|
|
1204
|
+
size: "small",
|
|
1205
|
+
children: t("actions.cancel")
|
|
1206
|
+
}
|
|
1207
|
+
)
|
|
1208
|
+
] });
|
|
1209
|
+
};
|
|
1210
|
+
var ExchangeBody = ({
|
|
1211
|
+
exchange,
|
|
1212
|
+
exchangeReturn
|
|
1213
|
+
}) => {
|
|
1214
|
+
const prompt = usePrompt();
|
|
1215
|
+
const { t } = useTranslation7();
|
|
1216
|
+
const isCanceled = !!exchange.canceled_at;
|
|
1217
|
+
const { mutateAsync: cancelExchange } = useCancelExchange(
|
|
1218
|
+
exchange.id,
|
|
1219
|
+
exchange.order_id
|
|
1220
|
+
);
|
|
1221
|
+
const onCancel = async () => {
|
|
1222
|
+
const res = await prompt({
|
|
1223
|
+
title: t("orders.exchanges.cancel.title"),
|
|
1224
|
+
description: t("orders.exchanges.cancel.description"),
|
|
1225
|
+
confirmText: t("actions.confirm"),
|
|
1226
|
+
cancelText: t("actions.cancel")
|
|
1227
|
+
});
|
|
1228
|
+
if (!res) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
await cancelExchange().catch((error) => {
|
|
1232
|
+
toast5.error(error.message);
|
|
1233
|
+
});
|
|
1234
|
+
};
|
|
1235
|
+
const outboundItems = (exchange.additional_items || []).reduce(
|
|
1236
|
+
(acc, item) => acc + item.quantity,
|
|
1237
|
+
0
|
|
1238
|
+
);
|
|
1239
|
+
const inboundItems = (exchangeReturn?.items || []).reduce(
|
|
1240
|
+
(acc, item) => acc + item.quantity,
|
|
1241
|
+
0
|
|
1242
|
+
);
|
|
1243
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
1244
|
+
outboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsInbound", {
|
|
1245
|
+
count: outboundItems
|
|
1246
|
+
}) }),
|
|
1247
|
+
inboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsOutbound", {
|
|
1248
|
+
count: inboundItems
|
|
1249
|
+
}) }),
|
|
1250
|
+
!isCanceled && /* @__PURE__ */ jsx7(
|
|
1251
|
+
Button5,
|
|
1252
|
+
{
|
|
1253
|
+
onClick: onCancel,
|
|
1254
|
+
className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
|
|
1255
|
+
variant: "transparent",
|
|
1256
|
+
size: "small",
|
|
1257
|
+
children: t("actions.cancel")
|
|
1258
|
+
}
|
|
1259
|
+
)
|
|
1260
|
+
] });
|
|
1261
|
+
};
|
|
1262
|
+
var OrderEditBody = ({ edit }) => {
|
|
1263
|
+
const { t } = useTranslation7();
|
|
1264
|
+
const [itemsAdded, itemsRemoved] = useMemo2(
|
|
1265
|
+
() => countItemsChange(edit.actions),
|
|
1266
|
+
[edit]
|
|
1267
|
+
);
|
|
1268
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
1269
|
+
itemsAdded > 0 && /* @__PURE__ */ jsxs8(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1270
|
+
t("labels.added"),
|
|
1271
|
+
": ",
|
|
1272
|
+
itemsAdded
|
|
1273
|
+
] }),
|
|
1274
|
+
itemsRemoved > 0 && /* @__PURE__ */ jsxs8(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1275
|
+
t("labels.removed"),
|
|
1276
|
+
": ",
|
|
1277
|
+
itemsRemoved
|
|
1278
|
+
] })
|
|
1279
|
+
] });
|
|
1280
|
+
};
|
|
1281
|
+
var TransferOrderRequestBody = ({
|
|
1282
|
+
transfer
|
|
1283
|
+
}) => {
|
|
1284
|
+
const prompt = usePrompt();
|
|
1285
|
+
const { t } = useTranslation7();
|
|
1286
|
+
const action = transfer.actions[0];
|
|
1287
|
+
const { customer } = useCustomer(action.reference_id);
|
|
1288
|
+
const isCompleted = !!transfer.confirmed_at;
|
|
1289
|
+
const { mutateAsync: cancelTransfer } = useCancelOrderTransfer(
|
|
1290
|
+
transfer.order_id
|
|
1291
|
+
);
|
|
1292
|
+
const handleDelete = async () => {
|
|
1293
|
+
const res = await prompt({
|
|
1294
|
+
title: t("general.areYouSure"),
|
|
1295
|
+
description: t("actions.cannotUndo"),
|
|
1296
|
+
confirmText: t("actions.delete"),
|
|
1297
|
+
cancelText: t("actions.cancel")
|
|
1298
|
+
});
|
|
1299
|
+
if (!res) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
await cancelTransfer().catch((error) => {
|
|
1303
|
+
toast5.error(error.message);
|
|
1304
|
+
});
|
|
1305
|
+
};
|
|
1306
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
1307
|
+
/* @__PURE__ */ jsxs8(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1308
|
+
t("orders.activity.from"),
|
|
1309
|
+
": ",
|
|
1310
|
+
action.details?.original_email
|
|
1311
|
+
] }),
|
|
1312
|
+
/* @__PURE__ */ jsxs8(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1313
|
+
t("orders.activity.to"),
|
|
1314
|
+
":",
|
|
1315
|
+
" ",
|
|
1316
|
+
customer?.first_name ? `${customer?.first_name} ${customer?.last_name}` : customer?.email
|
|
1317
|
+
] }),
|
|
1318
|
+
!isCompleted && /* @__PURE__ */ jsx7(
|
|
1319
|
+
Button5,
|
|
1320
|
+
{
|
|
1321
|
+
onClick: handleDelete,
|
|
1322
|
+
className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
|
|
1323
|
+
variant: "transparent",
|
|
1324
|
+
size: "small",
|
|
1325
|
+
children: t("actions.cancel")
|
|
1326
|
+
}
|
|
1327
|
+
)
|
|
1328
|
+
] });
|
|
1329
|
+
};
|
|
1330
|
+
function countItemsChange(actions) {
|
|
1331
|
+
let added = 0;
|
|
1332
|
+
let removed = 0;
|
|
1333
|
+
actions.forEach((action) => {
|
|
1334
|
+
if (action.action === "ITEM_ADD") {
|
|
1335
|
+
added += action.details.quantity;
|
|
1336
|
+
}
|
|
1337
|
+
if (action.action === "ITEM_UPDATE") {
|
|
1338
|
+
const quantityDiff = action.details.quantity_diff;
|
|
1339
|
+
if (quantityDiff > 0) {
|
|
1340
|
+
added += quantityDiff;
|
|
1341
|
+
} else {
|
|
1342
|
+
removed += Math.abs(quantityDiff);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
return [added, removed];
|
|
1347
|
+
}
|
|
1348
|
+
function getMissingLineItemIds(order, changes) {
|
|
1349
|
+
if (!changes?.length) {
|
|
1350
|
+
return [];
|
|
1351
|
+
}
|
|
1352
|
+
const retIds = /* @__PURE__ */ new Set();
|
|
1353
|
+
const existingItemsMap = new Map(order.items.map((item) => [item.id, true]));
|
|
1354
|
+
changes.forEach((change) => {
|
|
1355
|
+
change.actions.forEach((action) => {
|
|
1356
|
+
if (!action.details?.reference_id) {
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (action.details.reference_id.startsWith("ordli_") && !existingItemsMap.has(action.details.reference_id)) {
|
|
1360
|
+
retIds.add(action.details.reference_id);
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
return Array.from(retIds);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// src/pages/orders/order-detail/components/order-activity-section/order-activity-section.tsx
|
|
1368
|
+
import { jsx as jsx8, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1369
|
+
var OrderActivitySection = ({ order }) => {
|
|
1370
|
+
const { t } = useTranslation8();
|
|
1371
|
+
return /* @__PURE__ */ jsxs9(Container5, { className: "flex flex-col gap-y-8 px-6 py-4", "data-testid": "order-activity-section", children: [
|
|
1372
|
+
/* @__PURE__ */ jsx8("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsx8("div", { className: "flex items-center justify-between", "data-testid": "order-activity-header", children: /* @__PURE__ */ jsx8(Heading5, { level: "h2", "data-testid": "order-activity-heading", children: t("orders.activity.header") }) }) }),
|
|
1373
|
+
/* @__PURE__ */ jsx8(OrderTimeline, { order })
|
|
1374
|
+
] });
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
// src/pages/orders/order-detail/components/order-customer-section/order-customer-section.tsx
|
|
1378
|
+
import { ArrowPath as ArrowPath2, CurrencyDollar, Envelope, FlyingBox } from "@medusajs/icons";
|
|
1379
|
+
import { Container as Container6, Heading as Heading6 } from "@medusajs/ui";
|
|
1380
|
+
import { useTranslation as useTranslation10 } from "react-i18next";
|
|
1381
|
+
|
|
1382
|
+
// src/components/common/customer-info/customer-info.tsx
|
|
1383
|
+
import { Avatar, Copy as Copy2, Text as Text7 } from "@medusajs/ui";
|
|
1384
|
+
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
1385
|
+
import { Link } from "react-router-dom";
|
|
1386
|
+
import { jsx as jsx9, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1387
|
+
var ID = ({ data }) => {
|
|
1388
|
+
const { t } = useTranslation9();
|
|
1389
|
+
const id = data.customer_id;
|
|
1390
|
+
const name = getOrderCustomer(data);
|
|
1391
|
+
const email = data.email;
|
|
1392
|
+
const fallback = (name || email || "").charAt(0).toUpperCase();
|
|
1393
|
+
return /* @__PURE__ */ jsxs10("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
1394
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("fields.id") }),
|
|
1395
|
+
/* @__PURE__ */ jsx9(
|
|
1396
|
+
Link,
|
|
1397
|
+
{
|
|
1398
|
+
to: `/customers/${id}`,
|
|
1399
|
+
className: "focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",
|
|
1400
|
+
children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-x-2 overflow-hidden", children: [
|
|
1401
|
+
/* @__PURE__ */ jsx9(Avatar, { size: "2xsmall", fallback }),
|
|
1402
|
+
/* @__PURE__ */ jsx9(
|
|
1403
|
+
Text7,
|
|
1404
|
+
{
|
|
1405
|
+
size: "small",
|
|
1406
|
+
leading: "compact",
|
|
1407
|
+
className: "text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",
|
|
1408
|
+
children: name || email
|
|
1409
|
+
}
|
|
1410
|
+
)
|
|
1411
|
+
] })
|
|
1412
|
+
}
|
|
1413
|
+
)
|
|
1414
|
+
] });
|
|
1415
|
+
};
|
|
1416
|
+
var Company = ({ data }) => {
|
|
1417
|
+
const { t } = useTranslation9();
|
|
1418
|
+
const company = data.shipping_address?.company || data.billing_address?.company;
|
|
1419
|
+
if (!company) {
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
return /* @__PURE__ */ jsxs10("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
1423
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("fields.company") }),
|
|
1424
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", className: "truncate", children: company })
|
|
1425
|
+
] });
|
|
1426
|
+
};
|
|
1427
|
+
var Contact = ({ data }) => {
|
|
1428
|
+
const { t } = useTranslation9();
|
|
1429
|
+
const phone = data.shipping_address?.phone || data.billing_address?.phone;
|
|
1430
|
+
const email = data.email || "";
|
|
1431
|
+
return /* @__PURE__ */ jsxs10("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
1432
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("orders.customer.contactLabel") }),
|
|
1433
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-y-2", children: [
|
|
1434
|
+
/* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
1435
|
+
/* @__PURE__ */ jsx9(
|
|
1436
|
+
Text7,
|
|
1437
|
+
{
|
|
1438
|
+
size: "small",
|
|
1439
|
+
leading: "compact",
|
|
1440
|
+
className: "text-pretty break-all",
|
|
1441
|
+
children: email
|
|
1442
|
+
}
|
|
1443
|
+
),
|
|
1444
|
+
/* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(Copy2, { content: email, className: "text-ui-fg-muted" }) })
|
|
1445
|
+
] }),
|
|
1446
|
+
phone && /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
1447
|
+
/* @__PURE__ */ jsx9(
|
|
1448
|
+
Text7,
|
|
1449
|
+
{
|
|
1450
|
+
size: "small",
|
|
1451
|
+
leading: "compact",
|
|
1452
|
+
className: "text-pretty break-all",
|
|
1453
|
+
children: phone
|
|
1454
|
+
}
|
|
1455
|
+
),
|
|
1456
|
+
/* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(Copy2, { content: phone, className: "text-ui-fg-muted" }) })
|
|
1457
|
+
] })
|
|
1458
|
+
] })
|
|
1459
|
+
] });
|
|
1460
|
+
};
|
|
1461
|
+
var AddressPrint = ({
|
|
1462
|
+
address,
|
|
1463
|
+
type
|
|
1464
|
+
}) => {
|
|
1465
|
+
const { t } = useTranslation9();
|
|
1466
|
+
return /* @__PURE__ */ jsxs10("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
1467
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: type === "shipping" ? t("addresses.shippingAddress.label") : t("addresses.billingAddress.label") }),
|
|
1468
|
+
address ? /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
1469
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", children: getFormattedAddress({ address }).map((line, i) => {
|
|
1470
|
+
return /* @__PURE__ */ jsxs10("span", { className: "break-words", children: [
|
|
1471
|
+
line,
|
|
1472
|
+
/* @__PURE__ */ jsx9("br", {})
|
|
1473
|
+
] }, i);
|
|
1474
|
+
}) }),
|
|
1475
|
+
/* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(
|
|
1476
|
+
Copy2,
|
|
1477
|
+
{
|
|
1478
|
+
content: getFormattedAddress({ address }).join("\n"),
|
|
1479
|
+
className: "text-ui-fg-muted"
|
|
1480
|
+
}
|
|
1481
|
+
) })
|
|
1482
|
+
] }) : /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", children: "-" })
|
|
1483
|
+
] });
|
|
1484
|
+
};
|
|
1485
|
+
var Addresses = ({ data }) => {
|
|
1486
|
+
const { t } = useTranslation9();
|
|
1487
|
+
return /* @__PURE__ */ jsxs10("div", { className: "divide-y", children: [
|
|
1488
|
+
/* @__PURE__ */ jsx9(AddressPrint, { address: data.shipping_address, type: "shipping" }),
|
|
1489
|
+
!isSameAddress(data.shipping_address, data.billing_address) ? /* @__PURE__ */ jsx9(AddressPrint, { address: data.billing_address, type: "billing" }) : /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-2 items-center px-6 py-4", children: [
|
|
1490
|
+
/* @__PURE__ */ jsx9(
|
|
1491
|
+
Text7,
|
|
1492
|
+
{
|
|
1493
|
+
size: "small",
|
|
1494
|
+
leading: "compact",
|
|
1495
|
+
weight: "plus",
|
|
1496
|
+
className: "text-ui-fg-subtle",
|
|
1497
|
+
children: t("addresses.billingAddress.label")
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
/* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: t("addresses.billingAddress.sameAsShipping") })
|
|
1501
|
+
] })
|
|
1502
|
+
] });
|
|
1503
|
+
};
|
|
1504
|
+
var CustomerInfo = Object.assign(
|
|
1505
|
+
{},
|
|
1506
|
+
{
|
|
1507
|
+
ID,
|
|
1508
|
+
Company,
|
|
1509
|
+
Contact,
|
|
1510
|
+
Addresses
|
|
1511
|
+
}
|
|
1512
|
+
);
|
|
1513
|
+
var getOrderCustomer = (obj) => {
|
|
1514
|
+
const { first_name: sFirstName, last_name: sLastName } = obj.shipping_address || {};
|
|
1515
|
+
const { first_name: bFirstName, last_name: bLastName } = obj.billing_address || {};
|
|
1516
|
+
const { first_name: cFirstName, last_name: cLastName } = obj.customer || {};
|
|
1517
|
+
const customerName = [cFirstName, cLastName].filter(Boolean).join(" ");
|
|
1518
|
+
const shippingName = [sFirstName, sLastName].filter(Boolean).join(" ");
|
|
1519
|
+
const billingName = [bFirstName, bLastName].filter(Boolean).join(" ");
|
|
1520
|
+
const name = customerName || shippingName || billingName;
|
|
1521
|
+
return name;
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
// src/pages/orders/order-detail/components/order-customer-section/order-customer-section.tsx
|
|
1525
|
+
import { jsx as jsx10, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1526
|
+
var OrderCustomerSection = ({ order }) => {
|
|
1527
|
+
return /* @__PURE__ */ jsxs11(
|
|
1528
|
+
Container6,
|
|
1529
|
+
{
|
|
1530
|
+
className: "divide-y p-0",
|
|
1531
|
+
"data-testid": "order-customer-section",
|
|
1532
|
+
children: [
|
|
1533
|
+
/* @__PURE__ */ jsx10(Header, { order }),
|
|
1534
|
+
/* @__PURE__ */ jsx10(CustomerInfo.ID, { data: order }),
|
|
1535
|
+
/* @__PURE__ */ jsx10(CustomerInfo.Contact, { data: order }),
|
|
1536
|
+
/* @__PURE__ */ jsx10(CustomerInfo.Company, { data: order }),
|
|
1537
|
+
/* @__PURE__ */ jsx10(CustomerInfo.Addresses, { data: order })
|
|
1538
|
+
]
|
|
1539
|
+
}
|
|
1540
|
+
);
|
|
1541
|
+
};
|
|
1542
|
+
var Header = ({ order }) => {
|
|
1543
|
+
const { t } = useTranslation10();
|
|
1544
|
+
return /* @__PURE__ */ jsxs11(
|
|
1545
|
+
"div",
|
|
1546
|
+
{
|
|
1547
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
1548
|
+
"data-testid": "order-customer-header",
|
|
1549
|
+
children: [
|
|
1550
|
+
/* @__PURE__ */ jsx10(
|
|
1551
|
+
Heading6,
|
|
1552
|
+
{
|
|
1553
|
+
level: "h2",
|
|
1554
|
+
"data-testid": "order-customer-heading",
|
|
1555
|
+
children: t("fields.customer")
|
|
1556
|
+
}
|
|
1557
|
+
),
|
|
1558
|
+
/* @__PURE__ */ jsx10(
|
|
1559
|
+
ActionMenu,
|
|
1560
|
+
{
|
|
1561
|
+
groups: [
|
|
1562
|
+
{
|
|
1563
|
+
actions: [
|
|
1564
|
+
{
|
|
1565
|
+
label: t("transferOwnership.label"),
|
|
1566
|
+
to: `transfer`,
|
|
1567
|
+
icon: /* @__PURE__ */ jsx10(ArrowPath2, {})
|
|
1568
|
+
}
|
|
1569
|
+
]
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
actions: [
|
|
1573
|
+
{
|
|
1574
|
+
label: t("addresses.shippingAddress.editLabel"),
|
|
1575
|
+
to: "shipping-address",
|
|
1576
|
+
icon: /* @__PURE__ */ jsx10(FlyingBox, {})
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
label: t("addresses.billingAddress.editLabel"),
|
|
1580
|
+
to: "billing-address",
|
|
1581
|
+
icon: /* @__PURE__ */ jsx10(CurrencyDollar, {})
|
|
1582
|
+
}
|
|
1583
|
+
]
|
|
1584
|
+
},
|
|
1585
|
+
{
|
|
1586
|
+
actions: [
|
|
1587
|
+
{
|
|
1588
|
+
label: t("email.editLabel"),
|
|
1589
|
+
to: `email`,
|
|
1590
|
+
icon: /* @__PURE__ */ jsx10(Envelope, {}),
|
|
1591
|
+
disabled: order.status === "canceled"
|
|
1592
|
+
}
|
|
1593
|
+
]
|
|
1594
|
+
}
|
|
1595
|
+
],
|
|
1596
|
+
"data-testid": "order-customer-action-menu"
|
|
1597
|
+
}
|
|
1598
|
+
)
|
|
1599
|
+
]
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
// src/pages/orders/order-detail/components/order-fulfillment-section/order-fulfillment-section.tsx
|
|
1605
|
+
import { Buildings, XCircle } from "@medusajs/icons";
|
|
1606
|
+
import {
|
|
1607
|
+
Button as Button6,
|
|
1608
|
+
Container as Container7,
|
|
1609
|
+
Copy as Copy3,
|
|
1610
|
+
Heading as Heading7,
|
|
1611
|
+
StatusBadge,
|
|
1612
|
+
Text as Text8,
|
|
1613
|
+
Tooltip as Tooltip2,
|
|
1614
|
+
toast as toast6,
|
|
1615
|
+
usePrompt as usePrompt2
|
|
1616
|
+
} from "@medusajs/ui";
|
|
1617
|
+
import { format } from "date-fns";
|
|
1618
|
+
import { useTranslation as useTranslation11 } from "react-i18next";
|
|
1619
|
+
import { Link as Link2, useNavigate as useNavigate5 } from "react-router-dom";
|
|
1620
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1621
|
+
var OrderFulfillmentSection = ({
|
|
1622
|
+
order
|
|
1623
|
+
}) => {
|
|
1624
|
+
const fulfillments = order.fulfillments || [];
|
|
1625
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-y-3", "data-testid": "order-fulfillment-section", children: [
|
|
1626
|
+
/* @__PURE__ */ jsx11(UnfulfilledItemBreakdown, { order }),
|
|
1627
|
+
fulfillments.map((f, index) => /* @__PURE__ */ jsx11(Fulfillment, { index, fulfillment: f, order }, f.id))
|
|
1628
|
+
] });
|
|
1629
|
+
};
|
|
1630
|
+
var UnfulfilledItem = ({
|
|
1631
|
+
item,
|
|
1632
|
+
currencyCode
|
|
1633
|
+
}) => {
|
|
1634
|
+
return /* @__PURE__ */ jsxs12(
|
|
1635
|
+
"div",
|
|
1636
|
+
{
|
|
1637
|
+
className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",
|
|
1638
|
+
children: [
|
|
1639
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-x-4", children: [
|
|
1640
|
+
/* @__PURE__ */ jsx11(Thumbnail, { src: item.thumbnail }),
|
|
1641
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
1642
|
+
/* @__PURE__ */ jsx11(
|
|
1643
|
+
Text8,
|
|
1644
|
+
{
|
|
1645
|
+
size: "small",
|
|
1646
|
+
leading: "compact",
|
|
1647
|
+
weight: "plus",
|
|
1648
|
+
className: "text-ui-fg-base",
|
|
1649
|
+
children: item.title
|
|
1650
|
+
}
|
|
1651
|
+
),
|
|
1652
|
+
item.variant_sku && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-1", children: [
|
|
1653
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", children: item.variant_sku }),
|
|
1654
|
+
/* @__PURE__ */ jsx11(Copy3, { content: item.variant_sku, className: "text-ui-fg-muted" })
|
|
1655
|
+
] }),
|
|
1656
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
|
|
1657
|
+
] })
|
|
1658
|
+
] }),
|
|
1659
|
+
/* @__PURE__ */ jsxs12("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
|
|
1660
|
+
/* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx11(Text8, { size: "small", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
1661
|
+
/* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxs12(Text8, { children: [
|
|
1662
|
+
/* @__PURE__ */ jsx11("span", { className: "tabular-nums", children: item.quantity - item.detail.fulfilled_quantity }),
|
|
1663
|
+
"x"
|
|
1664
|
+
] }) }),
|
|
1665
|
+
/* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx11(Text8, { size: "small", children: getLocaleAmount(item.subtotal || 0, currencyCode) }) })
|
|
1666
|
+
] })
|
|
1667
|
+
]
|
|
1668
|
+
},
|
|
1669
|
+
item.id
|
|
1670
|
+
);
|
|
1671
|
+
};
|
|
1672
|
+
var UnfulfilledItemBreakdown = ({ order }) => {
|
|
1673
|
+
const unfulfilledItemsWithShipping = order.items.filter(
|
|
1674
|
+
(i) => i.requires_shipping && i.detail.fulfilled_quantity < i.quantity
|
|
1675
|
+
);
|
|
1676
|
+
const unfulfilledItemsWithoutShipping = order.items.filter(
|
|
1677
|
+
(i) => !i.requires_shipping && i.detail.fulfilled_quantity < i.quantity
|
|
1678
|
+
);
|
|
1679
|
+
return /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
1680
|
+
!!unfulfilledItemsWithShipping.length && /* @__PURE__ */ jsx11(
|
|
1681
|
+
UnfulfilledItemDisplay,
|
|
1682
|
+
{
|
|
1683
|
+
order,
|
|
1684
|
+
unfulfilledItems: unfulfilledItemsWithShipping,
|
|
1685
|
+
requiresShipping: true
|
|
1686
|
+
}
|
|
1687
|
+
),
|
|
1688
|
+
!!unfulfilledItemsWithoutShipping.length && /* @__PURE__ */ jsx11(
|
|
1689
|
+
UnfulfilledItemDisplay,
|
|
1690
|
+
{
|
|
1691
|
+
order,
|
|
1692
|
+
unfulfilledItems: unfulfilledItemsWithoutShipping,
|
|
1693
|
+
requiresShipping: false
|
|
1694
|
+
}
|
|
1695
|
+
)
|
|
1696
|
+
] });
|
|
1697
|
+
};
|
|
1698
|
+
var UnfulfilledItemDisplay = ({
|
|
1699
|
+
order,
|
|
1700
|
+
unfulfilledItems,
|
|
1701
|
+
requiresShipping = false
|
|
1702
|
+
}) => {
|
|
1703
|
+
const { t } = useTranslation11();
|
|
1704
|
+
if (order.status === "canceled") {
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
return /* @__PURE__ */ jsxs12(Container7, { className: "divide-y p-0", "data-testid": "order-fulfillment-unfulfilled", children: [
|
|
1708
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": "order-fulfillment-unfulfilled-header", children: [
|
|
1709
|
+
/* @__PURE__ */ jsx11(Heading7, { level: "h2", "data-testid": "order-fulfillment-unfulfilled-heading", children: t("orders.fulfillment.unfulfilledItems") }),
|
|
1710
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-4", "data-testid": "order-fulfillment-unfulfilled-badges", children: [
|
|
1711
|
+
requiresShipping && /* @__PURE__ */ jsx11(StatusBadge, { color: "red", className: "text-nowrap", "data-testid": "order-fulfillment-unfulfilled-requires-shipping-badge", children: t("orders.fulfillment.requiresShipping") }),
|
|
1712
|
+
/* @__PURE__ */ jsx11(StatusBadge, { color: "red", className: "text-nowrap", "data-testid": "order-fulfillment-unfulfilled-awaiting-badge", children: t("orders.fulfillment.awaitingFulfillmentBadge") }),
|
|
1713
|
+
/* @__PURE__ */ jsx11(
|
|
1714
|
+
ActionMenu,
|
|
1715
|
+
{
|
|
1716
|
+
groups: [
|
|
1717
|
+
{
|
|
1718
|
+
actions: [
|
|
1719
|
+
{
|
|
1720
|
+
label: t("orders.fulfillment.fulfillItems"),
|
|
1721
|
+
icon: /* @__PURE__ */ jsx11(Buildings, {}),
|
|
1722
|
+
to: `/orders/${order.id}/fulfillment?requires_shipping=${requiresShipping}`
|
|
1723
|
+
}
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
],
|
|
1727
|
+
"data-testid": "order-fulfillment-unfulfilled-action-menu"
|
|
1728
|
+
}
|
|
1729
|
+
)
|
|
1730
|
+
] })
|
|
1731
|
+
] }),
|
|
1732
|
+
/* @__PURE__ */ jsx11("div", { "data-testid": "order-fulfillment-unfulfilled-items", children: unfulfilledItems.map((item) => /* @__PURE__ */ jsx11(
|
|
1733
|
+
UnfulfilledItem,
|
|
1734
|
+
{
|
|
1735
|
+
item,
|
|
1736
|
+
currencyCode: order.currency_code
|
|
1737
|
+
},
|
|
1738
|
+
item.id
|
|
1739
|
+
)) })
|
|
1740
|
+
] });
|
|
1741
|
+
};
|
|
1742
|
+
var Fulfillment = ({
|
|
1743
|
+
fulfillment,
|
|
1744
|
+
order,
|
|
1745
|
+
index
|
|
1746
|
+
}) => {
|
|
1747
|
+
const { t } = useTranslation11();
|
|
1748
|
+
const prompt = usePrompt2();
|
|
1749
|
+
const navigate = useNavigate5();
|
|
1750
|
+
const showLocation = !!fulfillment.location_id;
|
|
1751
|
+
const isPickUpFulfillment = fulfillment.shipping_option?.service_zone.fulfillment_set.type === "pickup" /* Pickup */;
|
|
1752
|
+
const { stock_location, isError, error } = useStockLocation(
|
|
1753
|
+
fulfillment.location_id,
|
|
1754
|
+
void 0,
|
|
1755
|
+
{
|
|
1756
|
+
enabled: showLocation
|
|
1757
|
+
}
|
|
1758
|
+
);
|
|
1759
|
+
let statusText = fulfillment.requires_shipping ? isPickUpFulfillment ? "Awaiting pickup" : "Awaiting shipping" : "Awaiting delivery";
|
|
1760
|
+
let statusColor = "blue";
|
|
1761
|
+
let statusTimestamp = fulfillment.created_at;
|
|
1762
|
+
if (fulfillment.canceled_at) {
|
|
1763
|
+
statusText = "Canceled";
|
|
1764
|
+
statusColor = "red";
|
|
1765
|
+
statusTimestamp = fulfillment.canceled_at;
|
|
1766
|
+
} else if (fulfillment.delivered_at) {
|
|
1767
|
+
statusText = "Delivered";
|
|
1768
|
+
statusColor = "green";
|
|
1769
|
+
statusTimestamp = fulfillment.delivered_at;
|
|
1770
|
+
} else if (fulfillment.shipped_at) {
|
|
1771
|
+
statusText = "Shipped";
|
|
1772
|
+
statusColor = "green";
|
|
1773
|
+
statusTimestamp = fulfillment.shipped_at;
|
|
1774
|
+
}
|
|
1775
|
+
const { mutateAsync } = useCancelOrderFulfillment(order.id, fulfillment.id);
|
|
1776
|
+
const { mutateAsync: markAsDelivered } = useMarkOrderFulfillmentAsDelivered(
|
|
1777
|
+
order.id,
|
|
1778
|
+
fulfillment.id
|
|
1779
|
+
);
|
|
1780
|
+
const showShippingButton = !fulfillment.canceled_at && !fulfillment.shipped_at && !fulfillment.delivered_at && fulfillment.requires_shipping && !isPickUpFulfillment;
|
|
1781
|
+
const showDeliveryButton = !fulfillment.canceled_at && !fulfillment.delivered_at;
|
|
1782
|
+
const handleMarkAsDelivered = async () => {
|
|
1783
|
+
const res = await prompt({
|
|
1784
|
+
title: t("general.areYouSure"),
|
|
1785
|
+
description: t("orders.fulfillment.markAsDeliveredWarning"),
|
|
1786
|
+
confirmText: t("actions.continue"),
|
|
1787
|
+
cancelText: t("actions.cancel"),
|
|
1788
|
+
variant: "confirmation"
|
|
1789
|
+
});
|
|
1790
|
+
if (res) {
|
|
1791
|
+
await markAsDelivered(void 0, {
|
|
1792
|
+
onSuccess: () => {
|
|
1793
|
+
toast6.success(
|
|
1794
|
+
t(
|
|
1795
|
+
isPickUpFulfillment ? "orders.fulfillment.toast.fulfillmentPickedUp" : "orders.fulfillment.toast.fulfillmentDelivered"
|
|
1796
|
+
)
|
|
1797
|
+
);
|
|
1798
|
+
},
|
|
1799
|
+
onError: (e) => {
|
|
1800
|
+
toast6.error(e.message);
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
const handleCancel = async () => {
|
|
1806
|
+
if (fulfillment.shipped_at) {
|
|
1807
|
+
toast6.warning(t("orders.fulfillment.toast.fulfillmentShipped"));
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
const res = await prompt({
|
|
1811
|
+
title: t("general.areYouSure"),
|
|
1812
|
+
description: t("orders.fulfillment.cancelWarning"),
|
|
1813
|
+
confirmText: t("actions.continue"),
|
|
1814
|
+
cancelText: t("actions.cancel")
|
|
1815
|
+
});
|
|
1816
|
+
if (res) {
|
|
1817
|
+
await mutateAsync(void 0, {
|
|
1818
|
+
onSuccess: () => {
|
|
1819
|
+
toast6.success(t("orders.fulfillment.toast.canceled"));
|
|
1820
|
+
},
|
|
1821
|
+
onError: (e) => {
|
|
1822
|
+
toast6.error(e.message);
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
if (isError) {
|
|
1828
|
+
throw error;
|
|
1829
|
+
}
|
|
1830
|
+
const isValidUrl = (url) => url && url.length > 0 && url !== "#";
|
|
1831
|
+
return /* @__PURE__ */ jsxs12(Container7, { className: "divide-y p-0", "data-testid": `order-fulfillment-${fulfillment.id}`, children: [
|
|
1832
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": `order-fulfillment-${fulfillment.id}-header`, children: [
|
|
1833
|
+
/* @__PURE__ */ jsx11(Heading7, { level: "h2", "data-testid": `order-fulfillment-${fulfillment.id}-heading`, children: t("orders.fulfillment.number", {
|
|
1834
|
+
number: index + 1
|
|
1835
|
+
}) }),
|
|
1836
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-4", "data-testid": `order-fulfillment-${fulfillment.id}-status-container`, children: [
|
|
1837
|
+
/* @__PURE__ */ jsx11(
|
|
1838
|
+
Tooltip2,
|
|
1839
|
+
{
|
|
1840
|
+
content: format(
|
|
1841
|
+
new Date(statusTimestamp),
|
|
1842
|
+
"dd MMM, yyyy, HH:mm:ss"
|
|
1843
|
+
),
|
|
1844
|
+
children: /* @__PURE__ */ jsx11(StatusBadge, { color: statusColor, className: "text-nowrap", "data-testid": `order-fulfillment-${fulfillment.id}-status-badge`, children: statusText })
|
|
1845
|
+
}
|
|
1846
|
+
),
|
|
1847
|
+
/* @__PURE__ */ jsx11(
|
|
1848
|
+
ActionMenu,
|
|
1849
|
+
{
|
|
1850
|
+
groups: [
|
|
1851
|
+
{
|
|
1852
|
+
actions: [
|
|
1853
|
+
{
|
|
1854
|
+
label: t("actions.cancel"),
|
|
1855
|
+
icon: /* @__PURE__ */ jsx11(XCircle, {}),
|
|
1856
|
+
onClick: handleCancel,
|
|
1857
|
+
disabled: !!fulfillment.canceled_at || !!fulfillment.shipped_at || !!fulfillment.delivered_at
|
|
1858
|
+
}
|
|
1859
|
+
]
|
|
1860
|
+
}
|
|
1861
|
+
],
|
|
1862
|
+
"data-testid": `order-fulfillment-${fulfillment.id}-action-menu`
|
|
1863
|
+
}
|
|
1864
|
+
)
|
|
1865
|
+
] })
|
|
1866
|
+
] }),
|
|
1867
|
+
/* @__PURE__ */ jsxs12("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
1868
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.itemsLabel") }),
|
|
1869
|
+
/* @__PURE__ */ jsx11("ul", { children: fulfillment.items.map((f_item) => /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsxs12(Text8, { size: "small", leading: "compact", children: [
|
|
1870
|
+
f_item.quantity,
|
|
1871
|
+
"x ",
|
|
1872
|
+
f_item.title
|
|
1873
|
+
] }) }, f_item.line_item_id)) })
|
|
1874
|
+
] }),
|
|
1875
|
+
showLocation && /* @__PURE__ */ jsxs12("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
1876
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.shippingFromLabel") }),
|
|
1877
|
+
stock_location ? /* @__PURE__ */ jsx11(
|
|
1878
|
+
Link2,
|
|
1879
|
+
{
|
|
1880
|
+
to: `/settings/locations/${stock_location.id}`,
|
|
1881
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
|
|
1882
|
+
children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: stock_location.name })
|
|
1883
|
+
}
|
|
1884
|
+
) : /* @__PURE__ */ jsx11(Skeleton, { className: "w-16" })
|
|
1885
|
+
] }),
|
|
1886
|
+
/* @__PURE__ */ jsxs12("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
1887
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("fields.provider") }),
|
|
1888
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: formatProvider(fulfillment.provider_id) })
|
|
1889
|
+
] }),
|
|
1890
|
+
/* @__PURE__ */ jsxs12("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
1891
|
+
/* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.trackingLabel") }),
|
|
1892
|
+
/* @__PURE__ */ jsx11("div", { children: fulfillment.labels && fulfillment.labels.length > 0 ? /* @__PURE__ */ jsx11("ul", { children: fulfillment.labels.map((tlink) => {
|
|
1893
|
+
const hasTrackingUrl = isValidUrl(tlink.tracking_url);
|
|
1894
|
+
const hasLabelUrl = isValidUrl(tlink.label_url);
|
|
1895
|
+
if (hasTrackingUrl || hasLabelUrl) {
|
|
1896
|
+
return /* @__PURE__ */ jsxs12("li", { children: [
|
|
1897
|
+
hasTrackingUrl && /* @__PURE__ */ jsx11(
|
|
1898
|
+
"a",
|
|
1899
|
+
{
|
|
1900
|
+
href: tlink.tracking_url,
|
|
1901
|
+
target: "_blank",
|
|
1902
|
+
rel: "noopener noreferrer",
|
|
1903
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
|
|
1904
|
+
children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", as: "span", children: tlink.tracking_number })
|
|
1905
|
+
}
|
|
1906
|
+
),
|
|
1907
|
+
hasTrackingUrl && hasLabelUrl && " - ",
|
|
1908
|
+
hasLabelUrl && /* @__PURE__ */ jsx11(
|
|
1909
|
+
"a",
|
|
1910
|
+
{
|
|
1911
|
+
href: tlink.label_url,
|
|
1912
|
+
target: "_blank",
|
|
1913
|
+
rel: "noopener noreferrer",
|
|
1914
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
|
|
1915
|
+
children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", as: "span", children: "Label" })
|
|
1916
|
+
}
|
|
1917
|
+
)
|
|
1918
|
+
] }, tlink.tracking_number);
|
|
1919
|
+
}
|
|
1920
|
+
return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: tlink.tracking_number }) }, tlink.tracking_number);
|
|
1921
|
+
}) }) : /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: "-" }) })
|
|
1922
|
+
] }),
|
|
1923
|
+
(showShippingButton || showDeliveryButton) && /* @__PURE__ */ jsxs12("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": `order-fulfillment-${fulfillment.id}-actions`, children: [
|
|
1924
|
+
showDeliveryButton && /* @__PURE__ */ jsx11(Button6, { onClick: handleMarkAsDelivered, variant: "secondary", "data-testid": `order-fulfillment-${fulfillment.id}-mark-delivered-button`, children: t(
|
|
1925
|
+
isPickUpFulfillment ? "orders.fulfillment.markAsPickedUp" : "orders.fulfillment.markAsDelivered"
|
|
1926
|
+
) }),
|
|
1927
|
+
showShippingButton && /* @__PURE__ */ jsx11(
|
|
1928
|
+
Button6,
|
|
1929
|
+
{
|
|
1930
|
+
onClick: () => navigate(`./${fulfillment.id}/create-shipment`),
|
|
1931
|
+
variant: "secondary",
|
|
1932
|
+
"data-testid": `order-fulfillment-${fulfillment.id}-mark-shipped-button`,
|
|
1933
|
+
children: t("orders.fulfillment.markAsShipped")
|
|
1934
|
+
}
|
|
1935
|
+
)
|
|
1936
|
+
] })
|
|
1937
|
+
] });
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
// src/pages/orders/order-detail/components/order-general-section/order-general-section.tsx
|
|
1941
|
+
import { XCircle as XCircle2 } from "@medusajs/icons";
|
|
1942
|
+
import {
|
|
1943
|
+
Container as Container8,
|
|
1944
|
+
Copy as Copy4,
|
|
1945
|
+
Heading as Heading8,
|
|
1946
|
+
StatusBadge as StatusBadge2,
|
|
1947
|
+
Text as Text9,
|
|
1948
|
+
toast as toast7,
|
|
1949
|
+
usePrompt as usePrompt3
|
|
1950
|
+
} from "@medusajs/ui";
|
|
1951
|
+
import { useTranslation as useTranslation12 } from "react-i18next";
|
|
1952
|
+
import { jsx as jsx12, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1953
|
+
var OrderGeneralSection = ({ order }) => {
|
|
1954
|
+
const { t } = useTranslation12();
|
|
1955
|
+
const prompt = usePrompt3();
|
|
1956
|
+
const { getFullDate } = useDate();
|
|
1957
|
+
const { mutateAsync: cancelOrder } = useCancelOrder(order.id);
|
|
1958
|
+
const handleCancel = async () => {
|
|
1959
|
+
const res = await prompt({
|
|
1960
|
+
title: t("general.areYouSure"),
|
|
1961
|
+
description: t("orders.cancelWarning", {
|
|
1962
|
+
id: `#${order.display_id}`
|
|
1963
|
+
}),
|
|
1964
|
+
confirmText: t("actions.continue"),
|
|
1965
|
+
cancelText: t("actions.cancel")
|
|
1966
|
+
});
|
|
1967
|
+
if (!res) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
await cancelOrder(void 0, {
|
|
1971
|
+
onSuccess: () => {
|
|
1972
|
+
toast7.success(t("orders.orderCanceled"));
|
|
1973
|
+
},
|
|
1974
|
+
onError: (e) => {
|
|
1975
|
+
toast7.error(e.message);
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
};
|
|
1979
|
+
return /* @__PURE__ */ jsxs13(Container8, { className: "flex items-center justify-between px-6 py-4", "data-testid": "order-general-section", children: [
|
|
1980
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1981
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-x-1", "data-testid": "order-general-section-id-container", children: [
|
|
1982
|
+
/* @__PURE__ */ jsxs13(Heading8, { "data-testid": "order-general-section-id-heading", children: [
|
|
1983
|
+
"#",
|
|
1984
|
+
order.display_id
|
|
1985
|
+
] }),
|
|
1986
|
+
/* @__PURE__ */ jsx12(Copy4, { content: `#${order.display_id}`, className: "text-ui-fg-muted", "data-testid": "order-general-section-id-copy" })
|
|
1987
|
+
] }),
|
|
1988
|
+
/* @__PURE__ */ jsx12(Text9, { size: "small", className: "text-ui-fg-subtle", "data-testid": "order-general-section-date", children: t("orders.onDateFromSalesChannel", {
|
|
1989
|
+
date: getFullDate({ date: order.created_at, includeTime: true }),
|
|
1990
|
+
salesChannel: order.sales_channel?.name
|
|
1991
|
+
}) })
|
|
1992
|
+
] }),
|
|
1993
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-x-4", "data-testid": "order-general-section-badges-container", children: [
|
|
1994
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-x-1.5", "data-testid": "order-general-section-badges", children: [
|
|
1995
|
+
/* @__PURE__ */ jsx12(OrderBadge, { order }),
|
|
1996
|
+
/* @__PURE__ */ jsx12(PaymentBadge, { order }),
|
|
1997
|
+
/* @__PURE__ */ jsx12(FulfillmentBadge, { order })
|
|
1998
|
+
] }),
|
|
1999
|
+
/* @__PURE__ */ jsx12(
|
|
2000
|
+
ActionMenu,
|
|
2001
|
+
{
|
|
2002
|
+
groups: [
|
|
2003
|
+
{
|
|
2004
|
+
actions: [
|
|
2005
|
+
{
|
|
2006
|
+
label: t("actions.cancel"),
|
|
2007
|
+
onClick: handleCancel,
|
|
2008
|
+
disabled: !!order.canceled_at,
|
|
2009
|
+
icon: /* @__PURE__ */ jsx12(XCircle2, {})
|
|
2010
|
+
}
|
|
2011
|
+
]
|
|
2012
|
+
}
|
|
2013
|
+
],
|
|
2014
|
+
"data-testid": "order-general-section-action-menu"
|
|
2015
|
+
}
|
|
2016
|
+
)
|
|
2017
|
+
] })
|
|
2018
|
+
] });
|
|
2019
|
+
};
|
|
2020
|
+
var FulfillmentBadge = ({ order }) => {
|
|
2021
|
+
const { t } = useTranslation12();
|
|
2022
|
+
const { label, color } = getOrderFulfillmentStatus(
|
|
2023
|
+
t,
|
|
2024
|
+
order.fulfillment_status
|
|
2025
|
+
);
|
|
2026
|
+
return /* @__PURE__ */ jsx12(StatusBadge2, { color, className: "text-nowrap", "data-testid": "order-general-section-fulfillment-badge", children: label });
|
|
2027
|
+
};
|
|
2028
|
+
var PaymentBadge = ({ order }) => {
|
|
2029
|
+
const { t } = useTranslation12();
|
|
2030
|
+
const { label, color } = getOrderPaymentStatus(t, order.payment_status);
|
|
2031
|
+
return /* @__PURE__ */ jsx12(StatusBadge2, { color, className: "text-nowrap", "data-testid": "order-general-section-payment-badge", children: label });
|
|
2032
|
+
};
|
|
2033
|
+
var OrderBadge = ({ order }) => {
|
|
2034
|
+
const { t } = useTranslation12();
|
|
2035
|
+
const orderStatus = getCanceledOrderStatus(t, order.status);
|
|
2036
|
+
if (!orderStatus) {
|
|
2037
|
+
return null;
|
|
2038
|
+
}
|
|
2039
|
+
return /* @__PURE__ */ jsx12(StatusBadge2, { color: orderStatus.color, className: "text-nowrap", "data-testid": "order-general-section-order-badge", children: orderStatus.label });
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
// src/components/common/display-id/display-id.tsx
|
|
2043
|
+
import { useTranslation as useTranslation13 } from "react-i18next";
|
|
2044
|
+
import { useState as useState4 } from "react";
|
|
2045
|
+
import copy from "copy-to-clipboard";
|
|
2046
|
+
import { clx as clx2, toast as toast8, Tooltip as Tooltip3 } from "@medusajs/ui";
|
|
2047
|
+
import { jsx as jsx13, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2048
|
+
function DisplayId({ id, className }) {
|
|
2049
|
+
const { t } = useTranslation13();
|
|
2050
|
+
const [open, setOpen] = useState4(false);
|
|
2051
|
+
const onClick = () => {
|
|
2052
|
+
copy(id);
|
|
2053
|
+
toast8.success(t("actions.idCopiedToClipboard"));
|
|
2054
|
+
};
|
|
2055
|
+
return /* @__PURE__ */ jsx13(Tooltip3, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs14("span", { onClick, className: clx2("cursor-pointer", className), children: [
|
|
2056
|
+
"#",
|
|
2057
|
+
id.slice(-7)
|
|
2058
|
+
] }) });
|
|
2059
|
+
}
|
|
2060
|
+
var display_id_default = DisplayId;
|
|
2061
|
+
|
|
2062
|
+
// src/lib/payment.ts
|
|
2063
|
+
var getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc, paymentCollection) => {
|
|
2064
|
+
acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
|
|
2065
|
+
return acc;
|
|
2066
|
+
}, 0);
|
|
2067
|
+
var getTotalPending = (paymentCollections) => paymentCollections.filter((pc) => pc.status !== "canceled").reduce((acc, paymentCollection) => {
|
|
2068
|
+
acc += paymentCollection.amount - paymentCollection.captured_amount;
|
|
2069
|
+
return acc;
|
|
2070
|
+
}, 0);
|
|
2071
|
+
|
|
2072
|
+
// src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx
|
|
2073
|
+
import { ArrowDownRightMini, DocumentText, XCircle as XCircle3 } from "@medusajs/icons";
|
|
2074
|
+
import {
|
|
2075
|
+
Badge,
|
|
2076
|
+
Button as Button7,
|
|
2077
|
+
Container as Container9,
|
|
2078
|
+
Heading as Heading9,
|
|
2079
|
+
StatusBadge as StatusBadge3,
|
|
2080
|
+
Text as Text10,
|
|
2081
|
+
toast as toast9,
|
|
2082
|
+
Tooltip as Tooltip4,
|
|
2083
|
+
usePrompt as usePrompt4
|
|
2084
|
+
} from "@medusajs/ui";
|
|
2085
|
+
import { format as format2 } from "date-fns";
|
|
2086
|
+
import { Trans, useTranslation as useTranslation14 } from "react-i18next";
|
|
2087
|
+
import { jsx as jsx14, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2088
|
+
var OrderPaymentSection = ({ order }) => {
|
|
2089
|
+
const payments = getPaymentsFromOrder(order);
|
|
2090
|
+
const refunds = payments.map((payment) => payment?.refunds).flat(1).filter(Boolean);
|
|
2091
|
+
return /* @__PURE__ */ jsxs15(
|
|
2092
|
+
Container9,
|
|
2093
|
+
{
|
|
2094
|
+
className: "divide-y divide-dashed p-0",
|
|
2095
|
+
"data-testid": "order-payment-section",
|
|
2096
|
+
children: [
|
|
2097
|
+
/* @__PURE__ */ jsx14(Header2, { order }),
|
|
2098
|
+
/* @__PURE__ */ jsx14(
|
|
2099
|
+
PaymentBreakdown,
|
|
2100
|
+
{
|
|
2101
|
+
order,
|
|
2102
|
+
payments,
|
|
2103
|
+
refunds,
|
|
2104
|
+
currencyCode: order.currency_code
|
|
2105
|
+
}
|
|
2106
|
+
),
|
|
2107
|
+
/* @__PURE__ */ jsx14(Total, { order })
|
|
2108
|
+
]
|
|
2109
|
+
}
|
|
2110
|
+
);
|
|
2111
|
+
};
|
|
2112
|
+
var Header2 = ({ order }) => {
|
|
2113
|
+
const { t } = useTranslation14();
|
|
2114
|
+
const { label, color } = getOrderPaymentStatus(t, order.payment_status);
|
|
2115
|
+
return /* @__PURE__ */ jsxs15(
|
|
2116
|
+
"div",
|
|
2117
|
+
{
|
|
2118
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
2119
|
+
"data-testid": "order-payment-header",
|
|
2120
|
+
children: [
|
|
2121
|
+
/* @__PURE__ */ jsx14(Heading9, { level: "h2", "data-testid": "order-payment-heading", children: t("orders.payment.title") }),
|
|
2122
|
+
/* @__PURE__ */ jsx14(
|
|
2123
|
+
StatusBadge3,
|
|
2124
|
+
{
|
|
2125
|
+
color,
|
|
2126
|
+
className: "text-nowrap",
|
|
2127
|
+
"data-testid": "order-payment-status-badge",
|
|
2128
|
+
children: label
|
|
2129
|
+
}
|
|
2130
|
+
)
|
|
2131
|
+
]
|
|
2132
|
+
}
|
|
2133
|
+
);
|
|
2134
|
+
};
|
|
2135
|
+
var Refund = ({
|
|
2136
|
+
refund,
|
|
2137
|
+
currencyCode
|
|
2138
|
+
}) => {
|
|
2139
|
+
const { t } = useTranslation14();
|
|
2140
|
+
const RefundReasonBadge = refund?.refund_reason && /* @__PURE__ */ jsx14(
|
|
2141
|
+
Badge,
|
|
2142
|
+
{
|
|
2143
|
+
size: "2xsmall",
|
|
2144
|
+
rounded: "full",
|
|
2145
|
+
className: "line-clamp-1",
|
|
2146
|
+
title: refund.refund_reason.label,
|
|
2147
|
+
children: refund.refund_reason.label
|
|
2148
|
+
}
|
|
2149
|
+
);
|
|
2150
|
+
const RefundNoteIndicator = refund.note && /* @__PURE__ */ jsx14(Tooltip4, { content: refund.note, children: /* @__PURE__ */ jsx14(DocumentText, { className: "ml-1 inline text-ui-tag-neutral-icon" }) });
|
|
2151
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex items-start gap-x-4 bg-ui-bg-subtle px-6 py-4 text-ui-fg-subtle sm:items-center", children: [
|
|
2152
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-1 flex-col gap-3 sm:flex-row sm:items-center", children: [
|
|
2153
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 flex-row items-center gap-x-3", children: [
|
|
2154
|
+
/* @__PURE__ */ jsx14(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
|
|
2155
|
+
/* @__PURE__ */ jsxs15("div", { children: [
|
|
2156
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", weight: "plus", children: t("orders.payment.refund") }),
|
|
2157
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: format2(new Date(refund.created_at), "dd MMM, yyyy, HH:mm:ss") })
|
|
2158
|
+
] })
|
|
2159
|
+
] }),
|
|
2160
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-x-3", children: [
|
|
2161
|
+
/* @__PURE__ */ jsx14("div", { className: "shrink-0", children: RefundNoteIndicator }),
|
|
2162
|
+
RefundReasonBadge
|
|
2163
|
+
] })
|
|
2164
|
+
] }),
|
|
2165
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 items-center justify-end gap-4", children: [
|
|
2166
|
+
/* @__PURE__ */ jsxs15(Text10, { size: "small", leading: "compact", children: [
|
|
2167
|
+
"- ",
|
|
2168
|
+
getLocaleAmount(refund.amount, currencyCode)
|
|
2169
|
+
] }),
|
|
2170
|
+
/* @__PURE__ */ jsx14("div", { className: "h-7 w-5" })
|
|
2171
|
+
] })
|
|
2172
|
+
] });
|
|
2173
|
+
};
|
|
2174
|
+
var Payment = ({
|
|
2175
|
+
order,
|
|
2176
|
+
payment,
|
|
2177
|
+
refunds,
|
|
2178
|
+
currencyCode
|
|
2179
|
+
}) => {
|
|
2180
|
+
const { t } = useTranslation14();
|
|
2181
|
+
const prompt = usePrompt4();
|
|
2182
|
+
const { mutateAsync } = useCapturePayment(order.id, payment.id);
|
|
2183
|
+
const handleCapture = async () => {
|
|
2184
|
+
const res = await prompt({
|
|
2185
|
+
title: t("orders.payment.capture"),
|
|
2186
|
+
description: t("orders.payment.capturePayment", {
|
|
2187
|
+
amount: formatCurrency(payment.amount, currencyCode)
|
|
2188
|
+
}),
|
|
2189
|
+
confirmText: t("actions.confirm"),
|
|
2190
|
+
cancelText: t("actions.cancel"),
|
|
2191
|
+
variant: "confirmation"
|
|
2192
|
+
});
|
|
2193
|
+
if (!res) {
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
await mutateAsync(
|
|
2197
|
+
{ amount: payment.amount },
|
|
2198
|
+
{
|
|
2199
|
+
onSuccess: () => {
|
|
2200
|
+
toast9.success(
|
|
2201
|
+
t("orders.payment.capturePaymentSuccess", {
|
|
2202
|
+
amount: formatCurrency(payment.amount, currencyCode)
|
|
2203
|
+
})
|
|
2204
|
+
);
|
|
2205
|
+
},
|
|
2206
|
+
onError: (error) => {
|
|
2207
|
+
toast9.error(error.message);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
};
|
|
2212
|
+
const getPaymentStatusAttributes = (payment2) => {
|
|
2213
|
+
if (payment2.canceled_at) {
|
|
2214
|
+
return ["Canceled", "red"];
|
|
2215
|
+
} else if (payment2.captured_at) {
|
|
2216
|
+
return ["Captured", "green"];
|
|
2217
|
+
} else {
|
|
2218
|
+
return ["Pending", "orange"];
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2221
|
+
const [status, color] = getPaymentStatusAttributes(payment);
|
|
2222
|
+
const showCapture = payment.captured_at === null && payment.canceled_at === null;
|
|
2223
|
+
const totalRefunded = payment.refunds?.reduce((acc, next) => next.amount + acc, 0) ?? 0;
|
|
2224
|
+
return /* @__PURE__ */ jsxs15(
|
|
2225
|
+
"div",
|
|
2226
|
+
{
|
|
2227
|
+
className: "divide-y divide-dashed",
|
|
2228
|
+
"data-testid": `order-payment-${payment.id}`,
|
|
2229
|
+
children: [
|
|
2230
|
+
/* @__PURE__ */ jsxs15(
|
|
2231
|
+
"div",
|
|
2232
|
+
{
|
|
2233
|
+
className: "grid grid-cols-[1fr_1fr_1fr_20px] items-center gap-x-4 px-6 py-4 text-ui-fg-subtle sm:grid-cols-[1fr_1fr_1fr_1fr_20px]",
|
|
2234
|
+
"data-testid": `order-payment-${payment.id}-row`,
|
|
2235
|
+
children: [
|
|
2236
|
+
/* @__PURE__ */ jsxs15("div", { className: "w-full min-w-[60px] overflow-hidden", children: [
|
|
2237
|
+
/* @__PURE__ */ jsx14(
|
|
2238
|
+
Text10,
|
|
2239
|
+
{
|
|
2240
|
+
size: "small",
|
|
2241
|
+
leading: "compact",
|
|
2242
|
+
weight: "plus",
|
|
2243
|
+
className: "truncate",
|
|
2244
|
+
"data-testid": `order-payment-${payment.id}-id`,
|
|
2245
|
+
children: /* @__PURE__ */ jsx14(display_id_default, { id: payment.id })
|
|
2246
|
+
}
|
|
2247
|
+
),
|
|
2248
|
+
/* @__PURE__ */ jsx14(
|
|
2249
|
+
Text10,
|
|
2250
|
+
{
|
|
2251
|
+
size: "small",
|
|
2252
|
+
leading: "compact",
|
|
2253
|
+
"data-testid": `order-payment-${payment.id}-date`,
|
|
2254
|
+
children: payment.created_at ? format2(new Date(payment.created_at), "dd MMM, yyyy, HH:mm:ss") : "-"
|
|
2255
|
+
}
|
|
2256
|
+
)
|
|
2257
|
+
] }),
|
|
2258
|
+
/* @__PURE__ */ jsx14("div", { className: "hidden items-center justify-end sm:flex", children: /* @__PURE__ */ jsx14(
|
|
2259
|
+
Text10,
|
|
2260
|
+
{
|
|
2261
|
+
size: "small",
|
|
2262
|
+
leading: "compact",
|
|
2263
|
+
className: "capitalize",
|
|
2264
|
+
"data-testid": `order-payment-${payment.id}-provider`,
|
|
2265
|
+
children: payment.provider_id
|
|
2266
|
+
}
|
|
2267
|
+
) }),
|
|
2268
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(
|
|
2269
|
+
StatusBadge3,
|
|
2270
|
+
{
|
|
2271
|
+
color,
|
|
2272
|
+
className: "text-nowrap",
|
|
2273
|
+
"data-testid": `order-payment-${payment.id}-status`,
|
|
2274
|
+
children: status
|
|
2275
|
+
}
|
|
2276
|
+
) }),
|
|
2277
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(
|
|
2278
|
+
Text10,
|
|
2279
|
+
{
|
|
2280
|
+
size: "small",
|
|
2281
|
+
leading: "compact",
|
|
2282
|
+
"data-testid": `order-payment-${payment.id}-amount`,
|
|
2283
|
+
children: getLocaleAmount(payment.amount, payment.currency_code)
|
|
2284
|
+
}
|
|
2285
|
+
) }),
|
|
2286
|
+
/* @__PURE__ */ jsx14(
|
|
2287
|
+
ActionMenu,
|
|
2288
|
+
{
|
|
2289
|
+
groups: [
|
|
2290
|
+
{
|
|
2291
|
+
actions: [
|
|
2292
|
+
{
|
|
2293
|
+
label: t("orders.payment.createRefund"),
|
|
2294
|
+
icon: /* @__PURE__ */ jsx14(XCircle3, {}),
|
|
2295
|
+
to: `/orders/${order.id}/refund?paymentId=${payment.id}`,
|
|
2296
|
+
disabled: !payment.captured_at || !!payment.canceled_at || totalRefunded >= payment.amount
|
|
2297
|
+
}
|
|
2298
|
+
]
|
|
2299
|
+
}
|
|
2300
|
+
],
|
|
2301
|
+
"data-testid": `order-payment-${payment.id}-action-menu`
|
|
2302
|
+
}
|
|
2303
|
+
)
|
|
2304
|
+
]
|
|
2305
|
+
}
|
|
2306
|
+
),
|
|
2307
|
+
showCapture && /* @__PURE__ */ jsxs15(
|
|
2308
|
+
"div",
|
|
2309
|
+
{
|
|
2310
|
+
className: "flex items-center justify-between bg-ui-bg-subtle px-6 py-4",
|
|
2311
|
+
"data-testid": `order-payment-${payment.id}-capture-section`,
|
|
2312
|
+
children: [
|
|
2313
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-x-2", children: [
|
|
2314
|
+
/* @__PURE__ */ jsx14(ArrowDownRightMini, { className: "shrink-0 text-ui-fg-muted" }),
|
|
2315
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: /* @__PURE__ */ jsx14(
|
|
2316
|
+
Trans,
|
|
2317
|
+
{
|
|
2318
|
+
i18nKey: "orders.payment.isReadyToBeCaptured",
|
|
2319
|
+
components: [/* @__PURE__ */ jsx14(display_id_default, { id: payment.id }, payment.id)]
|
|
2320
|
+
}
|
|
2321
|
+
) })
|
|
2322
|
+
] }),
|
|
2323
|
+
/* @__PURE__ */ jsxs15(
|
|
2324
|
+
Button7,
|
|
2325
|
+
{
|
|
2326
|
+
className: "shrink-0",
|
|
2327
|
+
size: "small",
|
|
2328
|
+
variant: "secondary",
|
|
2329
|
+
onClick: handleCapture,
|
|
2330
|
+
"data-testid": `order-payment-${payment.id}-capture-button`,
|
|
2331
|
+
children: [
|
|
2332
|
+
/* @__PURE__ */ jsx14("span", { className: "hidden sm:block", children: t("orders.payment.capture") }),
|
|
2333
|
+
/* @__PURE__ */ jsx14("span", { className: "sm:hidden", children: t("orders.payment.capture_short") })
|
|
2334
|
+
]
|
|
2335
|
+
}
|
|
2336
|
+
)
|
|
2337
|
+
]
|
|
2338
|
+
}
|
|
2339
|
+
),
|
|
2340
|
+
refunds.map((refund) => /* @__PURE__ */ jsx14(Refund, { refund, currencyCode }, refund.id))
|
|
2341
|
+
]
|
|
2342
|
+
}
|
|
2343
|
+
);
|
|
2344
|
+
};
|
|
2345
|
+
var CreditLine = ({
|
|
2346
|
+
creditLine,
|
|
2347
|
+
currencyCode
|
|
2348
|
+
}) => {
|
|
2349
|
+
if (!loyaltyPlugin) {
|
|
2350
|
+
return null;
|
|
2351
|
+
}
|
|
2352
|
+
const prettyReference = creditLine.reference?.split("_").join(" ").split("-").join(" ");
|
|
2353
|
+
const prettyReferenceId = creditLine.reference_id ? /* @__PURE__ */ jsx14(display_id_default, { id: creditLine.reference_id }) : null;
|
|
2354
|
+
return /* @__PURE__ */ jsx14("div", { className: "divide-y divide-dashed", children: /* @__PURE__ */ jsxs15("div", { className: "grid grid-cols-[1fr_1fr_20px] items-center gap-x-4 px-6 py-4 text-ui-fg-subtle sm:grid-cols-[1fr_1fr_1fr_20px]", children: [
|
|
2355
|
+
/* @__PURE__ */ jsxs15("div", { className: "w-full min-w-[60px] overflow-hidden", children: [
|
|
2356
|
+
/* @__PURE__ */ jsx14(
|
|
2357
|
+
Text10,
|
|
2358
|
+
{
|
|
2359
|
+
size: "small",
|
|
2360
|
+
leading: "compact",
|
|
2361
|
+
weight: "plus",
|
|
2362
|
+
className: "truncate",
|
|
2363
|
+
children: /* @__PURE__ */ jsx14(display_id_default, { id: creditLine.id })
|
|
2364
|
+
}
|
|
2365
|
+
),
|
|
2366
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: creditLine.created_at ? format2(
|
|
2367
|
+
new Date(creditLine.created_at),
|
|
2368
|
+
"dd MMM, yyyy, HH:mm:ss"
|
|
2369
|
+
) : "-" })
|
|
2370
|
+
] }),
|
|
2371
|
+
/* @__PURE__ */ jsx14("div", { className: "hidden items-center justify-end sm:flex", children: /* @__PURE__ */ jsxs15(Text10, { size: "small", leading: "compact", className: "capitalize", children: [
|
|
2372
|
+
prettyReference,
|
|
2373
|
+
" (",
|
|
2374
|
+
prettyReferenceId,
|
|
2375
|
+
")"
|
|
2376
|
+
] }) }),
|
|
2377
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: getLocaleAmount(creditLine.amount, currencyCode) }) })
|
|
2378
|
+
] }) });
|
|
2379
|
+
};
|
|
2380
|
+
var PaymentBreakdown = ({
|
|
2381
|
+
order,
|
|
2382
|
+
payments,
|
|
2383
|
+
refunds,
|
|
2384
|
+
currencyCode
|
|
2385
|
+
}) => {
|
|
2386
|
+
const orderRefunds = refunds.filter((refund) => refund.payment_id === null);
|
|
2387
|
+
const creditLines = order.credit_lines ?? [];
|
|
2388
|
+
const creditLineRefunds = creditLines.filter(
|
|
2389
|
+
(creditLine) => creditLine.amount < 0
|
|
2390
|
+
);
|
|
2391
|
+
const entries = [...orderRefunds, ...payments, ...creditLineRefunds].sort((a, b) => {
|
|
2392
|
+
return new Date(a.created_at).getTime() - new Date(b.created_at).getTime();
|
|
2393
|
+
}).map((entry) => {
|
|
2394
|
+
let type = entry.id.startsWith("pay_") ? "payment" : "refund";
|
|
2395
|
+
if (entry.id.startsWith("ordcl_")) {
|
|
2396
|
+
type = "credit_line_refund";
|
|
2397
|
+
}
|
|
2398
|
+
return { event: entry, type };
|
|
2399
|
+
});
|
|
2400
|
+
return /* @__PURE__ */ jsx14(
|
|
2401
|
+
"div",
|
|
2402
|
+
{
|
|
2403
|
+
className: "flex flex-col divide-y divide-dashed",
|
|
2404
|
+
"data-testid": "order-payment-breakdown",
|
|
2405
|
+
children: entries.map(({ type, event }) => {
|
|
2406
|
+
switch (type) {
|
|
2407
|
+
case "payment":
|
|
2408
|
+
return /* @__PURE__ */ jsx14(
|
|
2409
|
+
Payment,
|
|
2410
|
+
{
|
|
2411
|
+
order,
|
|
2412
|
+
payment: event,
|
|
2413
|
+
refunds: refunds.filter(
|
|
2414
|
+
(refund) => refund.payment_id === event.id
|
|
2415
|
+
),
|
|
2416
|
+
currencyCode
|
|
2417
|
+
},
|
|
2418
|
+
event.id
|
|
2419
|
+
);
|
|
2420
|
+
case "refund":
|
|
2421
|
+
return /* @__PURE__ */ jsx14(
|
|
2422
|
+
Refund,
|
|
2423
|
+
{
|
|
2424
|
+
refund: event,
|
|
2425
|
+
currencyCode
|
|
2426
|
+
},
|
|
2427
|
+
event.id
|
|
2428
|
+
);
|
|
2429
|
+
case "credit_line_refund":
|
|
2430
|
+
return /* @__PURE__ */ jsx14(
|
|
2431
|
+
CreditLine,
|
|
2432
|
+
{
|
|
2433
|
+
creditLine: event,
|
|
2434
|
+
currencyCode
|
|
2435
|
+
},
|
|
2436
|
+
event.id
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
})
|
|
2440
|
+
}
|
|
2441
|
+
);
|
|
2442
|
+
};
|
|
2443
|
+
var Total = ({ order }) => {
|
|
2444
|
+
const { t } = useTranslation14();
|
|
2445
|
+
const totalPending = getTotalPending(order.payment_collections);
|
|
2446
|
+
return /* @__PURE__ */ jsxs15(
|
|
2447
|
+
"div",
|
|
2448
|
+
{
|
|
2449
|
+
className: "flex flex-col gap-y-4 px-6 py-4",
|
|
2450
|
+
"data-testid": "order-payment-total",
|
|
2451
|
+
children: [
|
|
2452
|
+
/* @__PURE__ */ jsxs15(
|
|
2453
|
+
"div",
|
|
2454
|
+
{
|
|
2455
|
+
className: "flex items-center justify-between",
|
|
2456
|
+
"data-testid": "order-payment-total-paid",
|
|
2457
|
+
children: [
|
|
2458
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: t("orders.payment.totalPaidByCustomer") }),
|
|
2459
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(
|
|
2460
|
+
getTotalCaptured(order.payment_collections),
|
|
2461
|
+
order.currency_code
|
|
2462
|
+
) })
|
|
2463
|
+
]
|
|
2464
|
+
}
|
|
2465
|
+
),
|
|
2466
|
+
order.status !== "canceled" && totalPending > 0 && /* @__PURE__ */ jsxs15(
|
|
2467
|
+
"div",
|
|
2468
|
+
{
|
|
2469
|
+
className: "flex items-center justify-between",
|
|
2470
|
+
"data-testid": "order-payment-total-pending",
|
|
2471
|
+
children: [
|
|
2472
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: "Total pending" }),
|
|
2473
|
+
/* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(totalPending, order.currency_code) })
|
|
2474
|
+
]
|
|
2475
|
+
}
|
|
2476
|
+
)
|
|
2477
|
+
]
|
|
2478
|
+
}
|
|
2479
|
+
);
|
|
2480
|
+
};
|
|
2481
|
+
|
|
2482
|
+
// src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
|
|
2483
|
+
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
2484
|
+
import { useTranslation as useTranslation17 } from "react-i18next";
|
|
2485
|
+
import { Link as Link3 } from "react-router-dom";
|
|
2486
|
+
import {
|
|
2487
|
+
ArrowDownRightMini as ArrowDownRightMini2,
|
|
2488
|
+
ArrowLongRight,
|
|
2489
|
+
ArrowPath as ArrowPath3,
|
|
2490
|
+
ArrowUturnLeft as ArrowUturnLeft2,
|
|
2491
|
+
DocumentText as DocumentText2,
|
|
2492
|
+
ExclamationCircle as ExclamationCircle2,
|
|
2493
|
+
PencilSquare,
|
|
2494
|
+
TriangleDownMini
|
|
2495
|
+
} from "@medusajs/icons";
|
|
2496
|
+
import {
|
|
2497
|
+
Badge as Badge4,
|
|
2498
|
+
Button as Button8,
|
|
2499
|
+
clx as clx3,
|
|
2500
|
+
Container as Container10,
|
|
2501
|
+
Copy as Copy5,
|
|
2502
|
+
Heading as Heading10,
|
|
2503
|
+
StatusBadge as StatusBadge4,
|
|
2504
|
+
Text as Text12,
|
|
2505
|
+
toast as toast10,
|
|
2506
|
+
Tooltip as Tooltip6,
|
|
2507
|
+
usePrompt as usePrompt5
|
|
2508
|
+
} from "@medusajs/ui";
|
|
2509
|
+
import { format as format3 } from "date-fns";
|
|
2510
|
+
|
|
2511
|
+
// src/lib/credit-line.ts
|
|
2512
|
+
var getTotalCreditLines = (creditLines) => creditLines.reduce((acc, creditLine) => {
|
|
2513
|
+
acc = acc + creditLine.amount;
|
|
2514
|
+
return acc;
|
|
2515
|
+
}, 0);
|
|
2516
|
+
|
|
2517
|
+
// src/pages/orders/order-detail/components/order-summary-section/return-info-popover.tsx
|
|
2518
|
+
import { InformationCircleSolid } from "@medusajs/icons";
|
|
2519
|
+
import { Badge as Badge2, Popover as Popover3, Text as Text11 } from "@medusajs/ui";
|
|
2520
|
+
import { useState as useState5 } from "react";
|
|
2521
|
+
import { useTranslation as useTranslation15 } from "react-i18next";
|
|
2522
|
+
import { jsx as jsx15, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2523
|
+
function ReturnInfoPopover({ orderReturn }) {
|
|
2524
|
+
const { t } = useTranslation15();
|
|
2525
|
+
const [open, setOpen] = useState5(false);
|
|
2526
|
+
const { getFullDate } = useDate();
|
|
2527
|
+
const handleMouseEnter = () => {
|
|
2528
|
+
setOpen(true);
|
|
2529
|
+
};
|
|
2530
|
+
const handleMouseLeave = () => {
|
|
2531
|
+
setOpen(false);
|
|
2532
|
+
};
|
|
2533
|
+
let returnType = "Return";
|
|
2534
|
+
let returnTypeId = orderReturn.id;
|
|
2535
|
+
if (orderReturn.claim_id) {
|
|
2536
|
+
returnType = "Claim";
|
|
2537
|
+
returnTypeId = orderReturn.claim_id;
|
|
2538
|
+
}
|
|
2539
|
+
if (orderReturn.exchange_id) {
|
|
2540
|
+
returnType = "Exchange";
|
|
2541
|
+
returnTypeId = orderReturn.exchange_id;
|
|
2542
|
+
}
|
|
2543
|
+
if (typeof orderReturn !== "object") {
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
return /* @__PURE__ */ jsxs16(Popover3, { open, children: [
|
|
2547
|
+
/* @__PURE__ */ jsx15(
|
|
2548
|
+
Popover3.Trigger,
|
|
2549
|
+
{
|
|
2550
|
+
onMouseEnter: handleMouseEnter,
|
|
2551
|
+
onMouseLeave: handleMouseLeave,
|
|
2552
|
+
autoFocus: false,
|
|
2553
|
+
className: "align-sub focus-visible:outline-none",
|
|
2554
|
+
children: /* @__PURE__ */ jsx15(InformationCircleSolid, {})
|
|
2555
|
+
}
|
|
2556
|
+
),
|
|
2557
|
+
/* @__PURE__ */ jsx15(
|
|
2558
|
+
Popover3.Content,
|
|
2559
|
+
{
|
|
2560
|
+
align: "center",
|
|
2561
|
+
side: "top",
|
|
2562
|
+
className: "bg-ui-bg-component p-2 focus-visible:outline-none",
|
|
2563
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "", children: [
|
|
2564
|
+
/* @__PURE__ */ jsxs16(Badge2, { size: "2xsmall", className: "mb-2", rounded: "full", children: [
|
|
2565
|
+
returnType,
|
|
2566
|
+
": #",
|
|
2567
|
+
returnTypeId.slice(-7)
|
|
2568
|
+
] }),
|
|
2569
|
+
/* @__PURE__ */ jsxs16(Text11, { size: "xsmall", children: [
|
|
2570
|
+
/* @__PURE__ */ jsx15("span", { className: "text-ui-fg-subtle", children: t(`orders.returns.returnRequested`) }),
|
|
2571
|
+
" \xB7 ",
|
|
2572
|
+
getFullDate({ date: orderReturn.requested_at, includeTime: true })
|
|
2573
|
+
] }),
|
|
2574
|
+
/* @__PURE__ */ jsxs16(Text11, { size: "xsmall", children: [
|
|
2575
|
+
/* @__PURE__ */ jsx15("span", { className: "text-ui-fg-subtle", children: t(`orders.returns.itemReceived`) }),
|
|
2576
|
+
" \xB7 ",
|
|
2577
|
+
orderReturn.received_at ? getFullDate({
|
|
2578
|
+
date: orderReturn.received_at,
|
|
2579
|
+
includeTime: true
|
|
2580
|
+
}) : "-"
|
|
2581
|
+
] })
|
|
2582
|
+
] })
|
|
2583
|
+
}
|
|
2584
|
+
)
|
|
2585
|
+
] });
|
|
2586
|
+
}
|
|
2587
|
+
var return_info_popover_default = ReturnInfoPopover;
|
|
2588
|
+
|
|
2589
|
+
// src/pages/orders/order-detail/components/order-summary-section/shipping-info-popover.tsx
|
|
2590
|
+
import { InformationCircleSolid as InformationCircleSolid2 } from "@medusajs/icons";
|
|
2591
|
+
import { Badge as Badge3, Tooltip as Tooltip5 } from "@medusajs/ui";
|
|
2592
|
+
import { useTranslation as useTranslation16 } from "react-i18next";
|
|
2593
|
+
import { jsx as jsx16, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2594
|
+
function ShippingInfoPopover({ shippingMethod }) {
|
|
2595
|
+
const { t } = useTranslation16();
|
|
2596
|
+
const shippingDetail = shippingMethod?.detail;
|
|
2597
|
+
if (!shippingDetail) {
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
let rmaType = t("orders.return");
|
|
2601
|
+
let rmaId = shippingDetail.return_id;
|
|
2602
|
+
if (shippingDetail.claim_id) {
|
|
2603
|
+
rmaType = t("orders.claim");
|
|
2604
|
+
rmaId = shippingDetail.claim_id;
|
|
2605
|
+
}
|
|
2606
|
+
if (shippingDetail.exchange_id) {
|
|
2607
|
+
rmaType = t("orders.exchange");
|
|
2608
|
+
rmaId = shippingDetail.exchange_id;
|
|
2609
|
+
}
|
|
2610
|
+
if (!rmaId) {
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2613
|
+
return /* @__PURE__ */ jsx16(
|
|
2614
|
+
Tooltip5,
|
|
2615
|
+
{
|
|
2616
|
+
content: /* @__PURE__ */ jsxs17(Badge3, { size: "2xsmall", rounded: "full", children: [
|
|
2617
|
+
rmaType,
|
|
2618
|
+
": #",
|
|
2619
|
+
rmaId.slice(-7)
|
|
2620
|
+
] }),
|
|
2621
|
+
children: /* @__PURE__ */ jsx16(InformationCircleSolid2, { className: "inline-block text-ui-fg-muted ml-1" })
|
|
2622
|
+
}
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
var shipping_info_popover_default = ShippingInfoPopover;
|
|
2626
|
+
|
|
2627
|
+
// src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
|
|
2628
|
+
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2629
|
+
var OrderSummarySection = ({ order }) => {
|
|
2630
|
+
const { t } = useTranslation17();
|
|
2631
|
+
const prompt = usePrompt5();
|
|
2632
|
+
const { reservations } = useReservationItems(
|
|
2633
|
+
{
|
|
2634
|
+
line_item_id: order?.items?.map((i) => i.id),
|
|
2635
|
+
limit: getReservationsLimitCount(order)
|
|
2636
|
+
},
|
|
2637
|
+
{ enabled: Array.isArray(order?.items) }
|
|
2638
|
+
);
|
|
2639
|
+
const { order: orderPreview } = useOrderPreview(order.id);
|
|
2640
|
+
const { returns = [] } = useReturns({
|
|
2641
|
+
status: "requested",
|
|
2642
|
+
order_id: order.id,
|
|
2643
|
+
fields: "+received_at"
|
|
2644
|
+
});
|
|
2645
|
+
const receivableReturns = useMemo3(
|
|
2646
|
+
() => returns.filter((r) => !r.canceled_at),
|
|
2647
|
+
[returns]
|
|
2648
|
+
);
|
|
2649
|
+
const showReturns = !!receivableReturns.length;
|
|
2650
|
+
const showAllocateButton = useMemo3(() => {
|
|
2651
|
+
if (!reservations) {
|
|
2652
|
+
return false;
|
|
2653
|
+
}
|
|
2654
|
+
const reservationsMap = new Map(
|
|
2655
|
+
reservations.map((r) => [r.line_item_id, r.id])
|
|
2656
|
+
);
|
|
2657
|
+
for (const item of order.items) {
|
|
2658
|
+
if (item.variant?.manage_inventory) {
|
|
2659
|
+
if (item.quantity - item.detail.fulfilled_quantity > 0) {
|
|
2660
|
+
if (!reservationsMap.has(item.id)) {
|
|
2661
|
+
return true;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
return false;
|
|
2667
|
+
}, [order.items, reservations]);
|
|
2668
|
+
const unpaidPaymentCollection = order.payment_collections.find(
|
|
2669
|
+
(pc) => pc.status === "not_paid"
|
|
2670
|
+
);
|
|
2671
|
+
const { mutateAsync: markAsPaid } = useMarkPaymentCollectionAsPaid(
|
|
2672
|
+
order.id,
|
|
2673
|
+
unpaidPaymentCollection?.id
|
|
2674
|
+
);
|
|
2675
|
+
const pendingDifference = order.summary?.pending_difference || 0;
|
|
2676
|
+
const isAmountSignificant = !isAmountLessThenRoundingError(
|
|
2677
|
+
pendingDifference,
|
|
2678
|
+
order.currency_code
|
|
2679
|
+
);
|
|
2680
|
+
const showPayment = unpaidPaymentCollection && pendingDifference > 0 && isAmountSignificant;
|
|
2681
|
+
const showRefund = pendingDifference < 0 && isAmountSignificant;
|
|
2682
|
+
const handleMarkAsPaid = async (paymentCollection) => {
|
|
2683
|
+
const res = await prompt({
|
|
2684
|
+
title: t("orders.payment.markAsPaid"),
|
|
2685
|
+
description: t("orders.payment.markAsPaidPayment", {
|
|
2686
|
+
amount: formatCurrency(
|
|
2687
|
+
paymentCollection.amount,
|
|
2688
|
+
order.currency_code
|
|
2689
|
+
)
|
|
2690
|
+
}),
|
|
2691
|
+
confirmText: t("actions.confirm"),
|
|
2692
|
+
cancelText: t("actions.cancel"),
|
|
2693
|
+
variant: "confirmation"
|
|
2694
|
+
});
|
|
2695
|
+
if (!res) {
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
await markAsPaid(
|
|
2699
|
+
{ order_id: order.id },
|
|
2700
|
+
{
|
|
2701
|
+
onSuccess: () => {
|
|
2702
|
+
toast10.success(
|
|
2703
|
+
t("orders.payment.markAsPaidPaymentSuccess", {
|
|
2704
|
+
amount: formatCurrency(
|
|
2705
|
+
paymentCollection.amount,
|
|
2706
|
+
order.currency_code
|
|
2707
|
+
)
|
|
2708
|
+
})
|
|
2709
|
+
);
|
|
2710
|
+
},
|
|
2711
|
+
onError: (error) => {
|
|
2712
|
+
toast10.error(error.message);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
);
|
|
2716
|
+
};
|
|
2717
|
+
return /* @__PURE__ */ jsxs18(
|
|
2718
|
+
Container10,
|
|
2719
|
+
{
|
|
2720
|
+
className: "divide-y divide-dashed p-0",
|
|
2721
|
+
"data-testid": "order-summary-section",
|
|
2722
|
+
children: [
|
|
2723
|
+
/* @__PURE__ */ jsx17(Header3, { order, orderPreview }),
|
|
2724
|
+
/* @__PURE__ */ jsx17(ItemBreakdown, { order, reservations }),
|
|
2725
|
+
/* @__PURE__ */ jsx17(CostBreakdown, { order }),
|
|
2726
|
+
/* @__PURE__ */ jsx17(DiscountAndTotalBreakdown, { order }),
|
|
2727
|
+
/* @__PURE__ */ jsx17(Total2, { order }),
|
|
2728
|
+
(showAllocateButton || showReturns || showPayment || showRefund) && /* @__PURE__ */ jsxs18(
|
|
2729
|
+
"div",
|
|
2730
|
+
{
|
|
2731
|
+
className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",
|
|
2732
|
+
"data-testid": "order-summary-actions",
|
|
2733
|
+
children: [
|
|
2734
|
+
showReturns && (receivableReturns.length === 1 ? /* @__PURE__ */ jsx17(
|
|
2735
|
+
Button8,
|
|
2736
|
+
{
|
|
2737
|
+
asChild: true,
|
|
2738
|
+
variant: "secondary",
|
|
2739
|
+
size: "small",
|
|
2740
|
+
"data-testid": "order-summary-receive-return-button",
|
|
2741
|
+
children: /* @__PURE__ */ jsx17(
|
|
2742
|
+
Link3,
|
|
2743
|
+
{
|
|
2744
|
+
to: `/orders/${order.id}/returns/${receivableReturns[0].id}/receive`,
|
|
2745
|
+
children: t("orders.returns.receive.action")
|
|
2746
|
+
}
|
|
2747
|
+
)
|
|
2748
|
+
}
|
|
2749
|
+
) : /* @__PURE__ */ jsx17(
|
|
2750
|
+
ActionMenu,
|
|
2751
|
+
{
|
|
2752
|
+
groups: [
|
|
2753
|
+
{
|
|
2754
|
+
actions: receivableReturns.map((r) => {
|
|
2755
|
+
let id = r.id;
|
|
2756
|
+
let returnType = "Return";
|
|
2757
|
+
if (r.exchange_id) {
|
|
2758
|
+
id = r.exchange_id;
|
|
2759
|
+
returnType = "Exchange";
|
|
2760
|
+
}
|
|
2761
|
+
if (r.claim_id) {
|
|
2762
|
+
id = r.claim_id;
|
|
2763
|
+
returnType = "Claim";
|
|
2764
|
+
}
|
|
2765
|
+
return {
|
|
2766
|
+
label: t("orders.returns.receive.receiveItems", {
|
|
2767
|
+
id: `#${id.slice(-7)}`,
|
|
2768
|
+
returnType
|
|
2769
|
+
}),
|
|
2770
|
+
icon: /* @__PURE__ */ jsx17(ArrowLongRight, {}),
|
|
2771
|
+
to: `/orders/${order.id}/returns/${r.id}/receive`
|
|
2772
|
+
};
|
|
2773
|
+
})
|
|
2774
|
+
}
|
|
2775
|
+
],
|
|
2776
|
+
"data-testid": "order-summary-receive-returns-menu",
|
|
2777
|
+
children: /* @__PURE__ */ jsx17(Button8, { variant: "secondary", size: "small", children: t("orders.returns.receive.action") })
|
|
2778
|
+
}
|
|
2779
|
+
)),
|
|
2780
|
+
showAllocateButton && /* @__PURE__ */ jsx17(
|
|
2781
|
+
Button8,
|
|
2782
|
+
{
|
|
2783
|
+
asChild: true,
|
|
2784
|
+
variant: "secondary",
|
|
2785
|
+
size: "small",
|
|
2786
|
+
"data-testid": "order-summary-allocate-items-button",
|
|
2787
|
+
children: /* @__PURE__ */ jsx17(Link3, { to: "allocate-items", children: t("orders.allocateItems.action") })
|
|
2788
|
+
}
|
|
2789
|
+
),
|
|
2790
|
+
showPayment && /* @__PURE__ */ jsx17(
|
|
2791
|
+
Button8,
|
|
2792
|
+
{
|
|
2793
|
+
size: "small",
|
|
2794
|
+
variant: "secondary",
|
|
2795
|
+
onClick: () => handleMarkAsPaid(unpaidPaymentCollection),
|
|
2796
|
+
"data-testid": "order-summary-mark-as-paid-button",
|
|
2797
|
+
children: t("orders.payment.markAsPaid")
|
|
2798
|
+
}
|
|
2799
|
+
),
|
|
2800
|
+
showRefund && /* @__PURE__ */ jsx17(
|
|
2801
|
+
Button8,
|
|
2802
|
+
{
|
|
2803
|
+
size: "small",
|
|
2804
|
+
variant: "secondary",
|
|
2805
|
+
asChild: true,
|
|
2806
|
+
"data-testid": "order-summary-refund-button",
|
|
2807
|
+
children: /* @__PURE__ */ jsx17(Link3, { to: `/orders/${order.id}/refund`, children: t("orders.payment.refundAmount", {
|
|
2808
|
+
amount: getStylizedAmount(
|
|
2809
|
+
pendingDifference * -1,
|
|
2810
|
+
order?.currency_code
|
|
2811
|
+
)
|
|
2812
|
+
}) })
|
|
2813
|
+
}
|
|
2814
|
+
)
|
|
2815
|
+
]
|
|
2816
|
+
}
|
|
2817
|
+
)
|
|
2818
|
+
]
|
|
2819
|
+
}
|
|
2820
|
+
);
|
|
2821
|
+
};
|
|
2822
|
+
var Header3 = ({
|
|
2823
|
+
order,
|
|
2824
|
+
orderPreview
|
|
2825
|
+
}) => {
|
|
2826
|
+
const { t } = useTranslation17();
|
|
2827
|
+
const shouldDisableReturn = order.items.every(
|
|
2828
|
+
(i) => !(getReturnableQuantity(i) > 0)
|
|
2829
|
+
);
|
|
2830
|
+
const isOrderEditActive = orderPreview?.order_change?.change_type === "edit";
|
|
2831
|
+
const isOrderEditPending = orderPreview?.order_change?.change_type === "edit" && orderPreview?.order_change?.status === "pending";
|
|
2832
|
+
return /* @__PURE__ */ jsxs18(
|
|
2833
|
+
"div",
|
|
2834
|
+
{
|
|
2835
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
2836
|
+
"data-testid": "order-summary-header",
|
|
2837
|
+
children: [
|
|
2838
|
+
/* @__PURE__ */ jsx17(Heading10, { level: "h2", "data-testid": "order-summary-heading", children: t("fields.summary") }),
|
|
2839
|
+
/* @__PURE__ */ jsx17(
|
|
2840
|
+
ActionMenu,
|
|
2841
|
+
{
|
|
2842
|
+
groups: [
|
|
2843
|
+
{
|
|
2844
|
+
actions: [
|
|
2845
|
+
{
|
|
2846
|
+
label: t(
|
|
2847
|
+
isOrderEditPending ? "orders.summary.editOrderContinue" : "orders.summary.editOrder"
|
|
2848
|
+
),
|
|
2849
|
+
to: `/orders/${order.id}/edits`,
|
|
2850
|
+
icon: /* @__PURE__ */ jsx17(PencilSquare, {}),
|
|
2851
|
+
disabled: order.status === "canceled" || orderPreview?.order_change && orderPreview?.order_change?.change_type !== "edit" || orderPreview?.order_change?.change_type === "edit" && orderPreview?.order_change?.status === "requested"
|
|
2852
|
+
}
|
|
2853
|
+
]
|
|
2854
|
+
},
|
|
2855
|
+
{
|
|
2856
|
+
actions: [
|
|
2857
|
+
{
|
|
2858
|
+
label: t("orders.returns.create"),
|
|
2859
|
+
to: `/orders/${order.id}/returns`,
|
|
2860
|
+
icon: /* @__PURE__ */ jsx17(ArrowUturnLeft2, {}),
|
|
2861
|
+
disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.exchange_id || !!orderPreview?.order_change?.claim_id
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
label: orderPreview?.order_change?.id && orderPreview?.order_change?.exchange_id ? t("orders.exchanges.manage") : t("orders.exchanges.create"),
|
|
2865
|
+
to: `/orders/${order.id}/exchanges`,
|
|
2866
|
+
icon: /* @__PURE__ */ jsx17(ArrowPath3, {}),
|
|
2867
|
+
disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.return_id && !orderPreview?.order_change?.exchange_id || !!orderPreview?.order_change?.claim_id
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
label: orderPreview?.order_change?.id && orderPreview?.order_change?.claim_id ? t("orders.claims.manage") : t("orders.claims.create"),
|
|
2871
|
+
to: `/orders/${order.id}/claims`,
|
|
2872
|
+
icon: /* @__PURE__ */ jsx17(ExclamationCircle2, {}),
|
|
2873
|
+
disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.return_id && !orderPreview?.order_change?.claim_id || !!orderPreview?.order_change?.exchange_id
|
|
2874
|
+
}
|
|
2875
|
+
]
|
|
2876
|
+
}
|
|
2877
|
+
],
|
|
2878
|
+
"data-testid": "order-summary-action-menu"
|
|
2879
|
+
}
|
|
2880
|
+
)
|
|
2881
|
+
]
|
|
2882
|
+
}
|
|
2883
|
+
);
|
|
2884
|
+
};
|
|
2885
|
+
var Item = ({
|
|
2886
|
+
item,
|
|
2887
|
+
currencyCode,
|
|
2888
|
+
reservation,
|
|
2889
|
+
returns,
|
|
2890
|
+
claims,
|
|
2891
|
+
exchanges
|
|
2892
|
+
}) => {
|
|
2893
|
+
const { t } = useTranslation17();
|
|
2894
|
+
const isInventoryManaged = item.variant?.manage_inventory;
|
|
2895
|
+
const hasInventoryKit = isInventoryManaged && ((item.variant?.inventory_items?.length || 0) > 1 || item.variant?.inventory_items?.some((i) => i.required_quantity > 1));
|
|
2896
|
+
const hasUnfulfilledItems = item.quantity - item.detail.fulfilled_quantity > 0;
|
|
2897
|
+
return /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
2898
|
+
/* @__PURE__ */ jsxs18(
|
|
2899
|
+
"div",
|
|
2900
|
+
{
|
|
2901
|
+
className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-x-4 px-6 py-4",
|
|
2902
|
+
"data-testid": `order-summary-item-${item.id}`,
|
|
2903
|
+
children: [
|
|
2904
|
+
/* @__PURE__ */ jsxs18(
|
|
2905
|
+
"div",
|
|
2906
|
+
{
|
|
2907
|
+
className: "flex items-start gap-x-4",
|
|
2908
|
+
"data-testid": `order-summary-item-${item.id}-info`,
|
|
2909
|
+
children: [
|
|
2910
|
+
/* @__PURE__ */ jsx17(Thumbnail, { src: item.thumbnail }),
|
|
2911
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
2912
|
+
/* @__PURE__ */ jsx17(
|
|
2913
|
+
Text12,
|
|
2914
|
+
{
|
|
2915
|
+
size: "small",
|
|
2916
|
+
leading: "compact",
|
|
2917
|
+
className: "text-ui-fg-base",
|
|
2918
|
+
"data-testid": `order-summary-item-${item.id}-title`,
|
|
2919
|
+
children: item.title
|
|
2920
|
+
}
|
|
2921
|
+
),
|
|
2922
|
+
item.variant_sku && /* @__PURE__ */ jsxs18(
|
|
2923
|
+
"div",
|
|
2924
|
+
{
|
|
2925
|
+
className: "flex items-center gap-x-1",
|
|
2926
|
+
"data-testid": `order-summary-item-${item.id}-sku`,
|
|
2927
|
+
children: [
|
|
2928
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", children: item.variant_sku }),
|
|
2929
|
+
/* @__PURE__ */ jsx17(Copy5, { content: item.variant_sku, className: "text-ui-fg-muted" })
|
|
2930
|
+
]
|
|
2931
|
+
}
|
|
2932
|
+
),
|
|
2933
|
+
/* @__PURE__ */ jsx17(
|
|
2934
|
+
Text12,
|
|
2935
|
+
{
|
|
2936
|
+
size: "small",
|
|
2937
|
+
"data-testid": `order-summary-item-${item.id}-options`,
|
|
2938
|
+
children: item.variant?.options?.map((o) => o.value).join(" \xB7 ")
|
|
2939
|
+
}
|
|
2940
|
+
)
|
|
2941
|
+
] })
|
|
2942
|
+
]
|
|
2943
|
+
}
|
|
2944
|
+
),
|
|
2945
|
+
/* @__PURE__ */ jsxs18(
|
|
2946
|
+
"div",
|
|
2947
|
+
{
|
|
2948
|
+
className: "grid grid-cols-3 items-center gap-x-4",
|
|
2949
|
+
"data-testid": `order-summary-item-${item.id}-pricing`,
|
|
2950
|
+
children: [
|
|
2951
|
+
/* @__PURE__ */ jsx17("div", { className: "flex items-center justify-end gap-x-4", children: /* @__PURE__ */ jsx17(
|
|
2952
|
+
Text12,
|
|
2953
|
+
{
|
|
2954
|
+
size: "small",
|
|
2955
|
+
"data-testid": `order-summary-item-${item.id}-unit-price`,
|
|
2956
|
+
children: getLocaleAmount(item.unit_price, currencyCode)
|
|
2957
|
+
}
|
|
2958
|
+
) }),
|
|
2959
|
+
/* @__PURE__ */ jsxs18(
|
|
2960
|
+
"div",
|
|
2961
|
+
{
|
|
2962
|
+
className: "flex items-center gap-x-2",
|
|
2963
|
+
"data-testid": `order-summary-item-${item.id}-quantity`,
|
|
2964
|
+
children: [
|
|
2965
|
+
/* @__PURE__ */ jsx17("div", { className: "w-fit min-w-[27px]", children: /* @__PURE__ */ jsxs18(Text12, { size: "small", children: [
|
|
2966
|
+
/* @__PURE__ */ jsx17("span", { className: "tabular-nums", children: item.quantity }),
|
|
2967
|
+
"x"
|
|
2968
|
+
] }) }),
|
|
2969
|
+
/* @__PURE__ */ jsx17("div", { className: "overflow-visible", children: isInventoryManaged && hasUnfulfilledItems && /* @__PURE__ */ jsx17(
|
|
2970
|
+
StatusBadge4,
|
|
2971
|
+
{
|
|
2972
|
+
color: reservation ? "green" : "orange",
|
|
2973
|
+
className: "text-nowrap",
|
|
2974
|
+
"data-testid": `order-summary-item-${item.id}-reservation-badge`,
|
|
2975
|
+
children: reservation ? t("orders.reservations.allocatedLabel") : t("orders.reservations.notAllocatedLabel")
|
|
2976
|
+
}
|
|
2977
|
+
) })
|
|
2978
|
+
]
|
|
2979
|
+
}
|
|
2980
|
+
),
|
|
2981
|
+
/* @__PURE__ */ jsx17("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx17(
|
|
2982
|
+
Text12,
|
|
2983
|
+
{
|
|
2984
|
+
size: "small",
|
|
2985
|
+
className: "pt-[1px]",
|
|
2986
|
+
"data-testid": `order-summary-item-${item.id}-subtotal`,
|
|
2987
|
+
children: getLocaleAmount(item.subtotal || 0, currencyCode)
|
|
2988
|
+
}
|
|
2989
|
+
) })
|
|
2990
|
+
]
|
|
2991
|
+
}
|
|
2992
|
+
)
|
|
2993
|
+
]
|
|
2994
|
+
},
|
|
2995
|
+
item.id
|
|
2996
|
+
),
|
|
2997
|
+
hasInventoryKit && /* @__PURE__ */ jsx17(InventoryKitBreakdown, { item }),
|
|
2998
|
+
returns.map((r) => /* @__PURE__ */ jsx17(ReturnBreakdown, { orderReturn: r, itemId: item.id }, r.id)),
|
|
2999
|
+
claims.map((claim) => /* @__PURE__ */ jsx17(ClaimBreakdown, { claim, itemId: item.id }, claim.id)),
|
|
3000
|
+
exchanges.map((exchange) => /* @__PURE__ */ jsx17(
|
|
3001
|
+
ExchangeBreakdown,
|
|
3002
|
+
{
|
|
3003
|
+
exchange,
|
|
3004
|
+
itemId: item.id
|
|
3005
|
+
},
|
|
3006
|
+
exchange.id
|
|
3007
|
+
))
|
|
3008
|
+
] });
|
|
3009
|
+
};
|
|
3010
|
+
var ItemBreakdown = ({
|
|
3011
|
+
order,
|
|
3012
|
+
reservations
|
|
3013
|
+
}) => {
|
|
3014
|
+
const { claims = [] } = useClaims({
|
|
3015
|
+
order_id: order.id,
|
|
3016
|
+
fields: "*additional_items"
|
|
3017
|
+
});
|
|
3018
|
+
const { exchanges = [] } = useExchanges({
|
|
3019
|
+
order_id: order.id,
|
|
3020
|
+
fields: "*additional_items"
|
|
3021
|
+
});
|
|
3022
|
+
const { returns = [] } = useReturns({
|
|
3023
|
+
order_id: order.id,
|
|
3024
|
+
fields: "*items,*items.reason"
|
|
3025
|
+
});
|
|
3026
|
+
const reservationsMap = useMemo3(
|
|
3027
|
+
() => new Map((reservations || []).map((r) => [r.line_item_id, r])),
|
|
3028
|
+
[reservations]
|
|
3029
|
+
);
|
|
3030
|
+
return /* @__PURE__ */ jsx17("div", { "data-testid": "order-summary-items-breakdown", children: order.items?.map((item) => {
|
|
3031
|
+
const reservation = reservationsMap.get(item.id);
|
|
3032
|
+
return /* @__PURE__ */ jsx17(
|
|
3033
|
+
Item,
|
|
3034
|
+
{
|
|
3035
|
+
item,
|
|
3036
|
+
currencyCode: order.currency_code,
|
|
3037
|
+
reservation,
|
|
3038
|
+
returns,
|
|
3039
|
+
exchanges,
|
|
3040
|
+
claims
|
|
3041
|
+
},
|
|
3042
|
+
item.id
|
|
3043
|
+
);
|
|
3044
|
+
}) });
|
|
3045
|
+
};
|
|
3046
|
+
var Cost = ({
|
|
3047
|
+
label,
|
|
3048
|
+
value,
|
|
3049
|
+
secondaryValue,
|
|
3050
|
+
tooltip
|
|
3051
|
+
}) => /* @__PURE__ */ jsxs18("div", { className: "grid grid-cols-3 items-center", children: [
|
|
3052
|
+
/* @__PURE__ */ jsxs18(Text12, { size: "small", leading: "compact", children: [
|
|
3053
|
+
label,
|
|
3054
|
+
" ",
|
|
3055
|
+
tooltip
|
|
3056
|
+
] }),
|
|
3057
|
+
/* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: secondaryValue }) }),
|
|
3058
|
+
/* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: value }) })
|
|
3059
|
+
] });
|
|
3060
|
+
var CostBreakdown = ({
|
|
3061
|
+
order
|
|
3062
|
+
}) => {
|
|
3063
|
+
const { t } = useTranslation17();
|
|
3064
|
+
const [isTaxOpen, setIsTaxOpen] = useState6(false);
|
|
3065
|
+
const [isShippingOpen, setIsShippingOpen] = useState6(false);
|
|
3066
|
+
const taxCodes = useMemo3(() => {
|
|
3067
|
+
const taxCodeMap = {};
|
|
3068
|
+
order.items.forEach((item) => {
|
|
3069
|
+
item.tax_lines?.forEach((line) => {
|
|
3070
|
+
const currTotal = line.subtotal || 0;
|
|
3071
|
+
const prevTotal = taxCodeMap[line.code]?.total || 0;
|
|
3072
|
+
taxCodeMap[line.code] = {
|
|
3073
|
+
total: prevTotal + currTotal,
|
|
3074
|
+
rate: line.rate
|
|
3075
|
+
};
|
|
3076
|
+
});
|
|
3077
|
+
});
|
|
3078
|
+
order.shipping_methods.forEach((sm) => {
|
|
3079
|
+
sm.tax_lines?.forEach((line) => {
|
|
3080
|
+
const currTotal = line.subtotal || 0;
|
|
3081
|
+
const prevTotal = taxCodeMap[line.code]?.total || 0;
|
|
3082
|
+
taxCodeMap[line.code] = {
|
|
3083
|
+
total: prevTotal + currTotal,
|
|
3084
|
+
rate: line.rate
|
|
3085
|
+
};
|
|
3086
|
+
});
|
|
3087
|
+
});
|
|
3088
|
+
return taxCodeMap;
|
|
3089
|
+
}, [order]);
|
|
3090
|
+
const hasTaxes = !!Object.keys(taxCodes).length;
|
|
3091
|
+
return /* @__PURE__ */ jsxs18(
|
|
3092
|
+
"div",
|
|
3093
|
+
{
|
|
3094
|
+
className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4",
|
|
3095
|
+
"data-testid": "order-summary-cost-breakdown",
|
|
3096
|
+
children: [
|
|
3097
|
+
/* @__PURE__ */ jsx17(
|
|
3098
|
+
Cost,
|
|
3099
|
+
{
|
|
3100
|
+
label: t("orders.summary.itemSubtotal"),
|
|
3101
|
+
value: getLocaleAmount(order.item_subtotal, order.currency_code)
|
|
3102
|
+
}
|
|
3103
|
+
),
|
|
3104
|
+
/* @__PURE__ */ jsx17(
|
|
3105
|
+
Cost,
|
|
3106
|
+
{
|
|
3107
|
+
label: /* @__PURE__ */ jsxs18(
|
|
3108
|
+
"div",
|
|
3109
|
+
{
|
|
3110
|
+
onClick: () => setIsShippingOpen((o) => !o),
|
|
3111
|
+
className: "flex cursor-pointer items-center gap-1",
|
|
3112
|
+
children: [
|
|
3113
|
+
/* @__PURE__ */ jsx17("span", { children: t("orders.summary.shippingSubtotal") }),
|
|
3114
|
+
/* @__PURE__ */ jsx17(
|
|
3115
|
+
TriangleDownMini,
|
|
3116
|
+
{
|
|
3117
|
+
style: {
|
|
3118
|
+
transform: `rotate(${isShippingOpen ? 0 : -90}deg)`
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
)
|
|
3122
|
+
]
|
|
3123
|
+
}
|
|
3124
|
+
),
|
|
3125
|
+
value: getLocaleAmount(order.shipping_subtotal, order.currency_code)
|
|
3126
|
+
}
|
|
3127
|
+
),
|
|
3128
|
+
isShippingOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: (order.shipping_methods || []).sort(
|
|
3129
|
+
(m1, m2) => m1.created_at.localeCompare(m2.created_at)
|
|
3130
|
+
).map((sm, i) => {
|
|
3131
|
+
return /* @__PURE__ */ jsxs18(
|
|
3132
|
+
"div",
|
|
3133
|
+
{
|
|
3134
|
+
className: "flex items-center justify-between gap-x-2",
|
|
3135
|
+
children: [
|
|
3136
|
+
/* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs18("span", { className: "txt-small", children: [
|
|
3137
|
+
sm.name,
|
|
3138
|
+
sm.detail.return_id && ` (${t("fields.returnShipping")})`,
|
|
3139
|
+
" ",
|
|
3140
|
+
/* @__PURE__ */ jsx17(shipping_info_popover_default, { shippingMethod: sm }, i)
|
|
3141
|
+
] }) }),
|
|
3142
|
+
/* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
|
|
3143
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(sm.subtotal, order.currency_code) })
|
|
3144
|
+
]
|
|
3145
|
+
},
|
|
3146
|
+
sm.id
|
|
3147
|
+
);
|
|
3148
|
+
}) }),
|
|
3149
|
+
/* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3150
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between", children: [
|
|
3151
|
+
/* @__PURE__ */ jsxs18(
|
|
3152
|
+
"div",
|
|
3153
|
+
{
|
|
3154
|
+
onClick: () => hasTaxes && setIsTaxOpen((o) => !o),
|
|
3155
|
+
className: clx3("flex items-center gap-1", {
|
|
3156
|
+
"cursor-pointer": hasTaxes
|
|
3157
|
+
}),
|
|
3158
|
+
children: [
|
|
3159
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small select-none", children: t("orders.summary.taxTotal") }),
|
|
3160
|
+
hasTaxes && /* @__PURE__ */ jsx17(
|
|
3161
|
+
TriangleDownMini,
|
|
3162
|
+
{
|
|
3163
|
+
style: {
|
|
3164
|
+
transform: `rotate(${isTaxOpen ? 0 : -90}deg)`
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
)
|
|
3168
|
+
]
|
|
3169
|
+
}
|
|
3170
|
+
),
|
|
3171
|
+
/* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: getLocaleAmount(order.original_tax_total, order.currency_code) }) })
|
|
3172
|
+
] }),
|
|
3173
|
+
isTaxOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: Object.entries(taxCodes).map(([code, { total, rate }]) => {
|
|
3174
|
+
return /* @__PURE__ */ jsxs18(
|
|
3175
|
+
"div",
|
|
3176
|
+
{
|
|
3177
|
+
className: "flex items-center justify-between gap-x-2",
|
|
3178
|
+
children: [
|
|
3179
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-1", children: [
|
|
3180
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small", children: code }),
|
|
3181
|
+
/* @__PURE__ */ jsxs18("span", { className: "txt-small", children: [
|
|
3182
|
+
"(",
|
|
3183
|
+
formatPercentage(rate),
|
|
3184
|
+
")"
|
|
3185
|
+
] })
|
|
3186
|
+
] }),
|
|
3187
|
+
/* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
|
|
3188
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
|
|
3189
|
+
]
|
|
3190
|
+
},
|
|
3191
|
+
code
|
|
3192
|
+
);
|
|
3193
|
+
}) })
|
|
3194
|
+
] }),
|
|
3195
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
|
|
3196
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.total") }),
|
|
3197
|
+
/* @__PURE__ */ jsx17(
|
|
3198
|
+
Text12,
|
|
3199
|
+
{
|
|
3200
|
+
className: "text-ui-fg-subtle text-bold",
|
|
3201
|
+
size: "small",
|
|
3202
|
+
leading: "compact",
|
|
3203
|
+
children: getLocaleAmount(order.original_total, order.currency_code)
|
|
3204
|
+
}
|
|
3205
|
+
)
|
|
3206
|
+
] })
|
|
3207
|
+
]
|
|
3208
|
+
}
|
|
3209
|
+
);
|
|
3210
|
+
};
|
|
3211
|
+
var DiscountAndTotalBreakdown = ({
|
|
3212
|
+
order
|
|
3213
|
+
}) => {
|
|
3214
|
+
const { t } = useTranslation17();
|
|
3215
|
+
const [isDiscountOpen, setIsDiscountOpen] = useState6(false);
|
|
3216
|
+
const [isCreditLinesOpen, setIsCreditLinesOpen] = useState6(false);
|
|
3217
|
+
const creditLines = order.credit_lines ?? [];
|
|
3218
|
+
const discounts = useMemo3(() => {
|
|
3219
|
+
const discounts2 = [];
|
|
3220
|
+
if (order.item_discount_total) {
|
|
3221
|
+
discounts2.push({
|
|
3222
|
+
type: "item",
|
|
3223
|
+
total: order.item_discount_total,
|
|
3224
|
+
codes: Array.from(
|
|
3225
|
+
new Set(
|
|
3226
|
+
order.items.flatMap((item) => item.adjustments || []).map((adjustment) => adjustment.code)
|
|
3227
|
+
)
|
|
3228
|
+
).sort()
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
if (order.shipping_discount_total) {
|
|
3232
|
+
discounts2.push({
|
|
3233
|
+
type: "shipping",
|
|
3234
|
+
total: order.shipping_discount_total,
|
|
3235
|
+
codes: Array.from(
|
|
3236
|
+
new Set(
|
|
3237
|
+
order.shipping_methods.flatMap((shippingMethod) => shippingMethod.adjustments || []).map((adjustment) => adjustment.code)
|
|
3238
|
+
)
|
|
3239
|
+
).sort()
|
|
3240
|
+
});
|
|
3241
|
+
}
|
|
3242
|
+
return discounts2;
|
|
3243
|
+
}, [order]);
|
|
3244
|
+
const hasDiscount = discounts.length > 0;
|
|
3245
|
+
const hasCreditLines = creditLines.length > 0;
|
|
3246
|
+
return /* @__PURE__ */ jsxs18(
|
|
3247
|
+
"div",
|
|
3248
|
+
{
|
|
3249
|
+
className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4",
|
|
3250
|
+
"data-testid": "order-summary-discount-breakdown",
|
|
3251
|
+
children: [
|
|
3252
|
+
/* @__PURE__ */ jsx17(
|
|
3253
|
+
Cost,
|
|
3254
|
+
{
|
|
3255
|
+
label: /* @__PURE__ */ jsxs18(
|
|
3256
|
+
"div",
|
|
3257
|
+
{
|
|
3258
|
+
onClick: () => hasDiscount && setIsDiscountOpen((o) => !o),
|
|
3259
|
+
className: clx3("flex items-center gap-1", {
|
|
3260
|
+
"cursor-pointer": hasDiscount
|
|
3261
|
+
}),
|
|
3262
|
+
"data-testid": "order-summary-discount-toggle",
|
|
3263
|
+
children: [
|
|
3264
|
+
/* @__PURE__ */ jsx17("span", { children: t("orders.summary.discountTotal") }),
|
|
3265
|
+
hasDiscount && /* @__PURE__ */ jsx17(
|
|
3266
|
+
TriangleDownMini,
|
|
3267
|
+
{
|
|
3268
|
+
style: {
|
|
3269
|
+
transform: `rotate(${isDiscountOpen ? 0 : -90}deg)`
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
)
|
|
3273
|
+
]
|
|
3274
|
+
}
|
|
3275
|
+
),
|
|
3276
|
+
value: getLocaleAmount(order.discount_total, order.currency_code)
|
|
3277
|
+
}
|
|
3278
|
+
),
|
|
3279
|
+
isDiscountOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: discounts.map(({ type, total, codes }) => {
|
|
3280
|
+
return /* @__PURE__ */ jsxs18(
|
|
3281
|
+
"div",
|
|
3282
|
+
{
|
|
3283
|
+
className: "flex items-center justify-between gap-x-2",
|
|
3284
|
+
children: [
|
|
3285
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-1", children: [
|
|
3286
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small", children: t(`fields.${type}`) }),
|
|
3287
|
+
/* @__PURE__ */ jsxs18("span", { className: "txt-small", children: [
|
|
3288
|
+
"(",
|
|
3289
|
+
codes.join(", "),
|
|
3290
|
+
")"
|
|
3291
|
+
] })
|
|
3292
|
+
] }),
|
|
3293
|
+
/* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
|
|
3294
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
|
|
3295
|
+
]
|
|
3296
|
+
},
|
|
3297
|
+
type
|
|
3298
|
+
);
|
|
3299
|
+
}) }),
|
|
3300
|
+
hasCreditLines && /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3301
|
+
/* @__PURE__ */ jsx17(
|
|
3302
|
+
Cost,
|
|
3303
|
+
{
|
|
3304
|
+
label: /* @__PURE__ */ jsxs18(
|
|
3305
|
+
"div",
|
|
3306
|
+
{
|
|
3307
|
+
onClick: () => setIsCreditLinesOpen((o) => !o),
|
|
3308
|
+
className: "flex cursor-pointer items-center gap-1",
|
|
3309
|
+
children: [
|
|
3310
|
+
/* @__PURE__ */ jsx17("span", { children: t("orders.creditLines.title") }),
|
|
3311
|
+
/* @__PURE__ */ jsx17(
|
|
3312
|
+
TriangleDownMini,
|
|
3313
|
+
{
|
|
3314
|
+
style: {
|
|
3315
|
+
transform: `rotate(${isCreditLinesOpen ? 0 : -90}deg)`
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
)
|
|
3319
|
+
]
|
|
3320
|
+
}
|
|
3321
|
+
),
|
|
3322
|
+
value: getLocaleAmount(
|
|
3323
|
+
order.credit_line_total,
|
|
3324
|
+
order.currency_code
|
|
3325
|
+
)
|
|
3326
|
+
}
|
|
3327
|
+
),
|
|
3328
|
+
isCreditLinesOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: creditLines.map((creditLine) => {
|
|
3329
|
+
const prettyReference = creditLine.reference?.split("_").join(" ").split("-").join(" ");
|
|
3330
|
+
return /* @__PURE__ */ jsxs18(
|
|
3331
|
+
"div",
|
|
3332
|
+
{
|
|
3333
|
+
className: "flex items-center justify-between gap-x-2",
|
|
3334
|
+
children: [
|
|
3335
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center", children: [
|
|
3336
|
+
/* @__PURE__ */ jsx17(
|
|
3337
|
+
Text12,
|
|
3338
|
+
{
|
|
3339
|
+
size: "small",
|
|
3340
|
+
leading: "compact",
|
|
3341
|
+
weight: "plus",
|
|
3342
|
+
className: "txt-small text-ui-fg-subtle font-medium",
|
|
3343
|
+
children: /* @__PURE__ */ jsx17(display_id_default, { id: creditLine.id })
|
|
3344
|
+
}
|
|
3345
|
+
),
|
|
3346
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-subtle mx-1", children: "-" }),
|
|
3347
|
+
/* @__PURE__ */ jsx17(
|
|
3348
|
+
Tooltip6,
|
|
3349
|
+
{
|
|
3350
|
+
content: format3(
|
|
3351
|
+
new Date(creditLine.created_at),
|
|
3352
|
+
"dd MMM, yyyy, HH:mm:ss"
|
|
3353
|
+
),
|
|
3354
|
+
children: /* @__PURE__ */ jsx17(
|
|
3355
|
+
Text12,
|
|
3356
|
+
{
|
|
3357
|
+
size: "small",
|
|
3358
|
+
leading: "compact",
|
|
3359
|
+
className: "txt-small text-ui-fg-subtle",
|
|
3360
|
+
children: format3(
|
|
3361
|
+
new Date(creditLine.created_at),
|
|
3362
|
+
"dd MMM, yyyy"
|
|
3363
|
+
)
|
|
3364
|
+
}
|
|
3365
|
+
)
|
|
3366
|
+
}
|
|
3367
|
+
),
|
|
3368
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-subtle mx-1", children: "-" }),
|
|
3369
|
+
/* @__PURE__ */ jsxs18(
|
|
3370
|
+
Text12,
|
|
3371
|
+
{
|
|
3372
|
+
size: "small",
|
|
3373
|
+
leading: "compact",
|
|
3374
|
+
className: "txt-small text-ui-fg-subtle capitalize",
|
|
3375
|
+
children: [
|
|
3376
|
+
"(",
|
|
3377
|
+
prettyReference,
|
|
3378
|
+
")"
|
|
3379
|
+
]
|
|
3380
|
+
}
|
|
3381
|
+
)
|
|
3382
|
+
] }),
|
|
3383
|
+
/* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
|
|
3384
|
+
/* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(
|
|
3385
|
+
creditLine.amount,
|
|
3386
|
+
order.currency_code
|
|
3387
|
+
) })
|
|
3388
|
+
]
|
|
3389
|
+
},
|
|
3390
|
+
creditLine.id
|
|
3391
|
+
);
|
|
3392
|
+
}) })
|
|
3393
|
+
] }),
|
|
3394
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
|
|
3395
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("orders.summary.totalAfterDiscount") }),
|
|
3396
|
+
/* @__PURE__ */ jsx17(
|
|
3397
|
+
Text12,
|
|
3398
|
+
{
|
|
3399
|
+
className: "text-ui-fg-subtle text-bold",
|
|
3400
|
+
size: "small",
|
|
3401
|
+
leading: "compact",
|
|
3402
|
+
children: getLocaleAmount(order.total, order.currency_code)
|
|
3403
|
+
}
|
|
3404
|
+
)
|
|
3405
|
+
] })
|
|
3406
|
+
]
|
|
3407
|
+
}
|
|
3408
|
+
);
|
|
3409
|
+
};
|
|
3410
|
+
var InventoryKitBreakdown = ({ item }) => {
|
|
3411
|
+
const { t } = useTranslation17();
|
|
3412
|
+
const [isOpen, setIsOpen] = useState6(false);
|
|
3413
|
+
const inventory = item.variant?.inventory_items || [];
|
|
3414
|
+
return /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3415
|
+
/* @__PURE__ */ jsxs18(
|
|
3416
|
+
"div",
|
|
3417
|
+
{
|
|
3418
|
+
onClick: () => setIsOpen((o) => !o),
|
|
3419
|
+
className: "flex cursor-pointer items-center gap-2 border-t border-dashed px-6 py-4",
|
|
3420
|
+
children: [
|
|
3421
|
+
/* @__PURE__ */ jsx17(
|
|
3422
|
+
TriangleDownMini,
|
|
3423
|
+
{
|
|
3424
|
+
style: {
|
|
3425
|
+
transform: `rotate(${isOpen ? 0 : -90}deg)`
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
),
|
|
3429
|
+
/* @__PURE__ */ jsx17("span", { className: "text-ui-fg-muted txt-small select-none", children: t("orders.summary.inventoryKit", { count: inventory.length }) })
|
|
3430
|
+
]
|
|
3431
|
+
}
|
|
3432
|
+
),
|
|
3433
|
+
isOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 px-6 pb-4", children: inventory.map((i) => {
|
|
3434
|
+
return /* @__PURE__ */ jsxs18(
|
|
3435
|
+
"div",
|
|
3436
|
+
{
|
|
3437
|
+
className: "flex items-center justify-between gap-x-2",
|
|
3438
|
+
children: [
|
|
3439
|
+
/* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs18("span", { className: "txt-small text-ui-fg-subtle font-medium", children: [
|
|
3440
|
+
i.inventory.title,
|
|
3441
|
+
i.inventory.sku && /* @__PURE__ */ jsxs18("span", { className: "text-ui-fg-subtle font-normal", children: [
|
|
3442
|
+
" ",
|
|
3443
|
+
"\u22C5 ",
|
|
3444
|
+
i.inventory.sku
|
|
3445
|
+
] })
|
|
3446
|
+
] }) }),
|
|
3447
|
+
/* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
|
|
3448
|
+
/* @__PURE__ */ jsxs18("span", { className: "txt-small text-ui-fg-muted", children: [
|
|
3449
|
+
i.required_quantity,
|
|
3450
|
+
"x"
|
|
3451
|
+
] })
|
|
3452
|
+
]
|
|
3453
|
+
},
|
|
3454
|
+
i.inventory.id
|
|
3455
|
+
);
|
|
3456
|
+
}) })
|
|
3457
|
+
] });
|
|
3458
|
+
};
|
|
3459
|
+
var ReturnBreakdownWithDamages = ({
|
|
3460
|
+
orderReturn,
|
|
3461
|
+
itemId
|
|
3462
|
+
}) => {
|
|
3463
|
+
const { t } = useTranslation17();
|
|
3464
|
+
const item = orderReturn?.items?.find((ri) => ri.item_id === itemId);
|
|
3465
|
+
const damagedQuantity = item?.damaged_quantity || 0;
|
|
3466
|
+
return item && /* @__PURE__ */ jsxs18(
|
|
3467
|
+
"div",
|
|
3468
|
+
{
|
|
3469
|
+
className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-t-2 border-dotted px-6 py-4",
|
|
3470
|
+
children: [
|
|
3471
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
3472
|
+
/* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
|
|
3473
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.returns.damagedItemsReturned`, {
|
|
3474
|
+
quantity: damagedQuantity
|
|
3475
|
+
}) }),
|
|
3476
|
+
item?.note && /* @__PURE__ */ jsx17(Tooltip6, { content: item.note, children: /* @__PURE__ */ jsx17(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
|
|
3477
|
+
item?.reason && /* @__PURE__ */ jsx17(
|
|
3478
|
+
Badge4,
|
|
3479
|
+
{
|
|
3480
|
+
size: "2xsmall",
|
|
3481
|
+
className: "cursor-default select-none capitalize",
|
|
3482
|
+
rounded: "full",
|
|
3483
|
+
children: item?.reason?.label
|
|
3484
|
+
}
|
|
3485
|
+
)
|
|
3486
|
+
] }),
|
|
3487
|
+
/* @__PURE__ */ jsxs18(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
|
|
3488
|
+
t(`orders.returns.damagedItemReceived`),
|
|
3489
|
+
/* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
|
|
3490
|
+
] })
|
|
3491
|
+
]
|
|
3492
|
+
},
|
|
3493
|
+
orderReturn.id
|
|
3494
|
+
);
|
|
3495
|
+
};
|
|
3496
|
+
var ReturnBreakdown = ({
|
|
3497
|
+
orderReturn,
|
|
3498
|
+
itemId
|
|
3499
|
+
}) => {
|
|
3500
|
+
const { t } = useTranslation17();
|
|
3501
|
+
const { getRelativeDate } = useDate();
|
|
3502
|
+
if (!["requested", "received", "partially_received"].includes(
|
|
3503
|
+
orderReturn.status || ""
|
|
3504
|
+
)) {
|
|
3505
|
+
return null;
|
|
3506
|
+
}
|
|
3507
|
+
const isRequested = orderReturn.status === "requested";
|
|
3508
|
+
const item = orderReturn?.items?.find((ri) => ri.item_id === itemId);
|
|
3509
|
+
const damagedQuantity = item?.damaged_quantity || 0;
|
|
3510
|
+
return item && /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3511
|
+
damagedQuantity > 0 && /* @__PURE__ */ jsx17(
|
|
3512
|
+
ReturnBreakdownWithDamages,
|
|
3513
|
+
{
|
|
3514
|
+
orderReturn,
|
|
3515
|
+
itemId
|
|
3516
|
+
}
|
|
3517
|
+
),
|
|
3518
|
+
/* @__PURE__ */ jsxs18(
|
|
3519
|
+
"div",
|
|
3520
|
+
{
|
|
3521
|
+
className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-t-2 border-dotted px-6 py-4",
|
|
3522
|
+
children: [
|
|
3523
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
3524
|
+
/* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
|
|
3525
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", children: t(
|
|
3526
|
+
`orders.returns.${isRequested ? "returnRequestedInfo" : "returnReceivedInfo"}`,
|
|
3527
|
+
{
|
|
3528
|
+
requestedItemsCount: item?.[isRequested ? "quantity" : "received_quantity"]
|
|
3529
|
+
}
|
|
3530
|
+
) }),
|
|
3531
|
+
item?.note && /* @__PURE__ */ jsx17(Tooltip6, { content: item.note, children: /* @__PURE__ */ jsx17(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
|
|
3532
|
+
item?.reason && /* @__PURE__ */ jsx17(
|
|
3533
|
+
Badge4,
|
|
3534
|
+
{
|
|
3535
|
+
size: "2xsmall",
|
|
3536
|
+
className: "cursor-default select-none capitalize",
|
|
3537
|
+
rounded: "full",
|
|
3538
|
+
children: item?.reason?.label
|
|
3539
|
+
}
|
|
3540
|
+
)
|
|
3541
|
+
] }),
|
|
3542
|
+
orderReturn && isRequested && /* @__PURE__ */ jsxs18(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
|
|
3543
|
+
getRelativeDate(orderReturn.created_at),
|
|
3544
|
+
/* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
|
|
3545
|
+
] }),
|
|
3546
|
+
orderReturn && !isRequested && /* @__PURE__ */ jsxs18(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
|
|
3547
|
+
t(`orders.returns.itemReceived`),
|
|
3548
|
+
/* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
|
|
3549
|
+
] })
|
|
3550
|
+
]
|
|
3551
|
+
},
|
|
3552
|
+
item.id
|
|
3553
|
+
)
|
|
3554
|
+
] });
|
|
3555
|
+
};
|
|
3556
|
+
var ClaimBreakdown = ({
|
|
3557
|
+
claim,
|
|
3558
|
+
itemId
|
|
3559
|
+
}) => {
|
|
3560
|
+
const { t } = useTranslation17();
|
|
3561
|
+
const { getRelativeDate } = useDate();
|
|
3562
|
+
const items = claim.additional_items.filter(
|
|
3563
|
+
(item) => item.item?.id === itemId
|
|
3564
|
+
);
|
|
3565
|
+
return !!items.length && /* @__PURE__ */ jsxs18(
|
|
3566
|
+
"div",
|
|
3567
|
+
{
|
|
3568
|
+
className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4",
|
|
3569
|
+
children: [
|
|
3570
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
3571
|
+
/* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
|
|
3572
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.claims.outboundItemAdded`, {
|
|
3573
|
+
itemsCount: items.reduce(
|
|
3574
|
+
(acc, item) => acc = acc + item.quantity,
|
|
3575
|
+
0
|
|
3576
|
+
)
|
|
3577
|
+
}) })
|
|
3578
|
+
] }),
|
|
3579
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: getRelativeDate(claim.created_at) })
|
|
3580
|
+
]
|
|
3581
|
+
},
|
|
3582
|
+
claim.id
|
|
3583
|
+
);
|
|
3584
|
+
};
|
|
3585
|
+
var ExchangeBreakdown = ({
|
|
3586
|
+
exchange,
|
|
3587
|
+
itemId
|
|
3588
|
+
}) => {
|
|
3589
|
+
const { t } = useTranslation17();
|
|
3590
|
+
const { getRelativeDate } = useDate();
|
|
3591
|
+
const items = exchange.additional_items.filter(
|
|
3592
|
+
(item) => item?.item?.id === itemId
|
|
3593
|
+
);
|
|
3594
|
+
return !!items.length && /* @__PURE__ */ jsxs18(
|
|
3595
|
+
"div",
|
|
3596
|
+
{
|
|
3597
|
+
className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4",
|
|
3598
|
+
children: [
|
|
3599
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
3600
|
+
/* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
|
|
3601
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.exchanges.outboundItemAdded`, {
|
|
3602
|
+
itemsCount: items.reduce(
|
|
3603
|
+
(acc, item) => acc = acc + item.quantity,
|
|
3604
|
+
0
|
|
3605
|
+
)
|
|
3606
|
+
}) })
|
|
3607
|
+
] }),
|
|
3608
|
+
/* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: getRelativeDate(exchange.created_at) })
|
|
3609
|
+
]
|
|
3610
|
+
},
|
|
3611
|
+
exchange.id
|
|
3612
|
+
);
|
|
3613
|
+
};
|
|
3614
|
+
var Total2 = ({ order }) => {
|
|
3615
|
+
const { t } = useTranslation17();
|
|
3616
|
+
return /* @__PURE__ */ jsxs18(
|
|
3617
|
+
"div",
|
|
3618
|
+
{
|
|
3619
|
+
className: " flex flex-col gap-y-2 px-6 py-4",
|
|
3620
|
+
"data-testid": "order-summary-total",
|
|
3621
|
+
children: [
|
|
3622
|
+
/* @__PURE__ */ jsxs18(
|
|
3623
|
+
"div",
|
|
3624
|
+
{
|
|
3625
|
+
className: "text-ui-fg-base flex items-center justify-between",
|
|
3626
|
+
"data-testid": "order-summary-paid-total",
|
|
3627
|
+
children: [
|
|
3628
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.paidTotal") }),
|
|
3629
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: getStylizedAmount(
|
|
3630
|
+
getTotalCaptured(order.payment_collections || []),
|
|
3631
|
+
order.currency_code
|
|
3632
|
+
) })
|
|
3633
|
+
]
|
|
3634
|
+
}
|
|
3635
|
+
),
|
|
3636
|
+
getTotalCreditLines(order.credit_lines ?? []) > 0 && /* @__PURE__ */ jsxs18("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
|
|
3637
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.creditTotal") }),
|
|
3638
|
+
/* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: getStylizedAmount(
|
|
3639
|
+
getTotalCreditLines(order.credit_lines ?? []),
|
|
3640
|
+
order.currency_code
|
|
3641
|
+
) })
|
|
3642
|
+
] }),
|
|
3643
|
+
/* @__PURE__ */ jsxs18(
|
|
3644
|
+
"div",
|
|
3645
|
+
{
|
|
3646
|
+
className: "text-ui-fg-base flex items-center justify-between",
|
|
3647
|
+
"data-testid": "order-summary-outstanding-amount",
|
|
3648
|
+
children: [
|
|
3649
|
+
/* @__PURE__ */ jsx17(
|
|
3650
|
+
Text12,
|
|
3651
|
+
{
|
|
3652
|
+
className: "text-ui-fg-subtle text-semibold",
|
|
3653
|
+
size: "small",
|
|
3654
|
+
leading: "compact",
|
|
3655
|
+
children: t("orders.returns.outstandingAmount")
|
|
3656
|
+
}
|
|
3657
|
+
),
|
|
3658
|
+
/* @__PURE__ */ jsx17(
|
|
3659
|
+
Text12,
|
|
3660
|
+
{
|
|
3661
|
+
className: "text-ui-fg-subtle text-bold",
|
|
3662
|
+
size: "small",
|
|
3663
|
+
leading: "compact",
|
|
3664
|
+
children: getStylizedAmount(
|
|
3665
|
+
order.summary.pending_difference || 0,
|
|
3666
|
+
order.currency_code
|
|
3667
|
+
)
|
|
3668
|
+
}
|
|
3669
|
+
)
|
|
3670
|
+
]
|
|
3671
|
+
}
|
|
3672
|
+
)
|
|
3673
|
+
]
|
|
3674
|
+
}
|
|
3675
|
+
);
|
|
3676
|
+
};
|
|
3677
|
+
|
|
3678
|
+
// src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx
|
|
3679
|
+
import {
|
|
3680
|
+
Badge as Badge5,
|
|
3681
|
+
Button as Button9,
|
|
3682
|
+
Container as Container11,
|
|
3683
|
+
Heading as Heading11,
|
|
3684
|
+
StatusBadge as StatusBadge5,
|
|
3685
|
+
Text as Text13
|
|
3686
|
+
} from "@medusajs/ui";
|
|
3687
|
+
import { useNavigate as useNavigate6, useParams } from "react-router-dom";
|
|
3688
|
+
import { useTranslation as useTranslation18 } from "react-i18next";
|
|
3689
|
+
import { jsx as jsx18, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3690
|
+
var OrderBadge2 = ({ order }) => {
|
|
3691
|
+
const { t } = useTranslation18();
|
|
3692
|
+
const orderStatus = getCanceledOrderStatus(t, order.status);
|
|
3693
|
+
if (!orderStatus) {
|
|
3694
|
+
return null;
|
|
3695
|
+
}
|
|
3696
|
+
return /* @__PURE__ */ jsx18(StatusBadge5, { color: orderStatus.color, className: "text-nowrap", children: orderStatus.label });
|
|
3697
|
+
};
|
|
3698
|
+
var PaymentBadge2 = ({ order }) => {
|
|
3699
|
+
const { t } = useTranslation18();
|
|
3700
|
+
const { label, color } = getOrderPaymentStatus(t, order.payment_status);
|
|
3701
|
+
return /* @__PURE__ */ jsx18(StatusBadge5, { color, className: "text-nowrap", children: label });
|
|
3702
|
+
};
|
|
3703
|
+
var OrderRemainingOrdersGroupSection = () => {
|
|
3704
|
+
const { id } = useParams();
|
|
3705
|
+
const navigate = useNavigate6();
|
|
3706
|
+
const { order_group, isLoading } = useOrderGroup(id);
|
|
3707
|
+
if (isLoading) {
|
|
3708
|
+
return /* @__PURE__ */ jsx18("div", { children: "Loading..." });
|
|
3709
|
+
}
|
|
3710
|
+
const { orders } = order_group || {};
|
|
3711
|
+
return /* @__PURE__ */ jsxs19(Container11, { "data-testid": "order-remaining-orders-group-section", children: [
|
|
3712
|
+
/* @__PURE__ */ jsx18(
|
|
3713
|
+
Heading11,
|
|
3714
|
+
{
|
|
3715
|
+
level: "h2",
|
|
3716
|
+
className: "text-lg font-medium",
|
|
3717
|
+
"data-testid": "order-remaining-orders-group-heading",
|
|
3718
|
+
children: "Remaining orders group"
|
|
3719
|
+
}
|
|
3720
|
+
),
|
|
3721
|
+
/* @__PURE__ */ jsx18("div", { "data-testid": "order-remaining-orders-group-list", children: orders?.map((order) => {
|
|
3722
|
+
const items = order.items.length > 1 ? `${order.items[0].subtitle} + ${order.items.length - 1} more` : order.items[0].subtitle;
|
|
3723
|
+
return /* @__PURE__ */ jsx18(
|
|
3724
|
+
Button9,
|
|
3725
|
+
{
|
|
3726
|
+
variant: "secondary",
|
|
3727
|
+
className: "cursor-pointer w-full flex text-left mt-4",
|
|
3728
|
+
onClick: () => {
|
|
3729
|
+
navigate(`/orders/${order.id}`);
|
|
3730
|
+
},
|
|
3731
|
+
"data-testid": `order-remaining-orders-group-item-${order.id}`,
|
|
3732
|
+
children: /* @__PURE__ */ jsxs19("div", { className: "w-full relative", children: [
|
|
3733
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between gap-2", children: [
|
|
3734
|
+
/* @__PURE__ */ jsxs19(
|
|
3735
|
+
Heading11,
|
|
3736
|
+
{
|
|
3737
|
+
level: "h3",
|
|
3738
|
+
className: "text-md font-medium w-1/3 truncate",
|
|
3739
|
+
"data-testid": `order-remaining-orders-group-item-${order.id}-heading`,
|
|
3740
|
+
children: [
|
|
3741
|
+
"#",
|
|
3742
|
+
order.display_id
|
|
3743
|
+
]
|
|
3744
|
+
}
|
|
3745
|
+
),
|
|
3746
|
+
/* @__PURE__ */ jsxs19(
|
|
3747
|
+
"div",
|
|
3748
|
+
{
|
|
3749
|
+
className: "flex w-2/3",
|
|
3750
|
+
"data-testid": `order-remaining-orders-group-item-${order.id}-badges`,
|
|
3751
|
+
children: [
|
|
3752
|
+
/* @__PURE__ */ jsxs19(Badge5, { className: "scale-75 -mr-8", children: [
|
|
3753
|
+
/* @__PURE__ */ jsx18("span", { className: "text-xs mr-2", children: "Payment" }),
|
|
3754
|
+
/* @__PURE__ */ jsx18(PaymentBadge2, { order })
|
|
3755
|
+
] }),
|
|
3756
|
+
/* @__PURE__ */ jsxs19(Badge5, { className: "scale-75 -mr-4", children: [
|
|
3757
|
+
/* @__PURE__ */ jsx18("span", { className: "text-xs mr-2", children: "Order" }),
|
|
3758
|
+
/* @__PURE__ */ jsx18(OrderBadge2, { order })
|
|
3759
|
+
] })
|
|
3760
|
+
]
|
|
3761
|
+
}
|
|
3762
|
+
)
|
|
3763
|
+
] }),
|
|
3764
|
+
/* @__PURE__ */ jsx18(
|
|
3765
|
+
Text13,
|
|
3766
|
+
{
|
|
3767
|
+
className: "truncate",
|
|
3768
|
+
"data-testid": `order-remaining-orders-group-item-${order.id}-items`,
|
|
3769
|
+
children: items
|
|
3770
|
+
}
|
|
3771
|
+
)
|
|
3772
|
+
] })
|
|
3773
|
+
},
|
|
3774
|
+
order.id
|
|
3775
|
+
);
|
|
3776
|
+
}) })
|
|
3777
|
+
] });
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
// src/pages/orders/order-detail/order-detail.tsx
|
|
3781
|
+
import { jsx as jsx19, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3782
|
+
var OrderDetail = () => {
|
|
3783
|
+
const initialData = useLoaderData();
|
|
3784
|
+
const { id } = useParams2();
|
|
3785
|
+
const { order, isLoading, isError, error } = useOrder(
|
|
3786
|
+
id,
|
|
3787
|
+
{
|
|
3788
|
+
fields: DEFAULT_FIELDS
|
|
3789
|
+
},
|
|
3790
|
+
{
|
|
3791
|
+
initialData
|
|
3792
|
+
}
|
|
3793
|
+
);
|
|
3794
|
+
if (order) {
|
|
3795
|
+
order.items = order.items.sort((itemA, itemB) => {
|
|
3796
|
+
if (itemA.created_at > itemB.created_at) {
|
|
3797
|
+
return 1;
|
|
3798
|
+
}
|
|
3799
|
+
if (itemA.created_at < itemB.created_at) {
|
|
3800
|
+
return -1;
|
|
3801
|
+
}
|
|
3802
|
+
return 0;
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
const { order: orderPreview, isLoading: isPreviewLoading } = useOrderPreview(
|
|
3806
|
+
id
|
|
3807
|
+
);
|
|
3808
|
+
if (isLoading || !order || isPreviewLoading) {
|
|
3809
|
+
return /* @__PURE__ */ jsx19(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 2, showJSON: true });
|
|
3810
|
+
}
|
|
3811
|
+
if (isError) {
|
|
3812
|
+
throw error;
|
|
3813
|
+
}
|
|
3814
|
+
return /* @__PURE__ */ jsxs20(
|
|
3815
|
+
TwoColumnPage,
|
|
3816
|
+
{
|
|
3817
|
+
data: order,
|
|
3818
|
+
showJSON: true,
|
|
3819
|
+
showMetadata: true,
|
|
3820
|
+
hasOutlet: true,
|
|
3821
|
+
"data-testid": "order-detail-page",
|
|
3822
|
+
children: [
|
|
3823
|
+
/* @__PURE__ */ jsxs20(TwoColumnPage.Main, { "data-testid": "order-detail-main", children: [
|
|
3824
|
+
/* @__PURE__ */ jsx19(OrderActiveEditSection, { order }),
|
|
3825
|
+
/* @__PURE__ */ jsx19(ActiveOrderClaimSection, { orderPreview }),
|
|
3826
|
+
/* @__PURE__ */ jsx19(ActiveOrderExchangeSection, { orderPreview }),
|
|
3827
|
+
/* @__PURE__ */ jsx19(ActiveOrderReturnSection, { orderPreview }),
|
|
3828
|
+
/* @__PURE__ */ jsx19(OrderGeneralSection, { order }),
|
|
3829
|
+
/* @__PURE__ */ jsx19(OrderSummarySection, { order }),
|
|
3830
|
+
/* @__PURE__ */ jsx19(OrderPaymentSection, { order }),
|
|
3831
|
+
/* @__PURE__ */ jsx19(OrderFulfillmentSection, { order })
|
|
3832
|
+
] }),
|
|
3833
|
+
/* @__PURE__ */ jsxs20(TwoColumnPage.Sidebar, { "data-testid": "order-detail-sidebar", children: [
|
|
3834
|
+
/* @__PURE__ */ jsx19(OrderCustomerSection, { order }),
|
|
3835
|
+
/* @__PURE__ */ jsx19(OrderActivitySection, { order }),
|
|
3836
|
+
/* @__PURE__ */ jsx19(OrderRemainingOrdersGroupSection, {})
|
|
3837
|
+
] })
|
|
3838
|
+
]
|
|
3839
|
+
}
|
|
3840
|
+
);
|
|
3841
|
+
};
|
|
3842
|
+
export {
|
|
3843
|
+
OrderDetailBreadcrumb as Breadcrumb,
|
|
3844
|
+
OrderDetail as Component,
|
|
3845
|
+
orderLoader as loader
|
|
3846
|
+
};
|