@mercurjs/vendor 2.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/[id]-23D3HY3G.js +444 -0
- package/dist/[id]-2VBOAZM4.js +1215 -0
- package/dist/[id]-A4FSDRER.js +325 -0
- package/dist/[id]-E45G2SDA.js +213 -0
- package/dist/[id]-FXKSI52D.js +477 -0
- package/dist/[id]-HHZ3BSXV.js +1166 -0
- package/dist/[id]-MIV4U5UW.js +137 -0
- package/dist/[id]-QSRIPPIP.js +612 -0
- package/dist/[id]-RGDXOC7T.js +499 -0
- package/dist/[id]-TI2MOR2C.js +377 -0
- package/dist/[id]-U5DT2ZLS.js +301 -0
- package/dist/[id]-UMFGLDM2.js +354 -0
- package/dist/[id]-VTFOP3BF.js +97 -0
- package/dist/[id]-ZYF75L6G.js +479 -0
- package/dist/[location_id]-4UIEW5KM.js +685 -0
- package/dist/[province_id]-ZCHPXXQN.js +205 -0
- package/dist/add-KNDQL6YN.js +660 -0
- package/dist/add-customer-groups-JA346MTF.js +275 -0
- package/dist/add-products-2VB57KXV.js +273 -0
- package/dist/add-promotions-KVKEP6EO.js +260 -0
- package/dist/add-to-campaign-V6D7JKRS.js +44 -0
- package/dist/additional-attributes-E36EZX4V.js +219 -0
- package/dist/adjust-inventory-P7AB7VIB.js +228 -0
- package/dist/allocate-items-QAS5PZLR.js +529 -0
- package/dist/areas-Y7VDWH7G.js +151 -0
- package/dist/attributes-UEM2VJKV.js +277 -0
- package/dist/breadcrumb-3QTVWXZB.js +27 -0
- package/dist/breadcrumb-5OTOCYNL.js +38 -0
- package/dist/breadcrumb-6NAAOPIY.js +11 -0
- package/dist/breadcrumb-ASB2YCNV.js +25 -0
- package/dist/breadcrumb-CIGKLKKS.js +28 -0
- package/dist/breadcrumb-EOYLR3IQ.js +22 -0
- package/dist/breadcrumb-LENACUAA.js +22 -0
- package/dist/breadcrumb-LIXGWUQF.js +44 -0
- package/dist/breadcrumb-MOQ7GI3Z.js +27 -0
- package/dist/breadcrumb-NCBGPQML.js +23 -0
- package/dist/breadcrumb-OVMEC5OZ.js +33 -0
- package/dist/breadcrumb-RIXJ5QSX.js +45 -0
- package/dist/breadcrumb-TZB6EWNC.js +31 -0
- package/dist/breadcrumb-WP34OXGQ.js +23 -0
- package/dist/campaigns-PMVKUFEA.js +28 -0
- package/dist/categories-CKKIUMYG.js +27 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2C3HUJ3Z.js +222 -0
- package/dist/chunk-2F3H6ORE.js +36 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-3CK6OINO.js +448 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3LPVUPZZ.js +74 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3SIDRPKT.js +185 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-4MFMCZEJ.js +70 -0
- package/dist/chunk-4TBDDMFP.js +425 -0
- package/dist/chunk-4TLP3TAA.js +34 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5NF4OTVV.js +169 -0
- package/dist/chunk-66V3GFSW.js +138 -0
- package/dist/chunk-6EYGH3TB.js +26 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6YA3C4NB.js +55 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-A2SY5L5G.js +183 -0
- package/dist/chunk-A5DJIOHN.js +4 -0
- package/dist/chunk-AIFLEWO2.js +56 -0
- package/dist/chunk-ASVMGV2B.js +80 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AYUG34XF.js +84 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-B2RVONU7.js +160 -0
- package/dist/chunk-BCU3FKP2.js +18 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BDZOSMAX.js +23 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CDIZEXFJ.js +145 -0
- package/dist/chunk-CFETU5BI.js +261 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-CUO22GTM.js +96 -0
- package/dist/chunk-CVVYQI5F.js +41 -0
- package/dist/chunk-DARJTN4I.js +60 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DC2K6CFQ.js +86 -0
- package/dist/chunk-DDEIH66R.js +123 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-DYUTYBAQ.js +67 -0
- package/dist/chunk-E3MNEQID.js +24 -0
- package/dist/chunk-FBZHM2QZ.js +247 -0
- package/dist/chunk-FDZC3TFZ.js +717 -0
- package/dist/chunk-FGCKXH45.js +263 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FOMEBUX6.js +89 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-GC33DBKG.js +143 -0
- package/dist/chunk-GDMNHL7E.js +144 -0
- package/dist/chunk-GTUR4HSV.js +53 -0
- package/dist/chunk-H35HHFTB.js +225 -0
- package/dist/chunk-HB3BP55W.js +25 -0
- package/dist/chunk-HHD2VUED.js +29 -0
- package/dist/chunk-HUNGNEPY.js +312 -0
- package/dist/chunk-HUZG6A3X.js +127 -0
- package/dist/chunk-INNFZYX2.js +183 -0
- package/dist/chunk-IQPN4PZJ.js +749 -0
- package/dist/chunk-IZ5RG5XI.js +72 -0
- package/dist/chunk-J2XP7VRG.js +1080 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JKXAL7WR.js +92 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-JVBLYMY2.js +268 -0
- package/dist/chunk-JXP5YZ77.js +86 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KHHY7EEM.js +267 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LWVBKUUL.js +77 -0
- package/dist/chunk-LYUCDASZ.js +115 -0
- package/dist/chunk-LZ7QV42C.js +37 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N3T24SEK.js +32 -0
- package/dist/chunk-NANYVBFI.js +106 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NX26QE2O.js +47 -0
- package/dist/chunk-NYDJTWRL.js +389 -0
- package/dist/chunk-O5LRZEG6.js +253 -0
- package/dist/chunk-O6PRBSFL.js +115 -0
- package/dist/chunk-OJCDB3N5.js +539 -0
- package/dist/chunk-OSFOX7MG.js +176 -0
- package/dist/chunk-OVPAOBZB.js +110 -0
- package/dist/chunk-PADOWAXM.js +118 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-PLSJ74T2.js +298 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PWZKFTJS.js +247 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-PYQJ5N25.js +191 -0
- package/dist/chunk-Q4UVXS46.js +14 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-QUNDGPF7.js +92801 -0
- package/dist/chunk-R65A4P4H.js +136 -0
- package/dist/chunk-RE7YXVFG.js +128 -0
- package/dist/chunk-RETT6WME.js +37 -0
- package/dist/chunk-RHKRREUU.js +15 -0
- package/dist/chunk-RIILGKYR.js +32 -0
- package/dist/chunk-RM5RSDYP.js +353 -0
- package/dist/chunk-RNC4NFVK.js +170 -0
- package/dist/chunk-RSMZHZI2.js +2078 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S3PQKKNV.js +49 -0
- package/dist/chunk-S5GQ2SES.js +276 -0
- package/dist/chunk-SECZTXSU.js +31 -0
- package/dist/chunk-SI4ALL7W.js +180 -0
- package/dist/chunk-SID3COTK.js +21 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-SOZMJA7V.js +61 -0
- package/dist/chunk-TG3TCIL6.js +207 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TTFCO5HU.js +173 -0
- package/dist/chunk-TXEPCJEQ.js +430 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U3X4DNV6.js +179 -0
- package/dist/chunk-UXKKD4AD.js +437 -0
- package/dist/chunk-UYJ65N46.js +261 -0
- package/dist/chunk-VDWGP2U6.js +71 -0
- package/dist/chunk-VGJTARSA.js +89 -0
- package/dist/chunk-VHMGJUYN.js +28 -0
- package/dist/chunk-VKC3XKFF.js +283 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-W4KHJ4D6.js +74 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-W6ZVQJYB.js +311 -0
- package/dist/chunk-WA3IVAUC.js +123 -0
- package/dist/chunk-WHTS4G5K.js +1551 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WPFTRRWV.js +455 -0
- package/dist/chunk-WQZ4ONQV.js +6 -0
- package/dist/chunk-WS652CCV.js +893 -0
- package/dist/chunk-XG4PTPRM.js +0 -0
- package/dist/chunk-XRNDVICA.js +85 -0
- package/dist/chunk-XXZJISPX.js +48 -0
- package/dist/chunk-Y224F4UU.js +81 -0
- package/dist/chunk-Y3FR5JC7.js +437 -0
- package/dist/chunk-Y4VBOHAP.js +111 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-Z2WPXJ6J.js +146 -0
- package/dist/chunk-ZA2KFUFR.js +19 -0
- package/dist/chunk-ZEKV7LGF.js +6 -0
- package/dist/chunk-ZFFA36DB.js +186 -0
- package/dist/chunk-ZPGWTLF2.js +499 -0
- package/dist/chunk-ZVT2QSWR.js +263 -0
- package/dist/chunk-ZZ7VKT2S.js +4113 -0
- package/dist/collections-TREF67TO.js +63 -0
- package/dist/configuration-KWAL2QZ5.js +152 -0
- package/dist/configuration-RNWBTRAH.js +205 -0
- package/dist/create-7UEEO5TM.js +125 -0
- package/dist/create-DTCDJMIT.js +634 -0
- package/dist/create-DYDRAY6V.js +622 -0
- package/dist/create-EJM5C2XP.js +27 -0
- package/dist/create-F7OMPGZV.js +853 -0
- package/dist/create-G4UJOJJ6.js +69 -0
- package/dist/create-IE6MYOIY.js +170 -0
- package/dist/create-L23TGTBH.js +225 -0
- package/dist/create-LOBCFTCT.js +583 -0
- package/dist/create-MKBBF2V3.js +150 -0
- package/dist/create-TFDUNJSI.js +163 -0
- package/dist/create-TMTZDKII.js +711 -0
- package/dist/create-XGF6DB5F.js +239 -0
- package/dist/create-YAAK7JQ3.js +1052 -0
- package/dist/create-YPCVTXAK.js +194 -0
- package/dist/create-ZU362U3B.js +310 -0
- package/dist/customers-4QWR5UOL.js +27 -0
- package/dist/edit-2QA5BVOY.js +735 -0
- package/dist/edit-47I7VVNB.js +167 -0
- package/dist/edit-5BUGSOTL.js +255 -0
- package/dist/edit-7LQATDUD.js +193 -0
- package/dist/edit-AQAPYMDY.js +260 -0
- package/dist/edit-BQLSTFTQ.js +138 -0
- package/dist/edit-BYXHU3IG.js +308 -0
- package/dist/edit-DG3MY3ZH.js +244 -0
- package/dist/edit-J3LD76JS.js +192 -0
- package/dist/edit-J6WCPHDS.js +205 -0
- package/dist/edit-KCZVZLSZ.js +131 -0
- package/dist/edit-LOKLQGM2.js +181 -0
- package/dist/edit-MDTTTB33.js +104 -0
- package/dist/edit-NFSU2K3O.js +413 -0
- package/dist/edit-RHNZWNXD.js +89 -0
- package/dist/edit-XU33IVZH.js +204 -0
- package/dist/edit-ZMINDMGM.js +116 -0
- package/dist/edit-budget-Z5USV462.js +145 -0
- package/dist/edit-inventory-item-YFW2AFRD.js +128 -0
- package/dist/edit-inventory-item-attributes-IYAMJDTB.js +278 -0
- package/dist/fulfillment-SKXAF3BZ.js +545 -0
- package/dist/fulfillment-providers-ACERVITQ.js +279 -0
- package/dist/home-PP7YYCSB.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +3656 -0
- package/dist/inventory-AIRQ2KNS.js +26 -0
- package/dist/locations-SQKM7JWN.js +23 -0
- package/dist/login-LKFCRHXN.js +35 -0
- package/dist/manage-locations-4PQS4QY7.js +195 -0
- package/dist/media-PL477QJO.js +703 -0
- package/dist/metadata-42MU3H7T.js +60 -0
- package/dist/metadata-DIJTVDF7.js +45 -0
- package/dist/metadata-NX3LEEB3.js +64 -0
- package/dist/metadata-RBDSM567.js +65 -0
- package/dist/metadata-VZTWNZPG.js +66 -0
- package/dist/metadata-X3XGQ563.js +67 -0
- package/dist/no-match-BO2NNLCM.js +33 -0
- package/dist/orders-2KHCHNO5.js +59 -0
- package/dist/organization-VQXCKHCN.js +233 -0
- package/dist/organize-3F5ZUIGB.js +23 -0
- package/dist/organize-WPWEPCF7.js +23 -0
- package/dist/pages/index.d.ts +1153 -0
- package/dist/pages/index.js +198 -0
- package/dist/payouts-3BY73LZ3.js +27 -0
- package/dist/price-lists-G256JJN7.js +34 -0
- package/dist/prices-EW7KBY6R.js +269 -0
- package/dist/pricing-3PUJDOZN.js +313 -0
- package/dist/product-tags-PI3RENEX.js +80 -0
- package/dist/product-types-WJPLJI7H.js +32 -0
- package/dist/product-variant-detail-EYTE7PHL.js +377 -0
- package/dist/product-variant-edit-PW7W5J5E.js +402 -0
- package/dist/products-GSN4I7BT.js +272 -0
- package/dist/products-RFYNEY57.js +85 -0
- package/dist/promotions-CIZIDQ64.js +31 -0
- package/dist/reset-password-OFUSH363.js +299 -0
- package/dist/return-reasons-4V2KVSRI.js +52 -0
- package/dist/sales-channels-MBWVM3X2.js +184 -0
- package/dist/sales-channels-ZKA62EAW.js +156 -0
- package/dist/seller-ZFDLKF5Y.js +36 -0
- package/dist/settings-NP2IAID5.js +111 -0
- package/dist/shipping-profile-7FTHSPY2.js +145 -0
- package/dist/shipping-profiles-7R6L65WG.js +43 -0
- package/dist/stock-ENMBCZRY.js +502 -0
- package/dist/stock-VYDJY46S.js +278 -0
- package/dist/tax-regions-V6G6244H.js +87 -0
- package/package.json +87 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFulfillableQuantity
|
|
3
|
+
} from "./chunk-RXM4B6HR.js";
|
|
4
|
+
import "./chunk-TKGWSUEI.js";
|
|
5
|
+
import {
|
|
6
|
+
KeyboundForm
|
|
7
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
8
|
+
import {
|
|
9
|
+
RouteFocusModal,
|
|
10
|
+
useRouteModal
|
|
11
|
+
} from "./chunk-3CK6OINO.js";
|
|
12
|
+
import {
|
|
13
|
+
Form
|
|
14
|
+
} from "./chunk-3QSRE5LS.js";
|
|
15
|
+
import {
|
|
16
|
+
Thumbnail
|
|
17
|
+
} from "./chunk-WIYFXWRI.js";
|
|
18
|
+
import {
|
|
19
|
+
useStockLocations
|
|
20
|
+
} from "./chunk-SI4ALL7W.js";
|
|
21
|
+
import {
|
|
22
|
+
ordersQueryKeys,
|
|
23
|
+
useCreateReservationItem,
|
|
24
|
+
useOrder
|
|
25
|
+
} from "./chunk-ZFFA36DB.js";
|
|
26
|
+
import "./chunk-WPFTRRWV.js";
|
|
27
|
+
import "./chunk-A5DJIOHN.js";
|
|
28
|
+
import {
|
|
29
|
+
queryClient
|
|
30
|
+
} from "./chunk-RHKRREUU.js";
|
|
31
|
+
import "./chunk-ZA2KFUFR.js";
|
|
32
|
+
import "./chunk-Y224F4UU.js";
|
|
33
|
+
import "./chunk-PKBMQBKP.js";
|
|
34
|
+
|
|
35
|
+
// src/pages/orders/[id]/allocate-items/index.tsx
|
|
36
|
+
import { useParams } from "react-router-dom";
|
|
37
|
+
|
|
38
|
+
// src/pages/orders/[id]/allocate-items/order-create-fulfillment-form/order-allocate-items-form.tsx
|
|
39
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
40
|
+
import { useEffect, useMemo as useMemo2, useState as useState2 } from "react";
|
|
41
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
42
|
+
import { Alert, Button, Heading, Input as Input2, Select, toast } from "@medusajs/ui";
|
|
43
|
+
import { useForm, useWatch as useWatch2 } from "react-hook-form";
|
|
44
|
+
|
|
45
|
+
// src/pages/orders/[id]/allocate-items/order-create-fulfillment-form/constants.ts
|
|
46
|
+
import { z } from "zod";
|
|
47
|
+
var AllocateItemsSchema = z.object({
|
|
48
|
+
location_id: z.string(),
|
|
49
|
+
quantity: z.record(z.string(), z.number().or(z.string()))
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/pages/orders/[id]/allocate-items/order-create-fulfillment-form/order-allocate-items-item.tsx
|
|
53
|
+
import { useMemo, useState } from "react";
|
|
54
|
+
import { useTranslation } from "react-i18next";
|
|
55
|
+
import {
|
|
56
|
+
Component,
|
|
57
|
+
ExclamationCircleSolid,
|
|
58
|
+
TriangleDownMini
|
|
59
|
+
} from "@medusajs/icons";
|
|
60
|
+
import { useWatch } from "react-hook-form";
|
|
61
|
+
import { Input, Text, clx } from "@medusajs/ui";
|
|
62
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
63
|
+
function OrderAllocateItemsItem({
|
|
64
|
+
item,
|
|
65
|
+
form,
|
|
66
|
+
locationId,
|
|
67
|
+
onQuantityChange
|
|
68
|
+
}) {
|
|
69
|
+
const { t } = useTranslation();
|
|
70
|
+
const variant = item.variant;
|
|
71
|
+
const inventory = item.variant?.inventory || [];
|
|
72
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
73
|
+
const quantityField = useWatch({
|
|
74
|
+
control: form.control,
|
|
75
|
+
name: "quantity"
|
|
76
|
+
});
|
|
77
|
+
const hasInventoryKit = !!variant?.inventory_items && variant.inventory_items.length > 1;
|
|
78
|
+
const { availableQuantity, inStockQuantity } = useMemo(() => {
|
|
79
|
+
if (!variant || !locationId) {
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
const locationInventory = inventory[0]?.location_levels?.find(
|
|
83
|
+
(inv) => inv.location_id === locationId
|
|
84
|
+
);
|
|
85
|
+
if (!locationInventory) {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
availableQuantity: locationInventory.available_quantity,
|
|
90
|
+
inStockQuantity: locationInventory.stocked_quantity
|
|
91
|
+
};
|
|
92
|
+
}, [variant, locationId]);
|
|
93
|
+
const hasQuantityError = !hasInventoryKit && availableQuantity && item.variant?.inventory?.[0]?.id && quantityField[`${item.id}-${item.variant.inventory[0].id}`] && Number(quantityField[`${item.id}-${item.variant.inventory[0].id}`]) > availableQuantity;
|
|
94
|
+
const minValue = 0;
|
|
95
|
+
const maxValue = Math.min(
|
|
96
|
+
getFulfillableQuantity(item) ?? 0,
|
|
97
|
+
availableQuantity || Number.MAX_SAFE_INTEGER
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 min-w-[720px] divide-y divide-dashed rounded-xl", children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3 p-3 text-sm", children: [
|
|
101
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
102
|
+
hasQuantityError && /* @__PURE__ */ jsx(ExclamationCircleSolid, { className: "text-ui-fg-error" }),
|
|
103
|
+
/* @__PURE__ */ jsx(Thumbnail, { src: item.thumbnail }),
|
|
104
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
|
|
106
|
+
/* @__PURE__ */ jsx(Text, { className: "txt-small flex", as: "span", weight: "plus", children: item.product_title }),
|
|
107
|
+
item.variant_sku && /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-subtle", children: [
|
|
108
|
+
" ",
|
|
109
|
+
"(",
|
|
110
|
+
item.variant_sku,
|
|
111
|
+
")"
|
|
112
|
+
] }),
|
|
113
|
+
hasInventoryKit && /* @__PURE__ */ jsx(Component, { className: "text-ui-fg-muted ml-2 overflow-visible pt-[2px]" })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ jsx(Text, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.title })
|
|
116
|
+
] })
|
|
117
|
+
] }) }),
|
|
118
|
+
/* @__PURE__ */ jsxs(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
className: clx(
|
|
122
|
+
"flex flex-1 items-center gap-x-3",
|
|
123
|
+
hasInventoryKit ? "justify-end" : "justify-between"
|
|
124
|
+
),
|
|
125
|
+
children: [
|
|
126
|
+
!hasInventoryKit && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
129
|
+
/* @__PURE__ */ jsxs("div", { className: "txt-small flex flex-col", children: [
|
|
130
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle font-medium", children: t("labels.available") }),
|
|
131
|
+
/* @__PURE__ */ jsxs("span", { className: "text-ui-fg-muted", children: [
|
|
132
|
+
availableQuantity || "-",
|
|
133
|
+
availableQuantity && !hasInventoryKit && item.variant?.inventory?.[0]?.id && quantityField[`${item.id}-${item.variant.inventory[0].id}`] && /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-error txt-small ml-1", children: [
|
|
134
|
+
"-",
|
|
135
|
+
quantityField[`${item.id}-${item.variant.inventory[0].id}`]
|
|
136
|
+
] })
|
|
137
|
+
] })
|
|
138
|
+
] })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
141
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "txt-small flex flex-col", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle font-medium", children: t("labels.inStock") }),
|
|
144
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: inStockQuantity || "-" })
|
|
145
|
+
] })
|
|
146
|
+
] })
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
149
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
150
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-row items-center gap-2", children: [
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
Form.Field,
|
|
153
|
+
{
|
|
154
|
+
control: form.control,
|
|
155
|
+
name: hasInventoryKit && item.variant?.inventory?.[0]?.id ? `quantity.${item.id}-` : `quantity.${item.id}-${item.variant?.inventory?.[0].id}`,
|
|
156
|
+
rules: {
|
|
157
|
+
required: !hasInventoryKit,
|
|
158
|
+
min: !hasInventoryKit ? minValue : void 0,
|
|
159
|
+
max: maxValue > 0 ? maxValue : void 0
|
|
160
|
+
},
|
|
161
|
+
render: ({ field }) => {
|
|
162
|
+
return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
163
|
+
Input,
|
|
164
|
+
{
|
|
165
|
+
className: "bg-ui-bg-base txt-small w-[46px] rounded-lg text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
166
|
+
type: "number",
|
|
167
|
+
...field,
|
|
168
|
+
disabled: !locationId,
|
|
169
|
+
onChange: (e) => {
|
|
170
|
+
const val = e.target.value === "" ? null : Number(e.target.value);
|
|
171
|
+
const firstInventory = item.variant?.inventory?.[0];
|
|
172
|
+
if (firstInventory) {
|
|
173
|
+
onQuantityChange(
|
|
174
|
+
firstInventory,
|
|
175
|
+
item,
|
|
176
|
+
hasInventoryKit,
|
|
177
|
+
val,
|
|
178
|
+
true
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
) }) });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
" ",
|
|
188
|
+
"/ ",
|
|
189
|
+
item.quantity,
|
|
190
|
+
" ",
|
|
191
|
+
t("fields.qty")
|
|
192
|
+
] })
|
|
193
|
+
] })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
] }),
|
|
198
|
+
hasInventoryKit && /* @__PURE__ */ jsx("div", { className: "px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
onClick: () => setIsOpen((o) => !o),
|
|
202
|
+
className: "flex items-center gap-x-2",
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ jsx(
|
|
205
|
+
TriangleDownMini,
|
|
206
|
+
{
|
|
207
|
+
style: { transform: `rotate(${isOpen ? -90 : 0}deg)` },
|
|
208
|
+
className: "text-ui-fg-muted -mt-[1px]"
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
/* @__PURE__ */ jsx("span", { className: "txt-small text-ui-fg-muted cursor-pointer", children: t("orders.allocateItems.consistsOf", {
|
|
212
|
+
num: inventory.length
|
|
213
|
+
}) })
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
) }),
|
|
217
|
+
isOpen && variant?.inventory?.map((i, ind) => {
|
|
218
|
+
const location = i.location_levels?.find(
|
|
219
|
+
(l) => l.location_id === locationId
|
|
220
|
+
);
|
|
221
|
+
const hasQuantityError2 = !!quantityField[`${item.id}-${i.id}`] && location && Number(quantityField[`${item.id}-${i.id}`]) > location.available_quantity;
|
|
222
|
+
return /* @__PURE__ */ jsxs("div", { className: "txt-small flex items-center gap-x-3 p-4", children: [
|
|
223
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-row items-center gap-3", children: [
|
|
224
|
+
hasQuantityError2 && /* @__PURE__ */ jsx(ExclamationCircleSolid, { className: "text-ui-fg-error" }),
|
|
225
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
226
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle", children: i?.title ?? i.sku ?? `Inventory Item ${ind + 1}` }),
|
|
227
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: t("orders.allocateItems.requires", {
|
|
228
|
+
num: variant?.inventory_items?.[ind]?.required_quantity || 0
|
|
229
|
+
}) })
|
|
230
|
+
] })
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-row justify-between", children: [
|
|
233
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
234
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
235
|
+
/* @__PURE__ */ jsxs("div", { className: "txt-small flex flex-col", children: [
|
|
236
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle font-medium", children: t("labels.available") }),
|
|
237
|
+
/* @__PURE__ */ jsxs("span", { className: "text-ui-fg-muted", children: [
|
|
238
|
+
location?.available_quantity || "-",
|
|
239
|
+
location?.available_quantity && quantityField[`${item.id}-${i.id}`] && /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-error txt-small ml-1", children: [
|
|
240
|
+
"-",
|
|
241
|
+
quantityField[`${item.id}-${i.id}`]
|
|
242
|
+
] })
|
|
243
|
+
] })
|
|
244
|
+
] })
|
|
245
|
+
] }),
|
|
246
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
247
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
248
|
+
/* @__PURE__ */ jsxs("div", { className: "txt-small flex flex-col", children: [
|
|
249
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle font-medium", children: t("labels.inStock") }),
|
|
250
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: location?.stocked_quantity || "-" })
|
|
251
|
+
] })
|
|
252
|
+
] }),
|
|
253
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
254
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-strong block h-[12px] w-[1px]" }),
|
|
255
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle txt-small mr-1 flex flex-row items-center gap-2", children: [
|
|
256
|
+
/* @__PURE__ */ jsx(
|
|
257
|
+
Form.Field,
|
|
258
|
+
{
|
|
259
|
+
control: form.control,
|
|
260
|
+
name: `quantity.${item.id}-${i.id}`,
|
|
261
|
+
rules: {
|
|
262
|
+
required: true,
|
|
263
|
+
min: 0,
|
|
264
|
+
max: location?.available_quantity
|
|
265
|
+
},
|
|
266
|
+
render: ({ field }) => {
|
|
267
|
+
return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
268
|
+
Input,
|
|
269
|
+
{
|
|
270
|
+
className: "bg-ui-bg-base txt-small w-[46px] rounded-lg text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
271
|
+
type: "number",
|
|
272
|
+
...field,
|
|
273
|
+
disabled: !locationId,
|
|
274
|
+
onChange: (e) => {
|
|
275
|
+
const val = e.target.value === "" ? null : Number(e.target.value);
|
|
276
|
+
onQuantityChange(
|
|
277
|
+
i,
|
|
278
|
+
item,
|
|
279
|
+
hasInventoryKit,
|
|
280
|
+
val
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
) }) });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
"/",
|
|
289
|
+
" ",
|
|
290
|
+
item.quantity * (variant.inventory_items?.[ind]?.required_quantity ?? 0),
|
|
291
|
+
" ",
|
|
292
|
+
t("fields.qty")
|
|
293
|
+
] })
|
|
294
|
+
] })
|
|
295
|
+
] })
|
|
296
|
+
] }, i.id);
|
|
297
|
+
})
|
|
298
|
+
] });
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/pages/orders/[id]/allocate-items/order-create-fulfillment-form/order-allocate-items-form.tsx
|
|
302
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
303
|
+
function OrderAllocateItemsForm({ order }) {
|
|
304
|
+
const { t } = useTranslation2();
|
|
305
|
+
const { handleSuccess } = useRouteModal();
|
|
306
|
+
const [disableSubmit, setDisableSubmit] = useState2(false);
|
|
307
|
+
const [filterTerm, setFilterTerm] = useState2("");
|
|
308
|
+
const { mutateAsync: allocateItems, isPending: isMutating } = useCreateReservationItem();
|
|
309
|
+
const itemsToAllocate = useMemo2(
|
|
310
|
+
() => order.items.filter(
|
|
311
|
+
(item) => item.variant?.manage_inventory && !!item.variant.inventory?.length && item?.quantity - item.detail?.fulfilled_quantity > 0
|
|
312
|
+
),
|
|
313
|
+
[order.items]
|
|
314
|
+
);
|
|
315
|
+
const filteredItems = useMemo2(() => {
|
|
316
|
+
return itemsToAllocate.filter(
|
|
317
|
+
(i) => i.variant_title?.toLowerCase().includes(filterTerm) || i.product_title?.toLowerCase().includes(filterTerm)
|
|
318
|
+
);
|
|
319
|
+
}, [itemsToAllocate, filterTerm]);
|
|
320
|
+
const form = useForm({
|
|
321
|
+
defaultValues: {
|
|
322
|
+
location_id: "",
|
|
323
|
+
quantity: defaultAllocations(itemsToAllocate)
|
|
324
|
+
},
|
|
325
|
+
resolver: zodResolver(AllocateItemsSchema)
|
|
326
|
+
});
|
|
327
|
+
const { stock_locations = [] } = useStockLocations();
|
|
328
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
329
|
+
try {
|
|
330
|
+
const payload = Object.entries(data.quantity).filter(([key]) => !key.endsWith("-")).map(([key, quantity]) => [...key.split("-"), quantity]);
|
|
331
|
+
if (payload.some((d) => d[2] === "")) {
|
|
332
|
+
form.setError("root.quantityNotAllocated", {
|
|
333
|
+
type: "manual",
|
|
334
|
+
message: t("orders.allocateItems.error.quantityNotAllocated")
|
|
335
|
+
});
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const promises = payload.map(
|
|
339
|
+
([itemId, inventoryId, quantity]) => allocateItems({
|
|
340
|
+
location_id: data.location_id,
|
|
341
|
+
inventory_item_id: String(inventoryId),
|
|
342
|
+
line_item_id: String(itemId),
|
|
343
|
+
quantity: typeof quantity === "string" ? Number(quantity) : quantity
|
|
344
|
+
})
|
|
345
|
+
);
|
|
346
|
+
await Promise.all(promises);
|
|
347
|
+
await queryClient.invalidateQueries({
|
|
348
|
+
queryKey: ordersQueryKeys.details()
|
|
349
|
+
});
|
|
350
|
+
handleSuccess(`/orders/${order.id}`);
|
|
351
|
+
toast.success(t("general.success"), {
|
|
352
|
+
description: t("orders.allocateItems.toast.created")
|
|
353
|
+
});
|
|
354
|
+
} catch (e) {
|
|
355
|
+
toast.error(t("general.error"), {
|
|
356
|
+
description: e instanceof FetchError ? e.message : "An unknown error occurred"
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
const onQuantityChange = (inventoryItem, lineItem, hasInventoryKit, value, isRoot) => {
|
|
361
|
+
let shouldDisableSubmit = false;
|
|
362
|
+
const key = isRoot && hasInventoryKit ? `quantity.${lineItem.id}-` : `quantity.${lineItem.id}-${inventoryItem.id}`;
|
|
363
|
+
form.setValue(key, value ?? "");
|
|
364
|
+
if (value && inventoryItem.location_levels) {
|
|
365
|
+
const location = inventoryItem.location_levels.find(
|
|
366
|
+
(l) => l.location_id === selectedLocationId
|
|
367
|
+
);
|
|
368
|
+
if (location) {
|
|
369
|
+
if (location.available_quantity < value) {
|
|
370
|
+
shouldDisableSubmit = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (hasInventoryKit && !isRoot) {
|
|
375
|
+
form.resetField(`quantity.${lineItem.id}-`, { defaultValue: "" });
|
|
376
|
+
}
|
|
377
|
+
if (hasInventoryKit && isRoot) {
|
|
378
|
+
const item = itemsToAllocate.find((i) => i.id === lineItem.id);
|
|
379
|
+
if (!item || !item.variant) return;
|
|
380
|
+
item.variant.inventory_items?.forEach((ii, ind) => {
|
|
381
|
+
const num = value || 0;
|
|
382
|
+
const inventory = item.variant?.inventory?.[ind];
|
|
383
|
+
if (!inventory) return;
|
|
384
|
+
form.setValue(
|
|
385
|
+
`quantity.${lineItem.id}-${inventory.id}`,
|
|
386
|
+
num * ii.required_quantity
|
|
387
|
+
);
|
|
388
|
+
if (value && inventory.location_levels) {
|
|
389
|
+
const location = inventory.location_levels.find(
|
|
390
|
+
(l) => l.location_id === selectedLocationId
|
|
391
|
+
);
|
|
392
|
+
if (location) {
|
|
393
|
+
if (location.available_quantity < value) {
|
|
394
|
+
shouldDisableSubmit = true;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
form.clearErrors("root.quantityNotAllocated");
|
|
401
|
+
setDisableSubmit(shouldDisableSubmit);
|
|
402
|
+
};
|
|
403
|
+
const selectedLocationId = useWatch2({
|
|
404
|
+
name: "location_id",
|
|
405
|
+
control: form.control
|
|
406
|
+
});
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
if (selectedLocationId) {
|
|
409
|
+
form.setValue("quantity", defaultAllocations(itemsToAllocate));
|
|
410
|
+
}
|
|
411
|
+
}, [selectedLocationId]);
|
|
412
|
+
const allocationError = form.formState.errors?.root?.quantityNotAllocated?.message;
|
|
413
|
+
return /* @__PURE__ */ jsx2(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs2(
|
|
414
|
+
KeyboundForm,
|
|
415
|
+
{
|
|
416
|
+
onSubmit: handleSubmit,
|
|
417
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ jsx2(RouteFocusModal.Header, {}),
|
|
420
|
+
/* @__PURE__ */ jsx2(RouteFocusModal.Body, { className: "flex h-full w-full flex-col items-center divide-y overflow-y-auto", children: /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col items-center overflow-auto p-16", children: /* @__PURE__ */ jsx2("div", { className: "flex w-full max-w-[736px] flex-col justify-center px-2 pb-2", children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-8 divide-y divide-dashed", children: [
|
|
421
|
+
/* @__PURE__ */ jsx2(Heading, { children: t("orders.allocateItems.title") }),
|
|
422
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex-1 divide-y divide-dashed pt-8", children: [
|
|
423
|
+
/* @__PURE__ */ jsx2(
|
|
424
|
+
Form.Field,
|
|
425
|
+
{
|
|
426
|
+
control: form.control,
|
|
427
|
+
name: "location_id",
|
|
428
|
+
render: ({ field: { onChange, ref, ...field } }) => {
|
|
429
|
+
return /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
430
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3", children: [
|
|
431
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex-1", children: [
|
|
432
|
+
/* @__PURE__ */ jsx2(Form.Label, { children: t("fields.location") }),
|
|
433
|
+
/* @__PURE__ */ jsx2(Form.Hint, { children: t("orders.allocateItems.locationDescription") })
|
|
434
|
+
] }),
|
|
435
|
+
/* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsxs2(Select, { onValueChange: onChange, ...field, children: [
|
|
436
|
+
/* @__PURE__ */ jsx2(
|
|
437
|
+
Select.Trigger,
|
|
438
|
+
{
|
|
439
|
+
className: "bg-ui-bg-base",
|
|
440
|
+
ref,
|
|
441
|
+
children: /* @__PURE__ */ jsx2(Select.Value, {})
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsx2(Select.Content, { children: stock_locations.map((l) => /* @__PURE__ */ jsx2(Select.Item, { value: l.id, children: l.name }, l.id)) })
|
|
445
|
+
] }) }) })
|
|
446
|
+
] }),
|
|
447
|
+
/* @__PURE__ */ jsx2(Form.ErrorMessage, {})
|
|
448
|
+
] });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsxs2(Form.Item, { className: "mt-8 pt-8", children: [
|
|
453
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-row items-center", children: [
|
|
454
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex-1", children: [
|
|
455
|
+
/* @__PURE__ */ jsx2(Form.Label, { children: t("orders.allocateItems.itemsToAllocate") }),
|
|
456
|
+
/* @__PURE__ */ jsx2(Form.Hint, { children: t("orders.allocateItems.itemsToAllocateDesc") })
|
|
457
|
+
] }),
|
|
458
|
+
/* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsx2(
|
|
459
|
+
Input2,
|
|
460
|
+
{
|
|
461
|
+
value: filterTerm,
|
|
462
|
+
onChange: (e) => setFilterTerm(e.target.value),
|
|
463
|
+
placeholder: t("orders.allocateItems.search"),
|
|
464
|
+
autoComplete: "off",
|
|
465
|
+
type: "search"
|
|
466
|
+
}
|
|
467
|
+
) })
|
|
468
|
+
] }),
|
|
469
|
+
allocationError && /* @__PURE__ */ jsx2(Alert, { className: "mb-4", dismissible: true, variant: "error", children: allocationError }),
|
|
470
|
+
/* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-y-1", children: filteredItems.map((item) => /* @__PURE__ */ jsx2(
|
|
471
|
+
OrderAllocateItemsItem,
|
|
472
|
+
{
|
|
473
|
+
form,
|
|
474
|
+
item,
|
|
475
|
+
locationId: selectedLocationId,
|
|
476
|
+
onQuantityChange
|
|
477
|
+
},
|
|
478
|
+
item.id
|
|
479
|
+
)) })
|
|
480
|
+
] })
|
|
481
|
+
] })
|
|
482
|
+
] }) }) }) }),
|
|
483
|
+
/* @__PURE__ */ jsx2(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
484
|
+
/* @__PURE__ */ jsx2(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx2(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
485
|
+
/* @__PURE__ */ jsx2(
|
|
486
|
+
Button,
|
|
487
|
+
{
|
|
488
|
+
size: "small",
|
|
489
|
+
type: "submit",
|
|
490
|
+
isLoading: isMutating,
|
|
491
|
+
disabled: !selectedLocationId || disableSubmit,
|
|
492
|
+
children: t("orders.allocateItems.action")
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
] }) })
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
) });
|
|
499
|
+
}
|
|
500
|
+
function defaultAllocations(items) {
|
|
501
|
+
const ret = {};
|
|
502
|
+
items.forEach((item) => {
|
|
503
|
+
const hasInventoryKit = (item.variant?.inventory_items?.length || 0) > 1;
|
|
504
|
+
ret[hasInventoryKit ? `${item.id}-` : `${item.id}-${item.variant?.inventory?.[0]?.id || ""}`] = "";
|
|
505
|
+
if (hasInventoryKit && item.variant?.inventory) {
|
|
506
|
+
item.variant.inventory.forEach((i) => {
|
|
507
|
+
ret[`${item.id}-${i.id}`] = "";
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
return ret;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/pages/orders/[id]/allocate-items/index.tsx
|
|
515
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
516
|
+
var Component2 = () => {
|
|
517
|
+
const { id } = useParams();
|
|
518
|
+
const { order, isLoading, isError, error } = useOrder(id, {
|
|
519
|
+
fields: "currency_code,*items,*items.variant,+items.variant.product.title,*items.variant.inventory,*items.variant.inventory.location_levels,*items.variant.inventory_items,*shipping_address"
|
|
520
|
+
});
|
|
521
|
+
if (isError) {
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
524
|
+
const ready = !isLoading && order;
|
|
525
|
+
return /* @__PURE__ */ jsx3(RouteFocusModal, { children: ready && /* @__PURE__ */ jsx3(OrderAllocateItemsForm, { order }) });
|
|
526
|
+
};
|
|
527
|
+
export {
|
|
528
|
+
Component2 as Component
|
|
529
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GeoZoneForm
|
|
3
|
+
} from "./chunk-4TBDDMFP.js";
|
|
4
|
+
import {
|
|
5
|
+
GEO_ZONE_STACKED_MODAL_ID
|
|
6
|
+
} from "./chunk-BCU3FKP2.js";
|
|
7
|
+
import "./chunk-FQERBIVS.js";
|
|
8
|
+
import "./chunk-WHTS4G5K.js";
|
|
9
|
+
import "./chunk-LYUCDASZ.js";
|
|
10
|
+
import "./chunk-KAZ5BYTQ.js";
|
|
11
|
+
import "./chunk-3EF54XFY.js";
|
|
12
|
+
import "./chunk-TKGWSUEI.js";
|
|
13
|
+
import {
|
|
14
|
+
KeyboundForm
|
|
15
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
16
|
+
import {
|
|
17
|
+
RouteFocusModal,
|
|
18
|
+
StackedFocusModal,
|
|
19
|
+
useRouteModal
|
|
20
|
+
} from "./chunk-3CK6OINO.js";
|
|
21
|
+
import "./chunk-3QSRE5LS.js";
|
|
22
|
+
import "./chunk-THHRRYRS.js";
|
|
23
|
+
import "./chunk-CFETU5BI.js";
|
|
24
|
+
import {
|
|
25
|
+
countries
|
|
26
|
+
} from "./chunk-JRTZWK77.js";
|
|
27
|
+
import "./chunk-Y7QKP6QU.js";
|
|
28
|
+
import "./chunk-INNFZYX2.js";
|
|
29
|
+
import {
|
|
30
|
+
useUpdateFulfillmentSetServiceZone
|
|
31
|
+
} from "./chunk-Y4VBOHAP.js";
|
|
32
|
+
import "./chunk-JKXAL7WR.js";
|
|
33
|
+
import {
|
|
34
|
+
useStockLocation
|
|
35
|
+
} from "./chunk-SI4ALL7W.js";
|
|
36
|
+
import "./chunk-RHKRREUU.js";
|
|
37
|
+
import "./chunk-ZA2KFUFR.js";
|
|
38
|
+
import "./chunk-Y224F4UU.js";
|
|
39
|
+
import "./chunk-PKBMQBKP.js";
|
|
40
|
+
|
|
41
|
+
// src/pages/settings/locations/[location_id]/fulfillment-set/[fset_id]/service-zone/[zone_id]/areas/index.tsx
|
|
42
|
+
import { json, useParams } from "react-router-dom";
|
|
43
|
+
|
|
44
|
+
// src/pages/settings/locations/[location_id]/fulfillment-set/[fset_id]/service-zone/[zone_id]/areas/_components/edit-service-zone-areas-form.tsx
|
|
45
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
46
|
+
import { Button, Heading, toast } from "@medusajs/ui";
|
|
47
|
+
import { useForm } from "react-hook-form";
|
|
48
|
+
import { useTranslation } from "react-i18next";
|
|
49
|
+
import { z } from "zod";
|
|
50
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
51
|
+
var EditeServiceZoneSchema = z.object({
|
|
52
|
+
countries: z.array(z.object({ iso_2: z.string().min(2), display_name: z.string() })).min(1)
|
|
53
|
+
});
|
|
54
|
+
function EditServiceZoneAreasForm({
|
|
55
|
+
fulfillmentSetId,
|
|
56
|
+
locationId,
|
|
57
|
+
zone
|
|
58
|
+
}) {
|
|
59
|
+
const { t } = useTranslation();
|
|
60
|
+
const { handleSuccess } = useRouteModal();
|
|
61
|
+
const form = useForm({
|
|
62
|
+
defaultValues: {
|
|
63
|
+
countries: zone.geo_zones.map((z2) => {
|
|
64
|
+
const country = countries.find((c) => c.iso_2 === z2.country_code);
|
|
65
|
+
return {
|
|
66
|
+
iso_2: z2.country_code,
|
|
67
|
+
display_name: country?.display_name || z2.country_code.toUpperCase()
|
|
68
|
+
};
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
resolver: zodResolver(EditeServiceZoneSchema)
|
|
72
|
+
});
|
|
73
|
+
const { mutateAsync: editServiceZone, isPending: isLoading } = useUpdateFulfillmentSetServiceZone(fulfillmentSetId, zone.id);
|
|
74
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
75
|
+
await editServiceZone(
|
|
76
|
+
{
|
|
77
|
+
geo_zones: data.countries.map(({ iso_2 }) => ({
|
|
78
|
+
country_code: iso_2,
|
|
79
|
+
type: "country"
|
|
80
|
+
}))
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
onSuccess: () => {
|
|
84
|
+
toast.success(
|
|
85
|
+
t("stockLocations.serviceZones.manageAreas.successToast", {
|
|
86
|
+
name: zone.name
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
handleSuccess(`/settings/locations/${locationId}`);
|
|
90
|
+
},
|
|
91
|
+
onError: (e) => {
|
|
92
|
+
toast.error(e.message);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
98
|
+
KeyboundForm,
|
|
99
|
+
{
|
|
100
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
101
|
+
onSubmit: handleSubmit,
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
104
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-auto", children: /* @__PURE__ */ jsxs(StackedFocusModal, { id: GEO_ZONE_STACKED_MODAL_ID, children: [
|
|
105
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
106
|
+
/* @__PURE__ */ jsx(Heading, { children: t("stockLocations.serviceZones.manageAreas.header", {
|
|
107
|
+
name: zone.name
|
|
108
|
+
}) }),
|
|
109
|
+
/* @__PURE__ */ jsx(GeoZoneForm, { form })
|
|
110
|
+
] }) }),
|
|
111
|
+
/* @__PURE__ */ jsx(GeoZoneForm.AreaDrawer, { form })
|
|
112
|
+
] }) }),
|
|
113
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: t("actions.cancel") }) }),
|
|
115
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "small", isLoading, children: t("actions.save") })
|
|
116
|
+
] }) })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
) });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/pages/settings/locations/[location_id]/fulfillment-set/[fset_id]/service-zone/[zone_id]/areas/index.tsx
|
|
123
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
124
|
+
var LocationServiceZoneManageAreas = () => {
|
|
125
|
+
const { location_id, fset_id, zone_id } = useParams();
|
|
126
|
+
const { stock_location, isPending, isFetching, isError, error } = useStockLocation(location_id, {
|
|
127
|
+
fields: "*fulfillment_sets.service_zones.geo_zones,fulfillment_sets.service_zones.name"
|
|
128
|
+
});
|
|
129
|
+
const zone = stock_location?.fulfillment_sets?.find((f) => f.id === fset_id)?.service_zones.find((z2) => z2.id === zone_id);
|
|
130
|
+
if (!isPending && !isFetching && !zone) {
|
|
131
|
+
throw json(
|
|
132
|
+
{ message: `Service zone with ID ${zone_id} was not found` },
|
|
133
|
+
404
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (isError) {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
return /* @__PURE__ */ jsx2(RouteFocusModal, { prev: `/settings/locations/${location_id}`, children: zone && /* @__PURE__ */ jsx2(
|
|
140
|
+
EditServiceZoneAreasForm,
|
|
141
|
+
{
|
|
142
|
+
zone,
|
|
143
|
+
fulfillmentSetId: fset_id,
|
|
144
|
+
locationId: location_id
|
|
145
|
+
}
|
|
146
|
+
) });
|
|
147
|
+
};
|
|
148
|
+
var Component = LocationServiceZoneManageAreas;
|
|
149
|
+
export {
|
|
150
|
+
Component
|
|
151
|
+
};
|