@medusajs/draft-order 2.10.2-preview-20250904060154 → 2.10.2-preview-20250904090151
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 +188 -188
- package/.medusa/server/src/admin/index.mjs +188 -188
- package/package.json +16 -16
|
@@ -9750,74 +9750,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9750
9750
|
) });
|
|
9751
9751
|
};
|
|
9752
9752
|
const schema$5 = addressSchema;
|
|
9753
|
-
const Email = () => {
|
|
9754
|
-
const { id } = reactRouterDom.useParams();
|
|
9755
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9756
|
-
fields: "+email"
|
|
9757
|
-
});
|
|
9758
|
-
if (isError) {
|
|
9759
|
-
throw error;
|
|
9760
|
-
}
|
|
9761
|
-
const isReady = !isPending && !!order;
|
|
9762
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9763
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9764
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9765
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9766
|
-
] }),
|
|
9767
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9768
|
-
] });
|
|
9769
|
-
};
|
|
9770
|
-
const EmailForm = ({ order }) => {
|
|
9771
|
-
const form = reactHookForm.useForm({
|
|
9772
|
-
defaultValues: {
|
|
9773
|
-
email: order.email ?? ""
|
|
9774
|
-
},
|
|
9775
|
-
resolver: zod.zodResolver(schema$4)
|
|
9776
|
-
});
|
|
9777
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9778
|
-
const { handleSuccess } = useRouteModal();
|
|
9779
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9780
|
-
await mutateAsync(
|
|
9781
|
-
{ email: data.email },
|
|
9782
|
-
{
|
|
9783
|
-
onSuccess: () => {
|
|
9784
|
-
handleSuccess();
|
|
9785
|
-
},
|
|
9786
|
-
onError: (error) => {
|
|
9787
|
-
ui.toast.error(error.message);
|
|
9788
|
-
}
|
|
9789
|
-
}
|
|
9790
|
-
);
|
|
9791
|
-
});
|
|
9792
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9793
|
-
KeyboundForm,
|
|
9794
|
-
{
|
|
9795
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9796
|
-
onSubmit,
|
|
9797
|
-
children: [
|
|
9798
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9799
|
-
Form$2.Field,
|
|
9800
|
-
{
|
|
9801
|
-
control: form.control,
|
|
9802
|
-
name: "email",
|
|
9803
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9804
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9805
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9806
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9807
|
-
] })
|
|
9808
|
-
}
|
|
9809
|
-
) }),
|
|
9810
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9811
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9812
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9813
|
-
] }) })
|
|
9814
|
-
]
|
|
9815
|
-
}
|
|
9816
|
-
) });
|
|
9817
|
-
};
|
|
9818
|
-
const schema$4 = objectType({
|
|
9819
|
-
email: stringType().email()
|
|
9820
|
-
});
|
|
9821
9753
|
const CustomItems = () => {
|
|
9822
9754
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9823
9755
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9826,7 +9758,7 @@ const CustomItems = () => {
|
|
|
9826
9758
|
};
|
|
9827
9759
|
const CustomItemsForm = () => {
|
|
9828
9760
|
const form = reactHookForm.useForm({
|
|
9829
|
-
resolver: zod.zodResolver(schema$
|
|
9761
|
+
resolver: zod.zodResolver(schema$4)
|
|
9830
9762
|
});
|
|
9831
9763
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9832
9764
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9836,7 +9768,7 @@ const CustomItemsForm = () => {
|
|
|
9836
9768
|
] }) })
|
|
9837
9769
|
] }) });
|
|
9838
9770
|
};
|
|
9839
|
-
const schema$
|
|
9771
|
+
const schema$4 = objectType({
|
|
9840
9772
|
email: stringType().email()
|
|
9841
9773
|
});
|
|
9842
9774
|
const NumberInput = React.forwardRef(
|
|
@@ -11440,112 +11372,6 @@ function getPromotionCodes(items, shippingMethods) {
|
|
|
11440
11372
|
}
|
|
11441
11373
|
return Array.from(codes);
|
|
11442
11374
|
}
|
|
11443
|
-
const SalesChannel = () => {
|
|
11444
|
-
const { id } = reactRouterDom.useParams();
|
|
11445
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11446
|
-
id,
|
|
11447
|
-
{
|
|
11448
|
-
fields: "+sales_channel_id"
|
|
11449
|
-
},
|
|
11450
|
-
{
|
|
11451
|
-
enabled: !!id
|
|
11452
|
-
}
|
|
11453
|
-
);
|
|
11454
|
-
if (isError) {
|
|
11455
|
-
throw error;
|
|
11456
|
-
}
|
|
11457
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11458
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11459
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11460
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11461
|
-
/* @__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" }) })
|
|
11462
|
-
] }),
|
|
11463
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11464
|
-
] });
|
|
11465
|
-
};
|
|
11466
|
-
const SalesChannelForm = ({ order }) => {
|
|
11467
|
-
const form = reactHookForm.useForm({
|
|
11468
|
-
defaultValues: {
|
|
11469
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11470
|
-
},
|
|
11471
|
-
resolver: zod.zodResolver(schema$2)
|
|
11472
|
-
});
|
|
11473
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11474
|
-
const { handleSuccess } = useRouteModal();
|
|
11475
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11476
|
-
await mutateAsync(
|
|
11477
|
-
{
|
|
11478
|
-
sales_channel_id: data.sales_channel_id
|
|
11479
|
-
},
|
|
11480
|
-
{
|
|
11481
|
-
onSuccess: () => {
|
|
11482
|
-
ui.toast.success("Sales channel updated");
|
|
11483
|
-
handleSuccess();
|
|
11484
|
-
},
|
|
11485
|
-
onError: (error) => {
|
|
11486
|
-
ui.toast.error(error.message);
|
|
11487
|
-
}
|
|
11488
|
-
}
|
|
11489
|
-
);
|
|
11490
|
-
});
|
|
11491
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11492
|
-
KeyboundForm,
|
|
11493
|
-
{
|
|
11494
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11495
|
-
onSubmit,
|
|
11496
|
-
children: [
|
|
11497
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11498
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11499
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11500
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11501
|
-
] }) })
|
|
11502
|
-
]
|
|
11503
|
-
}
|
|
11504
|
-
) });
|
|
11505
|
-
};
|
|
11506
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11507
|
-
const salesChannels = useComboboxData({
|
|
11508
|
-
queryFn: async (params) => {
|
|
11509
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11510
|
-
},
|
|
11511
|
-
queryKey: ["sales-channels"],
|
|
11512
|
-
getOptions: (data) => {
|
|
11513
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11514
|
-
label: salesChannel.name,
|
|
11515
|
-
value: salesChannel.id
|
|
11516
|
-
}));
|
|
11517
|
-
},
|
|
11518
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11519
|
-
});
|
|
11520
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11521
|
-
Form$2.Field,
|
|
11522
|
-
{
|
|
11523
|
-
control,
|
|
11524
|
-
name: "sales_channel_id",
|
|
11525
|
-
render: ({ field }) => {
|
|
11526
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11527
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11528
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
-
Combobox,
|
|
11530
|
-
{
|
|
11531
|
-
options: salesChannels.options,
|
|
11532
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11533
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11534
|
-
searchValue: salesChannels.searchValue,
|
|
11535
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11536
|
-
placeholder: "Select sales channel",
|
|
11537
|
-
...field
|
|
11538
|
-
}
|
|
11539
|
-
) }),
|
|
11540
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11541
|
-
] });
|
|
11542
|
-
}
|
|
11543
|
-
}
|
|
11544
|
-
);
|
|
11545
|
-
};
|
|
11546
|
-
const schema$2 = objectType({
|
|
11547
|
-
sales_channel_id: stringType().min(1)
|
|
11548
|
-
});
|
|
11549
11375
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11550
11376
|
const Shipping = () => {
|
|
11551
11377
|
var _a;
|
|
@@ -12353,6 +12179,112 @@ const CustomAmountField = ({
|
|
|
12353
12179
|
}
|
|
12354
12180
|
);
|
|
12355
12181
|
};
|
|
12182
|
+
const SalesChannel = () => {
|
|
12183
|
+
const { id } = reactRouterDom.useParams();
|
|
12184
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12185
|
+
id,
|
|
12186
|
+
{
|
|
12187
|
+
fields: "+sales_channel_id"
|
|
12188
|
+
},
|
|
12189
|
+
{
|
|
12190
|
+
enabled: !!id
|
|
12191
|
+
}
|
|
12192
|
+
);
|
|
12193
|
+
if (isError) {
|
|
12194
|
+
throw error;
|
|
12195
|
+
}
|
|
12196
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12197
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12198
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12199
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12200
|
+
/* @__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" }) })
|
|
12201
|
+
] }),
|
|
12202
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12203
|
+
] });
|
|
12204
|
+
};
|
|
12205
|
+
const SalesChannelForm = ({ order }) => {
|
|
12206
|
+
const form = reactHookForm.useForm({
|
|
12207
|
+
defaultValues: {
|
|
12208
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12209
|
+
},
|
|
12210
|
+
resolver: zod.zodResolver(schema$3)
|
|
12211
|
+
});
|
|
12212
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12213
|
+
const { handleSuccess } = useRouteModal();
|
|
12214
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12215
|
+
await mutateAsync(
|
|
12216
|
+
{
|
|
12217
|
+
sales_channel_id: data.sales_channel_id
|
|
12218
|
+
},
|
|
12219
|
+
{
|
|
12220
|
+
onSuccess: () => {
|
|
12221
|
+
ui.toast.success("Sales channel updated");
|
|
12222
|
+
handleSuccess();
|
|
12223
|
+
},
|
|
12224
|
+
onError: (error) => {
|
|
12225
|
+
ui.toast.error(error.message);
|
|
12226
|
+
}
|
|
12227
|
+
}
|
|
12228
|
+
);
|
|
12229
|
+
});
|
|
12230
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12231
|
+
KeyboundForm,
|
|
12232
|
+
{
|
|
12233
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12234
|
+
onSubmit,
|
|
12235
|
+
children: [
|
|
12236
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12237
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12238
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12239
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12240
|
+
] }) })
|
|
12241
|
+
]
|
|
12242
|
+
}
|
|
12243
|
+
) });
|
|
12244
|
+
};
|
|
12245
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12246
|
+
const salesChannels = useComboboxData({
|
|
12247
|
+
queryFn: async (params) => {
|
|
12248
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12249
|
+
},
|
|
12250
|
+
queryKey: ["sales-channels"],
|
|
12251
|
+
getOptions: (data) => {
|
|
12252
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12253
|
+
label: salesChannel.name,
|
|
12254
|
+
value: salesChannel.id
|
|
12255
|
+
}));
|
|
12256
|
+
},
|
|
12257
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12258
|
+
});
|
|
12259
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12260
|
+
Form$2.Field,
|
|
12261
|
+
{
|
|
12262
|
+
control,
|
|
12263
|
+
name: "sales_channel_id",
|
|
12264
|
+
render: ({ field }) => {
|
|
12265
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12266
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12267
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12268
|
+
Combobox,
|
|
12269
|
+
{
|
|
12270
|
+
options: salesChannels.options,
|
|
12271
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12272
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12273
|
+
searchValue: salesChannels.searchValue,
|
|
12274
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12275
|
+
placeholder: "Select sales channel",
|
|
12276
|
+
...field
|
|
12277
|
+
}
|
|
12278
|
+
) }),
|
|
12279
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12280
|
+
] });
|
|
12281
|
+
}
|
|
12282
|
+
}
|
|
12283
|
+
);
|
|
12284
|
+
};
|
|
12285
|
+
const schema$3 = objectType({
|
|
12286
|
+
sales_channel_id: stringType().min(1)
|
|
12287
|
+
});
|
|
12356
12288
|
const ShippingAddress = () => {
|
|
12357
12289
|
const { id } = reactRouterDom.useParams();
|
|
12358
12290
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12385,7 +12317,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12385
12317
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12386
12318
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12387
12319
|
},
|
|
12388
|
-
resolver: zod.zodResolver(schema$
|
|
12320
|
+
resolver: zod.zodResolver(schema$2)
|
|
12389
12321
|
});
|
|
12390
12322
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12391
12323
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12555,7 +12487,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12555
12487
|
}
|
|
12556
12488
|
) });
|
|
12557
12489
|
};
|
|
12558
|
-
const schema$
|
|
12490
|
+
const schema$2 = addressSchema;
|
|
12559
12491
|
const TransferOwnership = () => {
|
|
12560
12492
|
const { id } = reactRouterDom.useParams();
|
|
12561
12493
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12579,7 +12511,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12579
12511
|
defaultValues: {
|
|
12580
12512
|
customer_id: order.customer_id || ""
|
|
12581
12513
|
},
|
|
12582
|
-
resolver: zod.zodResolver(schema)
|
|
12514
|
+
resolver: zod.zodResolver(schema$1)
|
|
12583
12515
|
});
|
|
12584
12516
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12585
12517
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13029,9 +12961,77 @@ const Illustration = () => {
|
|
|
13029
12961
|
}
|
|
13030
12962
|
);
|
|
13031
12963
|
};
|
|
13032
|
-
const schema = objectType({
|
|
12964
|
+
const schema$1 = objectType({
|
|
13033
12965
|
customer_id: stringType().min(1)
|
|
13034
12966
|
});
|
|
12967
|
+
const Email = () => {
|
|
12968
|
+
const { id } = reactRouterDom.useParams();
|
|
12969
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12970
|
+
fields: "+email"
|
|
12971
|
+
});
|
|
12972
|
+
if (isError) {
|
|
12973
|
+
throw error;
|
|
12974
|
+
}
|
|
12975
|
+
const isReady = !isPending && !!order;
|
|
12976
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12977
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12978
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12979
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12980
|
+
] }),
|
|
12981
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12982
|
+
] });
|
|
12983
|
+
};
|
|
12984
|
+
const EmailForm = ({ order }) => {
|
|
12985
|
+
const form = reactHookForm.useForm({
|
|
12986
|
+
defaultValues: {
|
|
12987
|
+
email: order.email ?? ""
|
|
12988
|
+
},
|
|
12989
|
+
resolver: zod.zodResolver(schema)
|
|
12990
|
+
});
|
|
12991
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12992
|
+
const { handleSuccess } = useRouteModal();
|
|
12993
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12994
|
+
await mutateAsync(
|
|
12995
|
+
{ email: data.email },
|
|
12996
|
+
{
|
|
12997
|
+
onSuccess: () => {
|
|
12998
|
+
handleSuccess();
|
|
12999
|
+
},
|
|
13000
|
+
onError: (error) => {
|
|
13001
|
+
ui.toast.error(error.message);
|
|
13002
|
+
}
|
|
13003
|
+
}
|
|
13004
|
+
);
|
|
13005
|
+
});
|
|
13006
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
13007
|
+
KeyboundForm,
|
|
13008
|
+
{
|
|
13009
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13010
|
+
onSubmit,
|
|
13011
|
+
children: [
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
Form$2.Field,
|
|
13014
|
+
{
|
|
13015
|
+
control: form.control,
|
|
13016
|
+
name: "email",
|
|
13017
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13018
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
13019
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13021
|
+
] })
|
|
13022
|
+
}
|
|
13023
|
+
) }),
|
|
13024
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13025
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13027
|
+
] }) })
|
|
13028
|
+
]
|
|
13029
|
+
}
|
|
13030
|
+
) });
|
|
13031
|
+
};
|
|
13032
|
+
const schema = objectType({
|
|
13033
|
+
email: stringType().email()
|
|
13034
|
+
});
|
|
13035
13035
|
const widgetModule = { widgets: [] };
|
|
13036
13036
|
const routeModule = {
|
|
13037
13037
|
routes: [
|
|
@@ -13056,10 +13056,6 @@ const routeModule = {
|
|
|
13056
13056
|
Component: BillingAddress,
|
|
13057
13057
|
path: "/draft-orders/:id/billing-address"
|
|
13058
13058
|
},
|
|
13059
|
-
{
|
|
13060
|
-
Component: Email,
|
|
13061
|
-
path: "/draft-orders/:id/email"
|
|
13062
|
-
},
|
|
13063
13059
|
{
|
|
13064
13060
|
Component: CustomItems,
|
|
13065
13061
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13076,14 +13072,14 @@ const routeModule = {
|
|
|
13076
13072
|
Component: Promotions,
|
|
13077
13073
|
path: "/draft-orders/:id/promotions"
|
|
13078
13074
|
},
|
|
13079
|
-
{
|
|
13080
|
-
Component: SalesChannel,
|
|
13081
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13082
|
-
},
|
|
13083
13075
|
{
|
|
13084
13076
|
Component: Shipping,
|
|
13085
13077
|
path: "/draft-orders/:id/shipping"
|
|
13086
13078
|
},
|
|
13079
|
+
{
|
|
13080
|
+
Component: SalesChannel,
|
|
13081
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13082
|
+
},
|
|
13087
13083
|
{
|
|
13088
13084
|
Component: ShippingAddress,
|
|
13089
13085
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13091,6 +13087,10 @@ const routeModule = {
|
|
|
13091
13087
|
{
|
|
13092
13088
|
Component: TransferOwnership,
|
|
13093
13089
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13090
|
+
},
|
|
13091
|
+
{
|
|
13092
|
+
Component: Email,
|
|
13093
|
+
path: "/draft-orders/:id/email"
|
|
13094
13094
|
}
|
|
13095
13095
|
]
|
|
13096
13096
|
}
|
|
@@ -9744,74 +9744,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9744
9744
|
) });
|
|
9745
9745
|
};
|
|
9746
9746
|
const schema$5 = addressSchema;
|
|
9747
|
-
const Email = () => {
|
|
9748
|
-
const { id } = useParams();
|
|
9749
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9750
|
-
fields: "+email"
|
|
9751
|
-
});
|
|
9752
|
-
if (isError) {
|
|
9753
|
-
throw error;
|
|
9754
|
-
}
|
|
9755
|
-
const isReady = !isPending && !!order;
|
|
9756
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9757
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9758
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9759
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9760
|
-
] }),
|
|
9761
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9762
|
-
] });
|
|
9763
|
-
};
|
|
9764
|
-
const EmailForm = ({ order }) => {
|
|
9765
|
-
const form = useForm({
|
|
9766
|
-
defaultValues: {
|
|
9767
|
-
email: order.email ?? ""
|
|
9768
|
-
},
|
|
9769
|
-
resolver: zodResolver(schema$4)
|
|
9770
|
-
});
|
|
9771
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9772
|
-
const { handleSuccess } = useRouteModal();
|
|
9773
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9774
|
-
await mutateAsync(
|
|
9775
|
-
{ email: data.email },
|
|
9776
|
-
{
|
|
9777
|
-
onSuccess: () => {
|
|
9778
|
-
handleSuccess();
|
|
9779
|
-
},
|
|
9780
|
-
onError: (error) => {
|
|
9781
|
-
toast.error(error.message);
|
|
9782
|
-
}
|
|
9783
|
-
}
|
|
9784
|
-
);
|
|
9785
|
-
});
|
|
9786
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9787
|
-
KeyboundForm,
|
|
9788
|
-
{
|
|
9789
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9790
|
-
onSubmit,
|
|
9791
|
-
children: [
|
|
9792
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9793
|
-
Form$2.Field,
|
|
9794
|
-
{
|
|
9795
|
-
control: form.control,
|
|
9796
|
-
name: "email",
|
|
9797
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9798
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9799
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9800
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9801
|
-
] })
|
|
9802
|
-
}
|
|
9803
|
-
) }),
|
|
9804
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9805
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9806
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9807
|
-
] }) })
|
|
9808
|
-
]
|
|
9809
|
-
}
|
|
9810
|
-
) });
|
|
9811
|
-
};
|
|
9812
|
-
const schema$4 = objectType({
|
|
9813
|
-
email: stringType().email()
|
|
9814
|
-
});
|
|
9815
9747
|
const CustomItems = () => {
|
|
9816
9748
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9817
9749
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9820,7 +9752,7 @@ const CustomItems = () => {
|
|
|
9820
9752
|
};
|
|
9821
9753
|
const CustomItemsForm = () => {
|
|
9822
9754
|
const form = useForm({
|
|
9823
|
-
resolver: zodResolver(schema$
|
|
9755
|
+
resolver: zodResolver(schema$4)
|
|
9824
9756
|
});
|
|
9825
9757
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9826
9758
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9830,7 +9762,7 @@ const CustomItemsForm = () => {
|
|
|
9830
9762
|
] }) })
|
|
9831
9763
|
] }) });
|
|
9832
9764
|
};
|
|
9833
|
-
const schema$
|
|
9765
|
+
const schema$4 = objectType({
|
|
9834
9766
|
email: stringType().email()
|
|
9835
9767
|
});
|
|
9836
9768
|
const NumberInput = forwardRef(
|
|
@@ -11434,112 +11366,6 @@ function getPromotionCodes(items, shippingMethods) {
|
|
|
11434
11366
|
}
|
|
11435
11367
|
return Array.from(codes);
|
|
11436
11368
|
}
|
|
11437
|
-
const SalesChannel = () => {
|
|
11438
|
-
const { id } = useParams();
|
|
11439
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11440
|
-
id,
|
|
11441
|
-
{
|
|
11442
|
-
fields: "+sales_channel_id"
|
|
11443
|
-
},
|
|
11444
|
-
{
|
|
11445
|
-
enabled: !!id
|
|
11446
|
-
}
|
|
11447
|
-
);
|
|
11448
|
-
if (isError) {
|
|
11449
|
-
throw error;
|
|
11450
|
-
}
|
|
11451
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11452
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11453
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11454
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11455
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11456
|
-
] }),
|
|
11457
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11458
|
-
] });
|
|
11459
|
-
};
|
|
11460
|
-
const SalesChannelForm = ({ order }) => {
|
|
11461
|
-
const form = useForm({
|
|
11462
|
-
defaultValues: {
|
|
11463
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11464
|
-
},
|
|
11465
|
-
resolver: zodResolver(schema$2)
|
|
11466
|
-
});
|
|
11467
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11468
|
-
const { handleSuccess } = useRouteModal();
|
|
11469
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11470
|
-
await mutateAsync(
|
|
11471
|
-
{
|
|
11472
|
-
sales_channel_id: data.sales_channel_id
|
|
11473
|
-
},
|
|
11474
|
-
{
|
|
11475
|
-
onSuccess: () => {
|
|
11476
|
-
toast.success("Sales channel updated");
|
|
11477
|
-
handleSuccess();
|
|
11478
|
-
},
|
|
11479
|
-
onError: (error) => {
|
|
11480
|
-
toast.error(error.message);
|
|
11481
|
-
}
|
|
11482
|
-
}
|
|
11483
|
-
);
|
|
11484
|
-
});
|
|
11485
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11486
|
-
KeyboundForm,
|
|
11487
|
-
{
|
|
11488
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11489
|
-
onSubmit,
|
|
11490
|
-
children: [
|
|
11491
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11492
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11493
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11494
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11495
|
-
] }) })
|
|
11496
|
-
]
|
|
11497
|
-
}
|
|
11498
|
-
) });
|
|
11499
|
-
};
|
|
11500
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11501
|
-
const salesChannels = useComboboxData({
|
|
11502
|
-
queryFn: async (params) => {
|
|
11503
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11504
|
-
},
|
|
11505
|
-
queryKey: ["sales-channels"],
|
|
11506
|
-
getOptions: (data) => {
|
|
11507
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11508
|
-
label: salesChannel.name,
|
|
11509
|
-
value: salesChannel.id
|
|
11510
|
-
}));
|
|
11511
|
-
},
|
|
11512
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11513
|
-
});
|
|
11514
|
-
return /* @__PURE__ */ jsx(
|
|
11515
|
-
Form$2.Field,
|
|
11516
|
-
{
|
|
11517
|
-
control,
|
|
11518
|
-
name: "sales_channel_id",
|
|
11519
|
-
render: ({ field }) => {
|
|
11520
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11521
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11522
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11523
|
-
Combobox,
|
|
11524
|
-
{
|
|
11525
|
-
options: salesChannels.options,
|
|
11526
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11527
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11528
|
-
searchValue: salesChannels.searchValue,
|
|
11529
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11530
|
-
placeholder: "Select sales channel",
|
|
11531
|
-
...field
|
|
11532
|
-
}
|
|
11533
|
-
) }),
|
|
11534
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11535
|
-
] });
|
|
11536
|
-
}
|
|
11537
|
-
}
|
|
11538
|
-
);
|
|
11539
|
-
};
|
|
11540
|
-
const schema$2 = objectType({
|
|
11541
|
-
sales_channel_id: stringType().min(1)
|
|
11542
|
-
});
|
|
11543
11369
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11544
11370
|
const Shipping = () => {
|
|
11545
11371
|
var _a;
|
|
@@ -12347,6 +12173,112 @@ const CustomAmountField = ({
|
|
|
12347
12173
|
}
|
|
12348
12174
|
);
|
|
12349
12175
|
};
|
|
12176
|
+
const SalesChannel = () => {
|
|
12177
|
+
const { id } = useParams();
|
|
12178
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12179
|
+
id,
|
|
12180
|
+
{
|
|
12181
|
+
fields: "+sales_channel_id"
|
|
12182
|
+
},
|
|
12183
|
+
{
|
|
12184
|
+
enabled: !!id
|
|
12185
|
+
}
|
|
12186
|
+
);
|
|
12187
|
+
if (isError) {
|
|
12188
|
+
throw error;
|
|
12189
|
+
}
|
|
12190
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12191
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12192
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12193
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12194
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12195
|
+
] }),
|
|
12196
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12197
|
+
] });
|
|
12198
|
+
};
|
|
12199
|
+
const SalesChannelForm = ({ order }) => {
|
|
12200
|
+
const form = useForm({
|
|
12201
|
+
defaultValues: {
|
|
12202
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12203
|
+
},
|
|
12204
|
+
resolver: zodResolver(schema$3)
|
|
12205
|
+
});
|
|
12206
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12207
|
+
const { handleSuccess } = useRouteModal();
|
|
12208
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12209
|
+
await mutateAsync(
|
|
12210
|
+
{
|
|
12211
|
+
sales_channel_id: data.sales_channel_id
|
|
12212
|
+
},
|
|
12213
|
+
{
|
|
12214
|
+
onSuccess: () => {
|
|
12215
|
+
toast.success("Sales channel updated");
|
|
12216
|
+
handleSuccess();
|
|
12217
|
+
},
|
|
12218
|
+
onError: (error) => {
|
|
12219
|
+
toast.error(error.message);
|
|
12220
|
+
}
|
|
12221
|
+
}
|
|
12222
|
+
);
|
|
12223
|
+
});
|
|
12224
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12225
|
+
KeyboundForm,
|
|
12226
|
+
{
|
|
12227
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12228
|
+
onSubmit,
|
|
12229
|
+
children: [
|
|
12230
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12231
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12232
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12233
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12234
|
+
] }) })
|
|
12235
|
+
]
|
|
12236
|
+
}
|
|
12237
|
+
) });
|
|
12238
|
+
};
|
|
12239
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12240
|
+
const salesChannels = useComboboxData({
|
|
12241
|
+
queryFn: async (params) => {
|
|
12242
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12243
|
+
},
|
|
12244
|
+
queryKey: ["sales-channels"],
|
|
12245
|
+
getOptions: (data) => {
|
|
12246
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12247
|
+
label: salesChannel.name,
|
|
12248
|
+
value: salesChannel.id
|
|
12249
|
+
}));
|
|
12250
|
+
},
|
|
12251
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12252
|
+
});
|
|
12253
|
+
return /* @__PURE__ */ jsx(
|
|
12254
|
+
Form$2.Field,
|
|
12255
|
+
{
|
|
12256
|
+
control,
|
|
12257
|
+
name: "sales_channel_id",
|
|
12258
|
+
render: ({ field }) => {
|
|
12259
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12260
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12261
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12262
|
+
Combobox,
|
|
12263
|
+
{
|
|
12264
|
+
options: salesChannels.options,
|
|
12265
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12266
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12267
|
+
searchValue: salesChannels.searchValue,
|
|
12268
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12269
|
+
placeholder: "Select sales channel",
|
|
12270
|
+
...field
|
|
12271
|
+
}
|
|
12272
|
+
) }),
|
|
12273
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12274
|
+
] });
|
|
12275
|
+
}
|
|
12276
|
+
}
|
|
12277
|
+
);
|
|
12278
|
+
};
|
|
12279
|
+
const schema$3 = objectType({
|
|
12280
|
+
sales_channel_id: stringType().min(1)
|
|
12281
|
+
});
|
|
12350
12282
|
const ShippingAddress = () => {
|
|
12351
12283
|
const { id } = useParams();
|
|
12352
12284
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12379,7 +12311,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12379
12311
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12380
12312
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12381
12313
|
},
|
|
12382
|
-
resolver: zodResolver(schema$
|
|
12314
|
+
resolver: zodResolver(schema$2)
|
|
12383
12315
|
});
|
|
12384
12316
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12385
12317
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12549,7 +12481,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12549
12481
|
}
|
|
12550
12482
|
) });
|
|
12551
12483
|
};
|
|
12552
|
-
const schema$
|
|
12484
|
+
const schema$2 = addressSchema;
|
|
12553
12485
|
const TransferOwnership = () => {
|
|
12554
12486
|
const { id } = useParams();
|
|
12555
12487
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12573,7 +12505,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12573
12505
|
defaultValues: {
|
|
12574
12506
|
customer_id: order.customer_id || ""
|
|
12575
12507
|
},
|
|
12576
|
-
resolver: zodResolver(schema)
|
|
12508
|
+
resolver: zodResolver(schema$1)
|
|
12577
12509
|
});
|
|
12578
12510
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12579
12511
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13023,9 +12955,77 @@ const Illustration = () => {
|
|
|
13023
12955
|
}
|
|
13024
12956
|
);
|
|
13025
12957
|
};
|
|
13026
|
-
const schema = objectType({
|
|
12958
|
+
const schema$1 = objectType({
|
|
13027
12959
|
customer_id: stringType().min(1)
|
|
13028
12960
|
});
|
|
12961
|
+
const Email = () => {
|
|
12962
|
+
const { id } = useParams();
|
|
12963
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12964
|
+
fields: "+email"
|
|
12965
|
+
});
|
|
12966
|
+
if (isError) {
|
|
12967
|
+
throw error;
|
|
12968
|
+
}
|
|
12969
|
+
const isReady = !isPending && !!order;
|
|
12970
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12971
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12972
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
12973
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12974
|
+
] }),
|
|
12975
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
12976
|
+
] });
|
|
12977
|
+
};
|
|
12978
|
+
const EmailForm = ({ order }) => {
|
|
12979
|
+
const form = useForm({
|
|
12980
|
+
defaultValues: {
|
|
12981
|
+
email: order.email ?? ""
|
|
12982
|
+
},
|
|
12983
|
+
resolver: zodResolver(schema)
|
|
12984
|
+
});
|
|
12985
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12986
|
+
const { handleSuccess } = useRouteModal();
|
|
12987
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12988
|
+
await mutateAsync(
|
|
12989
|
+
{ email: data.email },
|
|
12990
|
+
{
|
|
12991
|
+
onSuccess: () => {
|
|
12992
|
+
handleSuccess();
|
|
12993
|
+
},
|
|
12994
|
+
onError: (error) => {
|
|
12995
|
+
toast.error(error.message);
|
|
12996
|
+
}
|
|
12997
|
+
}
|
|
12998
|
+
);
|
|
12999
|
+
});
|
|
13000
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
13001
|
+
KeyboundForm,
|
|
13002
|
+
{
|
|
13003
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13004
|
+
onSubmit,
|
|
13005
|
+
children: [
|
|
13006
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
13007
|
+
Form$2.Field,
|
|
13008
|
+
{
|
|
13009
|
+
control: form.control,
|
|
13010
|
+
name: "email",
|
|
13011
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
13013
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
+
] })
|
|
13016
|
+
}
|
|
13017
|
+
) }),
|
|
13018
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13019
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13020
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13021
|
+
] }) })
|
|
13022
|
+
]
|
|
13023
|
+
}
|
|
13024
|
+
) });
|
|
13025
|
+
};
|
|
13026
|
+
const schema = objectType({
|
|
13027
|
+
email: stringType().email()
|
|
13028
|
+
});
|
|
13029
13029
|
const widgetModule = { widgets: [] };
|
|
13030
13030
|
const routeModule = {
|
|
13031
13031
|
routes: [
|
|
@@ -13050,10 +13050,6 @@ const routeModule = {
|
|
|
13050
13050
|
Component: BillingAddress,
|
|
13051
13051
|
path: "/draft-orders/:id/billing-address"
|
|
13052
13052
|
},
|
|
13053
|
-
{
|
|
13054
|
-
Component: Email,
|
|
13055
|
-
path: "/draft-orders/:id/email"
|
|
13056
|
-
},
|
|
13057
13053
|
{
|
|
13058
13054
|
Component: CustomItems,
|
|
13059
13055
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13070,14 +13066,14 @@ const routeModule = {
|
|
|
13070
13066
|
Component: Promotions,
|
|
13071
13067
|
path: "/draft-orders/:id/promotions"
|
|
13072
13068
|
},
|
|
13073
|
-
{
|
|
13074
|
-
Component: SalesChannel,
|
|
13075
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13076
|
-
},
|
|
13077
13069
|
{
|
|
13078
13070
|
Component: Shipping,
|
|
13079
13071
|
path: "/draft-orders/:id/shipping"
|
|
13080
13072
|
},
|
|
13073
|
+
{
|
|
13074
|
+
Component: SalesChannel,
|
|
13075
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13076
|
+
},
|
|
13081
13077
|
{
|
|
13082
13078
|
Component: ShippingAddress,
|
|
13083
13079
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13085,6 +13081,10 @@ const routeModule = {
|
|
|
13085
13081
|
{
|
|
13086
13082
|
Component: TransferOwnership,
|
|
13087
13083
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13084
|
+
},
|
|
13085
|
+
{
|
|
13086
|
+
Component: Email,
|
|
13087
|
+
path: "/draft-orders/:id/email"
|
|
13088
13088
|
}
|
|
13089
13089
|
]
|
|
13090
13090
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.10.2-preview-
|
|
3
|
+
"version": "2.10.2-preview-20250904090151",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@hookform/resolvers": "3.4.2",
|
|
39
|
-
"@medusajs/js-sdk": "2.10.2-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.10.2-preview-20250904090151",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
41
41
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
42
42
|
"date-fns": "^3.6.0",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"react-hook-form": "7.49.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@medusajs/admin-sdk": "2.10.2-preview-
|
|
49
|
-
"@medusajs/cli": "2.10.2-preview-
|
|
50
|
-
"@medusajs/framework": "2.10.2-preview-
|
|
51
|
-
"@medusajs/icons": "2.10.2-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.10.2-preview-
|
|
53
|
-
"@medusajs/types": "2.10.2-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.22-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.10.2-preview-
|
|
48
|
+
"@medusajs/admin-sdk": "2.10.2-preview-20250904090151",
|
|
49
|
+
"@medusajs/cli": "2.10.2-preview-20250904090151",
|
|
50
|
+
"@medusajs/framework": "2.10.2-preview-20250904090151",
|
|
51
|
+
"@medusajs/icons": "2.10.2-preview-20250904090151",
|
|
52
|
+
"@medusajs/test-utils": "2.10.2-preview-20250904090151",
|
|
53
|
+
"@medusajs/types": "2.10.2-preview-20250904090151",
|
|
54
|
+
"@medusajs/ui": "4.0.22-preview-20250904090151",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.2-preview-20250904090151",
|
|
56
56
|
"@mikro-orm/cli": "6.4.3",
|
|
57
57
|
"@mikro-orm/core": "6.4.3",
|
|
58
58
|
"@mikro-orm/knex": "6.4.3",
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"yalc": "^1.0.0-pre.53"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@medusajs/admin-sdk": "2.10.2-preview-
|
|
80
|
-
"@medusajs/cli": "2.10.2-preview-
|
|
81
|
-
"@medusajs/framework": "2.10.2-preview-
|
|
82
|
-
"@medusajs/icons": "2.10.2-preview-
|
|
83
|
-
"@medusajs/test-utils": "2.10.2-preview-
|
|
84
|
-
"@medusajs/ui": "4.0.22-preview-
|
|
79
|
+
"@medusajs/admin-sdk": "2.10.2-preview-20250904090151",
|
|
80
|
+
"@medusajs/cli": "2.10.2-preview-20250904090151",
|
|
81
|
+
"@medusajs/framework": "2.10.2-preview-20250904090151",
|
|
82
|
+
"@medusajs/icons": "2.10.2-preview-20250904090151",
|
|
83
|
+
"@medusajs/test-utils": "2.10.2-preview-20250904090151",
|
|
84
|
+
"@medusajs/ui": "4.0.22-preview-20250904090151",
|
|
85
85
|
"@mikro-orm/cli": "6.4.3",
|
|
86
86
|
"@mikro-orm/core": "6.4.3",
|
|
87
87
|
"@mikro-orm/knex": "6.4.3",
|