@medusajs/draft-order 2.22.0 → 2.22.1
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 +211 -211
- package/.medusa/server/src/admin/index.mjs +211 -211
- package/package.json +18 -18
|
@@ -5983,6 +5983,95 @@ const ID = () => {
|
|
|
5983
5983
|
}
|
|
5984
5984
|
);
|
|
5985
5985
|
};
|
|
5986
|
+
const CustomItems = () => {
|
|
5987
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
5988
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
5989
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
5990
|
+
] });
|
|
5991
|
+
};
|
|
5992
|
+
const CustomItemsForm = () => {
|
|
5993
|
+
const form = reactHookForm.useForm({
|
|
5994
|
+
resolver: zod$1.zodResolver(schema$5)
|
|
5995
|
+
});
|
|
5996
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
5997
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
5998
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
5999
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6000
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
6001
|
+
] }) })
|
|
6002
|
+
] }) });
|
|
6003
|
+
};
|
|
6004
|
+
const schema$5 = zod.z.object({
|
|
6005
|
+
email: zod.z.string().email()
|
|
6006
|
+
});
|
|
6007
|
+
const Email = () => {
|
|
6008
|
+
const { id } = reactRouterDom.useParams();
|
|
6009
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
6010
|
+
fields: "+email"
|
|
6011
|
+
});
|
|
6012
|
+
if (isError) {
|
|
6013
|
+
throw error;
|
|
6014
|
+
}
|
|
6015
|
+
const isReady = !isPending && !!order;
|
|
6016
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6017
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
6018
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
6019
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
6020
|
+
] }),
|
|
6021
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
6022
|
+
] });
|
|
6023
|
+
};
|
|
6024
|
+
const EmailForm = ({ order }) => {
|
|
6025
|
+
const form = reactHookForm.useForm({
|
|
6026
|
+
defaultValues: {
|
|
6027
|
+
email: order.email ?? ""
|
|
6028
|
+
},
|
|
6029
|
+
resolver: zod$1.zodResolver(schema$4)
|
|
6030
|
+
});
|
|
6031
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6032
|
+
const { handleSuccess } = useRouteModal();
|
|
6033
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
6034
|
+
await mutateAsync(
|
|
6035
|
+
{ email: data.email },
|
|
6036
|
+
{
|
|
6037
|
+
onSuccess: () => {
|
|
6038
|
+
handleSuccess();
|
|
6039
|
+
},
|
|
6040
|
+
onError: (error) => {
|
|
6041
|
+
ui.toast.error(error.message);
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
);
|
|
6045
|
+
});
|
|
6046
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6047
|
+
KeyboundForm,
|
|
6048
|
+
{
|
|
6049
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
6050
|
+
onSubmit,
|
|
6051
|
+
children: [
|
|
6052
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6053
|
+
Form$2.Field,
|
|
6054
|
+
{
|
|
6055
|
+
control: form.control,
|
|
6056
|
+
name: "email",
|
|
6057
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6058
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
6059
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6060
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6061
|
+
] })
|
|
6062
|
+
}
|
|
6063
|
+
) }),
|
|
6064
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6065
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6066
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6067
|
+
] }) })
|
|
6068
|
+
]
|
|
6069
|
+
}
|
|
6070
|
+
) });
|
|
6071
|
+
};
|
|
6072
|
+
const schema$4 = zod.z.object({
|
|
6073
|
+
email: zod.z.string().email()
|
|
6074
|
+
});
|
|
5986
6075
|
const BillingAddress = () => {
|
|
5987
6076
|
const { id } = reactRouterDom.useParams();
|
|
5988
6077
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -6014,7 +6103,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
6014
6103
|
postal_code: order.billing_address?.postal_code ?? "",
|
|
6015
6104
|
phone: order.billing_address?.phone ?? ""
|
|
6016
6105
|
},
|
|
6017
|
-
resolver: zod$1.zodResolver(schema$
|
|
6106
|
+
resolver: zod$1.zodResolver(schema$3)
|
|
6018
6107
|
});
|
|
6019
6108
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6020
6109
|
const { handleSuccess } = useRouteModal();
|
|
@@ -6171,75 +6260,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
6171
6260
|
}
|
|
6172
6261
|
) });
|
|
6173
6262
|
};
|
|
6174
|
-
const schema$
|
|
6175
|
-
const Email = () => {
|
|
6176
|
-
const { id } = reactRouterDom.useParams();
|
|
6177
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
6178
|
-
fields: "+email"
|
|
6179
|
-
});
|
|
6180
|
-
if (isError) {
|
|
6181
|
-
throw error;
|
|
6182
|
-
}
|
|
6183
|
-
const isReady = !isPending && !!order;
|
|
6184
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6185
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
6186
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
6187
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
6188
|
-
] }),
|
|
6189
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
6190
|
-
] });
|
|
6191
|
-
};
|
|
6192
|
-
const EmailForm = ({ order }) => {
|
|
6193
|
-
const form = reactHookForm.useForm({
|
|
6194
|
-
defaultValues: {
|
|
6195
|
-
email: order.email ?? ""
|
|
6196
|
-
},
|
|
6197
|
-
resolver: zod$1.zodResolver(schema$4)
|
|
6198
|
-
});
|
|
6199
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6200
|
-
const { handleSuccess } = useRouteModal();
|
|
6201
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
6202
|
-
await mutateAsync(
|
|
6203
|
-
{ email: data.email },
|
|
6204
|
-
{
|
|
6205
|
-
onSuccess: () => {
|
|
6206
|
-
handleSuccess();
|
|
6207
|
-
},
|
|
6208
|
-
onError: (error) => {
|
|
6209
|
-
ui.toast.error(error.message);
|
|
6210
|
-
}
|
|
6211
|
-
}
|
|
6212
|
-
);
|
|
6213
|
-
});
|
|
6214
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6215
|
-
KeyboundForm,
|
|
6216
|
-
{
|
|
6217
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
6218
|
-
onSubmit,
|
|
6219
|
-
children: [
|
|
6220
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6221
|
-
Form$2.Field,
|
|
6222
|
-
{
|
|
6223
|
-
control: form.control,
|
|
6224
|
-
name: "email",
|
|
6225
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6226
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
6227
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6228
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6229
|
-
] })
|
|
6230
|
-
}
|
|
6231
|
-
) }),
|
|
6232
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6233
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6234
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6235
|
-
] }) })
|
|
6236
|
-
]
|
|
6237
|
-
}
|
|
6238
|
-
) });
|
|
6239
|
-
};
|
|
6240
|
-
const schema$4 = zod.z.object({
|
|
6241
|
-
email: zod.z.string().email()
|
|
6242
|
-
});
|
|
6263
|
+
const schema$3 = addressSchema;
|
|
6243
6264
|
const NumberInput = React.forwardRef(
|
|
6244
6265
|
({
|
|
6245
6266
|
value,
|
|
@@ -7259,27 +7280,6 @@ const customItemSchema = zod.z.object({
|
|
|
7259
7280
|
quantity: zod.z.number(),
|
|
7260
7281
|
unit_price: zod.z.union([zod.z.number(), zod.z.string()])
|
|
7261
7282
|
});
|
|
7262
|
-
const CustomItems = () => {
|
|
7263
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7264
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
7265
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
7266
|
-
] });
|
|
7267
|
-
};
|
|
7268
|
-
const CustomItemsForm = () => {
|
|
7269
|
-
const form = reactHookForm.useForm({
|
|
7270
|
-
resolver: zod$1.zodResolver(schema$3)
|
|
7271
|
-
});
|
|
7272
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
7273
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
7274
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7275
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7276
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
7277
|
-
] }) })
|
|
7278
|
-
] }) });
|
|
7279
|
-
};
|
|
7280
|
-
const schema$3 = zod.z.object({
|
|
7281
|
-
email: zod.z.string().email()
|
|
7282
|
-
});
|
|
7283
7283
|
const InlineTip = React.forwardRef(
|
|
7284
7284
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
7285
7285
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -7905,112 +7905,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
7905
7905
|
}
|
|
7906
7906
|
return Array.from(promotionIds);
|
|
7907
7907
|
}
|
|
7908
|
-
const SalesChannel = () => {
|
|
7909
|
-
const { id } = reactRouterDom.useParams();
|
|
7910
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7911
|
-
id,
|
|
7912
|
-
{
|
|
7913
|
-
fields: "+sales_channel_id"
|
|
7914
|
-
},
|
|
7915
|
-
{
|
|
7916
|
-
enabled: !!id
|
|
7917
|
-
}
|
|
7918
|
-
);
|
|
7919
|
-
if (isError) {
|
|
7920
|
-
throw error;
|
|
7921
|
-
}
|
|
7922
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7923
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7924
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7925
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
7926
|
-
/* @__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" }) })
|
|
7927
|
-
] }),
|
|
7928
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
7929
|
-
] });
|
|
7930
|
-
};
|
|
7931
|
-
const SalesChannelForm = ({ order }) => {
|
|
7932
|
-
const form = reactHookForm.useForm({
|
|
7933
|
-
defaultValues: {
|
|
7934
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7935
|
-
},
|
|
7936
|
-
resolver: zod$1.zodResolver(schema$2)
|
|
7937
|
-
});
|
|
7938
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7939
|
-
const { handleSuccess } = useRouteModal();
|
|
7940
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7941
|
-
await mutateAsync(
|
|
7942
|
-
{
|
|
7943
|
-
sales_channel_id: data.sales_channel_id
|
|
7944
|
-
},
|
|
7945
|
-
{
|
|
7946
|
-
onSuccess: () => {
|
|
7947
|
-
ui.toast.success("Sales channel updated");
|
|
7948
|
-
handleSuccess();
|
|
7949
|
-
},
|
|
7950
|
-
onError: (error) => {
|
|
7951
|
-
ui.toast.error(error.message);
|
|
7952
|
-
}
|
|
7953
|
-
}
|
|
7954
|
-
);
|
|
7955
|
-
});
|
|
7956
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7957
|
-
KeyboundForm,
|
|
7958
|
-
{
|
|
7959
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7960
|
-
onSubmit,
|
|
7961
|
-
children: [
|
|
7962
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7963
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7964
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7965
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7966
|
-
] }) })
|
|
7967
|
-
]
|
|
7968
|
-
}
|
|
7969
|
-
) });
|
|
7970
|
-
};
|
|
7971
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7972
|
-
const salesChannels = useComboboxData({
|
|
7973
|
-
queryFn: async (params) => {
|
|
7974
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7975
|
-
},
|
|
7976
|
-
queryKey: ["sales-channels"],
|
|
7977
|
-
getOptions: (data) => {
|
|
7978
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7979
|
-
label: salesChannel.name,
|
|
7980
|
-
value: salesChannel.id
|
|
7981
|
-
}));
|
|
7982
|
-
},
|
|
7983
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7984
|
-
});
|
|
7985
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7986
|
-
Form$2.Field,
|
|
7987
|
-
{
|
|
7988
|
-
control,
|
|
7989
|
-
name: "sales_channel_id",
|
|
7990
|
-
render: ({ field }) => {
|
|
7991
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7992
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7993
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7994
|
-
Combobox,
|
|
7995
|
-
{
|
|
7996
|
-
options: salesChannels.options,
|
|
7997
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7998
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7999
|
-
searchValue: salesChannels.searchValue,
|
|
8000
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
8001
|
-
placeholder: "Select sales channel",
|
|
8002
|
-
...field
|
|
8003
|
-
}
|
|
8004
|
-
) }),
|
|
8005
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8006
|
-
] });
|
|
8007
|
-
}
|
|
8008
|
-
}
|
|
8009
|
-
);
|
|
8010
|
-
};
|
|
8011
|
-
const schema$2 = zod.z.object({
|
|
8012
|
-
sales_channel_id: zod.z.string().min(1)
|
|
8013
|
-
});
|
|
8014
7908
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8015
7909
|
const Shipping = () => {
|
|
8016
7910
|
const { id } = reactRouterDom.useParams();
|
|
@@ -8836,7 +8730,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8836
8730
|
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8837
8731
|
phone: order.shipping_address?.phone ?? ""
|
|
8838
8732
|
},
|
|
8839
|
-
resolver: zod$1.zodResolver(schema$
|
|
8733
|
+
resolver: zod$1.zodResolver(schema$2)
|
|
8840
8734
|
});
|
|
8841
8735
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8842
8736
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9006,7 +8900,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
9006
8900
|
}
|
|
9007
8901
|
) });
|
|
9008
8902
|
};
|
|
9009
|
-
const schema$
|
|
8903
|
+
const schema$2 = addressSchema;
|
|
9010
8904
|
const TransferOwnership = () => {
|
|
9011
8905
|
const { id } = reactRouterDom.useParams();
|
|
9012
8906
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -9029,7 +8923,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
9029
8923
|
defaultValues: {
|
|
9030
8924
|
customer_id: order.customer_id || ""
|
|
9031
8925
|
},
|
|
9032
|
-
resolver: zod$1.zodResolver(schema)
|
|
8926
|
+
resolver: zod$1.zodResolver(schema$1)
|
|
9033
8927
|
});
|
|
9034
8928
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9035
8929
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9481,9 +9375,115 @@ const Illustration = () => {
|
|
|
9481
9375
|
}
|
|
9482
9376
|
);
|
|
9483
9377
|
};
|
|
9484
|
-
const schema = zod.z.object({
|
|
9378
|
+
const schema$1 = zod.z.object({
|
|
9485
9379
|
customer_id: zod.z.string().min(1)
|
|
9486
9380
|
});
|
|
9381
|
+
const SalesChannel = () => {
|
|
9382
|
+
const { id } = reactRouterDom.useParams();
|
|
9383
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9384
|
+
id,
|
|
9385
|
+
{
|
|
9386
|
+
fields: "+sales_channel_id"
|
|
9387
|
+
},
|
|
9388
|
+
{
|
|
9389
|
+
enabled: !!id
|
|
9390
|
+
}
|
|
9391
|
+
);
|
|
9392
|
+
if (isError) {
|
|
9393
|
+
throw error;
|
|
9394
|
+
}
|
|
9395
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
9396
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9397
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9398
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
9399
|
+
/* @__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" }) })
|
|
9400
|
+
] }),
|
|
9401
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
9402
|
+
] });
|
|
9403
|
+
};
|
|
9404
|
+
const SalesChannelForm = ({ order }) => {
|
|
9405
|
+
const form = reactHookForm.useForm({
|
|
9406
|
+
defaultValues: {
|
|
9407
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
9408
|
+
},
|
|
9409
|
+
resolver: zod$1.zodResolver(schema)
|
|
9410
|
+
});
|
|
9411
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9412
|
+
const { handleSuccess } = useRouteModal();
|
|
9413
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9414
|
+
await mutateAsync(
|
|
9415
|
+
{
|
|
9416
|
+
sales_channel_id: data.sales_channel_id
|
|
9417
|
+
},
|
|
9418
|
+
{
|
|
9419
|
+
onSuccess: () => {
|
|
9420
|
+
ui.toast.success("Sales channel updated");
|
|
9421
|
+
handleSuccess();
|
|
9422
|
+
},
|
|
9423
|
+
onError: (error) => {
|
|
9424
|
+
ui.toast.error(error.message);
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
);
|
|
9428
|
+
});
|
|
9429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9430
|
+
KeyboundForm,
|
|
9431
|
+
{
|
|
9432
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9433
|
+
onSubmit,
|
|
9434
|
+
children: [
|
|
9435
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9436
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9437
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9438
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9439
|
+
] }) })
|
|
9440
|
+
]
|
|
9441
|
+
}
|
|
9442
|
+
) });
|
|
9443
|
+
};
|
|
9444
|
+
const SalesChannelField = ({ control, order }) => {
|
|
9445
|
+
const salesChannels = useComboboxData({
|
|
9446
|
+
queryFn: async (params) => {
|
|
9447
|
+
return await sdk.admin.salesChannel.list(params);
|
|
9448
|
+
},
|
|
9449
|
+
queryKey: ["sales-channels"],
|
|
9450
|
+
getOptions: (data) => {
|
|
9451
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
9452
|
+
label: salesChannel.name,
|
|
9453
|
+
value: salesChannel.id
|
|
9454
|
+
}));
|
|
9455
|
+
},
|
|
9456
|
+
defaultValue: order.sales_channel_id || void 0
|
|
9457
|
+
});
|
|
9458
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9459
|
+
Form$2.Field,
|
|
9460
|
+
{
|
|
9461
|
+
control,
|
|
9462
|
+
name: "sales_channel_id",
|
|
9463
|
+
render: ({ field }) => {
|
|
9464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9465
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9466
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9467
|
+
Combobox,
|
|
9468
|
+
{
|
|
9469
|
+
options: salesChannels.options,
|
|
9470
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
9471
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9472
|
+
searchValue: salesChannels.searchValue,
|
|
9473
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9474
|
+
placeholder: "Select sales channel",
|
|
9475
|
+
...field
|
|
9476
|
+
}
|
|
9477
|
+
) }),
|
|
9478
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9479
|
+
] });
|
|
9480
|
+
}
|
|
9481
|
+
}
|
|
9482
|
+
);
|
|
9483
|
+
};
|
|
9484
|
+
const schema = zod.z.object({
|
|
9485
|
+
sales_channel_id: zod.z.string().min(1)
|
|
9486
|
+
});
|
|
9487
9487
|
const widgetModule = { widgets: [] };
|
|
9488
9488
|
const routeModule = {
|
|
9489
9489
|
routes: [
|
|
@@ -9505,20 +9505,20 @@ const routeModule = {
|
|
|
9505
9505
|
loader,
|
|
9506
9506
|
children: [
|
|
9507
9507
|
{
|
|
9508
|
-
Component:
|
|
9509
|
-
path: "/draft-orders/:id/
|
|
9508
|
+
Component: CustomItems,
|
|
9509
|
+
path: "/draft-orders/:id/custom-items"
|
|
9510
9510
|
},
|
|
9511
9511
|
{
|
|
9512
9512
|
Component: Email,
|
|
9513
9513
|
path: "/draft-orders/:id/email"
|
|
9514
9514
|
},
|
|
9515
9515
|
{
|
|
9516
|
-
Component:
|
|
9517
|
-
path: "/draft-orders/:id/
|
|
9516
|
+
Component: BillingAddress,
|
|
9517
|
+
path: "/draft-orders/:id/billing-address"
|
|
9518
9518
|
},
|
|
9519
9519
|
{
|
|
9520
|
-
Component:
|
|
9521
|
-
path: "/draft-orders/:id/
|
|
9520
|
+
Component: Items,
|
|
9521
|
+
path: "/draft-orders/:id/items"
|
|
9522
9522
|
},
|
|
9523
9523
|
{
|
|
9524
9524
|
Component: Metadata,
|
|
@@ -9528,10 +9528,6 @@ const routeModule = {
|
|
|
9528
9528
|
Component: Promotions,
|
|
9529
9529
|
path: "/draft-orders/:id/promotions"
|
|
9530
9530
|
},
|
|
9531
|
-
{
|
|
9532
|
-
Component: SalesChannel,
|
|
9533
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9534
|
-
},
|
|
9535
9531
|
{
|
|
9536
9532
|
Component: Shipping,
|
|
9537
9533
|
path: "/draft-orders/:id/shipping"
|
|
@@ -9543,6 +9539,10 @@ const routeModule = {
|
|
|
9543
9539
|
{
|
|
9544
9540
|
Component: TransferOwnership,
|
|
9545
9541
|
path: "/draft-orders/:id/transfer-ownership"
|
|
9542
|
+
},
|
|
9543
|
+
{
|
|
9544
|
+
Component: SalesChannel,
|
|
9545
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9546
9546
|
}
|
|
9547
9547
|
]
|
|
9548
9548
|
}
|
|
@@ -5976,6 +5976,95 @@ const ID = () => {
|
|
|
5976
5976
|
}
|
|
5977
5977
|
);
|
|
5978
5978
|
};
|
|
5979
|
+
const CustomItems = () => {
|
|
5980
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
5981
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
5982
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
5983
|
+
] });
|
|
5984
|
+
};
|
|
5985
|
+
const CustomItemsForm = () => {
|
|
5986
|
+
const form = useForm({
|
|
5987
|
+
resolver: zodResolver(schema$5)
|
|
5988
|
+
});
|
|
5989
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
5990
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
5991
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
5992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
5993
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
5994
|
+
] }) })
|
|
5995
|
+
] }) });
|
|
5996
|
+
};
|
|
5997
|
+
const schema$5 = z.object({
|
|
5998
|
+
email: z.string().email()
|
|
5999
|
+
});
|
|
6000
|
+
const Email = () => {
|
|
6001
|
+
const { id } = useParams();
|
|
6002
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
6003
|
+
fields: "+email"
|
|
6004
|
+
});
|
|
6005
|
+
if (isError) {
|
|
6006
|
+
throw error;
|
|
6007
|
+
}
|
|
6008
|
+
const isReady = !isPending && !!order;
|
|
6009
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
6010
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
6011
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
6012
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
6013
|
+
] }),
|
|
6014
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
6015
|
+
] });
|
|
6016
|
+
};
|
|
6017
|
+
const EmailForm = ({ order }) => {
|
|
6018
|
+
const form = useForm({
|
|
6019
|
+
defaultValues: {
|
|
6020
|
+
email: order.email ?? ""
|
|
6021
|
+
},
|
|
6022
|
+
resolver: zodResolver(schema$4)
|
|
6023
|
+
});
|
|
6024
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6025
|
+
const { handleSuccess } = useRouteModal();
|
|
6026
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
6027
|
+
await mutateAsync(
|
|
6028
|
+
{ email: data.email },
|
|
6029
|
+
{
|
|
6030
|
+
onSuccess: () => {
|
|
6031
|
+
handleSuccess();
|
|
6032
|
+
},
|
|
6033
|
+
onError: (error) => {
|
|
6034
|
+
toast.error(error.message);
|
|
6035
|
+
}
|
|
6036
|
+
}
|
|
6037
|
+
);
|
|
6038
|
+
});
|
|
6039
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
6040
|
+
KeyboundForm,
|
|
6041
|
+
{
|
|
6042
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
6043
|
+
onSubmit,
|
|
6044
|
+
children: [
|
|
6045
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
6046
|
+
Form$2.Field,
|
|
6047
|
+
{
|
|
6048
|
+
control: form.control,
|
|
6049
|
+
name: "email",
|
|
6050
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
6051
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
6052
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
6053
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
6054
|
+
] })
|
|
6055
|
+
}
|
|
6056
|
+
) }),
|
|
6057
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6058
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6059
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6060
|
+
] }) })
|
|
6061
|
+
]
|
|
6062
|
+
}
|
|
6063
|
+
) });
|
|
6064
|
+
};
|
|
6065
|
+
const schema$4 = z.object({
|
|
6066
|
+
email: z.string().email()
|
|
6067
|
+
});
|
|
5979
6068
|
const BillingAddress = () => {
|
|
5980
6069
|
const { id } = useParams();
|
|
5981
6070
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -6007,7 +6096,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
6007
6096
|
postal_code: order.billing_address?.postal_code ?? "",
|
|
6008
6097
|
phone: order.billing_address?.phone ?? ""
|
|
6009
6098
|
},
|
|
6010
|
-
resolver: zodResolver(schema$
|
|
6099
|
+
resolver: zodResolver(schema$3)
|
|
6011
6100
|
});
|
|
6012
6101
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6013
6102
|
const { handleSuccess } = useRouteModal();
|
|
@@ -6164,75 +6253,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
6164
6253
|
}
|
|
6165
6254
|
) });
|
|
6166
6255
|
};
|
|
6167
|
-
const schema$
|
|
6168
|
-
const Email = () => {
|
|
6169
|
-
const { id } = useParams();
|
|
6170
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
6171
|
-
fields: "+email"
|
|
6172
|
-
});
|
|
6173
|
-
if (isError) {
|
|
6174
|
-
throw error;
|
|
6175
|
-
}
|
|
6176
|
-
const isReady = !isPending && !!order;
|
|
6177
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
6178
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
6179
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
6180
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
6181
|
-
] }),
|
|
6182
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
6183
|
-
] });
|
|
6184
|
-
};
|
|
6185
|
-
const EmailForm = ({ order }) => {
|
|
6186
|
-
const form = useForm({
|
|
6187
|
-
defaultValues: {
|
|
6188
|
-
email: order.email ?? ""
|
|
6189
|
-
},
|
|
6190
|
-
resolver: zodResolver(schema$4)
|
|
6191
|
-
});
|
|
6192
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6193
|
-
const { handleSuccess } = useRouteModal();
|
|
6194
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
6195
|
-
await mutateAsync(
|
|
6196
|
-
{ email: data.email },
|
|
6197
|
-
{
|
|
6198
|
-
onSuccess: () => {
|
|
6199
|
-
handleSuccess();
|
|
6200
|
-
},
|
|
6201
|
-
onError: (error) => {
|
|
6202
|
-
toast.error(error.message);
|
|
6203
|
-
}
|
|
6204
|
-
}
|
|
6205
|
-
);
|
|
6206
|
-
});
|
|
6207
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
6208
|
-
KeyboundForm,
|
|
6209
|
-
{
|
|
6210
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
6211
|
-
onSubmit,
|
|
6212
|
-
children: [
|
|
6213
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
6214
|
-
Form$2.Field,
|
|
6215
|
-
{
|
|
6216
|
-
control: form.control,
|
|
6217
|
-
name: "email",
|
|
6218
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
6219
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
6220
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
6221
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
6222
|
-
] })
|
|
6223
|
-
}
|
|
6224
|
-
) }),
|
|
6225
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6226
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6227
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6228
|
-
] }) })
|
|
6229
|
-
]
|
|
6230
|
-
}
|
|
6231
|
-
) });
|
|
6232
|
-
};
|
|
6233
|
-
const schema$4 = z.object({
|
|
6234
|
-
email: z.string().email()
|
|
6235
|
-
});
|
|
6256
|
+
const schema$3 = addressSchema;
|
|
6236
6257
|
const NumberInput = forwardRef(
|
|
6237
6258
|
({
|
|
6238
6259
|
value,
|
|
@@ -7252,27 +7273,6 @@ const customItemSchema = z.object({
|
|
|
7252
7273
|
quantity: z.number(),
|
|
7253
7274
|
unit_price: z.union([z.number(), z.string()])
|
|
7254
7275
|
});
|
|
7255
|
-
const CustomItems = () => {
|
|
7256
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
7257
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
7258
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
7259
|
-
] });
|
|
7260
|
-
};
|
|
7261
|
-
const CustomItemsForm = () => {
|
|
7262
|
-
const form = useForm({
|
|
7263
|
-
resolver: zodResolver(schema$3)
|
|
7264
|
-
});
|
|
7265
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
7266
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
7267
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7268
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7269
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
7270
|
-
] }) })
|
|
7271
|
-
] }) });
|
|
7272
|
-
};
|
|
7273
|
-
const schema$3 = z.object({
|
|
7274
|
-
email: z.string().email()
|
|
7275
|
-
});
|
|
7276
7276
|
const InlineTip = forwardRef(
|
|
7277
7277
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
7278
7278
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -7898,112 +7898,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
7898
7898
|
}
|
|
7899
7899
|
return Array.from(promotionIds);
|
|
7900
7900
|
}
|
|
7901
|
-
const SalesChannel = () => {
|
|
7902
|
-
const { id } = useParams();
|
|
7903
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7904
|
-
id,
|
|
7905
|
-
{
|
|
7906
|
-
fields: "+sales_channel_id"
|
|
7907
|
-
},
|
|
7908
|
-
{
|
|
7909
|
-
enabled: !!id
|
|
7910
|
-
}
|
|
7911
|
-
);
|
|
7912
|
-
if (isError) {
|
|
7913
|
-
throw error;
|
|
7914
|
-
}
|
|
7915
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7916
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
7917
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
7918
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
7919
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
7920
|
-
] }),
|
|
7921
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
7922
|
-
] });
|
|
7923
|
-
};
|
|
7924
|
-
const SalesChannelForm = ({ order }) => {
|
|
7925
|
-
const form = useForm({
|
|
7926
|
-
defaultValues: {
|
|
7927
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7928
|
-
},
|
|
7929
|
-
resolver: zodResolver(schema$2)
|
|
7930
|
-
});
|
|
7931
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7932
|
-
const { handleSuccess } = useRouteModal();
|
|
7933
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7934
|
-
await mutateAsync(
|
|
7935
|
-
{
|
|
7936
|
-
sales_channel_id: data.sales_channel_id
|
|
7937
|
-
},
|
|
7938
|
-
{
|
|
7939
|
-
onSuccess: () => {
|
|
7940
|
-
toast.success("Sales channel updated");
|
|
7941
|
-
handleSuccess();
|
|
7942
|
-
},
|
|
7943
|
-
onError: (error) => {
|
|
7944
|
-
toast.error(error.message);
|
|
7945
|
-
}
|
|
7946
|
-
}
|
|
7947
|
-
);
|
|
7948
|
-
});
|
|
7949
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
7950
|
-
KeyboundForm,
|
|
7951
|
-
{
|
|
7952
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7953
|
-
onSubmit,
|
|
7954
|
-
children: [
|
|
7955
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7956
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7957
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7958
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7959
|
-
] }) })
|
|
7960
|
-
]
|
|
7961
|
-
}
|
|
7962
|
-
) });
|
|
7963
|
-
};
|
|
7964
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7965
|
-
const salesChannels = useComboboxData({
|
|
7966
|
-
queryFn: async (params) => {
|
|
7967
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7968
|
-
},
|
|
7969
|
-
queryKey: ["sales-channels"],
|
|
7970
|
-
getOptions: (data) => {
|
|
7971
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7972
|
-
label: salesChannel.name,
|
|
7973
|
-
value: salesChannel.id
|
|
7974
|
-
}));
|
|
7975
|
-
},
|
|
7976
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7977
|
-
});
|
|
7978
|
-
return /* @__PURE__ */ jsx(
|
|
7979
|
-
Form$2.Field,
|
|
7980
|
-
{
|
|
7981
|
-
control,
|
|
7982
|
-
name: "sales_channel_id",
|
|
7983
|
-
render: ({ field }) => {
|
|
7984
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
7985
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7986
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
7987
|
-
Combobox,
|
|
7988
|
-
{
|
|
7989
|
-
options: salesChannels.options,
|
|
7990
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7991
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7992
|
-
searchValue: salesChannels.searchValue,
|
|
7993
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7994
|
-
placeholder: "Select sales channel",
|
|
7995
|
-
...field
|
|
7996
|
-
}
|
|
7997
|
-
) }),
|
|
7998
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
7999
|
-
] });
|
|
8000
|
-
}
|
|
8001
|
-
}
|
|
8002
|
-
);
|
|
8003
|
-
};
|
|
8004
|
-
const schema$2 = z.object({
|
|
8005
|
-
sales_channel_id: z.string().min(1)
|
|
8006
|
-
});
|
|
8007
7901
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8008
7902
|
const Shipping = () => {
|
|
8009
7903
|
const { id } = useParams();
|
|
@@ -8829,7 +8723,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8829
8723
|
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8830
8724
|
phone: order.shipping_address?.phone ?? ""
|
|
8831
8725
|
},
|
|
8832
|
-
resolver: zodResolver(schema$
|
|
8726
|
+
resolver: zodResolver(schema$2)
|
|
8833
8727
|
});
|
|
8834
8728
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8835
8729
|
const { handleSuccess } = useRouteModal();
|
|
@@ -8999,7 +8893,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8999
8893
|
}
|
|
9000
8894
|
) });
|
|
9001
8895
|
};
|
|
9002
|
-
const schema$
|
|
8896
|
+
const schema$2 = addressSchema;
|
|
9003
8897
|
const TransferOwnership = () => {
|
|
9004
8898
|
const { id } = useParams();
|
|
9005
8899
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -9022,7 +8916,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
9022
8916
|
defaultValues: {
|
|
9023
8917
|
customer_id: order.customer_id || ""
|
|
9024
8918
|
},
|
|
9025
|
-
resolver: zodResolver(schema)
|
|
8919
|
+
resolver: zodResolver(schema$1)
|
|
9026
8920
|
});
|
|
9027
8921
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9028
8922
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9474,9 +9368,115 @@ const Illustration = () => {
|
|
|
9474
9368
|
}
|
|
9475
9369
|
);
|
|
9476
9370
|
};
|
|
9477
|
-
const schema = z.object({
|
|
9371
|
+
const schema$1 = z.object({
|
|
9478
9372
|
customer_id: z.string().min(1)
|
|
9479
9373
|
});
|
|
9374
|
+
const SalesChannel = () => {
|
|
9375
|
+
const { id } = useParams();
|
|
9376
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9377
|
+
id,
|
|
9378
|
+
{
|
|
9379
|
+
fields: "+sales_channel_id"
|
|
9380
|
+
},
|
|
9381
|
+
{
|
|
9382
|
+
enabled: !!id
|
|
9383
|
+
}
|
|
9384
|
+
);
|
|
9385
|
+
if (isError) {
|
|
9386
|
+
throw error;
|
|
9387
|
+
}
|
|
9388
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
9389
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9390
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9391
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
9392
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
9393
|
+
] }),
|
|
9394
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
9395
|
+
] });
|
|
9396
|
+
};
|
|
9397
|
+
const SalesChannelForm = ({ order }) => {
|
|
9398
|
+
const form = useForm({
|
|
9399
|
+
defaultValues: {
|
|
9400
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
9401
|
+
},
|
|
9402
|
+
resolver: zodResolver(schema)
|
|
9403
|
+
});
|
|
9404
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9405
|
+
const { handleSuccess } = useRouteModal();
|
|
9406
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9407
|
+
await mutateAsync(
|
|
9408
|
+
{
|
|
9409
|
+
sales_channel_id: data.sales_channel_id
|
|
9410
|
+
},
|
|
9411
|
+
{
|
|
9412
|
+
onSuccess: () => {
|
|
9413
|
+
toast.success("Sales channel updated");
|
|
9414
|
+
handleSuccess();
|
|
9415
|
+
},
|
|
9416
|
+
onError: (error) => {
|
|
9417
|
+
toast.error(error.message);
|
|
9418
|
+
}
|
|
9419
|
+
}
|
|
9420
|
+
);
|
|
9421
|
+
});
|
|
9422
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9423
|
+
KeyboundForm,
|
|
9424
|
+
{
|
|
9425
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9426
|
+
onSubmit,
|
|
9427
|
+
children: [
|
|
9428
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9429
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9430
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9431
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9432
|
+
] }) })
|
|
9433
|
+
]
|
|
9434
|
+
}
|
|
9435
|
+
) });
|
|
9436
|
+
};
|
|
9437
|
+
const SalesChannelField = ({ control, order }) => {
|
|
9438
|
+
const salesChannels = useComboboxData({
|
|
9439
|
+
queryFn: async (params) => {
|
|
9440
|
+
return await sdk.admin.salesChannel.list(params);
|
|
9441
|
+
},
|
|
9442
|
+
queryKey: ["sales-channels"],
|
|
9443
|
+
getOptions: (data) => {
|
|
9444
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
9445
|
+
label: salesChannel.name,
|
|
9446
|
+
value: salesChannel.id
|
|
9447
|
+
}));
|
|
9448
|
+
},
|
|
9449
|
+
defaultValue: order.sales_channel_id || void 0
|
|
9450
|
+
});
|
|
9451
|
+
return /* @__PURE__ */ jsx(
|
|
9452
|
+
Form$2.Field,
|
|
9453
|
+
{
|
|
9454
|
+
control,
|
|
9455
|
+
name: "sales_channel_id",
|
|
9456
|
+
render: ({ field }) => {
|
|
9457
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9458
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9459
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
9460
|
+
Combobox,
|
|
9461
|
+
{
|
|
9462
|
+
options: salesChannels.options,
|
|
9463
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
9464
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9465
|
+
searchValue: salesChannels.searchValue,
|
|
9466
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9467
|
+
placeholder: "Select sales channel",
|
|
9468
|
+
...field
|
|
9469
|
+
}
|
|
9470
|
+
) }),
|
|
9471
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9472
|
+
] });
|
|
9473
|
+
}
|
|
9474
|
+
}
|
|
9475
|
+
);
|
|
9476
|
+
};
|
|
9477
|
+
const schema = z.object({
|
|
9478
|
+
sales_channel_id: z.string().min(1)
|
|
9479
|
+
});
|
|
9480
9480
|
const widgetModule = { widgets: [] };
|
|
9481
9481
|
const routeModule = {
|
|
9482
9482
|
routes: [
|
|
@@ -9498,20 +9498,20 @@ const routeModule = {
|
|
|
9498
9498
|
loader,
|
|
9499
9499
|
children: [
|
|
9500
9500
|
{
|
|
9501
|
-
Component:
|
|
9502
|
-
path: "/draft-orders/:id/
|
|
9501
|
+
Component: CustomItems,
|
|
9502
|
+
path: "/draft-orders/:id/custom-items"
|
|
9503
9503
|
},
|
|
9504
9504
|
{
|
|
9505
9505
|
Component: Email,
|
|
9506
9506
|
path: "/draft-orders/:id/email"
|
|
9507
9507
|
},
|
|
9508
9508
|
{
|
|
9509
|
-
Component:
|
|
9510
|
-
path: "/draft-orders/:id/
|
|
9509
|
+
Component: BillingAddress,
|
|
9510
|
+
path: "/draft-orders/:id/billing-address"
|
|
9511
9511
|
},
|
|
9512
9512
|
{
|
|
9513
|
-
Component:
|
|
9514
|
-
path: "/draft-orders/:id/
|
|
9513
|
+
Component: Items,
|
|
9514
|
+
path: "/draft-orders/:id/items"
|
|
9515
9515
|
},
|
|
9516
9516
|
{
|
|
9517
9517
|
Component: Metadata,
|
|
@@ -9521,10 +9521,6 @@ const routeModule = {
|
|
|
9521
9521
|
Component: Promotions,
|
|
9522
9522
|
path: "/draft-orders/:id/promotions"
|
|
9523
9523
|
},
|
|
9524
|
-
{
|
|
9525
|
-
Component: SalesChannel,
|
|
9526
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9527
|
-
},
|
|
9528
9524
|
{
|
|
9529
9525
|
Component: Shipping,
|
|
9530
9526
|
path: "/draft-orders/:id/shipping"
|
|
@@ -9536,6 +9532,10 @@ const routeModule = {
|
|
|
9536
9532
|
{
|
|
9537
9533
|
Component: TransferOwnership,
|
|
9538
9534
|
path: "/draft-orders/:id/transfer-ownership"
|
|
9535
|
+
},
|
|
9536
|
+
{
|
|
9537
|
+
Component: SalesChannel,
|
|
9538
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9539
9539
|
}
|
|
9540
9540
|
]
|
|
9541
9541
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@ariakit/react": "^0.4.15",
|
|
51
51
|
"@babel/runtime": "^7.26.10",
|
|
52
52
|
"@hookform/resolvers": "5.5.7",
|
|
53
|
-
"@medusajs/js-sdk": "2.22.
|
|
53
|
+
"@medusajs/js-sdk": "2.22.1",
|
|
54
54
|
"@tanstack/react-query": "5.64.2",
|
|
55
55
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
56
56
|
"date-fns": "^3.6.0",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
"zod": "4.2.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@medusajs/admin-sdk": "2.22.
|
|
66
|
-
"@medusajs/cli": "2.22.
|
|
67
|
-
"@medusajs/dashboard": "2.22.
|
|
68
|
-
"@medusajs/framework": "2.22.
|
|
69
|
-
"@medusajs/icons": "2.22.
|
|
70
|
-
"@medusajs/test-utils": "2.22.
|
|
71
|
-
"@medusajs/types": "2.22.
|
|
72
|
-
"@medusajs/ui": "4.2.
|
|
73
|
-
"@medusajs/ui-preset": "2.22.
|
|
65
|
+
"@medusajs/admin-sdk": "2.22.1",
|
|
66
|
+
"@medusajs/cli": "2.22.1",
|
|
67
|
+
"@medusajs/dashboard": "2.22.1",
|
|
68
|
+
"@medusajs/framework": "2.22.1",
|
|
69
|
+
"@medusajs/icons": "2.22.1",
|
|
70
|
+
"@medusajs/test-utils": "2.22.1",
|
|
71
|
+
"@medusajs/types": "2.22.1",
|
|
72
|
+
"@medusajs/ui": "4.2.8",
|
|
73
|
+
"@medusajs/ui-preset": "2.22.1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@medusajs/admin-sdk": "2.22.
|
|
77
|
-
"@medusajs/cli": "2.22.
|
|
78
|
-
"@medusajs/dashboard": "2.22.
|
|
79
|
-
"@medusajs/framework": "2.22.
|
|
80
|
-
"@medusajs/icons": "2.22.
|
|
81
|
-
"@medusajs/test-utils": "2.22.
|
|
82
|
-
"@medusajs/ui": "4.2.
|
|
76
|
+
"@medusajs/admin-sdk": "2.22.1",
|
|
77
|
+
"@medusajs/cli": "2.22.1",
|
|
78
|
+
"@medusajs/dashboard": "2.22.1",
|
|
79
|
+
"@medusajs/framework": "2.22.1",
|
|
80
|
+
"@medusajs/icons": "2.22.1",
|
|
81
|
+
"@medusajs/test-utils": "2.22.1",
|
|
82
|
+
"@medusajs/ui": "4.2.8",
|
|
83
83
|
"react": "^18.3.1",
|
|
84
84
|
"react-dom": "^18.3.1",
|
|
85
85
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|