@medusajs/draft-order 2.10.4-snapshot-20250927183117 → 2.10.4-snapshot-20250928141742
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/.medusa/server/src/admin/index.js +696 -696
- package/.medusa/server/src/admin/index.mjs +696 -696
- package/package.json +24 -23
|
@@ -11762,584 +11762,108 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11762
11762
|
) });
|
|
11763
11763
|
};
|
|
11764
11764
|
const schema$1 = addressSchema;
|
|
11765
|
-
const
|
|
11765
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11766
|
+
const Shipping = () => {
|
|
11767
|
+
var _a;
|
|
11766
11768
|
const { id } = reactRouterDom.useParams();
|
|
11767
|
-
const {
|
|
11768
|
-
fields: "
|
|
11769
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11770
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11769
11771
|
});
|
|
11772
|
+
const {
|
|
11773
|
+
order: preview,
|
|
11774
|
+
isPending: isPreviewPending,
|
|
11775
|
+
isError: isPreviewError,
|
|
11776
|
+
error: previewError
|
|
11777
|
+
} = useOrderPreview(id);
|
|
11778
|
+
useInitiateOrderEdit({ preview });
|
|
11779
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11770
11780
|
if (isError) {
|
|
11771
11781
|
throw error;
|
|
11772
11782
|
}
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11783
|
+
if (isPreviewError) {
|
|
11784
|
+
throw previewError;
|
|
11785
|
+
}
|
|
11786
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11787
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11788
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11789
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11790
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
11791
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11792
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11793
|
+
] }) }) }),
|
|
11794
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11795
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11796
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11797
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11798
|
+
] }) });
|
|
11781
11799
|
};
|
|
11782
|
-
const
|
|
11783
|
-
var _a
|
|
11784
|
-
const
|
|
11785
|
-
|
|
11786
|
-
|
|
11800
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11801
|
+
var _a;
|
|
11802
|
+
const { setIsOpen } = useStackedModal();
|
|
11803
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11804
|
+
const [data, setData] = React.useState(null);
|
|
11805
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11806
|
+
const { shipping_options } = useShippingOptions(
|
|
11807
|
+
{
|
|
11808
|
+
id: appliedShippingOptionIds,
|
|
11809
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11787
11810
|
},
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11811
|
+
{
|
|
11812
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11813
|
+
}
|
|
11814
|
+
);
|
|
11815
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11816
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11817
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11818
|
+
profiles.set(profile.id, profile);
|
|
11819
|
+
});
|
|
11820
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11821
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11822
|
+
});
|
|
11823
|
+
return Array.from(profiles.values());
|
|
11824
|
+
}, [order.items, shipping_options]);
|
|
11791
11825
|
const { handleSuccess } = useRouteModal();
|
|
11792
|
-
const
|
|
11793
|
-
const
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
{
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
onError: (error) => {
|
|
11806
|
-
ui.toast.error(error.message);
|
|
11807
|
-
}
|
|
11826
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11827
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11828
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11829
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11830
|
+
const onSubmit = async () => {
|
|
11831
|
+
setIsSubmitting(true);
|
|
11832
|
+
let requestSucceeded = false;
|
|
11833
|
+
await requestOrderEdit(void 0, {
|
|
11834
|
+
onError: (e) => {
|
|
11835
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11836
|
+
},
|
|
11837
|
+
onSuccess: () => {
|
|
11838
|
+
requestSucceeded = true;
|
|
11808
11839
|
}
|
|
11809
|
-
);
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
{
|
|
11814
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11815
|
-
onSubmit,
|
|
11816
|
-
children: [
|
|
11817
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
11818
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
11819
|
-
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
11820
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11821
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
11822
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
11823
|
-
] }),
|
|
11824
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
11825
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
11826
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
11827
|
-
] })
|
|
11828
|
-
] }),
|
|
11829
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11830
|
-
CustomerField,
|
|
11831
|
-
{
|
|
11832
|
-
control: form.control,
|
|
11833
|
-
currentCustomerId: order.customer_id
|
|
11834
|
-
}
|
|
11835
|
-
)
|
|
11836
|
-
] }),
|
|
11837
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11838
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
11839
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11840
|
-
] }) })
|
|
11841
|
-
]
|
|
11840
|
+
});
|
|
11841
|
+
if (!requestSucceeded) {
|
|
11842
|
+
setIsSubmitting(false);
|
|
11843
|
+
return;
|
|
11842
11844
|
}
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
11845
|
+
await confirmOrderEdit(void 0, {
|
|
11846
|
+
onError: (e) => {
|
|
11847
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11848
|
+
},
|
|
11849
|
+
onSuccess: () => {
|
|
11850
|
+
handleSuccess();
|
|
11851
|
+
},
|
|
11852
|
+
onSettled: () => {
|
|
11853
|
+
setIsSubmitting(false);
|
|
11854
|
+
}
|
|
11855
|
+
});
|
|
11856
|
+
};
|
|
11857
|
+
const onKeydown = React.useCallback(
|
|
11858
|
+
(e) => {
|
|
11859
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11860
|
+
if (data || isSubmitting) {
|
|
11861
|
+
return;
|
|
11862
|
+
}
|
|
11863
|
+
onSubmit();
|
|
11864
|
+
}
|
|
11852
11865
|
},
|
|
11853
|
-
|
|
11854
|
-
getOptions: (data) => {
|
|
11855
|
-
return data.customers.map((customer) => {
|
|
11856
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
11857
|
-
return {
|
|
11858
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
11859
|
-
value: customer.id
|
|
11860
|
-
};
|
|
11861
|
-
});
|
|
11862
|
-
}
|
|
11863
|
-
});
|
|
11864
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11865
|
-
Form$2.Field,
|
|
11866
|
-
{
|
|
11867
|
-
name: "customer_id",
|
|
11868
|
-
control,
|
|
11869
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
11870
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11871
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
11872
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
11873
|
-
] }),
|
|
11874
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11875
|
-
Combobox,
|
|
11876
|
-
{
|
|
11877
|
-
options: customers.options,
|
|
11878
|
-
fetchNextPage: customers.fetchNextPage,
|
|
11879
|
-
isFetchingNextPage: customers.isFetchingNextPage,
|
|
11880
|
-
searchValue: customers.searchValue,
|
|
11881
|
-
onSearchValueChange: customers.onSearchValueChange,
|
|
11882
|
-
placeholder: "Select customer",
|
|
11883
|
-
...field
|
|
11884
|
-
}
|
|
11885
|
-
) }),
|
|
11886
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11887
|
-
] })
|
|
11888
|
-
}
|
|
11889
|
-
);
|
|
11890
|
-
};
|
|
11891
|
-
const Illustration = () => {
|
|
11892
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11893
|
-
"svg",
|
|
11894
|
-
{
|
|
11895
|
-
width: "280",
|
|
11896
|
-
height: "180",
|
|
11897
|
-
viewBox: "0 0 280 180",
|
|
11898
|
-
fill: "none",
|
|
11899
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
11900
|
-
children: [
|
|
11901
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11902
|
-
"rect",
|
|
11903
|
-
{
|
|
11904
|
-
x: "0.00428286",
|
|
11905
|
-
y: "-0.742904",
|
|
11906
|
-
width: "33.5",
|
|
11907
|
-
height: "65.5",
|
|
11908
|
-
rx: "6.75",
|
|
11909
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
11910
|
-
fill: "#D4D4D8",
|
|
11911
|
-
stroke: "#52525B",
|
|
11912
|
-
strokeWidth: "1.5"
|
|
11913
|
-
}
|
|
11914
|
-
),
|
|
11915
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11916
|
-
"rect",
|
|
11917
|
-
{
|
|
11918
|
-
x: "0.00428286",
|
|
11919
|
-
y: "-0.742904",
|
|
11920
|
-
width: "33.5",
|
|
11921
|
-
height: "65.5",
|
|
11922
|
-
rx: "6.75",
|
|
11923
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
11924
|
-
fill: "white",
|
|
11925
|
-
stroke: "#52525B",
|
|
11926
|
-
strokeWidth: "1.5"
|
|
11927
|
-
}
|
|
11928
|
-
),
|
|
11929
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11930
|
-
"path",
|
|
11931
|
-
{
|
|
11932
|
-
d: "M180.579 107.142L179.126 107.959",
|
|
11933
|
-
stroke: "#52525B",
|
|
11934
|
-
strokeWidth: "1.5",
|
|
11935
|
-
strokeLinecap: "round",
|
|
11936
|
-
strokeLinejoin: "round"
|
|
11937
|
-
}
|
|
11938
|
-
),
|
|
11939
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11940
|
-
"path",
|
|
11941
|
-
{
|
|
11942
|
-
opacity: "0.88",
|
|
11943
|
-
d: "M182.305 109.546L180.257 109.534",
|
|
11944
|
-
stroke: "#52525B",
|
|
11945
|
-
strokeWidth: "1.5",
|
|
11946
|
-
strokeLinecap: "round",
|
|
11947
|
-
strokeLinejoin: "round"
|
|
11948
|
-
}
|
|
11949
|
-
),
|
|
11950
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11951
|
-
"path",
|
|
11952
|
-
{
|
|
11953
|
-
opacity: "0.75",
|
|
11954
|
-
d: "M180.551 111.93L179.108 111.096",
|
|
11955
|
-
stroke: "#52525B",
|
|
11956
|
-
strokeWidth: "1.5",
|
|
11957
|
-
strokeLinecap: "round",
|
|
11958
|
-
strokeLinejoin: "round"
|
|
11959
|
-
}
|
|
11960
|
-
),
|
|
11961
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11962
|
-
"path",
|
|
11963
|
-
{
|
|
11964
|
-
opacity: "0.63",
|
|
11965
|
-
d: "M176.347 112.897L176.354 111.73",
|
|
11966
|
-
stroke: "#52525B",
|
|
11967
|
-
strokeWidth: "1.5",
|
|
11968
|
-
strokeLinecap: "round",
|
|
11969
|
-
strokeLinejoin: "round"
|
|
11970
|
-
}
|
|
11971
|
-
),
|
|
11972
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11973
|
-
"path",
|
|
11974
|
-
{
|
|
11975
|
-
opacity: "0.5",
|
|
11976
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
11977
|
-
stroke: "#52525B",
|
|
11978
|
-
strokeWidth: "1.5",
|
|
11979
|
-
strokeLinecap: "round",
|
|
11980
|
-
strokeLinejoin: "round"
|
|
11981
|
-
}
|
|
11982
|
-
),
|
|
11983
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11984
|
-
"path",
|
|
11985
|
-
{
|
|
11986
|
-
opacity: "0.38",
|
|
11987
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
11988
|
-
stroke: "#52525B",
|
|
11989
|
-
strokeWidth: "1.5",
|
|
11990
|
-
strokeLinecap: "round",
|
|
11991
|
-
strokeLinejoin: "round"
|
|
11992
|
-
}
|
|
11993
|
-
),
|
|
11994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11995
|
-
"path",
|
|
11996
|
-
{
|
|
11997
|
-
opacity: "0.25",
|
|
11998
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
11999
|
-
stroke: "#52525B",
|
|
12000
|
-
strokeWidth: "1.5",
|
|
12001
|
-
strokeLinecap: "round",
|
|
12002
|
-
strokeLinejoin: "round"
|
|
12003
|
-
}
|
|
12004
|
-
),
|
|
12005
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12006
|
-
"path",
|
|
12007
|
-
{
|
|
12008
|
-
opacity: "0.13",
|
|
12009
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
12010
|
-
stroke: "#52525B",
|
|
12011
|
-
strokeWidth: "1.5",
|
|
12012
|
-
strokeLinecap: "round",
|
|
12013
|
-
strokeLinejoin: "round"
|
|
12014
|
-
}
|
|
12015
|
-
),
|
|
12016
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12017
|
-
"rect",
|
|
12018
|
-
{
|
|
12019
|
-
width: "12",
|
|
12020
|
-
height: "3",
|
|
12021
|
-
rx: "1.5",
|
|
12022
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12023
|
-
fill: "#D4D4D8"
|
|
12024
|
-
}
|
|
12025
|
-
),
|
|
12026
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12027
|
-
"rect",
|
|
12028
|
-
{
|
|
12029
|
-
x: "0.00428286",
|
|
12030
|
-
y: "-0.742904",
|
|
12031
|
-
width: "33.5",
|
|
12032
|
-
height: "65.5",
|
|
12033
|
-
rx: "6.75",
|
|
12034
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12035
|
-
fill: "#D4D4D8",
|
|
12036
|
-
stroke: "#52525B",
|
|
12037
|
-
strokeWidth: "1.5"
|
|
12038
|
-
}
|
|
12039
|
-
),
|
|
12040
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12041
|
-
"rect",
|
|
12042
|
-
{
|
|
12043
|
-
x: "0.00428286",
|
|
12044
|
-
y: "-0.742904",
|
|
12045
|
-
width: "33.5",
|
|
12046
|
-
height: "65.5",
|
|
12047
|
-
rx: "6.75",
|
|
12048
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12049
|
-
fill: "white",
|
|
12050
|
-
stroke: "#52525B",
|
|
12051
|
-
strokeWidth: "1.5"
|
|
12052
|
-
}
|
|
12053
|
-
),
|
|
12054
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12055
|
-
"rect",
|
|
12056
|
-
{
|
|
12057
|
-
width: "12",
|
|
12058
|
-
height: "3",
|
|
12059
|
-
rx: "1.5",
|
|
12060
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12061
|
-
fill: "#D4D4D8"
|
|
12062
|
-
}
|
|
12063
|
-
),
|
|
12064
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12065
|
-
"rect",
|
|
12066
|
-
{
|
|
12067
|
-
width: "17",
|
|
12068
|
-
height: "3",
|
|
12069
|
-
rx: "1.5",
|
|
12070
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12071
|
-
fill: "#D4D4D8"
|
|
12072
|
-
}
|
|
12073
|
-
),
|
|
12074
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12075
|
-
"rect",
|
|
12076
|
-
{
|
|
12077
|
-
width: "12",
|
|
12078
|
-
height: "3",
|
|
12079
|
-
rx: "1.5",
|
|
12080
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12081
|
-
fill: "#D4D4D8"
|
|
12082
|
-
}
|
|
12083
|
-
),
|
|
12084
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12085
|
-
"path",
|
|
12086
|
-
{
|
|
12087
|
-
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
12088
|
-
fill: "#A1A1AA"
|
|
12089
|
-
}
|
|
12090
|
-
),
|
|
12091
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12092
|
-
"rect",
|
|
12093
|
-
{
|
|
12094
|
-
width: "17",
|
|
12095
|
-
height: "3",
|
|
12096
|
-
rx: "1.5",
|
|
12097
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12098
|
-
fill: "#A1A1AA"
|
|
12099
|
-
}
|
|
12100
|
-
),
|
|
12101
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12102
|
-
"rect",
|
|
12103
|
-
{
|
|
12104
|
-
width: "12",
|
|
12105
|
-
height: "3",
|
|
12106
|
-
rx: "1.5",
|
|
12107
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12108
|
-
fill: "#A1A1AA"
|
|
12109
|
-
}
|
|
12110
|
-
),
|
|
12111
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12112
|
-
"path",
|
|
12113
|
-
{
|
|
12114
|
-
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12115
|
-
fill: "#52525B"
|
|
12116
|
-
}
|
|
12117
|
-
),
|
|
12118
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12119
|
-
"path",
|
|
12120
|
-
{
|
|
12121
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12122
|
-
stroke: "#A1A1AA",
|
|
12123
|
-
strokeWidth: "1.5",
|
|
12124
|
-
strokeLinecap: "round",
|
|
12125
|
-
strokeLinejoin: "round"
|
|
12126
|
-
}
|
|
12127
|
-
) }),
|
|
12128
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12129
|
-
"path",
|
|
12130
|
-
{
|
|
12131
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12132
|
-
stroke: "#A1A1AA",
|
|
12133
|
-
strokeWidth: "1.5",
|
|
12134
|
-
strokeLinecap: "round",
|
|
12135
|
-
strokeLinejoin: "round"
|
|
12136
|
-
}
|
|
12137
|
-
) }),
|
|
12138
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12139
|
-
"path",
|
|
12140
|
-
{
|
|
12141
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12142
|
-
stroke: "#A1A1AA",
|
|
12143
|
-
strokeWidth: "1.5",
|
|
12144
|
-
strokeLinecap: "round",
|
|
12145
|
-
strokeLinejoin: "round"
|
|
12146
|
-
}
|
|
12147
|
-
) }),
|
|
12148
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12149
|
-
"path",
|
|
12150
|
-
{
|
|
12151
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12152
|
-
stroke: "#A1A1AA",
|
|
12153
|
-
strokeWidth: "1.5",
|
|
12154
|
-
strokeLinecap: "round",
|
|
12155
|
-
strokeLinejoin: "round"
|
|
12156
|
-
}
|
|
12157
|
-
) }),
|
|
12158
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12159
|
-
"path",
|
|
12160
|
-
{
|
|
12161
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12162
|
-
stroke: "#A1A1AA",
|
|
12163
|
-
strokeWidth: "1.5",
|
|
12164
|
-
strokeLinecap: "round",
|
|
12165
|
-
strokeLinejoin: "round"
|
|
12166
|
-
}
|
|
12167
|
-
) }),
|
|
12168
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12169
|
-
"path",
|
|
12170
|
-
{
|
|
12171
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12172
|
-
stroke: "#A1A1AA",
|
|
12173
|
-
strokeWidth: "1.5",
|
|
12174
|
-
strokeLinecap: "round",
|
|
12175
|
-
strokeLinejoin: "round"
|
|
12176
|
-
}
|
|
12177
|
-
) }),
|
|
12178
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12179
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12180
|
-
"rect",
|
|
12181
|
-
{
|
|
12182
|
-
width: "12",
|
|
12183
|
-
height: "12",
|
|
12184
|
-
fill: "white",
|
|
12185
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12186
|
-
}
|
|
12187
|
-
) }),
|
|
12188
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12189
|
-
"rect",
|
|
12190
|
-
{
|
|
12191
|
-
width: "12",
|
|
12192
|
-
height: "12",
|
|
12193
|
-
fill: "white",
|
|
12194
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12195
|
-
}
|
|
12196
|
-
) }),
|
|
12197
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12198
|
-
"rect",
|
|
12199
|
-
{
|
|
12200
|
-
width: "12",
|
|
12201
|
-
height: "12",
|
|
12202
|
-
fill: "white",
|
|
12203
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12204
|
-
}
|
|
12205
|
-
) }),
|
|
12206
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12207
|
-
"rect",
|
|
12208
|
-
{
|
|
12209
|
-
width: "12",
|
|
12210
|
-
height: "12",
|
|
12211
|
-
fill: "white",
|
|
12212
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12213
|
-
}
|
|
12214
|
-
) }),
|
|
12215
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12216
|
-
"rect",
|
|
12217
|
-
{
|
|
12218
|
-
width: "12",
|
|
12219
|
-
height: "12",
|
|
12220
|
-
fill: "white",
|
|
12221
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12222
|
-
}
|
|
12223
|
-
) }),
|
|
12224
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12225
|
-
"rect",
|
|
12226
|
-
{
|
|
12227
|
-
width: "12",
|
|
12228
|
-
height: "12",
|
|
12229
|
-
fill: "white",
|
|
12230
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12231
|
-
}
|
|
12232
|
-
) })
|
|
12233
|
-
] })
|
|
12234
|
-
]
|
|
12235
|
-
}
|
|
12236
|
-
);
|
|
12237
|
-
};
|
|
12238
|
-
const schema = objectType({
|
|
12239
|
-
customer_id: stringType().min(1)
|
|
12240
|
-
});
|
|
12241
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12242
|
-
const Shipping = () => {
|
|
12243
|
-
var _a;
|
|
12244
|
-
const { id } = reactRouterDom.useParams();
|
|
12245
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12246
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
12247
|
-
});
|
|
12248
|
-
const {
|
|
12249
|
-
order: preview,
|
|
12250
|
-
isPending: isPreviewPending,
|
|
12251
|
-
isError: isPreviewError,
|
|
12252
|
-
error: previewError
|
|
12253
|
-
} = useOrderPreview(id);
|
|
12254
|
-
useInitiateOrderEdit({ preview });
|
|
12255
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12256
|
-
if (isError) {
|
|
12257
|
-
throw error;
|
|
12258
|
-
}
|
|
12259
|
-
if (isPreviewError) {
|
|
12260
|
-
throw previewError;
|
|
12261
|
-
}
|
|
12262
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
12263
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
12264
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
12265
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
12266
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
12267
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
12268
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
12269
|
-
] }) }) }),
|
|
12270
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
12271
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12272
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
12273
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
12274
|
-
] }) });
|
|
12275
|
-
};
|
|
12276
|
-
const ShippingForm = ({ preview, order }) => {
|
|
12277
|
-
var _a;
|
|
12278
|
-
const { setIsOpen } = useStackedModal();
|
|
12279
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
12280
|
-
const [data, setData] = React.useState(null);
|
|
12281
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
12282
|
-
const { shipping_options } = useShippingOptions(
|
|
12283
|
-
{
|
|
12284
|
-
id: appliedShippingOptionIds,
|
|
12285
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
12286
|
-
},
|
|
12287
|
-
{
|
|
12288
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
12289
|
-
}
|
|
12290
|
-
);
|
|
12291
|
-
const uniqueShippingProfiles = React.useMemo(() => {
|
|
12292
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
12293
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
12294
|
-
profiles.set(profile.id, profile);
|
|
12295
|
-
});
|
|
12296
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
12297
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
12298
|
-
});
|
|
12299
|
-
return Array.from(profiles.values());
|
|
12300
|
-
}, [order.items, shipping_options]);
|
|
12301
|
-
const { handleSuccess } = useRouteModal();
|
|
12302
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12303
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
12304
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
12305
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
12306
|
-
const onSubmit = async () => {
|
|
12307
|
-
setIsSubmitting(true);
|
|
12308
|
-
let requestSucceeded = false;
|
|
12309
|
-
await requestOrderEdit(void 0, {
|
|
12310
|
-
onError: (e) => {
|
|
12311
|
-
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
12312
|
-
},
|
|
12313
|
-
onSuccess: () => {
|
|
12314
|
-
requestSucceeded = true;
|
|
12315
|
-
}
|
|
12316
|
-
});
|
|
12317
|
-
if (!requestSucceeded) {
|
|
12318
|
-
setIsSubmitting(false);
|
|
12319
|
-
return;
|
|
12320
|
-
}
|
|
12321
|
-
await confirmOrderEdit(void 0, {
|
|
12322
|
-
onError: (e) => {
|
|
12323
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
12324
|
-
},
|
|
12325
|
-
onSuccess: () => {
|
|
12326
|
-
handleSuccess();
|
|
12327
|
-
},
|
|
12328
|
-
onSettled: () => {
|
|
12329
|
-
setIsSubmitting(false);
|
|
12330
|
-
}
|
|
12331
|
-
});
|
|
12332
|
-
};
|
|
12333
|
-
const onKeydown = React.useCallback(
|
|
12334
|
-
(e) => {
|
|
12335
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
12336
|
-
if (data || isSubmitting) {
|
|
12337
|
-
return;
|
|
12338
|
-
}
|
|
12339
|
-
onSubmit();
|
|
12340
|
-
}
|
|
12341
|
-
},
|
|
12342
|
-
[data, isSubmitting, onSubmit]
|
|
11866
|
+
[data, isSubmitting, onSubmit]
|
|
12343
11867
|
);
|
|
12344
11868
|
React.useEffect(() => {
|
|
12345
11869
|
document.addEventListener("keydown", onKeydown);
|
|
@@ -12902,149 +12426,625 @@ const LocationField = ({ control, setValue }) => {
|
|
|
12902
12426
|
const locations = useComboboxData({
|
|
12903
12427
|
queryKey: ["locations"],
|
|
12904
12428
|
queryFn: async (params) => {
|
|
12905
|
-
return await sdk.admin.stockLocation.list(params);
|
|
12429
|
+
return await sdk.admin.stockLocation.list(params);
|
|
12430
|
+
},
|
|
12431
|
+
getOptions: (data) => {
|
|
12432
|
+
return data.stock_locations.map((location) => ({
|
|
12433
|
+
label: location.name,
|
|
12434
|
+
value: location.id
|
|
12435
|
+
}));
|
|
12436
|
+
}
|
|
12437
|
+
});
|
|
12438
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12439
|
+
Form$2.Field,
|
|
12440
|
+
{
|
|
12441
|
+
control,
|
|
12442
|
+
name: "location_id",
|
|
12443
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12444
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12446
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
12447
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12448
|
+
] }),
|
|
12449
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12450
|
+
Combobox,
|
|
12451
|
+
{
|
|
12452
|
+
options: locations.options,
|
|
12453
|
+
fetchNextPage: locations.fetchNextPage,
|
|
12454
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
12455
|
+
searchValue: locations.searchValue,
|
|
12456
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
12457
|
+
placeholder: "Select location",
|
|
12458
|
+
onChange: (value) => {
|
|
12459
|
+
setValue("shipping_option_id", "", {
|
|
12460
|
+
shouldDirty: true,
|
|
12461
|
+
shouldTouch: true
|
|
12462
|
+
});
|
|
12463
|
+
onChange(value);
|
|
12464
|
+
},
|
|
12465
|
+
...field
|
|
12466
|
+
}
|
|
12467
|
+
) })
|
|
12468
|
+
] }) });
|
|
12469
|
+
}
|
|
12470
|
+
}
|
|
12471
|
+
);
|
|
12472
|
+
};
|
|
12473
|
+
const ShippingOptionField = ({
|
|
12474
|
+
shippingProfileId,
|
|
12475
|
+
preview,
|
|
12476
|
+
control
|
|
12477
|
+
}) => {
|
|
12478
|
+
var _a;
|
|
12479
|
+
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12480
|
+
const shippingOptions = useComboboxData({
|
|
12481
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12482
|
+
queryFn: async (params) => {
|
|
12483
|
+
return await sdk.admin.shippingOption.list({
|
|
12484
|
+
...params,
|
|
12485
|
+
stock_location_id: locationId,
|
|
12486
|
+
shipping_profile_id: shippingProfileId
|
|
12487
|
+
});
|
|
12488
|
+
},
|
|
12489
|
+
getOptions: (data) => {
|
|
12490
|
+
return data.shipping_options.map((option) => {
|
|
12491
|
+
var _a2;
|
|
12492
|
+
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12493
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12494
|
+
)) {
|
|
12495
|
+
return void 0;
|
|
12496
|
+
}
|
|
12497
|
+
return {
|
|
12498
|
+
label: option.name,
|
|
12499
|
+
value: option.id
|
|
12500
|
+
};
|
|
12501
|
+
}).filter(Boolean);
|
|
12502
|
+
},
|
|
12503
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
12504
|
+
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12505
|
+
});
|
|
12506
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12507
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12508
|
+
Form$2.Field,
|
|
12509
|
+
{
|
|
12510
|
+
control,
|
|
12511
|
+
name: "shipping_option_id",
|
|
12512
|
+
render: ({ field }) => {
|
|
12513
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12514
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12515
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12516
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12517
|
+
] }),
|
|
12518
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12519
|
+
ConditionalTooltip,
|
|
12520
|
+
{
|
|
12521
|
+
content: tooltipContent,
|
|
12522
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
12523
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12524
|
+
Combobox,
|
|
12525
|
+
{
|
|
12526
|
+
options: shippingOptions.options,
|
|
12527
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
12528
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12529
|
+
searchValue: shippingOptions.searchValue,
|
|
12530
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
12531
|
+
placeholder: "Select shipping option",
|
|
12532
|
+
...field,
|
|
12533
|
+
disabled: !locationId || !shippingProfileId
|
|
12534
|
+
}
|
|
12535
|
+
) }) })
|
|
12536
|
+
}
|
|
12537
|
+
)
|
|
12538
|
+
] }) });
|
|
12539
|
+
}
|
|
12540
|
+
}
|
|
12541
|
+
);
|
|
12542
|
+
};
|
|
12543
|
+
const CustomAmountField = ({
|
|
12544
|
+
control,
|
|
12545
|
+
currencyCode
|
|
12546
|
+
}) => {
|
|
12547
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12548
|
+
Form$2.Field,
|
|
12549
|
+
{
|
|
12550
|
+
control,
|
|
12551
|
+
name: "custom_amount",
|
|
12552
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12553
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12554
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12555
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
12556
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
12557
|
+
] }),
|
|
12558
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12559
|
+
ui.CurrencyInput,
|
|
12560
|
+
{
|
|
12561
|
+
...field,
|
|
12562
|
+
onValueChange: (value) => onChange(value),
|
|
12563
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12564
|
+
code: currencyCode
|
|
12565
|
+
}
|
|
12566
|
+
) })
|
|
12567
|
+
] });
|
|
12568
|
+
}
|
|
12569
|
+
}
|
|
12570
|
+
);
|
|
12571
|
+
};
|
|
12572
|
+
const TransferOwnership = () => {
|
|
12573
|
+
const { id } = reactRouterDom.useParams();
|
|
12574
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12575
|
+
fields: "id,customer_id,customer.*"
|
|
12576
|
+
});
|
|
12577
|
+
if (isError) {
|
|
12578
|
+
throw error;
|
|
12579
|
+
}
|
|
12580
|
+
const isReady = !isPending && !!draft_order;
|
|
12581
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12582
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12583
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
12584
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12585
|
+
] }),
|
|
12586
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12587
|
+
] });
|
|
12588
|
+
};
|
|
12589
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12590
|
+
var _a, _b;
|
|
12591
|
+
const form = reactHookForm.useForm({
|
|
12592
|
+
defaultValues: {
|
|
12593
|
+
customer_id: order.customer_id || ""
|
|
12594
|
+
},
|
|
12595
|
+
resolver: zod.zodResolver(schema)
|
|
12596
|
+
});
|
|
12597
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12598
|
+
const { handleSuccess } = useRouteModal();
|
|
12599
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12600
|
+
const currentCustomer = order.customer ? {
|
|
12601
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12602
|
+
value: order.customer.id
|
|
12603
|
+
} : null;
|
|
12604
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12605
|
+
await mutateAsync(
|
|
12606
|
+
{ customer_id: data.customer_id },
|
|
12607
|
+
{
|
|
12608
|
+
onSuccess: () => {
|
|
12609
|
+
ui.toast.success("Customer updated");
|
|
12610
|
+
handleSuccess();
|
|
12611
|
+
},
|
|
12612
|
+
onError: (error) => {
|
|
12613
|
+
ui.toast.error(error.message);
|
|
12614
|
+
}
|
|
12615
|
+
}
|
|
12616
|
+
);
|
|
12617
|
+
});
|
|
12618
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12619
|
+
KeyboundForm,
|
|
12620
|
+
{
|
|
12621
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12622
|
+
onSubmit,
|
|
12623
|
+
children: [
|
|
12624
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12625
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
12626
|
+
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12627
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12628
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12629
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
12630
|
+
] }),
|
|
12631
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12632
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
12633
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12634
|
+
] })
|
|
12635
|
+
] }),
|
|
12636
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12637
|
+
CustomerField,
|
|
12638
|
+
{
|
|
12639
|
+
control: form.control,
|
|
12640
|
+
currentCustomerId: order.customer_id
|
|
12641
|
+
}
|
|
12642
|
+
)
|
|
12643
|
+
] }),
|
|
12644
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12645
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12646
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12647
|
+
] }) })
|
|
12648
|
+
]
|
|
12649
|
+
}
|
|
12650
|
+
) });
|
|
12651
|
+
};
|
|
12652
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12653
|
+
const customers = useComboboxData({
|
|
12654
|
+
queryFn: async (params) => {
|
|
12655
|
+
return await sdk.admin.customer.list({
|
|
12656
|
+
...params,
|
|
12657
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12658
|
+
});
|
|
12906
12659
|
},
|
|
12660
|
+
queryKey: ["customers"],
|
|
12907
12661
|
getOptions: (data) => {
|
|
12908
|
-
return data.
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12662
|
+
return data.customers.map((customer) => {
|
|
12663
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12664
|
+
return {
|
|
12665
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12666
|
+
value: customer.id
|
|
12667
|
+
};
|
|
12668
|
+
});
|
|
12912
12669
|
}
|
|
12913
12670
|
});
|
|
12914
12671
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12915
12672
|
Form$2.Field,
|
|
12916
12673
|
{
|
|
12674
|
+
name: "customer_id",
|
|
12917
12675
|
control,
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12676
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12677
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12678
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
12679
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
12680
|
+
] }),
|
|
12681
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12682
|
+
Combobox,
|
|
12683
|
+
{
|
|
12684
|
+
options: customers.options,
|
|
12685
|
+
fetchNextPage: customers.fetchNextPage,
|
|
12686
|
+
isFetchingNextPage: customers.isFetchingNextPage,
|
|
12687
|
+
searchValue: customers.searchValue,
|
|
12688
|
+
onSearchValueChange: customers.onSearchValueChange,
|
|
12689
|
+
placeholder: "Select customer",
|
|
12690
|
+
...field
|
|
12691
|
+
}
|
|
12692
|
+
) }),
|
|
12693
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12694
|
+
] })
|
|
12695
|
+
}
|
|
12696
|
+
);
|
|
12697
|
+
};
|
|
12698
|
+
const Illustration = () => {
|
|
12699
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12700
|
+
"svg",
|
|
12701
|
+
{
|
|
12702
|
+
width: "280",
|
|
12703
|
+
height: "180",
|
|
12704
|
+
viewBox: "0 0 280 180",
|
|
12705
|
+
fill: "none",
|
|
12706
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12707
|
+
children: [
|
|
12708
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12709
|
+
"rect",
|
|
12710
|
+
{
|
|
12711
|
+
x: "0.00428286",
|
|
12712
|
+
y: "-0.742904",
|
|
12713
|
+
width: "33.5",
|
|
12714
|
+
height: "65.5",
|
|
12715
|
+
rx: "6.75",
|
|
12716
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
12717
|
+
fill: "#D4D4D8",
|
|
12718
|
+
stroke: "#52525B",
|
|
12719
|
+
strokeWidth: "1.5"
|
|
12720
|
+
}
|
|
12721
|
+
),
|
|
12722
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12723
|
+
"rect",
|
|
12724
|
+
{
|
|
12725
|
+
x: "0.00428286",
|
|
12726
|
+
y: "-0.742904",
|
|
12727
|
+
width: "33.5",
|
|
12728
|
+
height: "65.5",
|
|
12729
|
+
rx: "6.75",
|
|
12730
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
12731
|
+
fill: "white",
|
|
12732
|
+
stroke: "#52525B",
|
|
12733
|
+
strokeWidth: "1.5"
|
|
12734
|
+
}
|
|
12735
|
+
),
|
|
12736
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12737
|
+
"path",
|
|
12738
|
+
{
|
|
12739
|
+
d: "M180.579 107.142L179.126 107.959",
|
|
12740
|
+
stroke: "#52525B",
|
|
12741
|
+
strokeWidth: "1.5",
|
|
12742
|
+
strokeLinecap: "round",
|
|
12743
|
+
strokeLinejoin: "round"
|
|
12744
|
+
}
|
|
12745
|
+
),
|
|
12746
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12747
|
+
"path",
|
|
12748
|
+
{
|
|
12749
|
+
opacity: "0.88",
|
|
12750
|
+
d: "M182.305 109.546L180.257 109.534",
|
|
12751
|
+
stroke: "#52525B",
|
|
12752
|
+
strokeWidth: "1.5",
|
|
12753
|
+
strokeLinecap: "round",
|
|
12754
|
+
strokeLinejoin: "round"
|
|
12755
|
+
}
|
|
12756
|
+
),
|
|
12757
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12758
|
+
"path",
|
|
12759
|
+
{
|
|
12760
|
+
opacity: "0.75",
|
|
12761
|
+
d: "M180.551 111.93L179.108 111.096",
|
|
12762
|
+
stroke: "#52525B",
|
|
12763
|
+
strokeWidth: "1.5",
|
|
12764
|
+
strokeLinecap: "round",
|
|
12765
|
+
strokeLinejoin: "round"
|
|
12766
|
+
}
|
|
12767
|
+
),
|
|
12768
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12769
|
+
"path",
|
|
12770
|
+
{
|
|
12771
|
+
opacity: "0.63",
|
|
12772
|
+
d: "M176.347 112.897L176.354 111.73",
|
|
12773
|
+
stroke: "#52525B",
|
|
12774
|
+
strokeWidth: "1.5",
|
|
12775
|
+
strokeLinecap: "round",
|
|
12776
|
+
strokeLinejoin: "round"
|
|
12777
|
+
}
|
|
12778
|
+
),
|
|
12779
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12780
|
+
"path",
|
|
12781
|
+
{
|
|
12782
|
+
opacity: "0.5",
|
|
12783
|
+
d: "M172.153 111.881L173.606 111.064",
|
|
12784
|
+
stroke: "#52525B",
|
|
12785
|
+
strokeWidth: "1.5",
|
|
12786
|
+
strokeLinecap: "round",
|
|
12787
|
+
strokeLinejoin: "round"
|
|
12788
|
+
}
|
|
12789
|
+
),
|
|
12790
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12791
|
+
"path",
|
|
12792
|
+
{
|
|
12793
|
+
opacity: "0.38",
|
|
12794
|
+
d: "M170.428 109.478L172.476 109.489",
|
|
12795
|
+
stroke: "#52525B",
|
|
12796
|
+
strokeWidth: "1.5",
|
|
12797
|
+
strokeLinecap: "round",
|
|
12798
|
+
strokeLinejoin: "round"
|
|
12799
|
+
}
|
|
12800
|
+
),
|
|
12801
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12802
|
+
"path",
|
|
12803
|
+
{
|
|
12804
|
+
opacity: "0.25",
|
|
12805
|
+
d: "M172.181 107.094L173.624 107.928",
|
|
12806
|
+
stroke: "#52525B",
|
|
12807
|
+
strokeWidth: "1.5",
|
|
12808
|
+
strokeLinecap: "round",
|
|
12809
|
+
strokeLinejoin: "round"
|
|
12810
|
+
}
|
|
12811
|
+
),
|
|
12812
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12813
|
+
"path",
|
|
12814
|
+
{
|
|
12815
|
+
opacity: "0.13",
|
|
12816
|
+
d: "M176.386 106.126L176.379 107.294",
|
|
12817
|
+
stroke: "#52525B",
|
|
12818
|
+
strokeWidth: "1.5",
|
|
12819
|
+
strokeLinecap: "round",
|
|
12820
|
+
strokeLinejoin: "round"
|
|
12821
|
+
}
|
|
12822
|
+
),
|
|
12823
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12824
|
+
"rect",
|
|
12825
|
+
{
|
|
12826
|
+
width: "12",
|
|
12827
|
+
height: "3",
|
|
12828
|
+
rx: "1.5",
|
|
12829
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12830
|
+
fill: "#D4D4D8"
|
|
12831
|
+
}
|
|
12832
|
+
),
|
|
12833
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12834
|
+
"rect",
|
|
12835
|
+
{
|
|
12836
|
+
x: "0.00428286",
|
|
12837
|
+
y: "-0.742904",
|
|
12838
|
+
width: "33.5",
|
|
12839
|
+
height: "65.5",
|
|
12840
|
+
rx: "6.75",
|
|
12841
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12842
|
+
fill: "#D4D4D8",
|
|
12843
|
+
stroke: "#52525B",
|
|
12844
|
+
strokeWidth: "1.5"
|
|
12845
|
+
}
|
|
12846
|
+
),
|
|
12847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12848
|
+
"rect",
|
|
12849
|
+
{
|
|
12850
|
+
x: "0.00428286",
|
|
12851
|
+
y: "-0.742904",
|
|
12852
|
+
width: "33.5",
|
|
12853
|
+
height: "65.5",
|
|
12854
|
+
rx: "6.75",
|
|
12855
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12856
|
+
fill: "white",
|
|
12857
|
+
stroke: "#52525B",
|
|
12858
|
+
strokeWidth: "1.5"
|
|
12859
|
+
}
|
|
12860
|
+
),
|
|
12861
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12862
|
+
"rect",
|
|
12863
|
+
{
|
|
12864
|
+
width: "12",
|
|
12865
|
+
height: "3",
|
|
12866
|
+
rx: "1.5",
|
|
12867
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12868
|
+
fill: "#D4D4D8"
|
|
12869
|
+
}
|
|
12870
|
+
),
|
|
12871
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12872
|
+
"rect",
|
|
12873
|
+
{
|
|
12874
|
+
width: "17",
|
|
12875
|
+
height: "3",
|
|
12876
|
+
rx: "1.5",
|
|
12877
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12878
|
+
fill: "#D4D4D8"
|
|
12879
|
+
}
|
|
12880
|
+
),
|
|
12881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12882
|
+
"rect",
|
|
12883
|
+
{
|
|
12884
|
+
width: "12",
|
|
12885
|
+
height: "3",
|
|
12886
|
+
rx: "1.5",
|
|
12887
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12888
|
+
fill: "#D4D4D8"
|
|
12889
|
+
}
|
|
12890
|
+
),
|
|
12891
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12892
|
+
"path",
|
|
12893
|
+
{
|
|
12894
|
+
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
12895
|
+
fill: "#A1A1AA"
|
|
12896
|
+
}
|
|
12897
|
+
),
|
|
12898
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12899
|
+
"rect",
|
|
12900
|
+
{
|
|
12901
|
+
width: "17",
|
|
12902
|
+
height: "3",
|
|
12903
|
+
rx: "1.5",
|
|
12904
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12905
|
+
fill: "#A1A1AA"
|
|
12906
|
+
}
|
|
12907
|
+
),
|
|
12908
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12909
|
+
"rect",
|
|
12910
|
+
{
|
|
12911
|
+
width: "12",
|
|
12912
|
+
height: "3",
|
|
12913
|
+
rx: "1.5",
|
|
12914
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12915
|
+
fill: "#A1A1AA"
|
|
12916
|
+
}
|
|
12917
|
+
),
|
|
12918
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12919
|
+
"path",
|
|
12920
|
+
{
|
|
12921
|
+
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12922
|
+
fill: "#52525B"
|
|
12923
|
+
}
|
|
12924
|
+
),
|
|
12925
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12926
|
+
"path",
|
|
12927
|
+
{
|
|
12928
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12929
|
+
stroke: "#A1A1AA",
|
|
12930
|
+
strokeWidth: "1.5",
|
|
12931
|
+
strokeLinecap: "round",
|
|
12932
|
+
strokeLinejoin: "round"
|
|
12933
|
+
}
|
|
12934
|
+
) }),
|
|
12935
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12936
|
+
"path",
|
|
12937
|
+
{
|
|
12938
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12939
|
+
stroke: "#A1A1AA",
|
|
12940
|
+
strokeWidth: "1.5",
|
|
12941
|
+
strokeLinecap: "round",
|
|
12942
|
+
strokeLinejoin: "round"
|
|
12943
|
+
}
|
|
12944
|
+
) }),
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12946
|
+
"path",
|
|
12947
|
+
{
|
|
12948
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12949
|
+
stroke: "#A1A1AA",
|
|
12950
|
+
strokeWidth: "1.5",
|
|
12951
|
+
strokeLinecap: "round",
|
|
12952
|
+
strokeLinejoin: "round"
|
|
12953
|
+
}
|
|
12954
|
+
) }),
|
|
12955
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12956
|
+
"path",
|
|
12957
|
+
{
|
|
12958
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12959
|
+
stroke: "#A1A1AA",
|
|
12960
|
+
strokeWidth: "1.5",
|
|
12961
|
+
strokeLinecap: "round",
|
|
12962
|
+
strokeLinejoin: "round"
|
|
12963
|
+
}
|
|
12964
|
+
) }),
|
|
12965
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12966
|
+
"path",
|
|
12967
|
+
{
|
|
12968
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12969
|
+
stroke: "#A1A1AA",
|
|
12970
|
+
strokeWidth: "1.5",
|
|
12971
|
+
strokeLinecap: "round",
|
|
12972
|
+
strokeLinejoin: "round"
|
|
12973
|
+
}
|
|
12974
|
+
) }),
|
|
12975
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12976
|
+
"path",
|
|
12977
|
+
{
|
|
12978
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12979
|
+
stroke: "#A1A1AA",
|
|
12980
|
+
strokeWidth: "1.5",
|
|
12981
|
+
strokeLinecap: "round",
|
|
12982
|
+
strokeLinejoin: "round"
|
|
12983
|
+
}
|
|
12984
|
+
) }),
|
|
12985
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12986
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12987
|
+
"rect",
|
|
12927
12988
|
{
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
12933
|
-
placeholder: "Select location",
|
|
12934
|
-
onChange: (value) => {
|
|
12935
|
-
setValue("shipping_option_id", "", {
|
|
12936
|
-
shouldDirty: true,
|
|
12937
|
-
shouldTouch: true
|
|
12938
|
-
});
|
|
12939
|
-
onChange(value);
|
|
12940
|
-
},
|
|
12941
|
-
...field
|
|
12989
|
+
width: "12",
|
|
12990
|
+
height: "12",
|
|
12991
|
+
fill: "white",
|
|
12992
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12942
12993
|
}
|
|
12943
|
-
) })
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
}
|
|
12947
|
-
);
|
|
12948
|
-
};
|
|
12949
|
-
const ShippingOptionField = ({
|
|
12950
|
-
shippingProfileId,
|
|
12951
|
-
preview,
|
|
12952
|
-
control
|
|
12953
|
-
}) => {
|
|
12954
|
-
var _a;
|
|
12955
|
-
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12956
|
-
const shippingOptions = useComboboxData({
|
|
12957
|
-
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12958
|
-
queryFn: async (params) => {
|
|
12959
|
-
return await sdk.admin.shippingOption.list({
|
|
12960
|
-
...params,
|
|
12961
|
-
stock_location_id: locationId,
|
|
12962
|
-
shipping_profile_id: shippingProfileId
|
|
12963
|
-
});
|
|
12964
|
-
},
|
|
12965
|
-
getOptions: (data) => {
|
|
12966
|
-
return data.shipping_options.map((option) => {
|
|
12967
|
-
var _a2;
|
|
12968
|
-
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12969
|
-
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12970
|
-
)) {
|
|
12971
|
-
return void 0;
|
|
12972
|
-
}
|
|
12973
|
-
return {
|
|
12974
|
-
label: option.name,
|
|
12975
|
-
value: option.id
|
|
12976
|
-
};
|
|
12977
|
-
}).filter(Boolean);
|
|
12978
|
-
},
|
|
12979
|
-
enabled: !!locationId && !!shippingProfileId,
|
|
12980
|
-
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12981
|
-
});
|
|
12982
|
-
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12983
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12984
|
-
Form$2.Field,
|
|
12985
|
-
{
|
|
12986
|
-
control,
|
|
12987
|
-
name: "shipping_option_id",
|
|
12988
|
-
render: ({ field }) => {
|
|
12989
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12990
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12991
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12992
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12993
|
-
] }),
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
-
ConditionalTooltip,
|
|
12994
|
+
) }),
|
|
12995
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12996
|
+
"rect",
|
|
12996
12997
|
{
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
{
|
|
13002
|
-
options: shippingOptions.options,
|
|
13003
|
-
fetchNextPage: shippingOptions.fetchNextPage,
|
|
13004
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
13005
|
-
searchValue: shippingOptions.searchValue,
|
|
13006
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
13007
|
-
placeholder: "Select shipping option",
|
|
13008
|
-
...field,
|
|
13009
|
-
disabled: !locationId || !shippingProfileId
|
|
13010
|
-
}
|
|
13011
|
-
) }) })
|
|
12998
|
+
width: "12",
|
|
12999
|
+
height: "12",
|
|
13000
|
+
fill: "white",
|
|
13001
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
13012
13002
|
}
|
|
13013
|
-
)
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
}
|
|
13017
|
-
);
|
|
13018
|
-
};
|
|
13019
|
-
const CustomAmountField = ({
|
|
13020
|
-
control,
|
|
13021
|
-
currencyCode
|
|
13022
|
-
}) => {
|
|
13023
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13024
|
-
Form$2.Field,
|
|
13025
|
-
{
|
|
13026
|
-
control,
|
|
13027
|
-
name: "custom_amount",
|
|
13028
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
13029
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
13030
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
13031
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
13032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
13033
|
-
] }),
|
|
13034
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13035
|
-
ui.CurrencyInput,
|
|
13003
|
+
) }),
|
|
13004
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13005
|
+
"rect",
|
|
13036
13006
|
{
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13007
|
+
width: "12",
|
|
13008
|
+
height: "12",
|
|
13009
|
+
fill: "white",
|
|
13010
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
13011
|
+
}
|
|
13012
|
+
) }),
|
|
13013
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
+
"rect",
|
|
13015
|
+
{
|
|
13016
|
+
width: "12",
|
|
13017
|
+
height: "12",
|
|
13018
|
+
fill: "white",
|
|
13019
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
13020
|
+
}
|
|
13021
|
+
) }),
|
|
13022
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13023
|
+
"rect",
|
|
13024
|
+
{
|
|
13025
|
+
width: "12",
|
|
13026
|
+
height: "12",
|
|
13027
|
+
fill: "white",
|
|
13028
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13029
|
+
}
|
|
13030
|
+
) }),
|
|
13031
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13032
|
+
"rect",
|
|
13033
|
+
{
|
|
13034
|
+
width: "12",
|
|
13035
|
+
height: "12",
|
|
13036
|
+
fill: "white",
|
|
13037
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13041
13038
|
}
|
|
13042
13039
|
) })
|
|
13043
|
-
] })
|
|
13044
|
-
|
|
13040
|
+
] })
|
|
13041
|
+
]
|
|
13045
13042
|
}
|
|
13046
13043
|
);
|
|
13047
13044
|
};
|
|
13045
|
+
const schema = objectType({
|
|
13046
|
+
customer_id: stringType().min(1)
|
|
13047
|
+
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -13097,13 +13097,13 @@ const routeModule = {
|
|
|
13097
13097
|
Component: ShippingAddress,
|
|
13098
13098
|
path: "/draft-orders/:id/shipping-address"
|
|
13099
13099
|
},
|
|
13100
|
-
{
|
|
13101
|
-
Component: TransferOwnership,
|
|
13102
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
|
-
},
|
|
13104
13100
|
{
|
|
13105
13101
|
Component: Shipping,
|
|
13106
13102
|
path: "/draft-orders/:id/shipping"
|
|
13103
|
+
},
|
|
13104
|
+
{
|
|
13105
|
+
Component: TransferOwnership,
|
|
13106
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|