@medusajs/draft-order 2.11.2-snapshot-20251030105712 → 2.11.2-snapshot-20251030153804
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 +1791 -1790
- package/.medusa/server/src/admin/index.mjs +1788 -1788
- package/package.json +32 -31
|
@@ -14,14 +14,15 @@ const reactHookForm = require("react-hook-form");
|
|
|
14
14
|
const radixUi = require("radix-ui");
|
|
15
15
|
const react = require("@ariakit/react");
|
|
16
16
|
const matchSorter = require("match-sorter");
|
|
17
|
-
const debounce = require("lodash
|
|
17
|
+
const debounce = require("lodash.debounce");
|
|
18
18
|
const Primitive = require("@uiw/react-json-view");
|
|
19
|
-
const
|
|
19
|
+
const isEqual = require("lodash.isequal");
|
|
20
20
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
21
21
|
const React__default = /* @__PURE__ */ _interopDefault(React);
|
|
22
22
|
const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
|
|
23
23
|
const debounce__default = /* @__PURE__ */ _interopDefault(debounce);
|
|
24
24
|
const Primitive__default = /* @__PURE__ */ _interopDefault(Primitive);
|
|
25
|
+
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
25
26
|
function useQueryParams(keys, prefix) {
|
|
26
27
|
const [params] = reactRouterDom.useSearchParams();
|
|
27
28
|
const result = {};
|
|
@@ -9761,6 +9762,74 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9761
9762
|
) });
|
|
9762
9763
|
};
|
|
9763
9764
|
const schema$5 = addressSchema;
|
|
9765
|
+
const Email = () => {
|
|
9766
|
+
const { id } = reactRouterDom.useParams();
|
|
9767
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9768
|
+
fields: "+email"
|
|
9769
|
+
});
|
|
9770
|
+
if (isError) {
|
|
9771
|
+
throw error;
|
|
9772
|
+
}
|
|
9773
|
+
const isReady = !isPending && !!order;
|
|
9774
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9775
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9776
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9777
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9778
|
+
] }),
|
|
9779
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9780
|
+
] });
|
|
9781
|
+
};
|
|
9782
|
+
const EmailForm = ({ order }) => {
|
|
9783
|
+
const form = reactHookForm.useForm({
|
|
9784
|
+
defaultValues: {
|
|
9785
|
+
email: order.email ?? ""
|
|
9786
|
+
},
|
|
9787
|
+
resolver: zod.zodResolver(schema$4)
|
|
9788
|
+
});
|
|
9789
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9790
|
+
const { handleSuccess } = useRouteModal();
|
|
9791
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9792
|
+
await mutateAsync(
|
|
9793
|
+
{ email: data.email },
|
|
9794
|
+
{
|
|
9795
|
+
onSuccess: () => {
|
|
9796
|
+
handleSuccess();
|
|
9797
|
+
},
|
|
9798
|
+
onError: (error) => {
|
|
9799
|
+
ui.toast.error(error.message);
|
|
9800
|
+
}
|
|
9801
|
+
}
|
|
9802
|
+
);
|
|
9803
|
+
});
|
|
9804
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9805
|
+
KeyboundForm,
|
|
9806
|
+
{
|
|
9807
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9808
|
+
onSubmit,
|
|
9809
|
+
children: [
|
|
9810
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9811
|
+
Form$2.Field,
|
|
9812
|
+
{
|
|
9813
|
+
control: form.control,
|
|
9814
|
+
name: "email",
|
|
9815
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9816
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9817
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9818
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9819
|
+
] })
|
|
9820
|
+
}
|
|
9821
|
+
) }),
|
|
9822
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9823
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9824
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9825
|
+
] }) })
|
|
9826
|
+
]
|
|
9827
|
+
}
|
|
9828
|
+
) });
|
|
9829
|
+
};
|
|
9830
|
+
const schema$4 = objectType({
|
|
9831
|
+
email: stringType().email()
|
|
9832
|
+
});
|
|
9764
9833
|
const CustomItems = () => {
|
|
9765
9834
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9766
9835
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9769,7 +9838,7 @@ const CustomItems = () => {
|
|
|
9769
9838
|
};
|
|
9770
9839
|
const CustomItemsForm = () => {
|
|
9771
9840
|
const form = reactHookForm.useForm({
|
|
9772
|
-
resolver: zod.zodResolver(schema$
|
|
9841
|
+
resolver: zod.zodResolver(schema$3)
|
|
9773
9842
|
});
|
|
9774
9843
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9775
9844
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9779,7 +9848,7 @@ const CustomItemsForm = () => {
|
|
|
9779
9848
|
] }) })
|
|
9780
9849
|
] }) });
|
|
9781
9850
|
};
|
|
9782
|
-
const schema$
|
|
9851
|
+
const schema$3 = objectType({
|
|
9783
9852
|
email: stringType().email()
|
|
9784
9853
|
});
|
|
9785
9854
|
const NumberInput = React.forwardRef(
|
|
@@ -10756,10 +10825,54 @@ const customItemSchema = objectType({
|
|
|
10756
10825
|
quantity: numberType(),
|
|
10757
10826
|
unit_price: unionType([numberType(), stringType()])
|
|
10758
10827
|
});
|
|
10759
|
-
const
|
|
10828
|
+
const InlineTip = React.forwardRef(
|
|
10829
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10830
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10832
|
+
"div",
|
|
10833
|
+
{
|
|
10834
|
+
ref,
|
|
10835
|
+
className: ui.clx(
|
|
10836
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10837
|
+
className
|
|
10838
|
+
),
|
|
10839
|
+
...props,
|
|
10840
|
+
children: [
|
|
10841
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10842
|
+
"div",
|
|
10843
|
+
{
|
|
10844
|
+
role: "presentation",
|
|
10845
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10846
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10847
|
+
})
|
|
10848
|
+
}
|
|
10849
|
+
),
|
|
10850
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10851
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10852
|
+
labelValue,
|
|
10853
|
+
":"
|
|
10854
|
+
] }),
|
|
10855
|
+
" ",
|
|
10856
|
+
children
|
|
10857
|
+
] })
|
|
10858
|
+
]
|
|
10859
|
+
}
|
|
10860
|
+
);
|
|
10861
|
+
}
|
|
10862
|
+
);
|
|
10863
|
+
InlineTip.displayName = "InlineTip";
|
|
10864
|
+
const MetadataFieldSchema = objectType({
|
|
10865
|
+
key: stringType(),
|
|
10866
|
+
disabled: booleanType().optional(),
|
|
10867
|
+
value: anyType()
|
|
10868
|
+
});
|
|
10869
|
+
const MetadataSchema = objectType({
|
|
10870
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10871
|
+
});
|
|
10872
|
+
const Metadata = () => {
|
|
10760
10873
|
const { id } = reactRouterDom.useParams();
|
|
10761
10874
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10762
|
-
fields: "
|
|
10875
|
+
fields: "metadata"
|
|
10763
10876
|
});
|
|
10764
10877
|
if (isError) {
|
|
10765
10878
|
throw error;
|
|
@@ -10767,26 +10880,33 @@ const Email = () => {
|
|
|
10767
10880
|
const isReady = !isPending && !!order;
|
|
10768
10881
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10769
10882
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10770
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
10771
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
10883
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10884
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10772
10885
|
] }),
|
|
10773
|
-
isReady
|
|
10886
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10774
10887
|
] });
|
|
10775
10888
|
};
|
|
10776
|
-
const
|
|
10889
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10890
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10891
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10892
|
+
const { handleSuccess } = useRouteModal();
|
|
10893
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10894
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10777
10895
|
const form = reactHookForm.useForm({
|
|
10778
10896
|
defaultValues: {
|
|
10779
|
-
|
|
10897
|
+
metadata: getDefaultValues(metadata)
|
|
10780
10898
|
},
|
|
10781
|
-
resolver: zod.zodResolver(
|
|
10899
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10782
10900
|
});
|
|
10783
|
-
const
|
|
10784
|
-
|
|
10785
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10901
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10902
|
+
const parsedData = parseValues(data);
|
|
10786
10903
|
await mutateAsync(
|
|
10787
|
-
{
|
|
10904
|
+
{
|
|
10905
|
+
metadata: parsedData
|
|
10906
|
+
},
|
|
10788
10907
|
{
|
|
10789
10908
|
onSuccess: () => {
|
|
10909
|
+
ui.toast.success("Metadata updated");
|
|
10790
10910
|
handleSuccess();
|
|
10791
10911
|
},
|
|
10792
10912
|
onError: (error) => {
|
|
@@ -10795,170 +10915,401 @@ const EmailForm = ({ order }) => {
|
|
|
10795
10915
|
}
|
|
10796
10916
|
);
|
|
10797
10917
|
});
|
|
10918
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
10919
|
+
control: form.control,
|
|
10920
|
+
name: "metadata"
|
|
10921
|
+
});
|
|
10922
|
+
function deleteRow(index) {
|
|
10923
|
+
remove(index);
|
|
10924
|
+
if (fields.length === 1) {
|
|
10925
|
+
insert(0, {
|
|
10926
|
+
key: "",
|
|
10927
|
+
value: "",
|
|
10928
|
+
disabled: false
|
|
10929
|
+
});
|
|
10930
|
+
}
|
|
10931
|
+
}
|
|
10932
|
+
function insertRow(index, position) {
|
|
10933
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10934
|
+
key: "",
|
|
10935
|
+
value: "",
|
|
10936
|
+
disabled: false
|
|
10937
|
+
});
|
|
10938
|
+
}
|
|
10798
10939
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10799
10940
|
KeyboundForm,
|
|
10800
10941
|
{
|
|
10942
|
+
onSubmit: handleSubmit,
|
|
10801
10943
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
10802
|
-
onSubmit,
|
|
10803
10944
|
children: [
|
|
10804
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
};
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
}
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10945
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10948
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
10949
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
10950
|
+
] }),
|
|
10951
|
+
fields.map((field, index) => {
|
|
10952
|
+
const isDisabled = field.disabled || false;
|
|
10953
|
+
let placeholder = "-";
|
|
10954
|
+
if (typeof field.value === "object") {
|
|
10955
|
+
placeholder = "{ ... }";
|
|
10956
|
+
}
|
|
10957
|
+
if (Array.isArray(field.value)) {
|
|
10958
|
+
placeholder = "[ ... ]";
|
|
10959
|
+
}
|
|
10960
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10961
|
+
ConditionalTooltip,
|
|
10962
|
+
{
|
|
10963
|
+
showTooltip: isDisabled,
|
|
10964
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10965
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10966
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10967
|
+
"div",
|
|
10968
|
+
{
|
|
10969
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10970
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10971
|
+
}),
|
|
10972
|
+
children: [
|
|
10973
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10974
|
+
Form$2.Field,
|
|
10975
|
+
{
|
|
10976
|
+
control: form.control,
|
|
10977
|
+
name: `metadata.${index}.key`,
|
|
10978
|
+
render: ({ field: field2 }) => {
|
|
10979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10980
|
+
GridInput,
|
|
10981
|
+
{
|
|
10982
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10983
|
+
...field2,
|
|
10984
|
+
disabled: isDisabled,
|
|
10985
|
+
placeholder: "Key"
|
|
10986
|
+
}
|
|
10987
|
+
) }) });
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
),
|
|
10991
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10992
|
+
Form$2.Field,
|
|
10993
|
+
{
|
|
10994
|
+
control: form.control,
|
|
10995
|
+
name: `metadata.${index}.value`,
|
|
10996
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10997
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10998
|
+
GridInput,
|
|
10999
|
+
{
|
|
11000
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11001
|
+
...field2,
|
|
11002
|
+
value: isDisabled ? placeholder : value,
|
|
11003
|
+
disabled: isDisabled,
|
|
11004
|
+
placeholder: "Value"
|
|
11005
|
+
}
|
|
11006
|
+
) }) });
|
|
11007
|
+
}
|
|
11008
|
+
}
|
|
11009
|
+
)
|
|
11010
|
+
]
|
|
11011
|
+
}
|
|
11012
|
+
),
|
|
11013
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11014
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11015
|
+
ui.DropdownMenu.Trigger,
|
|
11016
|
+
{
|
|
11017
|
+
className: ui.clx(
|
|
11018
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11019
|
+
{
|
|
11020
|
+
hidden: isDisabled
|
|
11021
|
+
}
|
|
11022
|
+
),
|
|
11023
|
+
disabled: isDisabled,
|
|
11024
|
+
asChild: true,
|
|
11025
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11026
|
+
}
|
|
11027
|
+
),
|
|
11028
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11029
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11030
|
+
ui.DropdownMenu.Item,
|
|
11031
|
+
{
|
|
11032
|
+
className: "gap-x-2",
|
|
11033
|
+
onClick: () => insertRow(index, "above"),
|
|
11034
|
+
children: [
|
|
11035
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11036
|
+
"Insert row above"
|
|
11037
|
+
]
|
|
11038
|
+
}
|
|
11039
|
+
),
|
|
11040
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11041
|
+
ui.DropdownMenu.Item,
|
|
11042
|
+
{
|
|
11043
|
+
className: "gap-x-2",
|
|
11044
|
+
onClick: () => insertRow(index, "below"),
|
|
11045
|
+
children: [
|
|
11046
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11047
|
+
"Insert row below"
|
|
11048
|
+
]
|
|
11049
|
+
}
|
|
11050
|
+
),
|
|
11051
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11052
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11053
|
+
ui.DropdownMenu.Item,
|
|
11054
|
+
{
|
|
11055
|
+
className: "gap-x-2",
|
|
11056
|
+
onClick: () => deleteRow(index),
|
|
11057
|
+
children: [
|
|
11058
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11059
|
+
"Delete row"
|
|
11060
|
+
]
|
|
11061
|
+
}
|
|
11062
|
+
)
|
|
11063
|
+
] })
|
|
11064
|
+
] })
|
|
11065
|
+
] })
|
|
11066
|
+
},
|
|
11067
|
+
field.id
|
|
11068
|
+
);
|
|
11069
|
+
})
|
|
11070
|
+
] }),
|
|
11071
|
+
hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
11072
|
+
] }),
|
|
11073
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11074
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11075
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11076
|
+
] }) })
|
|
11077
|
+
]
|
|
10895
11078
|
}
|
|
10896
|
-
});
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
11079
|
+
) });
|
|
11080
|
+
};
|
|
11081
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
11082
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11083
|
+
"input",
|
|
11084
|
+
{
|
|
11085
|
+
ref,
|
|
11086
|
+
...props,
|
|
11087
|
+
autoComplete: "off",
|
|
11088
|
+
className: ui.clx(
|
|
11089
|
+
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
11090
|
+
className
|
|
11091
|
+
)
|
|
10900
11092
|
}
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
11093
|
+
);
|
|
11094
|
+
});
|
|
11095
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
11096
|
+
const PlaceholderInner = () => {
|
|
11097
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11098
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11101
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11102
|
+
] }) })
|
|
11103
|
+
] });
|
|
11104
|
+
};
|
|
11105
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11106
|
+
function getDefaultValues(metadata) {
|
|
11107
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
11108
|
+
return [
|
|
10905
11109
|
{
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
setComboboxValue("");
|
|
10910
|
-
},
|
|
10911
|
-
onSuccess: () => {
|
|
10912
|
-
comboboxData.onSearchValueChange("");
|
|
10913
|
-
setComboboxValue("");
|
|
10914
|
-
}
|
|
10915
|
-
}
|
|
10916
|
-
);
|
|
10917
|
-
};
|
|
10918
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10919
|
-
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
10920
|
-
const onSubmit = async () => {
|
|
10921
|
-
setIsSubmitting(true);
|
|
10922
|
-
let requestSucceeded = false;
|
|
10923
|
-
await requestOrderEdit(void 0, {
|
|
10924
|
-
onError: (e) => {
|
|
10925
|
-
ui.toast.error(e.message);
|
|
10926
|
-
},
|
|
10927
|
-
onSuccess: () => {
|
|
10928
|
-
requestSucceeded = true;
|
|
11110
|
+
key: "",
|
|
11111
|
+
value: "",
|
|
11112
|
+
disabled: false
|
|
10929
11113
|
}
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
11114
|
+
];
|
|
11115
|
+
}
|
|
11116
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
11117
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11118
|
+
return {
|
|
11119
|
+
key,
|
|
11120
|
+
value,
|
|
11121
|
+
disabled: true
|
|
11122
|
+
};
|
|
10934
11123
|
}
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
11124
|
+
let stringValue = value;
|
|
11125
|
+
if (typeof value !== "string") {
|
|
11126
|
+
stringValue = JSON.stringify(value);
|
|
11127
|
+
}
|
|
11128
|
+
return {
|
|
11129
|
+
key,
|
|
11130
|
+
value: stringValue,
|
|
11131
|
+
original_key: key
|
|
11132
|
+
};
|
|
11133
|
+
});
|
|
11134
|
+
}
|
|
11135
|
+
function parseValues(values) {
|
|
11136
|
+
const metadata = values.metadata;
|
|
11137
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11138
|
+
if (isEmpty) {
|
|
11139
|
+
return null;
|
|
10949
11140
|
}
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
11141
|
+
const update = {};
|
|
11142
|
+
metadata.forEach((field) => {
|
|
11143
|
+
let key = field.key;
|
|
11144
|
+
let value = field.value;
|
|
11145
|
+
const disabled = field.disabled;
|
|
11146
|
+
if (!key || !value) {
|
|
11147
|
+
return;
|
|
11148
|
+
}
|
|
11149
|
+
if (disabled) {
|
|
11150
|
+
update[key] = value;
|
|
11151
|
+
return;
|
|
11152
|
+
}
|
|
11153
|
+
key = key.trim();
|
|
11154
|
+
value = value.trim();
|
|
11155
|
+
if (value === "true") {
|
|
11156
|
+
update[key] = true;
|
|
11157
|
+
} else if (value === "false") {
|
|
11158
|
+
update[key] = false;
|
|
11159
|
+
} else {
|
|
11160
|
+
const parsedNumber = parseFloat(value);
|
|
11161
|
+
if (!isNaN(parsedNumber)) {
|
|
11162
|
+
update[key] = parsedNumber;
|
|
11163
|
+
} else {
|
|
11164
|
+
update[key] = value;
|
|
11165
|
+
}
|
|
11166
|
+
}
|
|
11167
|
+
});
|
|
11168
|
+
return update;
|
|
11169
|
+
}
|
|
11170
|
+
function getHasUneditableRows(metadata) {
|
|
11171
|
+
if (!metadata) {
|
|
11172
|
+
return false;
|
|
11173
|
+
}
|
|
11174
|
+
return Object.values(metadata).some(
|
|
11175
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11176
|
+
);
|
|
11177
|
+
}
|
|
11178
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11179
|
+
const promotionsQueryKeys = {
|
|
11180
|
+
list: (query2) => [
|
|
11181
|
+
PROMOTION_QUERY_KEY,
|
|
11182
|
+
query2 ? query2 : void 0
|
|
11183
|
+
],
|
|
11184
|
+
detail: (id, query2) => [
|
|
11185
|
+
PROMOTION_QUERY_KEY,
|
|
11186
|
+
id,
|
|
11187
|
+
query2 ? query2 : void 0
|
|
11188
|
+
]
|
|
11189
|
+
};
|
|
11190
|
+
const usePromotions = (query2, options) => {
|
|
11191
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11192
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11193
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11194
|
+
...options
|
|
11195
|
+
});
|
|
11196
|
+
return { ...data, ...rest };
|
|
11197
|
+
};
|
|
11198
|
+
const Promotions = () => {
|
|
11199
|
+
const { id } = reactRouterDom.useParams();
|
|
11200
|
+
const {
|
|
11201
|
+
order: preview,
|
|
11202
|
+
isError: isPreviewError,
|
|
11203
|
+
error: previewError
|
|
11204
|
+
} = useOrderPreview(id, void 0);
|
|
11205
|
+
useInitiateOrderEdit({ preview });
|
|
11206
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11207
|
+
if (isPreviewError) {
|
|
11208
|
+
throw previewError;
|
|
11209
|
+
}
|
|
11210
|
+
const isReady = !!preview;
|
|
11211
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11212
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11213
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11214
|
+
] });
|
|
11215
|
+
};
|
|
11216
|
+
const PromotionForm = ({ preview }) => {
|
|
11217
|
+
const { items, shipping_methods } = preview;
|
|
11218
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11219
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
11220
|
+
const { handleSuccess } = useRouteModal();
|
|
11221
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11222
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11223
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
11224
|
+
{
|
|
11225
|
+
id: promoIds
|
|
11226
|
+
},
|
|
11227
|
+
{
|
|
11228
|
+
enabled: !!promoIds.length
|
|
11229
|
+
}
|
|
11230
|
+
);
|
|
11231
|
+
const comboboxData = useComboboxData({
|
|
11232
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
11233
|
+
queryFn: async (params) => {
|
|
11234
|
+
return await sdk.admin.promotion.list({
|
|
11235
|
+
...params,
|
|
11236
|
+
id: {
|
|
11237
|
+
$nin: promoIds
|
|
11238
|
+
}
|
|
11239
|
+
});
|
|
11240
|
+
},
|
|
11241
|
+
getOptions: (data) => {
|
|
11242
|
+
return data.promotions.map((promotion) => ({
|
|
11243
|
+
label: promotion.code,
|
|
11244
|
+
value: promotion.code
|
|
11245
|
+
}));
|
|
11246
|
+
}
|
|
11247
|
+
});
|
|
11248
|
+
const add = async (value) => {
|
|
11249
|
+
if (!value) {
|
|
11250
|
+
return;
|
|
11251
|
+
}
|
|
11252
|
+
addPromotions(
|
|
11253
|
+
{
|
|
11254
|
+
promo_codes: [value]
|
|
11255
|
+
},
|
|
11256
|
+
{
|
|
11257
|
+
onError: (e) => {
|
|
11258
|
+
ui.toast.error(e.message);
|
|
11259
|
+
comboboxData.onSearchValueChange("");
|
|
11260
|
+
setComboboxValue("");
|
|
11261
|
+
},
|
|
11262
|
+
onSuccess: () => {
|
|
11263
|
+
comboboxData.onSearchValueChange("");
|
|
11264
|
+
setComboboxValue("");
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
);
|
|
11268
|
+
};
|
|
11269
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11270
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11271
|
+
const onSubmit = async () => {
|
|
11272
|
+
setIsSubmitting(true);
|
|
11273
|
+
let requestSucceeded = false;
|
|
11274
|
+
await requestOrderEdit(void 0, {
|
|
11275
|
+
onError: (e) => {
|
|
11276
|
+
ui.toast.error(e.message);
|
|
11277
|
+
},
|
|
11278
|
+
onSuccess: () => {
|
|
11279
|
+
requestSucceeded = true;
|
|
11280
|
+
}
|
|
11281
|
+
});
|
|
11282
|
+
if (!requestSucceeded) {
|
|
11283
|
+
setIsSubmitting(false);
|
|
11284
|
+
return;
|
|
11285
|
+
}
|
|
11286
|
+
await confirmOrderEdit(void 0, {
|
|
11287
|
+
onError: (e) => {
|
|
11288
|
+
ui.toast.error(e.message);
|
|
11289
|
+
},
|
|
11290
|
+
onSuccess: () => {
|
|
11291
|
+
handleSuccess();
|
|
11292
|
+
},
|
|
11293
|
+
onSettled: () => {
|
|
11294
|
+
setIsSubmitting(false);
|
|
11295
|
+
}
|
|
11296
|
+
});
|
|
11297
|
+
};
|
|
11298
|
+
if (isError) {
|
|
11299
|
+
throw error;
|
|
11300
|
+
}
|
|
11301
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11302
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11305
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11306
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11307
|
+
] }),
|
|
11308
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11309
|
+
Combobox,
|
|
11310
|
+
{
|
|
11311
|
+
id: "promotion-combobox",
|
|
11312
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
10962
11313
|
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10963
11314
|
fetchNextPage: comboboxData.fetchNextPage,
|
|
10964
11315
|
options: comboboxData.options,
|
|
@@ -11101,88 +11452,46 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11101
11452
|
}
|
|
11102
11453
|
return Array.from(promotionIds);
|
|
11103
11454
|
}
|
|
11104
|
-
const
|
|
11105
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
11106
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
11107
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11108
|
-
"div",
|
|
11109
|
-
{
|
|
11110
|
-
ref,
|
|
11111
|
-
className: ui.clx(
|
|
11112
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
11113
|
-
className
|
|
11114
|
-
),
|
|
11115
|
-
...props,
|
|
11116
|
-
children: [
|
|
11117
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11118
|
-
"div",
|
|
11119
|
-
{
|
|
11120
|
-
role: "presentation",
|
|
11121
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
11122
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
11123
|
-
})
|
|
11124
|
-
}
|
|
11125
|
-
),
|
|
11126
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
11127
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
11128
|
-
labelValue,
|
|
11129
|
-
":"
|
|
11130
|
-
] }),
|
|
11131
|
-
" ",
|
|
11132
|
-
children
|
|
11133
|
-
] })
|
|
11134
|
-
]
|
|
11135
|
-
}
|
|
11136
|
-
);
|
|
11137
|
-
}
|
|
11138
|
-
);
|
|
11139
|
-
InlineTip.displayName = "InlineTip";
|
|
11140
|
-
const MetadataFieldSchema = objectType({
|
|
11141
|
-
key: stringType(),
|
|
11142
|
-
disabled: booleanType().optional(),
|
|
11143
|
-
value: anyType()
|
|
11144
|
-
});
|
|
11145
|
-
const MetadataSchema = objectType({
|
|
11146
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
11147
|
-
});
|
|
11148
|
-
const Metadata = () => {
|
|
11455
|
+
const SalesChannel = () => {
|
|
11149
11456
|
const { id } = reactRouterDom.useParams();
|
|
11150
|
-
const {
|
|
11151
|
-
|
|
11152
|
-
|
|
11457
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11458
|
+
id,
|
|
11459
|
+
{
|
|
11460
|
+
fields: "+sales_channel_id"
|
|
11461
|
+
},
|
|
11462
|
+
{
|
|
11463
|
+
enabled: !!id
|
|
11464
|
+
}
|
|
11465
|
+
);
|
|
11153
11466
|
if (isError) {
|
|
11154
11467
|
throw error;
|
|
11155
11468
|
}
|
|
11156
|
-
const
|
|
11469
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11157
11470
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11158
11471
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11159
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
11160
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
11472
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11473
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11161
11474
|
] }),
|
|
11162
|
-
|
|
11475
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11163
11476
|
] });
|
|
11164
11477
|
};
|
|
11165
|
-
const
|
|
11166
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
11167
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
11168
|
-
const { handleSuccess } = useRouteModal();
|
|
11169
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
11170
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
11478
|
+
const SalesChannelForm = ({ order }) => {
|
|
11171
11479
|
const form = reactHookForm.useForm({
|
|
11172
11480
|
defaultValues: {
|
|
11173
|
-
|
|
11481
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11174
11482
|
},
|
|
11175
|
-
resolver: zod.zodResolver(
|
|
11483
|
+
resolver: zod.zodResolver(schema$2)
|
|
11176
11484
|
});
|
|
11177
|
-
const
|
|
11178
|
-
|
|
11485
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11486
|
+
const { handleSuccess } = useRouteModal();
|
|
11487
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11179
11488
|
await mutateAsync(
|
|
11180
11489
|
{
|
|
11181
|
-
|
|
11490
|
+
sales_channel_id: data.sales_channel_id
|
|
11182
11491
|
},
|
|
11183
11492
|
{
|
|
11184
11493
|
onSuccess: () => {
|
|
11185
|
-
ui.toast.success("
|
|
11494
|
+
ui.toast.success("Sales channel updated");
|
|
11186
11495
|
handleSuccess();
|
|
11187
11496
|
},
|
|
11188
11497
|
onError: (error) => {
|
|
@@ -11191,1214 +11500,227 @@ const MetadataForm = ({ orderId, metadata }) => {
|
|
|
11191
11500
|
}
|
|
11192
11501
|
);
|
|
11193
11502
|
});
|
|
11194
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
11195
|
-
control: form.control,
|
|
11196
|
-
name: "metadata"
|
|
11197
|
-
});
|
|
11198
|
-
function deleteRow(index) {
|
|
11199
|
-
remove(index);
|
|
11200
|
-
if (fields.length === 1) {
|
|
11201
|
-
insert(0, {
|
|
11202
|
-
key: "",
|
|
11203
|
-
value: "",
|
|
11204
|
-
disabled: false
|
|
11205
|
-
});
|
|
11206
|
-
}
|
|
11207
|
-
}
|
|
11208
|
-
function insertRow(index, position) {
|
|
11209
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
11210
|
-
key: "",
|
|
11211
|
-
value: "",
|
|
11212
|
-
disabled: false
|
|
11213
|
-
});
|
|
11214
|
-
}
|
|
11215
11503
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11216
11504
|
KeyboundForm,
|
|
11217
11505
|
{
|
|
11218
|
-
onSubmit: handleSubmit,
|
|
11219
11506
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11507
|
+
onSubmit,
|
|
11220
11508
|
children: [
|
|
11221
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
11225
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
11226
|
-
] }),
|
|
11227
|
-
fields.map((field, index) => {
|
|
11228
|
-
const isDisabled = field.disabled || false;
|
|
11229
|
-
let placeholder = "-";
|
|
11230
|
-
if (typeof field.value === "object") {
|
|
11231
|
-
placeholder = "{ ... }";
|
|
11232
|
-
}
|
|
11233
|
-
if (Array.isArray(field.value)) {
|
|
11234
|
-
placeholder = "[ ... ]";
|
|
11235
|
-
}
|
|
11236
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11237
|
-
ConditionalTooltip,
|
|
11238
|
-
{
|
|
11239
|
-
showTooltip: isDisabled,
|
|
11240
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
11241
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
11242
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11243
|
-
"div",
|
|
11244
|
-
{
|
|
11245
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
11246
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
11247
|
-
}),
|
|
11248
|
-
children: [
|
|
11249
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11250
|
-
Form$2.Field,
|
|
11251
|
-
{
|
|
11252
|
-
control: form.control,
|
|
11253
|
-
name: `metadata.${index}.key`,
|
|
11254
|
-
render: ({ field: field2 }) => {
|
|
11255
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11256
|
-
GridInput,
|
|
11257
|
-
{
|
|
11258
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
11259
|
-
...field2,
|
|
11260
|
-
disabled: isDisabled,
|
|
11261
|
-
placeholder: "Key"
|
|
11262
|
-
}
|
|
11263
|
-
) }) });
|
|
11264
|
-
}
|
|
11265
|
-
}
|
|
11266
|
-
),
|
|
11267
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11268
|
-
Form$2.Field,
|
|
11269
|
-
{
|
|
11270
|
-
control: form.control,
|
|
11271
|
-
name: `metadata.${index}.value`,
|
|
11272
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
11273
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11274
|
-
GridInput,
|
|
11275
|
-
{
|
|
11276
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11277
|
-
...field2,
|
|
11278
|
-
value: isDisabled ? placeholder : value,
|
|
11279
|
-
disabled: isDisabled,
|
|
11280
|
-
placeholder: "Value"
|
|
11281
|
-
}
|
|
11282
|
-
) }) });
|
|
11283
|
-
}
|
|
11284
|
-
}
|
|
11285
|
-
)
|
|
11286
|
-
]
|
|
11287
|
-
}
|
|
11288
|
-
),
|
|
11289
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11290
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11291
|
-
ui.DropdownMenu.Trigger,
|
|
11292
|
-
{
|
|
11293
|
-
className: ui.clx(
|
|
11294
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11295
|
-
{
|
|
11296
|
-
hidden: isDisabled
|
|
11297
|
-
}
|
|
11298
|
-
),
|
|
11299
|
-
disabled: isDisabled,
|
|
11300
|
-
asChild: true,
|
|
11301
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11302
|
-
}
|
|
11303
|
-
),
|
|
11304
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11305
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11306
|
-
ui.DropdownMenu.Item,
|
|
11307
|
-
{
|
|
11308
|
-
className: "gap-x-2",
|
|
11309
|
-
onClick: () => insertRow(index, "above"),
|
|
11310
|
-
children: [
|
|
11311
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11312
|
-
"Insert row above"
|
|
11313
|
-
]
|
|
11314
|
-
}
|
|
11315
|
-
),
|
|
11316
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11317
|
-
ui.DropdownMenu.Item,
|
|
11318
|
-
{
|
|
11319
|
-
className: "gap-x-2",
|
|
11320
|
-
onClick: () => insertRow(index, "below"),
|
|
11321
|
-
children: [
|
|
11322
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11323
|
-
"Insert row below"
|
|
11324
|
-
]
|
|
11325
|
-
}
|
|
11326
|
-
),
|
|
11327
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11328
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11329
|
-
ui.DropdownMenu.Item,
|
|
11330
|
-
{
|
|
11331
|
-
className: "gap-x-2",
|
|
11332
|
-
onClick: () => deleteRow(index),
|
|
11333
|
-
children: [
|
|
11334
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11335
|
-
"Delete row"
|
|
11336
|
-
]
|
|
11337
|
-
}
|
|
11338
|
-
)
|
|
11339
|
-
] })
|
|
11340
|
-
] })
|
|
11341
|
-
] })
|
|
11342
|
-
},
|
|
11343
|
-
field.id
|
|
11344
|
-
);
|
|
11345
|
-
})
|
|
11346
|
-
] }),
|
|
11347
|
-
hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
11348
|
-
] }),
|
|
11349
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11350
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11509
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11510
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11511
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11351
11512
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11352
11513
|
] }) })
|
|
11353
11514
|
]
|
|
11354
11515
|
}
|
|
11355
11516
|
) });
|
|
11356
11517
|
};
|
|
11357
|
-
const
|
|
11518
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11519
|
+
const salesChannels = useComboboxData({
|
|
11520
|
+
queryFn: async (params) => {
|
|
11521
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11522
|
+
},
|
|
11523
|
+
queryKey: ["sales-channels"],
|
|
11524
|
+
getOptions: (data) => {
|
|
11525
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11526
|
+
label: salesChannel.name,
|
|
11527
|
+
value: salesChannel.id
|
|
11528
|
+
}));
|
|
11529
|
+
},
|
|
11530
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11531
|
+
});
|
|
11358
11532
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11359
|
-
|
|
11533
|
+
Form$2.Field,
|
|
11360
11534
|
{
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11535
|
+
control,
|
|
11536
|
+
name: "sales_channel_id",
|
|
11537
|
+
render: ({ field }) => {
|
|
11538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11540
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11541
|
+
Combobox,
|
|
11542
|
+
{
|
|
11543
|
+
options: salesChannels.options,
|
|
11544
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11545
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11546
|
+
searchValue: salesChannels.searchValue,
|
|
11547
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11548
|
+
placeholder: "Select sales channel",
|
|
11549
|
+
...field
|
|
11550
|
+
}
|
|
11551
|
+
) }),
|
|
11552
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11553
|
+
] });
|
|
11554
|
+
}
|
|
11368
11555
|
}
|
|
11369
11556
|
);
|
|
11370
|
-
});
|
|
11371
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
11372
|
-
const PlaceholderInner = () => {
|
|
11373
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11374
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11375
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11376
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11377
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11378
|
-
] }) })
|
|
11379
|
-
] });
|
|
11380
11557
|
};
|
|
11381
|
-
const
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
];
|
|
11391
|
-
}
|
|
11392
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
11393
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11394
|
-
return {
|
|
11395
|
-
key,
|
|
11396
|
-
value,
|
|
11397
|
-
disabled: true
|
|
11398
|
-
};
|
|
11399
|
-
}
|
|
11400
|
-
let stringValue = value;
|
|
11401
|
-
if (typeof value !== "string") {
|
|
11402
|
-
stringValue = JSON.stringify(value);
|
|
11403
|
-
}
|
|
11404
|
-
return {
|
|
11405
|
-
key,
|
|
11406
|
-
value: stringValue,
|
|
11407
|
-
original_key: key
|
|
11408
|
-
};
|
|
11558
|
+
const schema$2 = objectType({
|
|
11559
|
+
sales_channel_id: stringType().min(1)
|
|
11560
|
+
});
|
|
11561
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11562
|
+
const Shipping = () => {
|
|
11563
|
+
var _a;
|
|
11564
|
+
const { id } = reactRouterDom.useParams();
|
|
11565
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11566
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11409
11567
|
});
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
}
|
|
11417
|
-
const
|
|
11418
|
-
metadata.forEach((field) => {
|
|
11419
|
-
let key = field.key;
|
|
11420
|
-
let value = field.value;
|
|
11421
|
-
const disabled = field.disabled;
|
|
11422
|
-
if (!key || !value) {
|
|
11423
|
-
return;
|
|
11424
|
-
}
|
|
11425
|
-
if (disabled) {
|
|
11426
|
-
update[key] = value;
|
|
11427
|
-
return;
|
|
11428
|
-
}
|
|
11429
|
-
key = key.trim();
|
|
11430
|
-
value = value.trim();
|
|
11431
|
-
if (value === "true") {
|
|
11432
|
-
update[key] = true;
|
|
11433
|
-
} else if (value === "false") {
|
|
11434
|
-
update[key] = false;
|
|
11435
|
-
} else {
|
|
11436
|
-
const parsedNumber = parseFloat(value);
|
|
11437
|
-
if (!isNaN(parsedNumber)) {
|
|
11438
|
-
update[key] = parsedNumber;
|
|
11439
|
-
} else {
|
|
11440
|
-
update[key] = value;
|
|
11441
|
-
}
|
|
11442
|
-
}
|
|
11443
|
-
});
|
|
11444
|
-
return update;
|
|
11445
|
-
}
|
|
11446
|
-
function getHasUneditableRows(metadata) {
|
|
11447
|
-
if (!metadata) {
|
|
11448
|
-
return false;
|
|
11449
|
-
}
|
|
11450
|
-
return Object.values(metadata).some(
|
|
11451
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11452
|
-
);
|
|
11453
|
-
}
|
|
11454
|
-
const SalesChannel = () => {
|
|
11455
|
-
const { id } = reactRouterDom.useParams();
|
|
11456
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11457
|
-
id,
|
|
11458
|
-
{
|
|
11459
|
-
fields: "+sales_channel_id"
|
|
11460
|
-
},
|
|
11461
|
-
{
|
|
11462
|
-
enabled: !!id
|
|
11463
|
-
}
|
|
11464
|
-
);
|
|
11568
|
+
const {
|
|
11569
|
+
order: preview,
|
|
11570
|
+
isPending: isPreviewPending,
|
|
11571
|
+
isError: isPreviewError,
|
|
11572
|
+
error: previewError
|
|
11573
|
+
} = useOrderPreview(id);
|
|
11574
|
+
useInitiateOrderEdit({ preview });
|
|
11575
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11465
11576
|
if (isError) {
|
|
11466
11577
|
throw error;
|
|
11467
11578
|
}
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11579
|
+
if (isPreviewError) {
|
|
11580
|
+
throw previewError;
|
|
11581
|
+
}
|
|
11582
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11583
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11584
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11585
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11586
|
+
/* @__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 px-6 py-16", children: [
|
|
11587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11588
|
+
/* @__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." }) })
|
|
11589
|
+
] }) }) }),
|
|
11590
|
+
/* @__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" }) }) })
|
|
11591
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11592
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11593
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11594
|
+
] }) });
|
|
11476
11595
|
};
|
|
11477
|
-
const
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
}
|
|
11484
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11485
|
-
const { handleSuccess } = useRouteModal();
|
|
11486
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11487
|
-
await mutateAsync(
|
|
11488
|
-
{
|
|
11489
|
-
sales_channel_id: data.sales_channel_id
|
|
11490
|
-
},
|
|
11491
|
-
{
|
|
11492
|
-
onSuccess: () => {
|
|
11493
|
-
ui.toast.success("Sales channel updated");
|
|
11494
|
-
handleSuccess();
|
|
11495
|
-
},
|
|
11496
|
-
onError: (error) => {
|
|
11497
|
-
ui.toast.error(error.message);
|
|
11498
|
-
}
|
|
11499
|
-
}
|
|
11500
|
-
);
|
|
11501
|
-
});
|
|
11502
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11503
|
-
KeyboundForm,
|
|
11596
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11597
|
+
var _a;
|
|
11598
|
+
const { setIsOpen } = useStackedModal();
|
|
11599
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11600
|
+
const [data, setData] = React.useState(null);
|
|
11601
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11602
|
+
const { shipping_options } = useShippingOptions(
|
|
11504
11603
|
{
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
children: [
|
|
11508
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11509
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11510
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11511
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11512
|
-
] }) })
|
|
11513
|
-
]
|
|
11514
|
-
}
|
|
11515
|
-
) });
|
|
11516
|
-
};
|
|
11517
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11518
|
-
const salesChannels = useComboboxData({
|
|
11519
|
-
queryFn: async (params) => {
|
|
11520
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11521
|
-
},
|
|
11522
|
-
queryKey: ["sales-channels"],
|
|
11523
|
-
getOptions: (data) => {
|
|
11524
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11525
|
-
label: salesChannel.name,
|
|
11526
|
-
value: salesChannel.id
|
|
11527
|
-
}));
|
|
11604
|
+
id: appliedShippingOptionIds,
|
|
11605
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11528
11606
|
},
|
|
11529
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11530
|
-
});
|
|
11531
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11532
|
-
Form$2.Field,
|
|
11533
11607
|
{
|
|
11534
|
-
|
|
11535
|
-
name: "sales_channel_id",
|
|
11536
|
-
render: ({ field }) => {
|
|
11537
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11538
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11539
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11540
|
-
Combobox,
|
|
11541
|
-
{
|
|
11542
|
-
options: salesChannels.options,
|
|
11543
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11544
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11545
|
-
searchValue: salesChannels.searchValue,
|
|
11546
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11547
|
-
placeholder: "Select sales channel",
|
|
11548
|
-
...field
|
|
11549
|
-
}
|
|
11550
|
-
) }),
|
|
11551
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11552
|
-
] });
|
|
11553
|
-
}
|
|
11608
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11554
11609
|
}
|
|
11555
11610
|
);
|
|
11556
|
-
|
|
11557
|
-
const
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
throw error;
|
|
11567
|
-
}
|
|
11568
|
-
const isReady = !isPending && !!order;
|
|
11569
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11570
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11571
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11572
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11573
|
-
] }),
|
|
11574
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11575
|
-
] });
|
|
11576
|
-
};
|
|
11577
|
-
const ShippingAddressForm = ({ order }) => {
|
|
11578
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11579
|
-
const form = reactHookForm.useForm({
|
|
11580
|
-
defaultValues: {
|
|
11581
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11582
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11583
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11584
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11585
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11586
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11587
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11588
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11589
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11590
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11591
|
-
},
|
|
11592
|
-
resolver: zod.zodResolver(schema$1)
|
|
11593
|
-
});
|
|
11594
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11611
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11612
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11613
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11614
|
+
profiles.set(profile.id, profile);
|
|
11615
|
+
});
|
|
11616
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11617
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11618
|
+
});
|
|
11619
|
+
return Array.from(profiles.values());
|
|
11620
|
+
}, [order.items, shipping_options]);
|
|
11595
11621
|
const { handleSuccess } = useRouteModal();
|
|
11596
|
-
const
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
province: data.province,
|
|
11607
|
-
country_code: data.country_code,
|
|
11608
|
-
postal_code: data.postal_code,
|
|
11609
|
-
phone: data.phone
|
|
11610
|
-
}
|
|
11622
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11623
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11624
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11625
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11626
|
+
const onSubmit = async () => {
|
|
11627
|
+
setIsSubmitting(true);
|
|
11628
|
+
let requestSucceeded = false;
|
|
11629
|
+
await requestOrderEdit(void 0, {
|
|
11630
|
+
onError: (e) => {
|
|
11631
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11611
11632
|
},
|
|
11612
|
-
{
|
|
11613
|
-
|
|
11614
|
-
handleSuccess();
|
|
11615
|
-
},
|
|
11616
|
-
onError: (error) => {
|
|
11617
|
-
ui.toast.error(error.message);
|
|
11618
|
-
}
|
|
11633
|
+
onSuccess: () => {
|
|
11634
|
+
requestSucceeded = true;
|
|
11619
11635
|
}
|
|
11620
|
-
);
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11636
|
+
});
|
|
11637
|
+
if (!requestSucceeded) {
|
|
11638
|
+
setIsSubmitting(false);
|
|
11639
|
+
return;
|
|
11640
|
+
}
|
|
11641
|
+
await confirmOrderEdit(void 0, {
|
|
11642
|
+
onError: (e) => {
|
|
11643
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11644
|
+
},
|
|
11645
|
+
onSuccess: () => {
|
|
11646
|
+
handleSuccess();
|
|
11647
|
+
},
|
|
11648
|
+
onSettled: () => {
|
|
11649
|
+
setIsSubmitting(false);
|
|
11650
|
+
}
|
|
11651
|
+
});
|
|
11652
|
+
};
|
|
11653
|
+
const onKeydown = React.useCallback(
|
|
11654
|
+
(e) => {
|
|
11655
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11656
|
+
if (data || isSubmitting) {
|
|
11657
|
+
return;
|
|
11658
|
+
}
|
|
11659
|
+
onSubmit();
|
|
11660
|
+
}
|
|
11661
|
+
},
|
|
11662
|
+
[data, isSubmitting, onSubmit]
|
|
11663
|
+
);
|
|
11664
|
+
React.useEffect(() => {
|
|
11665
|
+
document.addEventListener("keydown", onKeydown);
|
|
11666
|
+
return () => {
|
|
11667
|
+
document.removeEventListener("keydown", onKeydown);
|
|
11668
|
+
};
|
|
11669
|
+
}, [onKeydown]);
|
|
11670
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11671
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11672
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11673
|
+
/* @__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 px-6 py-16", children: [
|
|
11674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11675
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11676
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11677
|
+
] }),
|
|
11678
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11679
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11680
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11642
11681
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11643
|
-
|
|
11682
|
+
ui.Text,
|
|
11644
11683
|
{
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11650
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11651
|
-
] })
|
|
11684
|
+
size: "xsmall",
|
|
11685
|
+
weight: "plus",
|
|
11686
|
+
className: "text-ui-fg-muted",
|
|
11687
|
+
children: "Shipping profile"
|
|
11652
11688
|
}
|
|
11653
11689
|
),
|
|
11654
11690
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11655
|
-
|
|
11691
|
+
ui.Text,
|
|
11656
11692
|
{
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11662
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11663
|
-
] })
|
|
11693
|
+
size: "xsmall",
|
|
11694
|
+
weight: "plus",
|
|
11695
|
+
className: "text-ui-fg-muted",
|
|
11696
|
+
children: "Action"
|
|
11664
11697
|
}
|
|
11665
11698
|
)
|
|
11666
11699
|
] }),
|
|
11667
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11686
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11687
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11688
|
-
] })
|
|
11689
|
-
}
|
|
11690
|
-
),
|
|
11691
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11692
|
-
Form$2.Field,
|
|
11693
|
-
{
|
|
11694
|
-
control: form.control,
|
|
11695
|
-
name: "address_2",
|
|
11696
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11697
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11698
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11699
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11700
|
-
] })
|
|
11701
|
-
}
|
|
11702
|
-
),
|
|
11703
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11704
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11705
|
-
Form$2.Field,
|
|
11706
|
-
{
|
|
11707
|
-
control: form.control,
|
|
11708
|
-
name: "postal_code",
|
|
11709
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11710
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11711
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11712
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11713
|
-
] })
|
|
11714
|
-
}
|
|
11715
|
-
),
|
|
11716
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11717
|
-
Form$2.Field,
|
|
11718
|
-
{
|
|
11719
|
-
control: form.control,
|
|
11720
|
-
name: "city",
|
|
11721
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11722
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11723
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11724
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11725
|
-
] })
|
|
11726
|
-
}
|
|
11727
|
-
)
|
|
11728
|
-
] }),
|
|
11729
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11730
|
-
Form$2.Field,
|
|
11731
|
-
{
|
|
11732
|
-
control: form.control,
|
|
11733
|
-
name: "province",
|
|
11734
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11735
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11736
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11737
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11738
|
-
] })
|
|
11739
|
-
}
|
|
11740
|
-
),
|
|
11741
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11742
|
-
Form$2.Field,
|
|
11743
|
-
{
|
|
11744
|
-
control: form.control,
|
|
11745
|
-
name: "phone",
|
|
11746
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11747
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11748
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11749
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11750
|
-
] })
|
|
11751
|
-
}
|
|
11752
|
-
)
|
|
11753
|
-
] }) }),
|
|
11754
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11755
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11756
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11757
|
-
] }) })
|
|
11758
|
-
]
|
|
11759
|
-
}
|
|
11760
|
-
) });
|
|
11761
|
-
};
|
|
11762
|
-
const schema$1 = addressSchema;
|
|
11763
|
-
const TransferOwnership = () => {
|
|
11764
|
-
const { id } = reactRouterDom.useParams();
|
|
11765
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
11766
|
-
fields: "id,customer_id,customer.*"
|
|
11767
|
-
});
|
|
11768
|
-
if (isError) {
|
|
11769
|
-
throw error;
|
|
11770
|
-
}
|
|
11771
|
-
const isReady = !isPending && !!draft_order;
|
|
11772
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11773
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11774
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
11775
|
-
/* @__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" }) })
|
|
11776
|
-
] }),
|
|
11777
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
11778
|
-
] });
|
|
11779
|
-
};
|
|
11780
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
11781
|
-
var _a, _b;
|
|
11782
|
-
const form = reactHookForm.useForm({
|
|
11783
|
-
defaultValues: {
|
|
11784
|
-
customer_id: order.customer_id || ""
|
|
11785
|
-
},
|
|
11786
|
-
resolver: zod.zodResolver(schema)
|
|
11787
|
-
});
|
|
11788
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11789
|
-
const { handleSuccess } = useRouteModal();
|
|
11790
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
11791
|
-
const currentCustomer = order.customer ? {
|
|
11792
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
11793
|
-
value: order.customer.id
|
|
11794
|
-
} : null;
|
|
11795
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11796
|
-
await mutateAsync(
|
|
11797
|
-
{ customer_id: data.customer_id },
|
|
11798
|
-
{
|
|
11799
|
-
onSuccess: () => {
|
|
11800
|
-
ui.toast.success("Customer updated");
|
|
11801
|
-
handleSuccess();
|
|
11802
|
-
},
|
|
11803
|
-
onError: (error) => {
|
|
11804
|
-
ui.toast.error(error.message);
|
|
11805
|
-
}
|
|
11806
|
-
}
|
|
11807
|
-
);
|
|
11808
|
-
});
|
|
11809
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11810
|
-
KeyboundForm,
|
|
11811
|
-
{
|
|
11812
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11813
|
-
onSubmit,
|
|
11814
|
-
children: [
|
|
11815
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
11816
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
11817
|
-
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
11818
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11819
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
11820
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
11821
|
-
] }),
|
|
11822
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
11823
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
11824
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
11825
|
-
] })
|
|
11826
|
-
] }),
|
|
11827
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11828
|
-
CustomerField,
|
|
11829
|
-
{
|
|
11830
|
-
control: form.control,
|
|
11831
|
-
currentCustomerId: order.customer_id
|
|
11832
|
-
}
|
|
11833
|
-
)
|
|
11834
|
-
] }),
|
|
11835
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11836
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
11837
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11838
|
-
] }) })
|
|
11839
|
-
]
|
|
11840
|
-
}
|
|
11841
|
-
) });
|
|
11842
|
-
};
|
|
11843
|
-
const CustomerField = ({ control, currentCustomerId }) => {
|
|
11844
|
-
const customers = useComboboxData({
|
|
11845
|
-
queryFn: async (params) => {
|
|
11846
|
-
return await sdk.admin.customer.list({
|
|
11847
|
-
...params,
|
|
11848
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
11849
|
-
});
|
|
11850
|
-
},
|
|
11851
|
-
queryKey: ["customers"],
|
|
11852
|
-
getOptions: (data) => {
|
|
11853
|
-
return data.customers.map((customer) => {
|
|
11854
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
11855
|
-
return {
|
|
11856
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
11857
|
-
value: customer.id
|
|
11858
|
-
};
|
|
11859
|
-
});
|
|
11860
|
-
}
|
|
11861
|
-
});
|
|
11862
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11863
|
-
Form$2.Field,
|
|
11864
|
-
{
|
|
11865
|
-
name: "customer_id",
|
|
11866
|
-
control,
|
|
11867
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
11868
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11869
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
11870
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
11871
|
-
] }),
|
|
11872
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11873
|
-
Combobox,
|
|
11874
|
-
{
|
|
11875
|
-
options: customers.options,
|
|
11876
|
-
fetchNextPage: customers.fetchNextPage,
|
|
11877
|
-
isFetchingNextPage: customers.isFetchingNextPage,
|
|
11878
|
-
searchValue: customers.searchValue,
|
|
11879
|
-
onSearchValueChange: customers.onSearchValueChange,
|
|
11880
|
-
placeholder: "Select customer",
|
|
11881
|
-
...field
|
|
11882
|
-
}
|
|
11883
|
-
) }),
|
|
11884
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11885
|
-
] })
|
|
11886
|
-
}
|
|
11887
|
-
);
|
|
11888
|
-
};
|
|
11889
|
-
const Illustration = () => {
|
|
11890
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11891
|
-
"svg",
|
|
11892
|
-
{
|
|
11893
|
-
width: "280",
|
|
11894
|
-
height: "180",
|
|
11895
|
-
viewBox: "0 0 280 180",
|
|
11896
|
-
fill: "none",
|
|
11897
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
11898
|
-
children: [
|
|
11899
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11900
|
-
"rect",
|
|
11901
|
-
{
|
|
11902
|
-
x: "0.00428286",
|
|
11903
|
-
y: "-0.742904",
|
|
11904
|
-
width: "33.5",
|
|
11905
|
-
height: "65.5",
|
|
11906
|
-
rx: "6.75",
|
|
11907
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
11908
|
-
fill: "#D4D4D8",
|
|
11909
|
-
stroke: "#52525B",
|
|
11910
|
-
strokeWidth: "1.5"
|
|
11911
|
-
}
|
|
11912
|
-
),
|
|
11913
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11914
|
-
"rect",
|
|
11915
|
-
{
|
|
11916
|
-
x: "0.00428286",
|
|
11917
|
-
y: "-0.742904",
|
|
11918
|
-
width: "33.5",
|
|
11919
|
-
height: "65.5",
|
|
11920
|
-
rx: "6.75",
|
|
11921
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
11922
|
-
fill: "white",
|
|
11923
|
-
stroke: "#52525B",
|
|
11924
|
-
strokeWidth: "1.5"
|
|
11925
|
-
}
|
|
11926
|
-
),
|
|
11927
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11928
|
-
"path",
|
|
11929
|
-
{
|
|
11930
|
-
d: "M180.579 107.142L179.126 107.959",
|
|
11931
|
-
stroke: "#52525B",
|
|
11932
|
-
strokeWidth: "1.5",
|
|
11933
|
-
strokeLinecap: "round",
|
|
11934
|
-
strokeLinejoin: "round"
|
|
11935
|
-
}
|
|
11936
|
-
),
|
|
11937
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11938
|
-
"path",
|
|
11939
|
-
{
|
|
11940
|
-
opacity: "0.88",
|
|
11941
|
-
d: "M182.305 109.546L180.257 109.534",
|
|
11942
|
-
stroke: "#52525B",
|
|
11943
|
-
strokeWidth: "1.5",
|
|
11944
|
-
strokeLinecap: "round",
|
|
11945
|
-
strokeLinejoin: "round"
|
|
11946
|
-
}
|
|
11947
|
-
),
|
|
11948
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11949
|
-
"path",
|
|
11950
|
-
{
|
|
11951
|
-
opacity: "0.75",
|
|
11952
|
-
d: "M180.551 111.93L179.108 111.096",
|
|
11953
|
-
stroke: "#52525B",
|
|
11954
|
-
strokeWidth: "1.5",
|
|
11955
|
-
strokeLinecap: "round",
|
|
11956
|
-
strokeLinejoin: "round"
|
|
11957
|
-
}
|
|
11958
|
-
),
|
|
11959
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11960
|
-
"path",
|
|
11961
|
-
{
|
|
11962
|
-
opacity: "0.63",
|
|
11963
|
-
d: "M176.347 112.897L176.354 111.73",
|
|
11964
|
-
stroke: "#52525B",
|
|
11965
|
-
strokeWidth: "1.5",
|
|
11966
|
-
strokeLinecap: "round",
|
|
11967
|
-
strokeLinejoin: "round"
|
|
11968
|
-
}
|
|
11969
|
-
),
|
|
11970
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11971
|
-
"path",
|
|
11972
|
-
{
|
|
11973
|
-
opacity: "0.5",
|
|
11974
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
11975
|
-
stroke: "#52525B",
|
|
11976
|
-
strokeWidth: "1.5",
|
|
11977
|
-
strokeLinecap: "round",
|
|
11978
|
-
strokeLinejoin: "round"
|
|
11979
|
-
}
|
|
11980
|
-
),
|
|
11981
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11982
|
-
"path",
|
|
11983
|
-
{
|
|
11984
|
-
opacity: "0.38",
|
|
11985
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
11986
|
-
stroke: "#52525B",
|
|
11987
|
-
strokeWidth: "1.5",
|
|
11988
|
-
strokeLinecap: "round",
|
|
11989
|
-
strokeLinejoin: "round"
|
|
11990
|
-
}
|
|
11991
|
-
),
|
|
11992
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11993
|
-
"path",
|
|
11994
|
-
{
|
|
11995
|
-
opacity: "0.25",
|
|
11996
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
11997
|
-
stroke: "#52525B",
|
|
11998
|
-
strokeWidth: "1.5",
|
|
11999
|
-
strokeLinecap: "round",
|
|
12000
|
-
strokeLinejoin: "round"
|
|
12001
|
-
}
|
|
12002
|
-
),
|
|
12003
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12004
|
-
"path",
|
|
12005
|
-
{
|
|
12006
|
-
opacity: "0.13",
|
|
12007
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
12008
|
-
stroke: "#52525B",
|
|
12009
|
-
strokeWidth: "1.5",
|
|
12010
|
-
strokeLinecap: "round",
|
|
12011
|
-
strokeLinejoin: "round"
|
|
12012
|
-
}
|
|
12013
|
-
),
|
|
12014
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12015
|
-
"rect",
|
|
12016
|
-
{
|
|
12017
|
-
width: "12",
|
|
12018
|
-
height: "3",
|
|
12019
|
-
rx: "1.5",
|
|
12020
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12021
|
-
fill: "#D4D4D8"
|
|
12022
|
-
}
|
|
12023
|
-
),
|
|
12024
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12025
|
-
"rect",
|
|
12026
|
-
{
|
|
12027
|
-
x: "0.00428286",
|
|
12028
|
-
y: "-0.742904",
|
|
12029
|
-
width: "33.5",
|
|
12030
|
-
height: "65.5",
|
|
12031
|
-
rx: "6.75",
|
|
12032
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12033
|
-
fill: "#D4D4D8",
|
|
12034
|
-
stroke: "#52525B",
|
|
12035
|
-
strokeWidth: "1.5"
|
|
12036
|
-
}
|
|
12037
|
-
),
|
|
12038
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12039
|
-
"rect",
|
|
12040
|
-
{
|
|
12041
|
-
x: "0.00428286",
|
|
12042
|
-
y: "-0.742904",
|
|
12043
|
-
width: "33.5",
|
|
12044
|
-
height: "65.5",
|
|
12045
|
-
rx: "6.75",
|
|
12046
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12047
|
-
fill: "white",
|
|
12048
|
-
stroke: "#52525B",
|
|
12049
|
-
strokeWidth: "1.5"
|
|
12050
|
-
}
|
|
12051
|
-
),
|
|
12052
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12053
|
-
"rect",
|
|
12054
|
-
{
|
|
12055
|
-
width: "12",
|
|
12056
|
-
height: "3",
|
|
12057
|
-
rx: "1.5",
|
|
12058
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12059
|
-
fill: "#D4D4D8"
|
|
12060
|
-
}
|
|
12061
|
-
),
|
|
12062
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12063
|
-
"rect",
|
|
12064
|
-
{
|
|
12065
|
-
width: "17",
|
|
12066
|
-
height: "3",
|
|
12067
|
-
rx: "1.5",
|
|
12068
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12069
|
-
fill: "#D4D4D8"
|
|
12070
|
-
}
|
|
12071
|
-
),
|
|
12072
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12073
|
-
"rect",
|
|
12074
|
-
{
|
|
12075
|
-
width: "12",
|
|
12076
|
-
height: "3",
|
|
12077
|
-
rx: "1.5",
|
|
12078
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12079
|
-
fill: "#D4D4D8"
|
|
12080
|
-
}
|
|
12081
|
-
),
|
|
12082
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12083
|
-
"path",
|
|
12084
|
-
{
|
|
12085
|
-
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",
|
|
12086
|
-
fill: "#A1A1AA"
|
|
12087
|
-
}
|
|
12088
|
-
),
|
|
12089
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12090
|
-
"rect",
|
|
12091
|
-
{
|
|
12092
|
-
width: "17",
|
|
12093
|
-
height: "3",
|
|
12094
|
-
rx: "1.5",
|
|
12095
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12096
|
-
fill: "#A1A1AA"
|
|
12097
|
-
}
|
|
12098
|
-
),
|
|
12099
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12100
|
-
"rect",
|
|
12101
|
-
{
|
|
12102
|
-
width: "12",
|
|
12103
|
-
height: "3",
|
|
12104
|
-
rx: "1.5",
|
|
12105
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12106
|
-
fill: "#A1A1AA"
|
|
12107
|
-
}
|
|
12108
|
-
),
|
|
12109
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12110
|
-
"path",
|
|
12111
|
-
{
|
|
12112
|
-
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",
|
|
12113
|
-
fill: "#52525B"
|
|
12114
|
-
}
|
|
12115
|
-
),
|
|
12116
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12117
|
-
"path",
|
|
12118
|
-
{
|
|
12119
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12120
|
-
stroke: "#A1A1AA",
|
|
12121
|
-
strokeWidth: "1.5",
|
|
12122
|
-
strokeLinecap: "round",
|
|
12123
|
-
strokeLinejoin: "round"
|
|
12124
|
-
}
|
|
12125
|
-
) }),
|
|
12126
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12127
|
-
"path",
|
|
12128
|
-
{
|
|
12129
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12130
|
-
stroke: "#A1A1AA",
|
|
12131
|
-
strokeWidth: "1.5",
|
|
12132
|
-
strokeLinecap: "round",
|
|
12133
|
-
strokeLinejoin: "round"
|
|
12134
|
-
}
|
|
12135
|
-
) }),
|
|
12136
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12137
|
-
"path",
|
|
12138
|
-
{
|
|
12139
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12140
|
-
stroke: "#A1A1AA",
|
|
12141
|
-
strokeWidth: "1.5",
|
|
12142
|
-
strokeLinecap: "round",
|
|
12143
|
-
strokeLinejoin: "round"
|
|
12144
|
-
}
|
|
12145
|
-
) }),
|
|
12146
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12147
|
-
"path",
|
|
12148
|
-
{
|
|
12149
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12150
|
-
stroke: "#A1A1AA",
|
|
12151
|
-
strokeWidth: "1.5",
|
|
12152
|
-
strokeLinecap: "round",
|
|
12153
|
-
strokeLinejoin: "round"
|
|
12154
|
-
}
|
|
12155
|
-
) }),
|
|
12156
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12157
|
-
"path",
|
|
12158
|
-
{
|
|
12159
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12160
|
-
stroke: "#A1A1AA",
|
|
12161
|
-
strokeWidth: "1.5",
|
|
12162
|
-
strokeLinecap: "round",
|
|
12163
|
-
strokeLinejoin: "round"
|
|
12164
|
-
}
|
|
12165
|
-
) }),
|
|
12166
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12167
|
-
"path",
|
|
12168
|
-
{
|
|
12169
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12170
|
-
stroke: "#A1A1AA",
|
|
12171
|
-
strokeWidth: "1.5",
|
|
12172
|
-
strokeLinecap: "round",
|
|
12173
|
-
strokeLinejoin: "round"
|
|
12174
|
-
}
|
|
12175
|
-
) }),
|
|
12176
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12177
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12178
|
-
"rect",
|
|
12179
|
-
{
|
|
12180
|
-
width: "12",
|
|
12181
|
-
height: "12",
|
|
12182
|
-
fill: "white",
|
|
12183
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12184
|
-
}
|
|
12185
|
-
) }),
|
|
12186
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12187
|
-
"rect",
|
|
12188
|
-
{
|
|
12189
|
-
width: "12",
|
|
12190
|
-
height: "12",
|
|
12191
|
-
fill: "white",
|
|
12192
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12193
|
-
}
|
|
12194
|
-
) }),
|
|
12195
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12196
|
-
"rect",
|
|
12197
|
-
{
|
|
12198
|
-
width: "12",
|
|
12199
|
-
height: "12",
|
|
12200
|
-
fill: "white",
|
|
12201
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12202
|
-
}
|
|
12203
|
-
) }),
|
|
12204
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12205
|
-
"rect",
|
|
12206
|
-
{
|
|
12207
|
-
width: "12",
|
|
12208
|
-
height: "12",
|
|
12209
|
-
fill: "white",
|
|
12210
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12211
|
-
}
|
|
12212
|
-
) }),
|
|
12213
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12214
|
-
"rect",
|
|
12215
|
-
{
|
|
12216
|
-
width: "12",
|
|
12217
|
-
height: "12",
|
|
12218
|
-
fill: "white",
|
|
12219
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12220
|
-
}
|
|
12221
|
-
) }),
|
|
12222
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12223
|
-
"rect",
|
|
12224
|
-
{
|
|
12225
|
-
width: "12",
|
|
12226
|
-
height: "12",
|
|
12227
|
-
fill: "white",
|
|
12228
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12229
|
-
}
|
|
12230
|
-
) })
|
|
12231
|
-
] })
|
|
12232
|
-
]
|
|
12233
|
-
}
|
|
12234
|
-
);
|
|
12235
|
-
};
|
|
12236
|
-
const schema = objectType({
|
|
12237
|
-
customer_id: stringType().min(1)
|
|
12238
|
-
});
|
|
12239
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12240
|
-
const Shipping = () => {
|
|
12241
|
-
var _a;
|
|
12242
|
-
const { id } = reactRouterDom.useParams();
|
|
12243
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12244
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
12245
|
-
});
|
|
12246
|
-
const {
|
|
12247
|
-
order: preview,
|
|
12248
|
-
isPending: isPreviewPending,
|
|
12249
|
-
isError: isPreviewError,
|
|
12250
|
-
error: previewError
|
|
12251
|
-
} = useOrderPreview(id);
|
|
12252
|
-
useInitiateOrderEdit({ preview });
|
|
12253
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12254
|
-
if (isError) {
|
|
12255
|
-
throw error;
|
|
12256
|
-
}
|
|
12257
|
-
if (isPreviewError) {
|
|
12258
|
-
throw previewError;
|
|
12259
|
-
}
|
|
12260
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
12261
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
12262
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
12263
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
12264
|
-
/* @__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: [
|
|
12265
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
12266
|
-
/* @__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." }) })
|
|
12267
|
-
] }) }) }),
|
|
12268
|
-
/* @__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" }) }) })
|
|
12269
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12270
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
12271
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
12272
|
-
] }) });
|
|
12273
|
-
};
|
|
12274
|
-
const ShippingForm = ({ preview, order }) => {
|
|
12275
|
-
var _a;
|
|
12276
|
-
const { setIsOpen } = useStackedModal();
|
|
12277
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
12278
|
-
const [data, setData] = React.useState(null);
|
|
12279
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
12280
|
-
const { shipping_options } = useShippingOptions(
|
|
12281
|
-
{
|
|
12282
|
-
id: appliedShippingOptionIds,
|
|
12283
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
12284
|
-
},
|
|
12285
|
-
{
|
|
12286
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
12287
|
-
}
|
|
12288
|
-
);
|
|
12289
|
-
const uniqueShippingProfiles = React.useMemo(() => {
|
|
12290
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
12291
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
12292
|
-
profiles.set(profile.id, profile);
|
|
12293
|
-
});
|
|
12294
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
12295
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
12296
|
-
});
|
|
12297
|
-
return Array.from(profiles.values());
|
|
12298
|
-
}, [order.items, shipping_options]);
|
|
12299
|
-
const { handleSuccess } = useRouteModal();
|
|
12300
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12301
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
12302
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
12303
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
12304
|
-
const onSubmit = async () => {
|
|
12305
|
-
setIsSubmitting(true);
|
|
12306
|
-
let requestSucceeded = false;
|
|
12307
|
-
await requestOrderEdit(void 0, {
|
|
12308
|
-
onError: (e) => {
|
|
12309
|
-
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
12310
|
-
},
|
|
12311
|
-
onSuccess: () => {
|
|
12312
|
-
requestSucceeded = true;
|
|
12313
|
-
}
|
|
12314
|
-
});
|
|
12315
|
-
if (!requestSucceeded) {
|
|
12316
|
-
setIsSubmitting(false);
|
|
12317
|
-
return;
|
|
12318
|
-
}
|
|
12319
|
-
await confirmOrderEdit(void 0, {
|
|
12320
|
-
onError: (e) => {
|
|
12321
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
12322
|
-
},
|
|
12323
|
-
onSuccess: () => {
|
|
12324
|
-
handleSuccess();
|
|
12325
|
-
},
|
|
12326
|
-
onSettled: () => {
|
|
12327
|
-
setIsSubmitting(false);
|
|
12328
|
-
}
|
|
12329
|
-
});
|
|
12330
|
-
};
|
|
12331
|
-
const onKeydown = React.useCallback(
|
|
12332
|
-
(e) => {
|
|
12333
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
12334
|
-
if (data || isSubmitting) {
|
|
12335
|
-
return;
|
|
12336
|
-
}
|
|
12337
|
-
onSubmit();
|
|
12338
|
-
}
|
|
12339
|
-
},
|
|
12340
|
-
[data, isSubmitting, onSubmit]
|
|
12341
|
-
);
|
|
12342
|
-
React.useEffect(() => {
|
|
12343
|
-
document.addEventListener("keydown", onKeydown);
|
|
12344
|
-
return () => {
|
|
12345
|
-
document.removeEventListener("keydown", onKeydown);
|
|
12346
|
-
};
|
|
12347
|
-
}, [onKeydown]);
|
|
12348
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
12349
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
12350
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12351
|
-
/* @__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: [
|
|
12352
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12353
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
12354
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
12355
|
-
] }),
|
|
12356
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12357
|
-
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
|
|
12358
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
|
|
12359
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12360
|
-
ui.Text,
|
|
12361
|
-
{
|
|
12362
|
-
size: "xsmall",
|
|
12363
|
-
weight: "plus",
|
|
12364
|
-
className: "text-ui-fg-muted",
|
|
12365
|
-
children: "Shipping profile"
|
|
12366
|
-
}
|
|
12367
|
-
),
|
|
12368
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12369
|
-
ui.Text,
|
|
12370
|
-
{
|
|
12371
|
-
size: "xsmall",
|
|
12372
|
-
weight: "plus",
|
|
12373
|
-
className: "text-ui-fg-muted",
|
|
12374
|
-
children: "Action"
|
|
12375
|
-
}
|
|
12376
|
-
)
|
|
12377
|
-
] }),
|
|
12378
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
|
|
12379
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
12380
|
-
const items = getItemsWithShippingProfile(
|
|
12381
|
-
profile.id,
|
|
12382
|
-
order.items
|
|
12383
|
-
);
|
|
12384
|
-
const hasItems = items.length > 0;
|
|
12385
|
-
const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
|
|
12386
|
-
(option) => option.shipping_profile_id === profile.id
|
|
12387
|
-
);
|
|
12388
|
-
const shippingMethod = preview.shipping_methods.find(
|
|
12389
|
-
(method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
|
|
12390
|
-
);
|
|
12391
|
-
const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
|
|
12392
|
-
(action) => action.action === "SHIPPING_ADD"
|
|
12393
|
-
);
|
|
12394
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12395
|
-
radixUi.Accordion.Item,
|
|
11700
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
|
|
11701
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
11702
|
+
const items = getItemsWithShippingProfile(
|
|
11703
|
+
profile.id,
|
|
11704
|
+
order.items
|
|
11705
|
+
);
|
|
11706
|
+
const hasItems = items.length > 0;
|
|
11707
|
+
const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
|
|
11708
|
+
(option) => option.shipping_profile_id === profile.id
|
|
11709
|
+
);
|
|
11710
|
+
const shippingMethod = preview.shipping_methods.find(
|
|
11711
|
+
(method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
|
|
11712
|
+
);
|
|
11713
|
+
const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
|
|
11714
|
+
(action) => action.action === "SHIPPING_ADD"
|
|
11715
|
+
);
|
|
11716
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11717
|
+
radixUi.Accordion.Item,
|
|
12396
11718
|
{
|
|
12397
11719
|
value: profile.id,
|
|
12398
11720
|
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
12399
11721
|
children: [
|
|
12400
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
12401
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3
|
|
11722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
|
|
11723
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
|
|
12402
11724
|
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12403
11725
|
ui.IconButton,
|
|
12404
11726
|
{
|
|
@@ -12406,12 +11728,12 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12406
11728
|
variant: "transparent",
|
|
12407
11729
|
className: "group/trigger",
|
|
12408
11730
|
disabled: !hasItems,
|
|
12409
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90
|
|
11731
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-90" })
|
|
12410
11732
|
}
|
|
12411
11733
|
) }),
|
|
12412
11734
|
!shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12413
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
12414
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-
|
|
11735
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-bg-component-hover flex size-6 items-center justify-center rounded", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
|
|
11736
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
12415
11737
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12416
11738
|
ui.Text,
|
|
12417
11739
|
{
|
|
@@ -12435,7 +11757,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12435
11757
|
}
|
|
12436
11758
|
)
|
|
12437
11759
|
] })
|
|
12438
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start
|
|
11760
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-1 items-center gap-[5px] overflow-hidden max-sm:flex-col max-sm:items-start", children: [
|
|
12439
11761
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12440
11762
|
ui.Tooltip,
|
|
12441
11763
|
{
|
|
@@ -12452,7 +11774,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12452
11774
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12453
11775
|
ui.Badge,
|
|
12454
11776
|
{
|
|
12455
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11777
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
12456
11778
|
size: "xsmall",
|
|
12457
11779
|
children: [
|
|
12458
11780
|
/* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
|
|
@@ -12477,7 +11799,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12477
11799
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12478
11800
|
ui.Badge,
|
|
12479
11801
|
{
|
|
12480
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11802
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
12481
11803
|
size: "xsmall",
|
|
12482
11804
|
children: [
|
|
12483
11805
|
/* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
|
|
@@ -12490,7 +11812,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12490
11812
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12491
11813
|
ui.Badge,
|
|
12492
11814
|
{
|
|
12493
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11815
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
12494
11816
|
size: "xsmall",
|
|
12495
11817
|
children: [
|
|
12496
11818
|
/* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
|
|
@@ -12561,17 +11883,17 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12561
11883
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12562
11884
|
"div",
|
|
12563
11885
|
{
|
|
12564
|
-
className: "
|
|
11886
|
+
className: "flex items-center gap-x-3 px-3",
|
|
12565
11887
|
children: [
|
|
12566
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
11888
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-[56px] w-5 flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12567
11889
|
ui.Divider,
|
|
12568
11890
|
{
|
|
12569
11891
|
variant: "dashed",
|
|
12570
11892
|
orientation: "vertical"
|
|
12571
11893
|
}
|
|
12572
11894
|
) }),
|
|
12573
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
12574
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7
|
|
11895
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 py-2", children: [
|
|
11896
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-7 items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12575
11897
|
ui.Text,
|
|
12576
11898
|
{
|
|
12577
11899
|
size: "small",
|
|
@@ -12624,425 +11946,1104 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12624
11946
|
);
|
|
12625
11947
|
}) })
|
|
12626
11948
|
] }) })
|
|
12627
|
-
] }) }),
|
|
12628
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12629
|
-
StackedFocusModal,
|
|
11949
|
+
] }) }),
|
|
11950
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11951
|
+
StackedFocusModal,
|
|
11952
|
+
{
|
|
11953
|
+
id: STACKED_FOCUS_MODAL_ID,
|
|
11954
|
+
onOpenChangeCallback: (open) => {
|
|
11955
|
+
if (!open) {
|
|
11956
|
+
setData(null);
|
|
11957
|
+
}
|
|
11958
|
+
return open;
|
|
11959
|
+
},
|
|
11960
|
+
children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
|
|
11961
|
+
}
|
|
11962
|
+
)
|
|
11963
|
+
] }),
|
|
11964
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
11965
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11967
|
+
ui.Button,
|
|
11968
|
+
{
|
|
11969
|
+
size: "small",
|
|
11970
|
+
type: "button",
|
|
11971
|
+
isLoading: isSubmitting,
|
|
11972
|
+
onClick: onSubmit,
|
|
11973
|
+
children: "Save"
|
|
11974
|
+
}
|
|
11975
|
+
)
|
|
11976
|
+
] }) })
|
|
11977
|
+
] });
|
|
11978
|
+
};
|
|
11979
|
+
const StackedModalTrigger = ({
|
|
11980
|
+
shippingProfileId,
|
|
11981
|
+
shippingOption,
|
|
11982
|
+
shippingMethod,
|
|
11983
|
+
setData,
|
|
11984
|
+
children
|
|
11985
|
+
}) => {
|
|
11986
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
11987
|
+
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
11988
|
+
const onToggle = () => {
|
|
11989
|
+
if (isOpen) {
|
|
11990
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11991
|
+
setData(null);
|
|
11992
|
+
} else {
|
|
11993
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
11994
|
+
setData({
|
|
11995
|
+
shippingProfileId,
|
|
11996
|
+
shippingOption,
|
|
11997
|
+
shippingMethod
|
|
11998
|
+
});
|
|
11999
|
+
}
|
|
12000
|
+
};
|
|
12001
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12002
|
+
ui.Button,
|
|
12003
|
+
{
|
|
12004
|
+
size: "small",
|
|
12005
|
+
variant: "secondary",
|
|
12006
|
+
onClick: onToggle,
|
|
12007
|
+
className: "text-ui-fg-primary shrink-0",
|
|
12008
|
+
children
|
|
12009
|
+
}
|
|
12010
|
+
);
|
|
12011
|
+
};
|
|
12012
|
+
const ShippingProfileForm = ({
|
|
12013
|
+
data,
|
|
12014
|
+
order,
|
|
12015
|
+
preview
|
|
12016
|
+
}) => {
|
|
12017
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12018
|
+
const { setIsOpen } = useStackedModal();
|
|
12019
|
+
const form = reactHookForm.useForm({
|
|
12020
|
+
resolver: zod.zodResolver(shippingMethodSchema),
|
|
12021
|
+
defaultValues: {
|
|
12022
|
+
location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
|
|
12023
|
+
shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
|
|
12024
|
+
custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
|
|
12025
|
+
}
|
|
12026
|
+
});
|
|
12027
|
+
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
12028
|
+
const {
|
|
12029
|
+
mutateAsync: updateShippingMethod,
|
|
12030
|
+
isPending: isUpdatingShippingMethod
|
|
12031
|
+
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
12032
|
+
const onSubmit = form.handleSubmit(async (values) => {
|
|
12033
|
+
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
12034
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12035
|
+
return;
|
|
12036
|
+
}
|
|
12037
|
+
if (data.shippingMethod) {
|
|
12038
|
+
await updateShippingMethod(
|
|
12039
|
+
{
|
|
12040
|
+
method_id: data.shippingMethod.id,
|
|
12041
|
+
shipping_option_id: values.shipping_option_id,
|
|
12042
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12043
|
+
},
|
|
12044
|
+
{
|
|
12045
|
+
onError: (e) => {
|
|
12046
|
+
ui.toast.error(e.message);
|
|
12047
|
+
},
|
|
12048
|
+
onSuccess: () => {
|
|
12049
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12050
|
+
}
|
|
12051
|
+
}
|
|
12052
|
+
);
|
|
12053
|
+
return;
|
|
12054
|
+
}
|
|
12055
|
+
await addShippingMethod(
|
|
12056
|
+
{
|
|
12057
|
+
shipping_option_id: values.shipping_option_id,
|
|
12058
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12059
|
+
},
|
|
12060
|
+
{
|
|
12061
|
+
onError: (e) => {
|
|
12062
|
+
ui.toast.error(e.message);
|
|
12063
|
+
},
|
|
12064
|
+
onSuccess: () => {
|
|
12065
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12066
|
+
}
|
|
12067
|
+
}
|
|
12068
|
+
);
|
|
12069
|
+
});
|
|
12070
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12071
|
+
KeyboundForm,
|
|
12072
|
+
{
|
|
12073
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
12074
|
+
onSubmit,
|
|
12075
|
+
children: [
|
|
12076
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
12077
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.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 px-6 py-16", children: [
|
|
12078
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12079
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
12080
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
12081
|
+
] }),
|
|
12082
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12083
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12084
|
+
LocationField,
|
|
12085
|
+
{
|
|
12086
|
+
control: form.control,
|
|
12087
|
+
setValue: form.setValue
|
|
12088
|
+
}
|
|
12089
|
+
),
|
|
12090
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12091
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12092
|
+
ShippingOptionField,
|
|
12093
|
+
{
|
|
12094
|
+
shippingProfileId: data.shippingProfileId,
|
|
12095
|
+
preview,
|
|
12096
|
+
control: form.control
|
|
12097
|
+
}
|
|
12098
|
+
),
|
|
12099
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12100
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12101
|
+
CustomAmountField,
|
|
12102
|
+
{
|
|
12103
|
+
control: form.control,
|
|
12104
|
+
currencyCode: order.currency_code
|
|
12105
|
+
}
|
|
12106
|
+
),
|
|
12107
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12109
|
+
ItemsPreview,
|
|
12110
|
+
{
|
|
12111
|
+
order,
|
|
12112
|
+
shippingProfileId: data.shippingProfileId
|
|
12113
|
+
}
|
|
12114
|
+
)
|
|
12115
|
+
] }) }) }),
|
|
12116
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12117
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12119
|
+
ui.Button,
|
|
12120
|
+
{
|
|
12121
|
+
size: "small",
|
|
12122
|
+
type: "submit",
|
|
12123
|
+
isLoading: isPending || isUpdatingShippingMethod,
|
|
12124
|
+
children: data.shippingMethod ? "Update" : "Add"
|
|
12125
|
+
}
|
|
12126
|
+
)
|
|
12127
|
+
] }) })
|
|
12128
|
+
]
|
|
12129
|
+
}
|
|
12130
|
+
) }) });
|
|
12131
|
+
};
|
|
12132
|
+
const shippingMethodSchema = objectType({
|
|
12133
|
+
location_id: stringType(),
|
|
12134
|
+
shipping_option_id: stringType(),
|
|
12135
|
+
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12136
|
+
});
|
|
12137
|
+
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12138
|
+
const matches = order.items.filter(
|
|
12139
|
+
(item) => {
|
|
12140
|
+
var _a, _b, _c;
|
|
12141
|
+
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12142
|
+
}
|
|
12143
|
+
);
|
|
12144
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12145
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12146
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12147
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12148
|
+
] }) }),
|
|
12149
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
12151
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12152
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12153
|
+
] }),
|
|
12154
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12155
|
+
"div",
|
|
12630
12156
|
{
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12157
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
12158
|
+
children: [
|
|
12159
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12160
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12161
|
+
Thumbnail,
|
|
12162
|
+
{
|
|
12163
|
+
thumbnail: item.thumbnail,
|
|
12164
|
+
alt: item.product_title ?? void 0
|
|
12165
|
+
}
|
|
12166
|
+
),
|
|
12167
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12168
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12169
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12170
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12171
|
+
ui.Text,
|
|
12172
|
+
{
|
|
12173
|
+
size: "small",
|
|
12174
|
+
leading: "compact",
|
|
12175
|
+
className: "text-ui-fg-subtle",
|
|
12176
|
+
children: [
|
|
12177
|
+
"(",
|
|
12178
|
+
item.variant_title,
|
|
12179
|
+
")"
|
|
12180
|
+
]
|
|
12181
|
+
}
|
|
12182
|
+
)
|
|
12183
|
+
] }),
|
|
12184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12185
|
+
ui.Text,
|
|
12186
|
+
{
|
|
12187
|
+
size: "small",
|
|
12188
|
+
leading: "compact",
|
|
12189
|
+
className: "text-ui-fg-subtle",
|
|
12190
|
+
children: item.variant_sku
|
|
12191
|
+
}
|
|
12192
|
+
)
|
|
12193
|
+
] })
|
|
12194
|
+
] }),
|
|
12195
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12196
|
+
ui.Text,
|
|
12197
|
+
{
|
|
12198
|
+
size: "small",
|
|
12199
|
+
leading: "compact",
|
|
12200
|
+
className: "text-ui-fg-subtle",
|
|
12201
|
+
children: [
|
|
12202
|
+
item.quantity,
|
|
12203
|
+
"x"
|
|
12204
|
+
]
|
|
12205
|
+
}
|
|
12206
|
+
)
|
|
12207
|
+
]
|
|
12208
|
+
},
|
|
12209
|
+
item.id
|
|
12210
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
12211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12212
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12213
|
+
'No items found for "',
|
|
12214
|
+
query,
|
|
12215
|
+
'".'
|
|
12216
|
+
] })
|
|
12217
|
+
] }) })
|
|
12218
|
+
] })
|
|
12219
|
+
] });
|
|
12220
|
+
};
|
|
12221
|
+
const LocationField = ({ control, setValue }) => {
|
|
12222
|
+
const locations = useComboboxData({
|
|
12223
|
+
queryKey: ["locations"],
|
|
12224
|
+
queryFn: async (params) => {
|
|
12225
|
+
return await sdk.admin.stockLocation.list(params);
|
|
12226
|
+
},
|
|
12227
|
+
getOptions: (data) => {
|
|
12228
|
+
return data.stock_locations.map((location) => ({
|
|
12229
|
+
label: location.name,
|
|
12230
|
+
value: location.id
|
|
12231
|
+
}));
|
|
12232
|
+
}
|
|
12233
|
+
});
|
|
12234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12235
|
+
Form$2.Field,
|
|
12236
|
+
{
|
|
12237
|
+
control,
|
|
12238
|
+
name: "location_id",
|
|
12239
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12241
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12242
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
12243
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12244
|
+
] }),
|
|
12245
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12246
|
+
Combobox,
|
|
12247
|
+
{
|
|
12248
|
+
options: locations.options,
|
|
12249
|
+
fetchNextPage: locations.fetchNextPage,
|
|
12250
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
12251
|
+
searchValue: locations.searchValue,
|
|
12252
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
12253
|
+
placeholder: "Select location",
|
|
12254
|
+
onChange: (value) => {
|
|
12255
|
+
setValue("shipping_option_id", "", {
|
|
12256
|
+
shouldDirty: true,
|
|
12257
|
+
shouldTouch: true
|
|
12258
|
+
});
|
|
12259
|
+
onChange(value);
|
|
12260
|
+
},
|
|
12261
|
+
...field
|
|
12262
|
+
}
|
|
12263
|
+
) })
|
|
12264
|
+
] }) });
|
|
12265
|
+
}
|
|
12266
|
+
}
|
|
12267
|
+
);
|
|
12268
|
+
};
|
|
12269
|
+
const ShippingOptionField = ({
|
|
12270
|
+
shippingProfileId,
|
|
12271
|
+
preview,
|
|
12272
|
+
control
|
|
12273
|
+
}) => {
|
|
12274
|
+
var _a;
|
|
12275
|
+
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12276
|
+
const shippingOptions = useComboboxData({
|
|
12277
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12278
|
+
queryFn: async (params) => {
|
|
12279
|
+
return await sdk.admin.shippingOption.list({
|
|
12280
|
+
...params,
|
|
12281
|
+
stock_location_id: locationId,
|
|
12282
|
+
shipping_profile_id: shippingProfileId
|
|
12283
|
+
});
|
|
12284
|
+
},
|
|
12285
|
+
getOptions: (data) => {
|
|
12286
|
+
return data.shipping_options.map((option) => {
|
|
12287
|
+
var _a2;
|
|
12288
|
+
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12289
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12290
|
+
)) {
|
|
12291
|
+
return void 0;
|
|
12292
|
+
}
|
|
12293
|
+
return {
|
|
12294
|
+
label: option.name,
|
|
12295
|
+
value: option.id
|
|
12296
|
+
};
|
|
12297
|
+
}).filter(Boolean);
|
|
12298
|
+
},
|
|
12299
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
12300
|
+
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12301
|
+
});
|
|
12302
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12303
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12304
|
+
Form$2.Field,
|
|
12305
|
+
{
|
|
12306
|
+
control,
|
|
12307
|
+
name: "shipping_option_id",
|
|
12308
|
+
render: ({ field }) => {
|
|
12309
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12310
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12311
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12312
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12313
|
+
] }),
|
|
12314
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12315
|
+
ConditionalTooltip,
|
|
12316
|
+
{
|
|
12317
|
+
content: tooltipContent,
|
|
12318
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
12319
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12320
|
+
Combobox,
|
|
12321
|
+
{
|
|
12322
|
+
options: shippingOptions.options,
|
|
12323
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
12324
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12325
|
+
searchValue: shippingOptions.searchValue,
|
|
12326
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
12327
|
+
placeholder: "Select shipping option",
|
|
12328
|
+
...field,
|
|
12329
|
+
disabled: !locationId || !shippingProfileId
|
|
12330
|
+
}
|
|
12331
|
+
) }) })
|
|
12332
|
+
}
|
|
12333
|
+
)
|
|
12334
|
+
] }) });
|
|
12335
|
+
}
|
|
12336
|
+
}
|
|
12337
|
+
);
|
|
12338
|
+
};
|
|
12339
|
+
const CustomAmountField = ({
|
|
12340
|
+
control,
|
|
12341
|
+
currencyCode
|
|
12342
|
+
}) => {
|
|
12343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12344
|
+
Form$2.Field,
|
|
12345
|
+
{
|
|
12346
|
+
control,
|
|
12347
|
+
name: "custom_amount",
|
|
12348
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12349
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12350
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12351
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
12352
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
12353
|
+
] }),
|
|
12354
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12355
|
+
ui.CurrencyInput,
|
|
12356
|
+
{
|
|
12357
|
+
...field,
|
|
12358
|
+
onValueChange: (value) => onChange(value),
|
|
12359
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12360
|
+
code: currencyCode
|
|
12635
12361
|
}
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12362
|
+
) })
|
|
12363
|
+
] });
|
|
12364
|
+
}
|
|
12365
|
+
}
|
|
12366
|
+
);
|
|
12367
|
+
};
|
|
12368
|
+
const ShippingAddress = () => {
|
|
12369
|
+
const { id } = reactRouterDom.useParams();
|
|
12370
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12371
|
+
fields: "+shipping_address"
|
|
12372
|
+
});
|
|
12373
|
+
if (isError) {
|
|
12374
|
+
throw error;
|
|
12375
|
+
}
|
|
12376
|
+
const isReady = !isPending && !!order;
|
|
12377
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12378
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12379
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12380
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12641
12381
|
] }),
|
|
12642
|
-
|
|
12643
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12644
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12645
|
-
ui.Button,
|
|
12646
|
-
{
|
|
12647
|
-
size: "small",
|
|
12648
|
-
type: "button",
|
|
12649
|
-
isLoading: isSubmitting,
|
|
12650
|
-
onClick: onSubmit,
|
|
12651
|
-
children: "Save"
|
|
12652
|
-
}
|
|
12653
|
-
)
|
|
12654
|
-
] }) })
|
|
12382
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12655
12383
|
] });
|
|
12656
12384
|
};
|
|
12657
|
-
const
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12385
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12386
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12387
|
+
const form = reactHookForm.useForm({
|
|
12388
|
+
defaultValues: {
|
|
12389
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12390
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12391
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12392
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12393
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12394
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12395
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12396
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12397
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12398
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12399
|
+
},
|
|
12400
|
+
resolver: zod.zodResolver(schema$1)
|
|
12401
|
+
});
|
|
12402
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12403
|
+
const { handleSuccess } = useRouteModal();
|
|
12404
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12405
|
+
await mutateAsync(
|
|
12406
|
+
{
|
|
12407
|
+
shipping_address: {
|
|
12408
|
+
first_name: data.first_name,
|
|
12409
|
+
last_name: data.last_name,
|
|
12410
|
+
company: data.company,
|
|
12411
|
+
address_1: data.address_1,
|
|
12412
|
+
address_2: data.address_2,
|
|
12413
|
+
city: data.city,
|
|
12414
|
+
province: data.province,
|
|
12415
|
+
country_code: data.country_code,
|
|
12416
|
+
postal_code: data.postal_code,
|
|
12417
|
+
phone: data.phone
|
|
12418
|
+
}
|
|
12419
|
+
},
|
|
12420
|
+
{
|
|
12421
|
+
onSuccess: () => {
|
|
12422
|
+
handleSuccess();
|
|
12423
|
+
},
|
|
12424
|
+
onError: (error) => {
|
|
12425
|
+
ui.toast.error(error.message);
|
|
12426
|
+
}
|
|
12427
|
+
}
|
|
12428
|
+
);
|
|
12429
|
+
});
|
|
12430
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12431
|
+
KeyboundForm,
|
|
12681
12432
|
{
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12433
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12434
|
+
onSubmit,
|
|
12435
|
+
children: [
|
|
12436
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12437
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12438
|
+
Form$2.Field,
|
|
12439
|
+
{
|
|
12440
|
+
control: form.control,
|
|
12441
|
+
name: "country_code",
|
|
12442
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12443
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12444
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12446
|
+
] })
|
|
12447
|
+
}
|
|
12448
|
+
),
|
|
12449
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12450
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12451
|
+
Form$2.Field,
|
|
12452
|
+
{
|
|
12453
|
+
control: form.control,
|
|
12454
|
+
name: "first_name",
|
|
12455
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12456
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12457
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12458
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12459
|
+
] })
|
|
12460
|
+
}
|
|
12461
|
+
),
|
|
12462
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12463
|
+
Form$2.Field,
|
|
12464
|
+
{
|
|
12465
|
+
control: form.control,
|
|
12466
|
+
name: "last_name",
|
|
12467
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12468
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12469
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12470
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12471
|
+
] })
|
|
12472
|
+
}
|
|
12473
|
+
)
|
|
12474
|
+
] }),
|
|
12475
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12476
|
+
Form$2.Field,
|
|
12477
|
+
{
|
|
12478
|
+
control: form.control,
|
|
12479
|
+
name: "company",
|
|
12480
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12481
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12482
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12483
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12484
|
+
] })
|
|
12485
|
+
}
|
|
12486
|
+
),
|
|
12487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12488
|
+
Form$2.Field,
|
|
12489
|
+
{
|
|
12490
|
+
control: form.control,
|
|
12491
|
+
name: "address_1",
|
|
12492
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12493
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12494
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12495
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12496
|
+
] })
|
|
12497
|
+
}
|
|
12498
|
+
),
|
|
12499
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12500
|
+
Form$2.Field,
|
|
12501
|
+
{
|
|
12502
|
+
control: form.control,
|
|
12503
|
+
name: "address_2",
|
|
12504
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12505
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12506
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12507
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12508
|
+
] })
|
|
12509
|
+
}
|
|
12510
|
+
),
|
|
12511
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12512
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12513
|
+
Form$2.Field,
|
|
12514
|
+
{
|
|
12515
|
+
control: form.control,
|
|
12516
|
+
name: "postal_code",
|
|
12517
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12518
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12519
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12520
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12521
|
+
] })
|
|
12522
|
+
}
|
|
12523
|
+
),
|
|
12524
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12525
|
+
Form$2.Field,
|
|
12526
|
+
{
|
|
12527
|
+
control: form.control,
|
|
12528
|
+
name: "city",
|
|
12529
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12530
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12531
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12532
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12533
|
+
] })
|
|
12534
|
+
}
|
|
12535
|
+
)
|
|
12536
|
+
] }),
|
|
12537
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12538
|
+
Form$2.Field,
|
|
12539
|
+
{
|
|
12540
|
+
control: form.control,
|
|
12541
|
+
name: "province",
|
|
12542
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12543
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12544
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12545
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12546
|
+
] })
|
|
12547
|
+
}
|
|
12548
|
+
),
|
|
12549
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12550
|
+
Form$2.Field,
|
|
12551
|
+
{
|
|
12552
|
+
control: form.control,
|
|
12553
|
+
name: "phone",
|
|
12554
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12555
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12556
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12557
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12558
|
+
] })
|
|
12559
|
+
}
|
|
12560
|
+
)
|
|
12561
|
+
] }) }),
|
|
12562
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12563
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12564
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12565
|
+
] }) })
|
|
12566
|
+
]
|
|
12687
12567
|
}
|
|
12688
|
-
);
|
|
12568
|
+
) });
|
|
12689
12569
|
};
|
|
12690
|
-
const
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12570
|
+
const schema$1 = addressSchema;
|
|
12571
|
+
const TransferOwnership = () => {
|
|
12572
|
+
const { id } = reactRouterDom.useParams();
|
|
12573
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12574
|
+
fields: "id,customer_id,customer.*"
|
|
12575
|
+
});
|
|
12576
|
+
if (isError) {
|
|
12577
|
+
throw error;
|
|
12578
|
+
}
|
|
12579
|
+
const isReady = !isPending && !!draft_order;
|
|
12580
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12581
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12582
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
12583
|
+
/* @__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" }) })
|
|
12584
|
+
] }),
|
|
12585
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12586
|
+
] });
|
|
12587
|
+
};
|
|
12588
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12589
|
+
var _a, _b;
|
|
12697
12590
|
const form = reactHookForm.useForm({
|
|
12698
|
-
resolver: zod.zodResolver(shippingMethodSchema),
|
|
12699
12591
|
defaultValues: {
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
}
|
|
12592
|
+
customer_id: order.customer_id || ""
|
|
12593
|
+
},
|
|
12594
|
+
resolver: zod.zodResolver(schema)
|
|
12704
12595
|
});
|
|
12705
|
-
const { mutateAsync
|
|
12706
|
-
const {
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
if (data.shippingMethod) {
|
|
12716
|
-
await updateShippingMethod(
|
|
12717
|
-
{
|
|
12718
|
-
method_id: data.shippingMethod.id,
|
|
12719
|
-
shipping_option_id: values.shipping_option_id,
|
|
12720
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12721
|
-
},
|
|
12722
|
-
{
|
|
12723
|
-
onError: (e) => {
|
|
12724
|
-
ui.toast.error(e.message);
|
|
12725
|
-
},
|
|
12726
|
-
onSuccess: () => {
|
|
12727
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12728
|
-
}
|
|
12729
|
-
}
|
|
12730
|
-
);
|
|
12731
|
-
return;
|
|
12732
|
-
}
|
|
12733
|
-
await addShippingMethod(
|
|
12734
|
-
{
|
|
12735
|
-
shipping_option_id: values.shipping_option_id,
|
|
12736
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12737
|
-
},
|
|
12596
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12597
|
+
const { handleSuccess } = useRouteModal();
|
|
12598
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12599
|
+
const currentCustomer = order.customer ? {
|
|
12600
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12601
|
+
value: order.customer.id
|
|
12602
|
+
} : null;
|
|
12603
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12604
|
+
await mutateAsync(
|
|
12605
|
+
{ customer_id: data.customer_id },
|
|
12738
12606
|
{
|
|
12739
|
-
onError: (e) => {
|
|
12740
|
-
ui.toast.error(e.message);
|
|
12741
|
-
},
|
|
12742
12607
|
onSuccess: () => {
|
|
12743
|
-
|
|
12608
|
+
ui.toast.success("Customer updated");
|
|
12609
|
+
handleSuccess();
|
|
12610
|
+
},
|
|
12611
|
+
onError: (error) => {
|
|
12612
|
+
ui.toast.error(error.message);
|
|
12744
12613
|
}
|
|
12745
12614
|
}
|
|
12746
12615
|
);
|
|
12747
12616
|
});
|
|
12748
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12617
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12749
12618
|
KeyboundForm,
|
|
12750
12619
|
{
|
|
12751
|
-
className: "flex
|
|
12620
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12752
12621
|
onSubmit,
|
|
12753
12622
|
children: [
|
|
12754
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12755
|
-
|
|
12756
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12757
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12758
|
-
|
|
12623
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12624
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
12625
|
+
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12626
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12627
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12628
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
12629
|
+
] }),
|
|
12630
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12631
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
12632
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12633
|
+
] })
|
|
12759
12634
|
] }),
|
|
12760
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12761
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12762
|
-
LocationField,
|
|
12763
|
-
{
|
|
12764
|
-
control: form.control,
|
|
12765
|
-
setValue: form.setValue
|
|
12766
|
-
}
|
|
12767
|
-
),
|
|
12768
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12769
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12770
|
-
ShippingOptionField,
|
|
12771
|
-
{
|
|
12772
|
-
shippingProfileId: data.shippingProfileId,
|
|
12773
|
-
preview,
|
|
12774
|
-
control: form.control
|
|
12775
|
-
}
|
|
12776
|
-
),
|
|
12777
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12778
12635
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12779
|
-
|
|
12636
|
+
CustomerField,
|
|
12780
12637
|
{
|
|
12781
12638
|
control: form.control,
|
|
12782
|
-
|
|
12783
|
-
}
|
|
12784
|
-
),
|
|
12785
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12786
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12787
|
-
ItemsPreview,
|
|
12788
|
-
{
|
|
12789
|
-
order,
|
|
12790
|
-
shippingProfileId: data.shippingProfileId
|
|
12791
|
-
}
|
|
12792
|
-
)
|
|
12793
|
-
] }) }) }),
|
|
12794
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12795
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12796
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12797
|
-
ui.Button,
|
|
12798
|
-
{
|
|
12799
|
-
size: "small",
|
|
12800
|
-
type: "submit",
|
|
12801
|
-
isLoading: isPending || isUpdatingShippingMethod,
|
|
12802
|
-
children: data.shippingMethod ? "Update" : "Add"
|
|
12639
|
+
currentCustomerId: order.customer_id
|
|
12803
12640
|
}
|
|
12804
12641
|
)
|
|
12642
|
+
] }),
|
|
12643
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12644
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12645
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12805
12646
|
] }) })
|
|
12806
12647
|
]
|
|
12807
12648
|
}
|
|
12808
|
-
) })
|
|
12809
|
-
};
|
|
12810
|
-
const shippingMethodSchema = objectType({
|
|
12811
|
-
location_id: stringType(),
|
|
12812
|
-
shipping_option_id: stringType(),
|
|
12813
|
-
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12814
|
-
});
|
|
12815
|
-
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12816
|
-
const matches = order.items.filter(
|
|
12817
|
-
(item) => {
|
|
12818
|
-
var _a, _b, _c;
|
|
12819
|
-
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12820
|
-
}
|
|
12821
|
-
);
|
|
12822
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12823
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12824
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12825
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12826
|
-
] }) }),
|
|
12827
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12828
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
12829
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12830
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12831
|
-
] }),
|
|
12832
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12833
|
-
"div",
|
|
12834
|
-
{
|
|
12835
|
-
className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
|
|
12836
|
-
children: [
|
|
12837
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12838
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12839
|
-
Thumbnail,
|
|
12840
|
-
{
|
|
12841
|
-
thumbnail: item.thumbnail,
|
|
12842
|
-
alt: item.product_title ?? void 0
|
|
12843
|
-
}
|
|
12844
|
-
),
|
|
12845
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12846
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12847
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12848
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12849
|
-
ui.Text,
|
|
12850
|
-
{
|
|
12851
|
-
size: "small",
|
|
12852
|
-
leading: "compact",
|
|
12853
|
-
className: "text-ui-fg-subtle",
|
|
12854
|
-
children: [
|
|
12855
|
-
"(",
|
|
12856
|
-
item.variant_title,
|
|
12857
|
-
")"
|
|
12858
|
-
]
|
|
12859
|
-
}
|
|
12860
|
-
)
|
|
12861
|
-
] }),
|
|
12862
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12863
|
-
ui.Text,
|
|
12864
|
-
{
|
|
12865
|
-
size: "small",
|
|
12866
|
-
leading: "compact",
|
|
12867
|
-
className: "text-ui-fg-subtle",
|
|
12868
|
-
children: item.variant_sku
|
|
12869
|
-
}
|
|
12870
|
-
)
|
|
12871
|
-
] })
|
|
12872
|
-
] }),
|
|
12873
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12874
|
-
ui.Text,
|
|
12875
|
-
{
|
|
12876
|
-
size: "small",
|
|
12877
|
-
leading: "compact",
|
|
12878
|
-
className: "text-ui-fg-subtle",
|
|
12879
|
-
children: [
|
|
12880
|
-
item.quantity,
|
|
12881
|
-
"x"
|
|
12882
|
-
]
|
|
12883
|
-
}
|
|
12884
|
-
)
|
|
12885
|
-
]
|
|
12886
|
-
},
|
|
12887
|
-
item.id
|
|
12888
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
12889
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12890
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12891
|
-
'No items found for "',
|
|
12892
|
-
query,
|
|
12893
|
-
'".'
|
|
12894
|
-
] })
|
|
12895
|
-
] }) })
|
|
12896
|
-
] })
|
|
12897
|
-
] });
|
|
12649
|
+
) });
|
|
12898
12650
|
};
|
|
12899
|
-
const
|
|
12900
|
-
const
|
|
12901
|
-
queryKey: ["locations"],
|
|
12651
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12652
|
+
const customers = useComboboxData({
|
|
12902
12653
|
queryFn: async (params) => {
|
|
12903
|
-
return await sdk.admin.
|
|
12654
|
+
return await sdk.admin.customer.list({
|
|
12655
|
+
...params,
|
|
12656
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12657
|
+
});
|
|
12904
12658
|
},
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12659
|
+
queryKey: ["customers"],
|
|
12660
|
+
getOptions: (data) => {
|
|
12661
|
+
return data.customers.map((customer) => {
|
|
12662
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12663
|
+
return {
|
|
12664
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12665
|
+
value: customer.id
|
|
12666
|
+
};
|
|
12667
|
+
});
|
|
12910
12668
|
}
|
|
12911
12669
|
});
|
|
12912
12670
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12913
12671
|
Form$2.Field,
|
|
12914
12672
|
{
|
|
12673
|
+
name: "customer_id",
|
|
12915
12674
|
control,
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12675
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12677
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
12678
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
12679
|
+
] }),
|
|
12680
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12681
|
+
Combobox,
|
|
12682
|
+
{
|
|
12683
|
+
options: customers.options,
|
|
12684
|
+
fetchNextPage: customers.fetchNextPage,
|
|
12685
|
+
isFetchingNextPage: customers.isFetchingNextPage,
|
|
12686
|
+
searchValue: customers.searchValue,
|
|
12687
|
+
onSearchValueChange: customers.onSearchValueChange,
|
|
12688
|
+
placeholder: "Select customer",
|
|
12689
|
+
...field
|
|
12690
|
+
}
|
|
12691
|
+
) }),
|
|
12692
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12693
|
+
] })
|
|
12694
|
+
}
|
|
12695
|
+
);
|
|
12696
|
+
};
|
|
12697
|
+
const Illustration = () => {
|
|
12698
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12699
|
+
"svg",
|
|
12700
|
+
{
|
|
12701
|
+
width: "280",
|
|
12702
|
+
height: "180",
|
|
12703
|
+
viewBox: "0 0 280 180",
|
|
12704
|
+
fill: "none",
|
|
12705
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12706
|
+
children: [
|
|
12707
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12708
|
+
"rect",
|
|
12709
|
+
{
|
|
12710
|
+
x: "0.00428286",
|
|
12711
|
+
y: "-0.742904",
|
|
12712
|
+
width: "33.5",
|
|
12713
|
+
height: "65.5",
|
|
12714
|
+
rx: "6.75",
|
|
12715
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
12716
|
+
fill: "#D4D4D8",
|
|
12717
|
+
stroke: "#52525B",
|
|
12718
|
+
strokeWidth: "1.5"
|
|
12719
|
+
}
|
|
12720
|
+
),
|
|
12721
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12722
|
+
"rect",
|
|
12723
|
+
{
|
|
12724
|
+
x: "0.00428286",
|
|
12725
|
+
y: "-0.742904",
|
|
12726
|
+
width: "33.5",
|
|
12727
|
+
height: "65.5",
|
|
12728
|
+
rx: "6.75",
|
|
12729
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
12730
|
+
fill: "white",
|
|
12731
|
+
stroke: "#52525B",
|
|
12732
|
+
strokeWidth: "1.5"
|
|
12733
|
+
}
|
|
12734
|
+
),
|
|
12735
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12736
|
+
"path",
|
|
12737
|
+
{
|
|
12738
|
+
d: "M180.579 107.142L179.126 107.959",
|
|
12739
|
+
stroke: "#52525B",
|
|
12740
|
+
strokeWidth: "1.5",
|
|
12741
|
+
strokeLinecap: "round",
|
|
12742
|
+
strokeLinejoin: "round"
|
|
12743
|
+
}
|
|
12744
|
+
),
|
|
12745
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12746
|
+
"path",
|
|
12747
|
+
{
|
|
12748
|
+
opacity: "0.88",
|
|
12749
|
+
d: "M182.305 109.546L180.257 109.534",
|
|
12750
|
+
stroke: "#52525B",
|
|
12751
|
+
strokeWidth: "1.5",
|
|
12752
|
+
strokeLinecap: "round",
|
|
12753
|
+
strokeLinejoin: "round"
|
|
12754
|
+
}
|
|
12755
|
+
),
|
|
12756
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12757
|
+
"path",
|
|
12758
|
+
{
|
|
12759
|
+
opacity: "0.75",
|
|
12760
|
+
d: "M180.551 111.93L179.108 111.096",
|
|
12761
|
+
stroke: "#52525B",
|
|
12762
|
+
strokeWidth: "1.5",
|
|
12763
|
+
strokeLinecap: "round",
|
|
12764
|
+
strokeLinejoin: "round"
|
|
12765
|
+
}
|
|
12766
|
+
),
|
|
12767
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12768
|
+
"path",
|
|
12769
|
+
{
|
|
12770
|
+
opacity: "0.63",
|
|
12771
|
+
d: "M176.347 112.897L176.354 111.73",
|
|
12772
|
+
stroke: "#52525B",
|
|
12773
|
+
strokeWidth: "1.5",
|
|
12774
|
+
strokeLinecap: "round",
|
|
12775
|
+
strokeLinejoin: "round"
|
|
12776
|
+
}
|
|
12777
|
+
),
|
|
12778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12779
|
+
"path",
|
|
12780
|
+
{
|
|
12781
|
+
opacity: "0.5",
|
|
12782
|
+
d: "M172.153 111.881L173.606 111.064",
|
|
12783
|
+
stroke: "#52525B",
|
|
12784
|
+
strokeWidth: "1.5",
|
|
12785
|
+
strokeLinecap: "round",
|
|
12786
|
+
strokeLinejoin: "round"
|
|
12787
|
+
}
|
|
12788
|
+
),
|
|
12789
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12790
|
+
"path",
|
|
12791
|
+
{
|
|
12792
|
+
opacity: "0.38",
|
|
12793
|
+
d: "M170.428 109.478L172.476 109.489",
|
|
12794
|
+
stroke: "#52525B",
|
|
12795
|
+
strokeWidth: "1.5",
|
|
12796
|
+
strokeLinecap: "round",
|
|
12797
|
+
strokeLinejoin: "round"
|
|
12798
|
+
}
|
|
12799
|
+
),
|
|
12800
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12801
|
+
"path",
|
|
12802
|
+
{
|
|
12803
|
+
opacity: "0.25",
|
|
12804
|
+
d: "M172.181 107.094L173.624 107.928",
|
|
12805
|
+
stroke: "#52525B",
|
|
12806
|
+
strokeWidth: "1.5",
|
|
12807
|
+
strokeLinecap: "round",
|
|
12808
|
+
strokeLinejoin: "round"
|
|
12809
|
+
}
|
|
12810
|
+
),
|
|
12811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12812
|
+
"path",
|
|
12813
|
+
{
|
|
12814
|
+
opacity: "0.13",
|
|
12815
|
+
d: "M176.386 106.126L176.379 107.294",
|
|
12816
|
+
stroke: "#52525B",
|
|
12817
|
+
strokeWidth: "1.5",
|
|
12818
|
+
strokeLinecap: "round",
|
|
12819
|
+
strokeLinejoin: "round"
|
|
12820
|
+
}
|
|
12821
|
+
),
|
|
12822
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12823
|
+
"rect",
|
|
12824
|
+
{
|
|
12825
|
+
width: "12",
|
|
12826
|
+
height: "3",
|
|
12827
|
+
rx: "1.5",
|
|
12828
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12829
|
+
fill: "#D4D4D8"
|
|
12830
|
+
}
|
|
12831
|
+
),
|
|
12832
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12833
|
+
"rect",
|
|
12834
|
+
{
|
|
12835
|
+
x: "0.00428286",
|
|
12836
|
+
y: "-0.742904",
|
|
12837
|
+
width: "33.5",
|
|
12838
|
+
height: "65.5",
|
|
12839
|
+
rx: "6.75",
|
|
12840
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12841
|
+
fill: "#D4D4D8",
|
|
12842
|
+
stroke: "#52525B",
|
|
12843
|
+
strokeWidth: "1.5"
|
|
12844
|
+
}
|
|
12845
|
+
),
|
|
12846
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12847
|
+
"rect",
|
|
12848
|
+
{
|
|
12849
|
+
x: "0.00428286",
|
|
12850
|
+
y: "-0.742904",
|
|
12851
|
+
width: "33.5",
|
|
12852
|
+
height: "65.5",
|
|
12853
|
+
rx: "6.75",
|
|
12854
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12855
|
+
fill: "white",
|
|
12856
|
+
stroke: "#52525B",
|
|
12857
|
+
strokeWidth: "1.5"
|
|
12858
|
+
}
|
|
12859
|
+
),
|
|
12860
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12861
|
+
"rect",
|
|
12862
|
+
{
|
|
12863
|
+
width: "12",
|
|
12864
|
+
height: "3",
|
|
12865
|
+
rx: "1.5",
|
|
12866
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12867
|
+
fill: "#D4D4D8"
|
|
12868
|
+
}
|
|
12869
|
+
),
|
|
12870
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12871
|
+
"rect",
|
|
12872
|
+
{
|
|
12873
|
+
width: "17",
|
|
12874
|
+
height: "3",
|
|
12875
|
+
rx: "1.5",
|
|
12876
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12877
|
+
fill: "#D4D4D8"
|
|
12878
|
+
}
|
|
12879
|
+
),
|
|
12880
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12881
|
+
"rect",
|
|
12882
|
+
{
|
|
12883
|
+
width: "12",
|
|
12884
|
+
height: "3",
|
|
12885
|
+
rx: "1.5",
|
|
12886
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12887
|
+
fill: "#D4D4D8"
|
|
12888
|
+
}
|
|
12889
|
+
),
|
|
12890
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12891
|
+
"path",
|
|
12892
|
+
{
|
|
12893
|
+
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",
|
|
12894
|
+
fill: "#A1A1AA"
|
|
12895
|
+
}
|
|
12896
|
+
),
|
|
12897
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12898
|
+
"rect",
|
|
12899
|
+
{
|
|
12900
|
+
width: "17",
|
|
12901
|
+
height: "3",
|
|
12902
|
+
rx: "1.5",
|
|
12903
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12904
|
+
fill: "#A1A1AA"
|
|
12905
|
+
}
|
|
12906
|
+
),
|
|
12907
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12908
|
+
"rect",
|
|
12909
|
+
{
|
|
12910
|
+
width: "12",
|
|
12911
|
+
height: "3",
|
|
12912
|
+
rx: "1.5",
|
|
12913
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12914
|
+
fill: "#A1A1AA"
|
|
12915
|
+
}
|
|
12916
|
+
),
|
|
12917
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12918
|
+
"path",
|
|
12919
|
+
{
|
|
12920
|
+
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",
|
|
12921
|
+
fill: "#52525B"
|
|
12922
|
+
}
|
|
12923
|
+
),
|
|
12924
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12925
|
+
"path",
|
|
12926
|
+
{
|
|
12927
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12928
|
+
stroke: "#A1A1AA",
|
|
12929
|
+
strokeWidth: "1.5",
|
|
12930
|
+
strokeLinecap: "round",
|
|
12931
|
+
strokeLinejoin: "round"
|
|
12932
|
+
}
|
|
12933
|
+
) }),
|
|
12934
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12935
|
+
"path",
|
|
12936
|
+
{
|
|
12937
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12938
|
+
stroke: "#A1A1AA",
|
|
12939
|
+
strokeWidth: "1.5",
|
|
12940
|
+
strokeLinecap: "round",
|
|
12941
|
+
strokeLinejoin: "round"
|
|
12942
|
+
}
|
|
12943
|
+
) }),
|
|
12944
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12945
|
+
"path",
|
|
12946
|
+
{
|
|
12947
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12948
|
+
stroke: "#A1A1AA",
|
|
12949
|
+
strokeWidth: "1.5",
|
|
12950
|
+
strokeLinecap: "round",
|
|
12951
|
+
strokeLinejoin: "round"
|
|
12952
|
+
}
|
|
12953
|
+
) }),
|
|
12954
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12955
|
+
"path",
|
|
12956
|
+
{
|
|
12957
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12958
|
+
stroke: "#A1A1AA",
|
|
12959
|
+
strokeWidth: "1.5",
|
|
12960
|
+
strokeLinecap: "round",
|
|
12961
|
+
strokeLinejoin: "round"
|
|
12962
|
+
}
|
|
12963
|
+
) }),
|
|
12964
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12965
|
+
"path",
|
|
12966
|
+
{
|
|
12967
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12968
|
+
stroke: "#A1A1AA",
|
|
12969
|
+
strokeWidth: "1.5",
|
|
12970
|
+
strokeLinecap: "round",
|
|
12971
|
+
strokeLinejoin: "round"
|
|
12972
|
+
}
|
|
12973
|
+
) }),
|
|
12974
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12975
|
+
"path",
|
|
12976
|
+
{
|
|
12977
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12978
|
+
stroke: "#A1A1AA",
|
|
12979
|
+
strokeWidth: "1.5",
|
|
12980
|
+
strokeLinecap: "round",
|
|
12981
|
+
strokeLinejoin: "round"
|
|
12982
|
+
}
|
|
12983
|
+
) }),
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12985
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12986
|
+
"rect",
|
|
12925
12987
|
{
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
12931
|
-
placeholder: "Select location",
|
|
12932
|
-
onChange: (value) => {
|
|
12933
|
-
setValue("shipping_option_id", "", {
|
|
12934
|
-
shouldDirty: true,
|
|
12935
|
-
shouldTouch: true
|
|
12936
|
-
});
|
|
12937
|
-
onChange(value);
|
|
12938
|
-
},
|
|
12939
|
-
...field
|
|
12988
|
+
width: "12",
|
|
12989
|
+
height: "12",
|
|
12990
|
+
fill: "white",
|
|
12991
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12940
12992
|
}
|
|
12941
|
-
) })
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
}
|
|
12945
|
-
);
|
|
12946
|
-
};
|
|
12947
|
-
const ShippingOptionField = ({
|
|
12948
|
-
shippingProfileId,
|
|
12949
|
-
preview,
|
|
12950
|
-
control
|
|
12951
|
-
}) => {
|
|
12952
|
-
var _a;
|
|
12953
|
-
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12954
|
-
const shippingOptions = useComboboxData({
|
|
12955
|
-
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12956
|
-
queryFn: async (params) => {
|
|
12957
|
-
return await sdk.admin.shippingOption.list({
|
|
12958
|
-
...params,
|
|
12959
|
-
stock_location_id: locationId,
|
|
12960
|
-
shipping_profile_id: shippingProfileId
|
|
12961
|
-
});
|
|
12962
|
-
},
|
|
12963
|
-
getOptions: (data) => {
|
|
12964
|
-
return data.shipping_options.map((option) => {
|
|
12965
|
-
var _a2;
|
|
12966
|
-
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12967
|
-
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12968
|
-
)) {
|
|
12969
|
-
return void 0;
|
|
12970
|
-
}
|
|
12971
|
-
return {
|
|
12972
|
-
label: option.name,
|
|
12973
|
-
value: option.id
|
|
12974
|
-
};
|
|
12975
|
-
}).filter(Boolean);
|
|
12976
|
-
},
|
|
12977
|
-
enabled: !!locationId && !!shippingProfileId,
|
|
12978
|
-
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12979
|
-
});
|
|
12980
|
-
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12981
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12982
|
-
Form$2.Field,
|
|
12983
|
-
{
|
|
12984
|
-
control,
|
|
12985
|
-
name: "shipping_option_id",
|
|
12986
|
-
render: ({ field }) => {
|
|
12987
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12988
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12989
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12990
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12991
|
-
] }),
|
|
12992
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12993
|
-
ConditionalTooltip,
|
|
12993
|
+
) }),
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
+
"rect",
|
|
12994
12996
|
{
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
{
|
|
13000
|
-
options: shippingOptions.options,
|
|
13001
|
-
fetchNextPage: shippingOptions.fetchNextPage,
|
|
13002
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
13003
|
-
searchValue: shippingOptions.searchValue,
|
|
13004
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
13005
|
-
placeholder: "Select shipping option",
|
|
13006
|
-
...field,
|
|
13007
|
-
disabled: !locationId || !shippingProfileId
|
|
13008
|
-
}
|
|
13009
|
-
) }) })
|
|
12997
|
+
width: "12",
|
|
12998
|
+
height: "12",
|
|
12999
|
+
fill: "white",
|
|
13000
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
13010
13001
|
}
|
|
13011
|
-
)
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
}
|
|
13015
|
-
);
|
|
13016
|
-
};
|
|
13017
|
-
const CustomAmountField = ({
|
|
13018
|
-
control,
|
|
13019
|
-
currencyCode
|
|
13020
|
-
}) => {
|
|
13021
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
-
Form$2.Field,
|
|
13023
|
-
{
|
|
13024
|
-
control,
|
|
13025
|
-
name: "custom_amount",
|
|
13026
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
13027
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
13028
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
13029
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
13030
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
13031
|
-
] }),
|
|
13032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13033
|
-
ui.CurrencyInput,
|
|
13002
|
+
) }),
|
|
13003
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13004
|
+
"rect",
|
|
13034
13005
|
{
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13006
|
+
width: "12",
|
|
13007
|
+
height: "12",
|
|
13008
|
+
fill: "white",
|
|
13009
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
13010
|
+
}
|
|
13011
|
+
) }),
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
"rect",
|
|
13014
|
+
{
|
|
13015
|
+
width: "12",
|
|
13016
|
+
height: "12",
|
|
13017
|
+
fill: "white",
|
|
13018
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
13019
|
+
}
|
|
13020
|
+
) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
+
"rect",
|
|
13023
|
+
{
|
|
13024
|
+
width: "12",
|
|
13025
|
+
height: "12",
|
|
13026
|
+
fill: "white",
|
|
13027
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13028
|
+
}
|
|
13029
|
+
) }),
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13031
|
+
"rect",
|
|
13032
|
+
{
|
|
13033
|
+
width: "12",
|
|
13034
|
+
height: "12",
|
|
13035
|
+
fill: "white",
|
|
13036
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13039
13037
|
}
|
|
13040
13038
|
) })
|
|
13041
|
-
] })
|
|
13042
|
-
|
|
13039
|
+
] })
|
|
13040
|
+
]
|
|
13043
13041
|
}
|
|
13044
13042
|
);
|
|
13045
13043
|
};
|
|
13044
|
+
const schema = objectType({
|
|
13045
|
+
customer_id: stringType().min(1)
|
|
13046
|
+
});
|
|
13046
13047
|
const widgetModule = { widgets: [] };
|
|
13047
13048
|
const routeModule = {
|
|
13048
13049
|
routes: [
|
|
@@ -13067,6 +13068,10 @@ const routeModule = {
|
|
|
13067
13068
|
Component: BillingAddress,
|
|
13068
13069
|
path: "/draft-orders/:id/billing-address"
|
|
13069
13070
|
},
|
|
13071
|
+
{
|
|
13072
|
+
Component: Email,
|
|
13073
|
+
path: "/draft-orders/:id/email"
|
|
13074
|
+
},
|
|
13070
13075
|
{
|
|
13071
13076
|
Component: CustomItems,
|
|
13072
13077
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13076,21 +13081,21 @@ const routeModule = {
|
|
|
13076
13081
|
path: "/draft-orders/:id/items"
|
|
13077
13082
|
},
|
|
13078
13083
|
{
|
|
13079
|
-
Component:
|
|
13080
|
-
path: "/draft-orders/:id/
|
|
13084
|
+
Component: Metadata,
|
|
13085
|
+
path: "/draft-orders/:id/metadata"
|
|
13081
13086
|
},
|
|
13082
13087
|
{
|
|
13083
13088
|
Component: Promotions,
|
|
13084
13089
|
path: "/draft-orders/:id/promotions"
|
|
13085
13090
|
},
|
|
13086
|
-
{
|
|
13087
|
-
Component: Metadata,
|
|
13088
|
-
path: "/draft-orders/:id/metadata"
|
|
13089
|
-
},
|
|
13090
13091
|
{
|
|
13091
13092
|
Component: SalesChannel,
|
|
13092
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
13093
13094
|
},
|
|
13095
|
+
{
|
|
13096
|
+
Component: Shipping,
|
|
13097
|
+
path: "/draft-orders/:id/shipping"
|
|
13098
|
+
},
|
|
13094
13099
|
{
|
|
13095
13100
|
Component: ShippingAddress,
|
|
13096
13101
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13098,10 +13103,6 @@ const routeModule = {
|
|
|
13098
13103
|
{
|
|
13099
13104
|
Component: TransferOwnership,
|
|
13100
13105
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13101
|
-
},
|
|
13102
|
-
{
|
|
13103
|
-
Component: Shipping,
|
|
13104
|
-
path: "/draft-orders/:id/shipping"
|
|
13105
13106
|
}
|
|
13106
13107
|
]
|
|
13107
13108
|
}
|