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