@medusajs/draft-order 2.12.1 → 2.12.2-snapshot-20251203100938
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 +1072 -1072
- package/.medusa/server/src/admin/index.mjs +1072 -1072
- package/package.json +16 -16
|
@@ -9762,27 +9762,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9762
9762
|
) });
|
|
9763
9763
|
};
|
|
9764
9764
|
const schema$5 = addressSchema;
|
|
9765
|
-
const CustomItems = () => {
|
|
9766
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9767
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9768
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9769
|
-
] });
|
|
9770
|
-
};
|
|
9771
|
-
const CustomItemsForm = () => {
|
|
9772
|
-
const form = reactHookForm.useForm({
|
|
9773
|
-
resolver: zod.zodResolver(schema$4)
|
|
9774
|
-
});
|
|
9775
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9777
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9778
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9779
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9780
|
-
] }) })
|
|
9781
|
-
] }) });
|
|
9782
|
-
};
|
|
9783
|
-
const schema$4 = objectType({
|
|
9784
|
-
email: stringType().email()
|
|
9785
|
-
});
|
|
9786
9765
|
const Email = () => {
|
|
9787
9766
|
const { id } = reactRouterDom.useParams();
|
|
9788
9767
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9805,7 +9784,7 @@ const EmailForm = ({ order }) => {
|
|
|
9805
9784
|
defaultValues: {
|
|
9806
9785
|
email: order.email ?? ""
|
|
9807
9786
|
},
|
|
9808
|
-
resolver: zod.zodResolver(schema$
|
|
9787
|
+
resolver: zod.zodResolver(schema$4)
|
|
9809
9788
|
});
|
|
9810
9789
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9811
9790
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9848,6 +9827,27 @@ const EmailForm = ({ order }) => {
|
|
|
9848
9827
|
}
|
|
9849
9828
|
) });
|
|
9850
9829
|
};
|
|
9830
|
+
const schema$4 = objectType({
|
|
9831
|
+
email: stringType().email()
|
|
9832
|
+
});
|
|
9833
|
+
const CustomItems = () => {
|
|
9834
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9835
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9836
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9837
|
+
] });
|
|
9838
|
+
};
|
|
9839
|
+
const CustomItemsForm = () => {
|
|
9840
|
+
const form = reactHookForm.useForm({
|
|
9841
|
+
resolver: zod.zodResolver(schema$3)
|
|
9842
|
+
});
|
|
9843
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9845
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9846
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9847
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9848
|
+
] }) })
|
|
9849
|
+
] }) });
|
|
9850
|
+
};
|
|
9851
9851
|
const schema$3 = objectType({
|
|
9852
9852
|
email: stringType().email()
|
|
9853
9853
|
});
|
|
@@ -10825,392 +10825,115 @@ const customItemSchema = objectType({
|
|
|
10825
10825
|
quantity: numberType(),
|
|
10826
10826
|
unit_price: unionType([numberType(), stringType()])
|
|
10827
10827
|
});
|
|
10828
|
-
const
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
}
|
|
10848
|
-
|
|
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 = () => {
|
|
10849
10873
|
const { id } = reactRouterDom.useParams();
|
|
10850
|
-
const {
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
useInitiateOrderEdit({ preview });
|
|
10856
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10857
|
-
if (isPreviewError) {
|
|
10858
|
-
throw previewError;
|
|
10874
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10875
|
+
fields: "metadata"
|
|
10876
|
+
});
|
|
10877
|
+
if (isError) {
|
|
10878
|
+
throw error;
|
|
10859
10879
|
}
|
|
10860
|
-
const isReady = !!
|
|
10861
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, {
|
|
10862
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10863
|
-
|
|
10880
|
+
const isReady = !isPending && !!order;
|
|
10881
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10882
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { 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." }) })
|
|
10885
|
+
] }),
|
|
10886
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10864
10887
|
] });
|
|
10865
10888
|
};
|
|
10866
|
-
const
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
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 }) => {
|
|
10870
10892
|
const { handleSuccess } = useRouteModal();
|
|
10871
|
-
const
|
|
10872
|
-
const
|
|
10873
|
-
const
|
|
10874
|
-
{
|
|
10875
|
-
|
|
10876
|
-
},
|
|
10877
|
-
{
|
|
10878
|
-
enabled: !!promoIds.length
|
|
10879
|
-
}
|
|
10880
|
-
);
|
|
10881
|
-
const comboboxData = useComboboxData({
|
|
10882
|
-
queryKey: ["promotions", "combobox", promoIds],
|
|
10883
|
-
queryFn: async (params) => {
|
|
10884
|
-
return await sdk.admin.promotion.list({
|
|
10885
|
-
...params,
|
|
10886
|
-
id: {
|
|
10887
|
-
$nin: promoIds
|
|
10888
|
-
}
|
|
10889
|
-
});
|
|
10893
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10894
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10895
|
+
const form = reactHookForm.useForm({
|
|
10896
|
+
defaultValues: {
|
|
10897
|
+
metadata: getDefaultValues(metadata)
|
|
10890
10898
|
},
|
|
10891
|
-
|
|
10892
|
-
return data.promotions.map((promotion) => ({
|
|
10893
|
-
label: promotion.code,
|
|
10894
|
-
value: promotion.code
|
|
10895
|
-
}));
|
|
10896
|
-
}
|
|
10899
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10897
10900
|
});
|
|
10898
|
-
const
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
}
|
|
10902
|
-
addPromotions(
|
|
10901
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10902
|
+
const parsedData = parseValues(data);
|
|
10903
|
+
await mutateAsync(
|
|
10903
10904
|
{
|
|
10904
|
-
|
|
10905
|
+
metadata: parsedData
|
|
10905
10906
|
},
|
|
10906
10907
|
{
|
|
10907
|
-
onError: (e) => {
|
|
10908
|
-
ui.toast.error(e.message);
|
|
10909
|
-
comboboxData.onSearchValueChange("");
|
|
10910
|
-
setComboboxValue("");
|
|
10911
|
-
},
|
|
10912
10908
|
onSuccess: () => {
|
|
10913
|
-
|
|
10914
|
-
|
|
10909
|
+
ui.toast.success("Metadata updated");
|
|
10910
|
+
handleSuccess();
|
|
10911
|
+
},
|
|
10912
|
+
onError: (error) => {
|
|
10913
|
+
ui.toast.error(error.message);
|
|
10915
10914
|
}
|
|
10916
10915
|
}
|
|
10917
10916
|
);
|
|
10918
|
-
};
|
|
10919
|
-
const {
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
}
|
|
10931
|
-
});
|
|
10932
|
-
if (!requestSucceeded) {
|
|
10933
|
-
setIsSubmitting(false);
|
|
10934
|
-
return;
|
|
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
|
+
});
|
|
10935
10930
|
}
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
},
|
|
10943
|
-
onSettled: () => {
|
|
10944
|
-
setIsSubmitting(false);
|
|
10945
|
-
}
|
|
10946
|
-
});
|
|
10947
|
-
};
|
|
10948
|
-
if (isError) {
|
|
10949
|
-
throw error;
|
|
10950
|
-
}
|
|
10951
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
10952
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
10953
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10954
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
10955
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
10956
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
10957
|
-
] }),
|
|
10958
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10959
|
-
Combobox,
|
|
10960
|
-
{
|
|
10961
|
-
id: "promotion-combobox",
|
|
10962
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
10963
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10964
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
10965
|
-
options: comboboxData.options,
|
|
10966
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10967
|
-
searchValue: comboboxData.searchValue,
|
|
10968
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10969
|
-
onChange: add,
|
|
10970
|
-
value: comboboxValue
|
|
10971
|
-
}
|
|
10972
|
-
)
|
|
10973
|
-
] }),
|
|
10974
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10975
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
10976
|
-
PromotionItem,
|
|
10977
|
-
{
|
|
10978
|
-
promotion,
|
|
10979
|
-
orderId: preview.id,
|
|
10980
|
-
isLoading: isPending
|
|
10981
|
-
},
|
|
10982
|
-
promotion.id
|
|
10983
|
-
)) })
|
|
10984
|
-
] }) }),
|
|
10985
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10986
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10987
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10988
|
-
ui.Button,
|
|
10989
|
-
{
|
|
10990
|
-
size: "small",
|
|
10991
|
-
type: "submit",
|
|
10992
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
10993
|
-
children: "Save"
|
|
10994
|
-
}
|
|
10995
|
-
)
|
|
10996
|
-
] }) })
|
|
10997
|
-
] });
|
|
10998
|
-
};
|
|
10999
|
-
const PromotionItem = ({
|
|
11000
|
-
promotion,
|
|
11001
|
-
orderId,
|
|
11002
|
-
isLoading
|
|
11003
|
-
}) => {
|
|
11004
|
-
var _a;
|
|
11005
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11006
|
-
const onRemove = async () => {
|
|
11007
|
-
removePromotions(
|
|
11008
|
-
{
|
|
11009
|
-
promo_codes: [promotion.code]
|
|
11010
|
-
},
|
|
11011
|
-
{
|
|
11012
|
-
onError: (e) => {
|
|
11013
|
-
ui.toast.error(e.message);
|
|
11014
|
-
}
|
|
11015
|
-
}
|
|
11016
|
-
);
|
|
11017
|
-
};
|
|
11018
|
-
const displayValue = getDisplayValue(promotion);
|
|
11019
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11020
|
-
"div",
|
|
11021
|
-
{
|
|
11022
|
-
className: ui.clx(
|
|
11023
|
-
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11024
|
-
{
|
|
11025
|
-
"animate-pulse": isLoading
|
|
11026
|
-
}
|
|
11027
|
-
),
|
|
11028
|
-
children: [
|
|
11029
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11030
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11031
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11032
|
-
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11033
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11034
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11035
|
-
] }),
|
|
11036
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11037
|
-
] })
|
|
11038
|
-
] }),
|
|
11039
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11040
|
-
ui.IconButton,
|
|
11041
|
-
{
|
|
11042
|
-
size: "small",
|
|
11043
|
-
type: "button",
|
|
11044
|
-
variant: "transparent",
|
|
11045
|
-
onClick: onRemove,
|
|
11046
|
-
isLoading: isPending || isLoading,
|
|
11047
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11048
|
-
}
|
|
11049
|
-
)
|
|
11050
|
-
]
|
|
11051
|
-
},
|
|
11052
|
-
promotion.id
|
|
11053
|
-
);
|
|
11054
|
-
};
|
|
11055
|
-
function getDisplayValue(promotion) {
|
|
11056
|
-
var _a, _b, _c, _d;
|
|
11057
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11058
|
-
if (!value) {
|
|
11059
|
-
return null;
|
|
11060
|
-
}
|
|
11061
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11062
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11063
|
-
if (!currency) {
|
|
11064
|
-
return null;
|
|
11065
|
-
}
|
|
11066
|
-
return getLocaleAmount(value, currency);
|
|
11067
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11068
|
-
return formatPercentage(value);
|
|
11069
|
-
}
|
|
11070
|
-
return null;
|
|
11071
|
-
}
|
|
11072
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11073
|
-
style: "percent",
|
|
11074
|
-
minimumFractionDigits: 2
|
|
11075
|
-
});
|
|
11076
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11077
|
-
let val = value || 0;
|
|
11078
|
-
if (!isPercentageValue) {
|
|
11079
|
-
val = val / 100;
|
|
11080
|
-
}
|
|
11081
|
-
return formatter.format(val);
|
|
11082
|
-
};
|
|
11083
|
-
function getPromotionIds(items, shippingMethods) {
|
|
11084
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
11085
|
-
for (const item of items) {
|
|
11086
|
-
if (item.adjustments) {
|
|
11087
|
-
for (const adjustment of item.adjustments) {
|
|
11088
|
-
if (adjustment.promotion_id) {
|
|
11089
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11090
|
-
}
|
|
11091
|
-
}
|
|
11092
|
-
}
|
|
11093
|
-
}
|
|
11094
|
-
for (const shippingMethod of shippingMethods) {
|
|
11095
|
-
if (shippingMethod.adjustments) {
|
|
11096
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11097
|
-
if (adjustment.promotion_id) {
|
|
11098
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11099
|
-
}
|
|
11100
|
-
}
|
|
11101
|
-
}
|
|
11102
|
-
}
|
|
11103
|
-
return Array.from(promotionIds);
|
|
11104
|
-
}
|
|
11105
|
-
const InlineTip = React.forwardRef(
|
|
11106
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
11107
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
11108
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11109
|
-
"div",
|
|
11110
|
-
{
|
|
11111
|
-
ref,
|
|
11112
|
-
className: ui.clx(
|
|
11113
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
11114
|
-
className
|
|
11115
|
-
),
|
|
11116
|
-
...props,
|
|
11117
|
-
children: [
|
|
11118
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11119
|
-
"div",
|
|
11120
|
-
{
|
|
11121
|
-
role: "presentation",
|
|
11122
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
11123
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
11124
|
-
})
|
|
11125
|
-
}
|
|
11126
|
-
),
|
|
11127
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
11128
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
11129
|
-
labelValue,
|
|
11130
|
-
":"
|
|
11131
|
-
] }),
|
|
11132
|
-
" ",
|
|
11133
|
-
children
|
|
11134
|
-
] })
|
|
11135
|
-
]
|
|
11136
|
-
}
|
|
11137
|
-
);
|
|
11138
|
-
}
|
|
11139
|
-
);
|
|
11140
|
-
InlineTip.displayName = "InlineTip";
|
|
11141
|
-
const MetadataFieldSchema = objectType({
|
|
11142
|
-
key: stringType(),
|
|
11143
|
-
disabled: booleanType().optional(),
|
|
11144
|
-
value: anyType()
|
|
11145
|
-
});
|
|
11146
|
-
const MetadataSchema = objectType({
|
|
11147
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
11148
|
-
});
|
|
11149
|
-
const Metadata = () => {
|
|
11150
|
-
const { id } = reactRouterDom.useParams();
|
|
11151
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11152
|
-
fields: "metadata"
|
|
11153
|
-
});
|
|
11154
|
-
if (isError) {
|
|
11155
|
-
throw error;
|
|
11156
|
-
}
|
|
11157
|
-
const isReady = !isPending && !!order;
|
|
11158
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11159
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11160
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
11161
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
11162
|
-
] }),
|
|
11163
|
-
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
11164
|
-
] });
|
|
11165
|
-
};
|
|
11166
|
-
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
11167
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
11168
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
11169
|
-
const { handleSuccess } = useRouteModal();
|
|
11170
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
11171
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
11172
|
-
const form = reactHookForm.useForm({
|
|
11173
|
-
defaultValues: {
|
|
11174
|
-
metadata: getDefaultValues(metadata)
|
|
11175
|
-
},
|
|
11176
|
-
resolver: zod.zodResolver(MetadataSchema)
|
|
11177
|
-
});
|
|
11178
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
11179
|
-
const parsedData = parseValues(data);
|
|
11180
|
-
await mutateAsync(
|
|
11181
|
-
{
|
|
11182
|
-
metadata: parsedData
|
|
11183
|
-
},
|
|
11184
|
-
{
|
|
11185
|
-
onSuccess: () => {
|
|
11186
|
-
ui.toast.success("Metadata updated");
|
|
11187
|
-
handleSuccess();
|
|
11188
|
-
},
|
|
11189
|
-
onError: (error) => {
|
|
11190
|
-
ui.toast.error(error.message);
|
|
11191
|
-
}
|
|
11192
|
-
}
|
|
11193
|
-
);
|
|
11194
|
-
});
|
|
11195
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
11196
|
-
control: form.control,
|
|
11197
|
-
name: "metadata"
|
|
11198
|
-
});
|
|
11199
|
-
function deleteRow(index) {
|
|
11200
|
-
remove(index);
|
|
11201
|
-
if (fields.length === 1) {
|
|
11202
|
-
insert(0, {
|
|
11203
|
-
key: "",
|
|
11204
|
-
value: "",
|
|
11205
|
-
disabled: false
|
|
11206
|
-
});
|
|
11207
|
-
}
|
|
11208
|
-
}
|
|
11209
|
-
function insertRow(index, position) {
|
|
11210
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
11211
|
-
key: "",
|
|
11212
|
-
value: "",
|
|
11213
|
-
disabled: false
|
|
10931
|
+
}
|
|
10932
|
+
function insertRow(index, position) {
|
|
10933
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10934
|
+
key: "",
|
|
10935
|
+
value: "",
|
|
10936
|
+
disabled: false
|
|
11214
10937
|
});
|
|
11215
10938
|
}
|
|
11216
10939
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -11452,150 +11175,323 @@ function getHasUneditableRows(metadata) {
|
|
|
11452
11175
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11453
11176
|
);
|
|
11454
11177
|
}
|
|
11455
|
-
const
|
|
11456
|
-
|
|
11457
|
-
|
|
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,
|
|
11458
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(
|
|
11459
11224
|
{
|
|
11460
|
-
|
|
11225
|
+
id: promoIds
|
|
11461
11226
|
},
|
|
11462
11227
|
{
|
|
11463
|
-
enabled: !!
|
|
11228
|
+
enabled: !!promoIds.length
|
|
11464
11229
|
}
|
|
11465
11230
|
);
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11476
|
-
] });
|
|
11477
|
-
};
|
|
11478
|
-
const SalesChannelForm = ({ order }) => {
|
|
11479
|
-
const form = reactHookForm.useForm({
|
|
11480
|
-
defaultValues: {
|
|
11481
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
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
|
+
});
|
|
11482
11240
|
},
|
|
11483
|
-
|
|
11241
|
+
getOptions: (data) => {
|
|
11242
|
+
return data.promotions.map((promotion) => ({
|
|
11243
|
+
label: promotion.code,
|
|
11244
|
+
value: promotion.code
|
|
11245
|
+
}));
|
|
11246
|
+
}
|
|
11484
11247
|
});
|
|
11485
|
-
const
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11248
|
+
const add = async (value) => {
|
|
11249
|
+
if (!value) {
|
|
11250
|
+
return;
|
|
11251
|
+
}
|
|
11252
|
+
addPromotions(
|
|
11489
11253
|
{
|
|
11490
|
-
|
|
11254
|
+
promo_codes: [value]
|
|
11491
11255
|
},
|
|
11492
11256
|
{
|
|
11493
|
-
|
|
11494
|
-
ui.toast.
|
|
11495
|
-
|
|
11257
|
+
onError: (e) => {
|
|
11258
|
+
ui.toast.error(e.message);
|
|
11259
|
+
comboboxData.onSearchValueChange("");
|
|
11260
|
+
setComboboxValue("");
|
|
11496
11261
|
},
|
|
11497
|
-
|
|
11498
|
-
|
|
11262
|
+
onSuccess: () => {
|
|
11263
|
+
comboboxData.onSearchValueChange("");
|
|
11264
|
+
setComboboxValue("");
|
|
11499
11265
|
}
|
|
11500
11266
|
}
|
|
11501
11267
|
);
|
|
11502
|
-
}
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
]
|
|
11515
|
-
}
|
|
11516
|
-
) });
|
|
11517
|
-
};
|
|
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
|
-
});
|
|
11532
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11533
|
-
Form$2.Field,
|
|
11534
|
-
{
|
|
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
|
-
] });
|
|
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;
|
|
11554
11280
|
}
|
|
11281
|
+
});
|
|
11282
|
+
if (!requestSucceeded) {
|
|
11283
|
+
setIsSubmitting(false);
|
|
11284
|
+
return;
|
|
11555
11285
|
}
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
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
|
+
};
|
|
11566
11298
|
if (isError) {
|
|
11567
11299
|
throw error;
|
|
11568
11300
|
}
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
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",
|
|
11313
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11314
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
11315
|
+
options: comboboxData.options,
|
|
11316
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11317
|
+
searchValue: comboboxData.searchValue,
|
|
11318
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11319
|
+
onChange: add,
|
|
11320
|
+
value: comboboxValue
|
|
11321
|
+
}
|
|
11322
|
+
)
|
|
11323
|
+
] }),
|
|
11324
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11325
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11326
|
+
PromotionItem,
|
|
11327
|
+
{
|
|
11328
|
+
promotion,
|
|
11329
|
+
orderId: preview.id,
|
|
11330
|
+
isLoading: isPending
|
|
11331
|
+
},
|
|
11332
|
+
promotion.id
|
|
11333
|
+
)) })
|
|
11334
|
+
] }) }),
|
|
11335
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11336
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11338
|
+
ui.Button,
|
|
11339
|
+
{
|
|
11340
|
+
size: "small",
|
|
11341
|
+
type: "submit",
|
|
11342
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
11343
|
+
children: "Save"
|
|
11344
|
+
}
|
|
11345
|
+
)
|
|
11346
|
+
] }) })
|
|
11576
11347
|
] });
|
|
11577
11348
|
};
|
|
11578
|
-
const
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
|
|
11349
|
+
const PromotionItem = ({
|
|
11350
|
+
promotion,
|
|
11351
|
+
orderId,
|
|
11352
|
+
isLoading
|
|
11353
|
+
}) => {
|
|
11354
|
+
var _a;
|
|
11355
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11356
|
+
const onRemove = async () => {
|
|
11357
|
+
removePromotions(
|
|
11358
|
+
{
|
|
11359
|
+
promo_codes: [promotion.code]
|
|
11360
|
+
},
|
|
11361
|
+
{
|
|
11362
|
+
onError: (e) => {
|
|
11363
|
+
ui.toast.error(e.message);
|
|
11364
|
+
}
|
|
11365
|
+
}
|
|
11366
|
+
);
|
|
11367
|
+
};
|
|
11368
|
+
const displayValue = getDisplayValue(promotion);
|
|
11369
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11370
|
+
"div",
|
|
11371
|
+
{
|
|
11372
|
+
className: ui.clx(
|
|
11373
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11374
|
+
{
|
|
11375
|
+
"animate-pulse": isLoading
|
|
11376
|
+
}
|
|
11377
|
+
),
|
|
11378
|
+
children: [
|
|
11379
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11380
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11381
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11382
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11383
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11385
|
+
] }),
|
|
11386
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11387
|
+
] })
|
|
11388
|
+
] }),
|
|
11389
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11390
|
+
ui.IconButton,
|
|
11391
|
+
{
|
|
11392
|
+
size: "small",
|
|
11393
|
+
type: "button",
|
|
11394
|
+
variant: "transparent",
|
|
11395
|
+
onClick: onRemove,
|
|
11396
|
+
isLoading: isPending || isLoading,
|
|
11397
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11398
|
+
}
|
|
11399
|
+
)
|
|
11400
|
+
]
|
|
11401
|
+
},
|
|
11402
|
+
promotion.id
|
|
11403
|
+
);
|
|
11404
|
+
};
|
|
11405
|
+
function getDisplayValue(promotion) {
|
|
11406
|
+
var _a, _b, _c, _d;
|
|
11407
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11408
|
+
if (!value) {
|
|
11409
|
+
return null;
|
|
11410
|
+
}
|
|
11411
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11412
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11413
|
+
if (!currency) {
|
|
11414
|
+
return null;
|
|
11415
|
+
}
|
|
11416
|
+
return getLocaleAmount(value, currency);
|
|
11417
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11418
|
+
return formatPercentage(value);
|
|
11419
|
+
}
|
|
11420
|
+
return null;
|
|
11421
|
+
}
|
|
11422
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11423
|
+
style: "percent",
|
|
11424
|
+
minimumFractionDigits: 2
|
|
11425
|
+
});
|
|
11426
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11427
|
+
let val = value || 0;
|
|
11428
|
+
if (!isPercentageValue) {
|
|
11429
|
+
val = val / 100;
|
|
11430
|
+
}
|
|
11431
|
+
return formatter.format(val);
|
|
11432
|
+
};
|
|
11433
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11434
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11435
|
+
for (const item of items) {
|
|
11436
|
+
if (item.adjustments) {
|
|
11437
|
+
for (const adjustment of item.adjustments) {
|
|
11438
|
+
if (adjustment.promotion_id) {
|
|
11439
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
}
|
|
11444
|
+
for (const shippingMethod of shippingMethods) {
|
|
11445
|
+
if (shippingMethod.adjustments) {
|
|
11446
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11447
|
+
if (adjustment.promotion_id) {
|
|
11448
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11449
|
+
}
|
|
11450
|
+
}
|
|
11451
|
+
}
|
|
11452
|
+
}
|
|
11453
|
+
return Array.from(promotionIds);
|
|
11454
|
+
}
|
|
11455
|
+
const SalesChannel = () => {
|
|
11456
|
+
const { id } = reactRouterDom.useParams();
|
|
11457
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11458
|
+
id,
|
|
11459
|
+
{
|
|
11460
|
+
fields: "+sales_channel_id"
|
|
11461
|
+
},
|
|
11462
|
+
{
|
|
11463
|
+
enabled: !!id
|
|
11464
|
+
}
|
|
11465
|
+
);
|
|
11466
|
+
if (isError) {
|
|
11467
|
+
throw error;
|
|
11468
|
+
}
|
|
11469
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11470
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11471
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { 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" }) })
|
|
11474
|
+
] }),
|
|
11475
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11476
|
+
] });
|
|
11477
|
+
};
|
|
11478
|
+
const SalesChannelForm = ({ order }) => {
|
|
11479
|
+
const form = reactHookForm.useForm({
|
|
11480
|
+
defaultValues: {
|
|
11481
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11482
|
+
},
|
|
11483
|
+
resolver: zod.zodResolver(schema$2)
|
|
11484
|
+
});
|
|
11485
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11587
11486
|
const { handleSuccess } = useRouteModal();
|
|
11588
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
11589
|
-
const currentCustomer = order.customer ? {
|
|
11590
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
11591
|
-
value: order.customer.id
|
|
11592
|
-
} : null;
|
|
11593
11487
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11594
11488
|
await mutateAsync(
|
|
11595
|
-
{
|
|
11489
|
+
{
|
|
11490
|
+
sales_channel_id: data.sales_channel_id
|
|
11491
|
+
},
|
|
11596
11492
|
{
|
|
11597
11493
|
onSuccess: () => {
|
|
11598
|
-
ui.toast.success("
|
|
11494
|
+
ui.toast.success("Sales channel updated");
|
|
11599
11495
|
handleSuccess();
|
|
11600
11496
|
},
|
|
11601
11497
|
onError: (error) => {
|
|
@@ -11610,430 +11506,261 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
11610
11506
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11611
11507
|
onSubmit,
|
|
11612
11508
|
children: [
|
|
11613
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11617
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
11618
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
11619
|
-
] }),
|
|
11620
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
11621
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
11622
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
11623
|
-
] })
|
|
11624
|
-
] }),
|
|
11625
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11626
|
-
CustomerField,
|
|
11627
|
-
{
|
|
11628
|
-
control: form.control,
|
|
11629
|
-
currentCustomerId: order.customer_id
|
|
11630
|
-
}
|
|
11631
|
-
)
|
|
11632
|
-
] }),
|
|
11633
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11634
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", 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" }) }),
|
|
11635
11512
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11636
11513
|
] }) })
|
|
11637
11514
|
]
|
|
11638
11515
|
}
|
|
11639
11516
|
) });
|
|
11640
11517
|
};
|
|
11641
|
-
const
|
|
11642
|
-
const
|
|
11518
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11519
|
+
const salesChannels = useComboboxData({
|
|
11643
11520
|
queryFn: async (params) => {
|
|
11644
|
-
return await sdk.admin.
|
|
11645
|
-
...params,
|
|
11646
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
11647
|
-
});
|
|
11521
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11648
11522
|
},
|
|
11649
|
-
queryKey: ["
|
|
11523
|
+
queryKey: ["sales-channels"],
|
|
11650
11524
|
getOptions: (data) => {
|
|
11651
|
-
return data.
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
});
|
|
11658
|
-
}
|
|
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
|
|
11659
11531
|
});
|
|
11660
11532
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11661
11533
|
Form$2.Field,
|
|
11662
11534
|
{
|
|
11663
|
-
name: "customer_id",
|
|
11664
11535
|
control,
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
}
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
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
|
+
}
|
|
11684
11555
|
}
|
|
11685
11556
|
);
|
|
11686
11557
|
};
|
|
11687
|
-
const
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
"path",
|
|
11770
|
-
{
|
|
11771
|
-
opacity: "0.5",
|
|
11772
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
11773
|
-
stroke: "#52525B",
|
|
11774
|
-
strokeWidth: "1.5",
|
|
11775
|
-
strokeLinecap: "round",
|
|
11776
|
-
strokeLinejoin: "round"
|
|
11777
|
-
}
|
|
11778
|
-
),
|
|
11779
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11780
|
-
"path",
|
|
11781
|
-
{
|
|
11782
|
-
opacity: "0.38",
|
|
11783
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
11784
|
-
stroke: "#52525B",
|
|
11785
|
-
strokeWidth: "1.5",
|
|
11786
|
-
strokeLinecap: "round",
|
|
11787
|
-
strokeLinejoin: "round"
|
|
11788
|
-
}
|
|
11789
|
-
),
|
|
11790
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11791
|
-
"path",
|
|
11792
|
-
{
|
|
11793
|
-
opacity: "0.25",
|
|
11794
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
11795
|
-
stroke: "#52525B",
|
|
11796
|
-
strokeWidth: "1.5",
|
|
11797
|
-
strokeLinecap: "round",
|
|
11798
|
-
strokeLinejoin: "round"
|
|
11799
|
-
}
|
|
11800
|
-
),
|
|
11801
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11802
|
-
"path",
|
|
11803
|
-
{
|
|
11804
|
-
opacity: "0.13",
|
|
11805
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
11806
|
-
stroke: "#52525B",
|
|
11807
|
-
strokeWidth: "1.5",
|
|
11808
|
-
strokeLinecap: "round",
|
|
11809
|
-
strokeLinejoin: "round"
|
|
11810
|
-
}
|
|
11811
|
-
),
|
|
11812
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11813
|
-
"rect",
|
|
11814
|
-
{
|
|
11815
|
-
width: "12",
|
|
11816
|
-
height: "3",
|
|
11817
|
-
rx: "1.5",
|
|
11818
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
11819
|
-
fill: "#D4D4D8"
|
|
11820
|
-
}
|
|
11821
|
-
),
|
|
11822
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11823
|
-
"rect",
|
|
11824
|
-
{
|
|
11825
|
-
x: "0.00428286",
|
|
11826
|
-
y: "-0.742904",
|
|
11827
|
-
width: "33.5",
|
|
11828
|
-
height: "65.5",
|
|
11829
|
-
rx: "6.75",
|
|
11830
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
11831
|
-
fill: "#D4D4D8",
|
|
11832
|
-
stroke: "#52525B",
|
|
11833
|
-
strokeWidth: "1.5"
|
|
11834
|
-
}
|
|
11835
|
-
),
|
|
11836
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11837
|
-
"rect",
|
|
11838
|
-
{
|
|
11839
|
-
x: "0.00428286",
|
|
11840
|
-
y: "-0.742904",
|
|
11841
|
-
width: "33.5",
|
|
11842
|
-
height: "65.5",
|
|
11843
|
-
rx: "6.75",
|
|
11844
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
11845
|
-
fill: "white",
|
|
11846
|
-
stroke: "#52525B",
|
|
11847
|
-
strokeWidth: "1.5"
|
|
11848
|
-
}
|
|
11849
|
-
),
|
|
11850
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11851
|
-
"rect",
|
|
11852
|
-
{
|
|
11853
|
-
width: "12",
|
|
11854
|
-
height: "3",
|
|
11855
|
-
rx: "1.5",
|
|
11856
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
11857
|
-
fill: "#D4D4D8"
|
|
11858
|
-
}
|
|
11859
|
-
),
|
|
11860
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11861
|
-
"rect",
|
|
11862
|
-
{
|
|
11863
|
-
width: "17",
|
|
11864
|
-
height: "3",
|
|
11865
|
-
rx: "1.5",
|
|
11866
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
11867
|
-
fill: "#D4D4D8"
|
|
11868
|
-
}
|
|
11869
|
-
),
|
|
11870
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11871
|
-
"rect",
|
|
11872
|
-
{
|
|
11873
|
-
width: "12",
|
|
11874
|
-
height: "3",
|
|
11875
|
-
rx: "1.5",
|
|
11876
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
11877
|
-
fill: "#D4D4D8"
|
|
11878
|
-
}
|
|
11879
|
-
),
|
|
11880
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11881
|
-
"path",
|
|
11882
|
-
{
|
|
11883
|
-
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",
|
|
11884
|
-
fill: "#A1A1AA"
|
|
11885
|
-
}
|
|
11886
|
-
),
|
|
11887
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11888
|
-
"rect",
|
|
11889
|
-
{
|
|
11890
|
-
width: "17",
|
|
11891
|
-
height: "3",
|
|
11892
|
-
rx: "1.5",
|
|
11893
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
11894
|
-
fill: "#A1A1AA"
|
|
11895
|
-
}
|
|
11896
|
-
),
|
|
11897
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11898
|
-
"rect",
|
|
11899
|
-
{
|
|
11900
|
-
width: "12",
|
|
11901
|
-
height: "3",
|
|
11902
|
-
rx: "1.5",
|
|
11903
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
11904
|
-
fill: "#A1A1AA"
|
|
11905
|
-
}
|
|
11906
|
-
),
|
|
11907
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11908
|
-
"path",
|
|
11909
|
-
{
|
|
11910
|
-
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",
|
|
11911
|
-
fill: "#52525B"
|
|
11912
|
-
}
|
|
11913
|
-
),
|
|
11914
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11915
|
-
"path",
|
|
11916
|
-
{
|
|
11917
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
11918
|
-
stroke: "#A1A1AA",
|
|
11919
|
-
strokeWidth: "1.5",
|
|
11920
|
-
strokeLinecap: "round",
|
|
11921
|
-
strokeLinejoin: "round"
|
|
11922
|
-
}
|
|
11923
|
-
) }),
|
|
11924
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11925
|
-
"path",
|
|
11926
|
-
{
|
|
11927
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
11928
|
-
stroke: "#A1A1AA",
|
|
11929
|
-
strokeWidth: "1.5",
|
|
11930
|
-
strokeLinecap: "round",
|
|
11931
|
-
strokeLinejoin: "round"
|
|
11932
|
-
}
|
|
11933
|
-
) }),
|
|
11934
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11935
|
-
"path",
|
|
11936
|
-
{
|
|
11937
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
11938
|
-
stroke: "#A1A1AA",
|
|
11939
|
-
strokeWidth: "1.5",
|
|
11940
|
-
strokeLinecap: "round",
|
|
11941
|
-
strokeLinejoin: "round"
|
|
11942
|
-
}
|
|
11943
|
-
) }),
|
|
11944
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11945
|
-
"path",
|
|
11946
|
-
{
|
|
11947
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
11948
|
-
stroke: "#A1A1AA",
|
|
11949
|
-
strokeWidth: "1.5",
|
|
11950
|
-
strokeLinecap: "round",
|
|
11951
|
-
strokeLinejoin: "round"
|
|
11952
|
-
}
|
|
11953
|
-
) }),
|
|
11954
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11955
|
-
"path",
|
|
11956
|
-
{
|
|
11957
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
11958
|
-
stroke: "#A1A1AA",
|
|
11959
|
-
strokeWidth: "1.5",
|
|
11960
|
-
strokeLinecap: "round",
|
|
11961
|
-
strokeLinejoin: "round"
|
|
11962
|
-
}
|
|
11963
|
-
) }),
|
|
11964
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11965
|
-
"path",
|
|
11966
|
-
{
|
|
11967
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
11968
|
-
stroke: "#A1A1AA",
|
|
11969
|
-
strokeWidth: "1.5",
|
|
11970
|
-
strokeLinecap: "round",
|
|
11971
|
-
strokeLinejoin: "round"
|
|
11972
|
-
}
|
|
11973
|
-
) }),
|
|
11974
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
11975
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11976
|
-
"rect",
|
|
11977
|
-
{
|
|
11978
|
-
width: "12",
|
|
11979
|
-
height: "12",
|
|
11980
|
-
fill: "white",
|
|
11981
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
11558
|
+
const schema$2 = objectType({
|
|
11559
|
+
sales_channel_id: stringType().min(1)
|
|
11560
|
+
});
|
|
11561
|
+
const ShippingAddress = () => {
|
|
11562
|
+
const { id } = reactRouterDom.useParams();
|
|
11563
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11564
|
+
fields: "+shipping_address"
|
|
11565
|
+
});
|
|
11566
|
+
if (isError) {
|
|
11567
|
+
throw error;
|
|
11568
|
+
}
|
|
11569
|
+
const isReady = !isPending && !!order;
|
|
11570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11571
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11572
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11573
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11574
|
+
] }),
|
|
11575
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11576
|
+
] });
|
|
11577
|
+
};
|
|
11578
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11579
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11580
|
+
const form = reactHookForm.useForm({
|
|
11581
|
+
defaultValues: {
|
|
11582
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11583
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11584
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11585
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11586
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11587
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11588
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11589
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11590
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11591
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11592
|
+
},
|
|
11593
|
+
resolver: zod.zodResolver(schema$1)
|
|
11594
|
+
});
|
|
11595
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11596
|
+
const { handleSuccess } = useRouteModal();
|
|
11597
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11598
|
+
await mutateAsync(
|
|
11599
|
+
{
|
|
11600
|
+
shipping_address: {
|
|
11601
|
+
first_name: data.first_name,
|
|
11602
|
+
last_name: data.last_name,
|
|
11603
|
+
company: data.company,
|
|
11604
|
+
address_1: data.address_1,
|
|
11605
|
+
address_2: data.address_2,
|
|
11606
|
+
city: data.city,
|
|
11607
|
+
province: data.province,
|
|
11608
|
+
country_code: data.country_code,
|
|
11609
|
+
postal_code: data.postal_code,
|
|
11610
|
+
phone: data.phone
|
|
11611
|
+
}
|
|
11612
|
+
},
|
|
11613
|
+
{
|
|
11614
|
+
onSuccess: () => {
|
|
11615
|
+
handleSuccess();
|
|
11616
|
+
},
|
|
11617
|
+
onError: (error) => {
|
|
11618
|
+
ui.toast.error(error.message);
|
|
11619
|
+
}
|
|
11620
|
+
}
|
|
11621
|
+
);
|
|
11622
|
+
});
|
|
11623
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11624
|
+
KeyboundForm,
|
|
11625
|
+
{
|
|
11626
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11627
|
+
onSubmit,
|
|
11628
|
+
children: [
|
|
11629
|
+
/* @__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: [
|
|
11630
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11631
|
+
Form$2.Field,
|
|
11632
|
+
{
|
|
11633
|
+
control: form.control,
|
|
11634
|
+
name: "country_code",
|
|
11635
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11636
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11637
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11639
|
+
] })
|
|
11982
11640
|
}
|
|
11983
|
-
)
|
|
11984
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11985
|
-
|
|
11641
|
+
),
|
|
11642
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11643
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11644
|
+
Form$2.Field,
|
|
11645
|
+
{
|
|
11646
|
+
control: form.control,
|
|
11647
|
+
name: "first_name",
|
|
11648
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11649
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11652
|
+
] })
|
|
11653
|
+
}
|
|
11654
|
+
),
|
|
11655
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11656
|
+
Form$2.Field,
|
|
11657
|
+
{
|
|
11658
|
+
control: form.control,
|
|
11659
|
+
name: "last_name",
|
|
11660
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11661
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11662
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11664
|
+
] })
|
|
11665
|
+
}
|
|
11666
|
+
)
|
|
11667
|
+
] }),
|
|
11668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11669
|
+
Form$2.Field,
|
|
11986
11670
|
{
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11671
|
+
control: form.control,
|
|
11672
|
+
name: "company",
|
|
11673
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11674
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11677
|
+
] })
|
|
11991
11678
|
}
|
|
11992
|
-
)
|
|
11993
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11994
|
-
|
|
11679
|
+
),
|
|
11680
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11681
|
+
Form$2.Field,
|
|
11995
11682
|
{
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
11683
|
+
control: form.control,
|
|
11684
|
+
name: "address_1",
|
|
11685
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11686
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11689
|
+
] })
|
|
12000
11690
|
}
|
|
12001
|
-
)
|
|
12002
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12003
|
-
|
|
11691
|
+
),
|
|
11692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11693
|
+
Form$2.Field,
|
|
12004
11694
|
{
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
11695
|
+
control: form.control,
|
|
11696
|
+
name: "address_2",
|
|
11697
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11698
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11699
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11701
|
+
] })
|
|
12009
11702
|
}
|
|
12010
|
-
)
|
|
12011
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12012
|
-
|
|
11703
|
+
),
|
|
11704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11706
|
+
Form$2.Field,
|
|
11707
|
+
{
|
|
11708
|
+
control: form.control,
|
|
11709
|
+
name: "postal_code",
|
|
11710
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11711
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11714
|
+
] })
|
|
11715
|
+
}
|
|
11716
|
+
),
|
|
11717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11718
|
+
Form$2.Field,
|
|
11719
|
+
{
|
|
11720
|
+
control: form.control,
|
|
11721
|
+
name: "city",
|
|
11722
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11723
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11724
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11726
|
+
] })
|
|
11727
|
+
}
|
|
11728
|
+
)
|
|
11729
|
+
] }),
|
|
11730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11731
|
+
Form$2.Field,
|
|
12013
11732
|
{
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
11733
|
+
control: form.control,
|
|
11734
|
+
name: "province",
|
|
11735
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11736
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11739
|
+
] })
|
|
12018
11740
|
}
|
|
12019
|
-
)
|
|
12020
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12021
|
-
|
|
11741
|
+
),
|
|
11742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11743
|
+
Form$2.Field,
|
|
12022
11744
|
{
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
11745
|
+
control: form.control,
|
|
11746
|
+
name: "phone",
|
|
11747
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11748
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11749
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11750
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11751
|
+
] })
|
|
12027
11752
|
}
|
|
12028
|
-
)
|
|
12029
|
-
] })
|
|
11753
|
+
)
|
|
11754
|
+
] }) }),
|
|
11755
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11756
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11757
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11758
|
+
] }) })
|
|
12030
11759
|
]
|
|
12031
11760
|
}
|
|
12032
|
-
);
|
|
11761
|
+
) });
|
|
12033
11762
|
};
|
|
12034
|
-
const schema$1 =
|
|
12035
|
-
customer_id: stringType().min(1)
|
|
12036
|
-
});
|
|
11763
|
+
const schema$1 = addressSchema;
|
|
12037
11764
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12038
11765
|
const Shipping = () => {
|
|
12039
11766
|
var _a;
|
|
@@ -12841,60 +12568,44 @@ const CustomAmountField = ({
|
|
|
12841
12568
|
}
|
|
12842
12569
|
);
|
|
12843
12570
|
};
|
|
12844
|
-
const
|
|
12571
|
+
const TransferOwnership = () => {
|
|
12845
12572
|
const { id } = reactRouterDom.useParams();
|
|
12846
|
-
const {
|
|
12847
|
-
fields: "
|
|
12573
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12574
|
+
fields: "id,customer_id,customer.*"
|
|
12848
12575
|
});
|
|
12849
12576
|
if (isError) {
|
|
12850
12577
|
throw error;
|
|
12851
12578
|
}
|
|
12852
|
-
const isReady = !isPending && !!
|
|
12579
|
+
const isReady = !isPending && !!draft_order;
|
|
12853
12580
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12854
12581
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12855
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
12856
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", 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" }) })
|
|
12857
12584
|
] }),
|
|
12858
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12585
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12859
12586
|
] });
|
|
12860
12587
|
};
|
|
12861
|
-
const
|
|
12862
|
-
var _a, _b
|
|
12588
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12589
|
+
var _a, _b;
|
|
12863
12590
|
const form = reactHookForm.useForm({
|
|
12864
12591
|
defaultValues: {
|
|
12865
|
-
|
|
12866
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12867
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12868
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12869
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12870
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12871
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12872
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12873
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12874
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12592
|
+
customer_id: order.customer_id || ""
|
|
12875
12593
|
},
|
|
12876
12594
|
resolver: zod.zodResolver(schema)
|
|
12877
12595
|
});
|
|
12878
12596
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12879
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;
|
|
12880
12603
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12881
12604
|
await mutateAsync(
|
|
12882
|
-
{
|
|
12883
|
-
shipping_address: {
|
|
12884
|
-
first_name: data.first_name,
|
|
12885
|
-
last_name: data.last_name,
|
|
12886
|
-
company: data.company,
|
|
12887
|
-
address_1: data.address_1,
|
|
12888
|
-
address_2: data.address_2,
|
|
12889
|
-
city: data.city,
|
|
12890
|
-
province: data.province,
|
|
12891
|
-
country_code: data.country_code,
|
|
12892
|
-
postal_code: data.postal_code,
|
|
12893
|
-
phone: data.phone
|
|
12894
|
-
}
|
|
12895
|
-
},
|
|
12605
|
+
{ customer_id: data.customer_id },
|
|
12896
12606
|
{
|
|
12897
12607
|
onSuccess: () => {
|
|
12608
|
+
ui.toast.success("Customer updated");
|
|
12898
12609
|
handleSuccess();
|
|
12899
12610
|
},
|
|
12900
12611
|
onError: (error) => {
|
|
@@ -12903,147 +12614,436 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12903
12614
|
}
|
|
12904
12615
|
);
|
|
12905
12616
|
});
|
|
12906
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12907
|
-
KeyboundForm,
|
|
12617
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12618
|
+
KeyboundForm,
|
|
12619
|
+
{
|
|
12620
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12621
|
+
onSubmit,
|
|
12622
|
+
children: [
|
|
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
|
+
] })
|
|
12634
|
+
] }),
|
|
12635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12636
|
+
CustomerField,
|
|
12637
|
+
{
|
|
12638
|
+
control: form.control,
|
|
12639
|
+
currentCustomerId: order.customer_id
|
|
12640
|
+
}
|
|
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" })
|
|
12646
|
+
] }) })
|
|
12647
|
+
]
|
|
12648
|
+
}
|
|
12649
|
+
) });
|
|
12650
|
+
};
|
|
12651
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12652
|
+
const customers = useComboboxData({
|
|
12653
|
+
queryFn: async (params) => {
|
|
12654
|
+
return await sdk.admin.customer.list({
|
|
12655
|
+
...params,
|
|
12656
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12657
|
+
});
|
|
12658
|
+
},
|
|
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
|
+
});
|
|
12668
|
+
}
|
|
12669
|
+
});
|
|
12670
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12671
|
+
Form$2.Field,
|
|
12908
12672
|
{
|
|
12909
|
-
|
|
12910
|
-
|
|
12673
|
+
name: "customer_id",
|
|
12674
|
+
control,
|
|
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",
|
|
12911
12706
|
children: [
|
|
12912
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12913
|
-
|
|
12914
|
-
|
|
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",
|
|
12915
12987
|
{
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12921
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12922
|
-
] })
|
|
12988
|
+
width: "12",
|
|
12989
|
+
height: "12",
|
|
12990
|
+
fill: "white",
|
|
12991
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12923
12992
|
}
|
|
12924
|
-
),
|
|
12925
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12926
|
-
|
|
12927
|
-
Form$2.Field,
|
|
12928
|
-
{
|
|
12929
|
-
control: form.control,
|
|
12930
|
-
name: "first_name",
|
|
12931
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12932
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12933
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12934
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12935
|
-
] })
|
|
12936
|
-
}
|
|
12937
|
-
),
|
|
12938
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12939
|
-
Form$2.Field,
|
|
12940
|
-
{
|
|
12941
|
-
control: form.control,
|
|
12942
|
-
name: "last_name",
|
|
12943
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12944
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12945
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12946
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12947
|
-
] })
|
|
12948
|
-
}
|
|
12949
|
-
)
|
|
12950
|
-
] }),
|
|
12951
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12952
|
-
Form$2.Field,
|
|
12993
|
+
) }),
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
+
"rect",
|
|
12953
12996
|
{
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12959
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12960
|
-
] })
|
|
12997
|
+
width: "12",
|
|
12998
|
+
height: "12",
|
|
12999
|
+
fill: "white",
|
|
13000
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12961
13001
|
}
|
|
12962
|
-
),
|
|
12963
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12964
|
-
|
|
13002
|
+
) }),
|
|
13003
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13004
|
+
"rect",
|
|
12965
13005
|
{
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12972
|
-
] })
|
|
13006
|
+
width: "12",
|
|
13007
|
+
height: "12",
|
|
13008
|
+
fill: "white",
|
|
13009
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12973
13010
|
}
|
|
12974
|
-
),
|
|
12975
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12976
|
-
|
|
13011
|
+
) }),
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
"rect",
|
|
12977
13014
|
{
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12983
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12984
|
-
] })
|
|
13015
|
+
width: "12",
|
|
13016
|
+
height: "12",
|
|
13017
|
+
fill: "white",
|
|
13018
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12985
13019
|
}
|
|
12986
|
-
),
|
|
12987
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12988
|
-
|
|
12989
|
-
Form$2.Field,
|
|
12990
|
-
{
|
|
12991
|
-
control: form.control,
|
|
12992
|
-
name: "postal_code",
|
|
12993
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12995
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12996
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12997
|
-
] })
|
|
12998
|
-
}
|
|
12999
|
-
),
|
|
13000
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13001
|
-
Form$2.Field,
|
|
13002
|
-
{
|
|
13003
|
-
control: form.control,
|
|
13004
|
-
name: "city",
|
|
13005
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13006
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13007
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13008
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13009
|
-
] })
|
|
13010
|
-
}
|
|
13011
|
-
)
|
|
13012
|
-
] }),
|
|
13013
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
-
Form$2.Field,
|
|
13020
|
+
) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
+
"rect",
|
|
13015
13023
|
{
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13021
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13022
|
-
] })
|
|
13024
|
+
width: "12",
|
|
13025
|
+
height: "12",
|
|
13026
|
+
fill: "white",
|
|
13027
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13023
13028
|
}
|
|
13024
|
-
),
|
|
13025
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13026
|
-
|
|
13029
|
+
) }),
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13031
|
+
"rect",
|
|
13027
13032
|
{
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13033
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13034
|
-
] })
|
|
13033
|
+
width: "12",
|
|
13034
|
+
height: "12",
|
|
13035
|
+
fill: "white",
|
|
13036
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13035
13037
|
}
|
|
13036
|
-
)
|
|
13037
|
-
] })
|
|
13038
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13039
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13040
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13041
|
-
] }) })
|
|
13038
|
+
) })
|
|
13039
|
+
] })
|
|
13042
13040
|
]
|
|
13043
13041
|
}
|
|
13044
|
-
)
|
|
13042
|
+
);
|
|
13045
13043
|
};
|
|
13046
|
-
const schema =
|
|
13044
|
+
const schema = objectType({
|
|
13045
|
+
customer_id: stringType().min(1)
|
|
13046
|
+
});
|
|
13047
13047
|
const widgetModule = { widgets: [] };
|
|
13048
13048
|
const routeModule = {
|
|
13049
13049
|
routes: [
|
|
@@ -13068,41 +13068,41 @@ const routeModule = {
|
|
|
13068
13068
|
Component: BillingAddress,
|
|
13069
13069
|
path: "/draft-orders/:id/billing-address"
|
|
13070
13070
|
},
|
|
13071
|
-
{
|
|
13072
|
-
Component: CustomItems,
|
|
13073
|
-
path: "/draft-orders/:id/custom-items"
|
|
13074
|
-
},
|
|
13075
13071
|
{
|
|
13076
13072
|
Component: Email,
|
|
13077
13073
|
path: "/draft-orders/:id/email"
|
|
13078
13074
|
},
|
|
13079
13075
|
{
|
|
13080
|
-
Component:
|
|
13081
|
-
path: "/draft-orders/:id/items"
|
|
13076
|
+
Component: CustomItems,
|
|
13077
|
+
path: "/draft-orders/:id/custom-items"
|
|
13082
13078
|
},
|
|
13083
13079
|
{
|
|
13084
|
-
Component:
|
|
13085
|
-
path: "/draft-orders/:id/
|
|
13080
|
+
Component: Items,
|
|
13081
|
+
path: "/draft-orders/:id/items"
|
|
13086
13082
|
},
|
|
13087
13083
|
{
|
|
13088
13084
|
Component: Metadata,
|
|
13089
13085
|
path: "/draft-orders/:id/metadata"
|
|
13090
13086
|
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: Promotions,
|
|
13089
|
+
path: "/draft-orders/:id/promotions"
|
|
13090
|
+
},
|
|
13091
13091
|
{
|
|
13092
13092
|
Component: SalesChannel,
|
|
13093
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
13094
13094
|
},
|
|
13095
13095
|
{
|
|
13096
|
-
Component:
|
|
13097
|
-
path: "/draft-orders/:id/
|
|
13096
|
+
Component: ShippingAddress,
|
|
13097
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13098
13098
|
},
|
|
13099
13099
|
{
|
|
13100
13100
|
Component: Shipping,
|
|
13101
13101
|
path: "/draft-orders/:id/shipping"
|
|
13102
13102
|
},
|
|
13103
13103
|
{
|
|
13104
|
-
Component:
|
|
13105
|
-
path: "/draft-orders/:id/
|
|
13104
|
+
Component: TransferOwnership,
|
|
13105
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13106
13106
|
}
|
|
13107
13107
|
]
|
|
13108
13108
|
}
|