@medusajs/draft-order 2.10.4-preview-20250929060158 → 2.10.4-preview-20250929120206
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 +201 -201
- package/.medusa/server/src/admin/index.mjs +201 -201
- package/package.json +16 -16
|
@@ -9573,27 +9573,6 @@ const ID = () => {
|
|
|
9573
9573
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9574
9574
|
] });
|
|
9575
9575
|
};
|
|
9576
|
-
const CustomItems = () => {
|
|
9577
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9578
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9579
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9580
|
-
] });
|
|
9581
|
-
};
|
|
9582
|
-
const CustomItemsForm = () => {
|
|
9583
|
-
const form = reactHookForm.useForm({
|
|
9584
|
-
resolver: zod.zodResolver(schema$5)
|
|
9585
|
-
});
|
|
9586
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9587
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9588
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9589
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9590
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9591
|
-
] }) })
|
|
9592
|
-
] }) });
|
|
9593
|
-
};
|
|
9594
|
-
const schema$5 = objectType({
|
|
9595
|
-
email: stringType().email()
|
|
9596
|
-
});
|
|
9597
9576
|
const BillingAddress = () => {
|
|
9598
9577
|
const { id } = reactRouterDom.useParams();
|
|
9599
9578
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9626,7 +9605,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9626
9605
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9627
9606
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9628
9607
|
},
|
|
9629
|
-
resolver: zod.zodResolver(schema$
|
|
9608
|
+
resolver: zod.zodResolver(schema$5)
|
|
9630
9609
|
});
|
|
9631
9610
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9632
9611
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9783,73 +9762,26 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9783
9762
|
}
|
|
9784
9763
|
) });
|
|
9785
9764
|
};
|
|
9786
|
-
const schema$
|
|
9787
|
-
const
|
|
9788
|
-
const { id } = reactRouterDom.useParams();
|
|
9789
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9790
|
-
fields: "+email"
|
|
9791
|
-
});
|
|
9792
|
-
if (isError) {
|
|
9793
|
-
throw error;
|
|
9794
|
-
}
|
|
9795
|
-
const isReady = !isPending && !!order;
|
|
9765
|
+
const schema$5 = addressSchema;
|
|
9766
|
+
const CustomItems = () => {
|
|
9796
9767
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9797
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9798
|
-
|
|
9799
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9800
|
-
] }),
|
|
9801
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9768
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9769
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9802
9770
|
] });
|
|
9803
9771
|
};
|
|
9804
|
-
const
|
|
9772
|
+
const CustomItemsForm = () => {
|
|
9805
9773
|
const form = reactHookForm.useForm({
|
|
9806
|
-
|
|
9807
|
-
email: order.email ?? ""
|
|
9808
|
-
},
|
|
9809
|
-
resolver: zod.zodResolver(schema$3)
|
|
9810
|
-
});
|
|
9811
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9812
|
-
const { handleSuccess } = useRouteModal();
|
|
9813
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9814
|
-
await mutateAsync(
|
|
9815
|
-
{ email: data.email },
|
|
9816
|
-
{
|
|
9817
|
-
onSuccess: () => {
|
|
9818
|
-
handleSuccess();
|
|
9819
|
-
},
|
|
9820
|
-
onError: (error) => {
|
|
9821
|
-
ui.toast.error(error.message);
|
|
9822
|
-
}
|
|
9823
|
-
}
|
|
9824
|
-
);
|
|
9774
|
+
resolver: zod.zodResolver(schema$4)
|
|
9825
9775
|
});
|
|
9826
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9827
|
-
|
|
9828
|
-
{
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
Form$2.Field,
|
|
9834
|
-
{
|
|
9835
|
-
control: form.control,
|
|
9836
|
-
name: "email",
|
|
9837
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9838
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9839
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9840
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9841
|
-
] })
|
|
9842
|
-
}
|
|
9843
|
-
) }),
|
|
9844
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9845
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9846
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9847
|
-
] }) })
|
|
9848
|
-
]
|
|
9849
|
-
}
|
|
9850
|
-
) });
|
|
9776
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9777
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9778
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9779
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9780
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9781
|
+
] }) })
|
|
9782
|
+
] }) });
|
|
9851
9783
|
};
|
|
9852
|
-
const schema$
|
|
9784
|
+
const schema$4 = objectType({
|
|
9853
9785
|
email: stringType().email()
|
|
9854
9786
|
});
|
|
9855
9787
|
const NumberInput = React.forwardRef(
|
|
@@ -11176,6 +11108,74 @@ function getHasUneditableRows(metadata) {
|
|
|
11176
11108
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11177
11109
|
);
|
|
11178
11110
|
}
|
|
11111
|
+
const Email = () => {
|
|
11112
|
+
const { id } = reactRouterDom.useParams();
|
|
11113
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11114
|
+
fields: "+email"
|
|
11115
|
+
});
|
|
11116
|
+
if (isError) {
|
|
11117
|
+
throw error;
|
|
11118
|
+
}
|
|
11119
|
+
const isReady = !isPending && !!order;
|
|
11120
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11121
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11122
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
11123
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11124
|
+
] }),
|
|
11125
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
11126
|
+
] });
|
|
11127
|
+
};
|
|
11128
|
+
const EmailForm = ({ order }) => {
|
|
11129
|
+
const form = reactHookForm.useForm({
|
|
11130
|
+
defaultValues: {
|
|
11131
|
+
email: order.email ?? ""
|
|
11132
|
+
},
|
|
11133
|
+
resolver: zod.zodResolver(schema$3)
|
|
11134
|
+
});
|
|
11135
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11136
|
+
const { handleSuccess } = useRouteModal();
|
|
11137
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11138
|
+
await mutateAsync(
|
|
11139
|
+
{ email: data.email },
|
|
11140
|
+
{
|
|
11141
|
+
onSuccess: () => {
|
|
11142
|
+
handleSuccess();
|
|
11143
|
+
},
|
|
11144
|
+
onError: (error) => {
|
|
11145
|
+
ui.toast.error(error.message);
|
|
11146
|
+
}
|
|
11147
|
+
}
|
|
11148
|
+
);
|
|
11149
|
+
});
|
|
11150
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11151
|
+
KeyboundForm,
|
|
11152
|
+
{
|
|
11153
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11154
|
+
onSubmit,
|
|
11155
|
+
children: [
|
|
11156
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11157
|
+
Form$2.Field,
|
|
11158
|
+
{
|
|
11159
|
+
control: form.control,
|
|
11160
|
+
name: "email",
|
|
11161
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11162
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
11163
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11164
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11165
|
+
] })
|
|
11166
|
+
}
|
|
11167
|
+
) }),
|
|
11168
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11169
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11170
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11171
|
+
] }) })
|
|
11172
|
+
]
|
|
11173
|
+
}
|
|
11174
|
+
) });
|
|
11175
|
+
};
|
|
11176
|
+
const schema$3 = objectType({
|
|
11177
|
+
email: stringType().email()
|
|
11178
|
+
});
|
|
11179
11179
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
11180
11180
|
const promotionsQueryKeys = {
|
|
11181
11181
|
list: (query2) => [
|
|
@@ -11453,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11453
11453
|
}
|
|
11454
11454
|
return Array.from(promotionIds);
|
|
11455
11455
|
}
|
|
11456
|
-
const SalesChannel = () => {
|
|
11457
|
-
const { id } = reactRouterDom.useParams();
|
|
11458
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11459
|
-
id,
|
|
11460
|
-
{
|
|
11461
|
-
fields: "+sales_channel_id"
|
|
11462
|
-
},
|
|
11463
|
-
{
|
|
11464
|
-
enabled: !!id
|
|
11465
|
-
}
|
|
11466
|
-
);
|
|
11467
|
-
if (isError) {
|
|
11468
|
-
throw error;
|
|
11469
|
-
}
|
|
11470
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11471
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11472
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11473
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11474
|
-
/* @__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" }) })
|
|
11475
|
-
] }),
|
|
11476
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11477
|
-
] });
|
|
11478
|
-
};
|
|
11479
|
-
const SalesChannelForm = ({ order }) => {
|
|
11480
|
-
const form = reactHookForm.useForm({
|
|
11481
|
-
defaultValues: {
|
|
11482
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11483
|
-
},
|
|
11484
|
-
resolver: zod.zodResolver(schema$2)
|
|
11485
|
-
});
|
|
11486
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11487
|
-
const { handleSuccess } = useRouteModal();
|
|
11488
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11489
|
-
await mutateAsync(
|
|
11490
|
-
{
|
|
11491
|
-
sales_channel_id: data.sales_channel_id
|
|
11492
|
-
},
|
|
11493
|
-
{
|
|
11494
|
-
onSuccess: () => {
|
|
11495
|
-
ui.toast.success("Sales channel updated");
|
|
11496
|
-
handleSuccess();
|
|
11497
|
-
},
|
|
11498
|
-
onError: (error) => {
|
|
11499
|
-
ui.toast.error(error.message);
|
|
11500
|
-
}
|
|
11501
|
-
}
|
|
11502
|
-
);
|
|
11503
|
-
});
|
|
11504
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11505
|
-
KeyboundForm,
|
|
11506
|
-
{
|
|
11507
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11508
|
-
onSubmit,
|
|
11509
|
-
children: [
|
|
11510
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11511
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11512
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11513
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11514
|
-
] }) })
|
|
11515
|
-
]
|
|
11516
|
-
}
|
|
11517
|
-
) });
|
|
11518
|
-
};
|
|
11519
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11520
|
-
const salesChannels = useComboboxData({
|
|
11521
|
-
queryFn: async (params) => {
|
|
11522
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11523
|
-
},
|
|
11524
|
-
queryKey: ["sales-channels"],
|
|
11525
|
-
getOptions: (data) => {
|
|
11526
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11527
|
-
label: salesChannel.name,
|
|
11528
|
-
value: salesChannel.id
|
|
11529
|
-
}));
|
|
11530
|
-
},
|
|
11531
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11532
|
-
});
|
|
11533
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11534
|
-
Form$2.Field,
|
|
11535
|
-
{
|
|
11536
|
-
control,
|
|
11537
|
-
name: "sales_channel_id",
|
|
11538
|
-
render: ({ field }) => {
|
|
11539
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11540
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11541
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11542
|
-
Combobox,
|
|
11543
|
-
{
|
|
11544
|
-
options: salesChannels.options,
|
|
11545
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11546
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11547
|
-
searchValue: salesChannels.searchValue,
|
|
11548
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11549
|
-
placeholder: "Select sales channel",
|
|
11550
|
-
...field
|
|
11551
|
-
}
|
|
11552
|
-
) }),
|
|
11553
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11554
|
-
] });
|
|
11555
|
-
}
|
|
11556
|
-
}
|
|
11557
|
-
);
|
|
11558
|
-
};
|
|
11559
|
-
const schema$2 = objectType({
|
|
11560
|
-
sales_channel_id: stringType().min(1)
|
|
11561
|
-
});
|
|
11562
11456
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11563
11457
|
const Shipping = () => {
|
|
11564
11458
|
var _a;
|
|
@@ -12389,7 +12283,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12389
12283
|
defaultValues: {
|
|
12390
12284
|
customer_id: order.customer_id || ""
|
|
12391
12285
|
},
|
|
12392
|
-
resolver: zod.zodResolver(schema$
|
|
12286
|
+
resolver: zod.zodResolver(schema$2)
|
|
12393
12287
|
});
|
|
12394
12288
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12395
12289
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12839,9 +12733,115 @@ const Illustration = () => {
|
|
|
12839
12733
|
}
|
|
12840
12734
|
);
|
|
12841
12735
|
};
|
|
12842
|
-
const schema$
|
|
12736
|
+
const schema$2 = objectType({
|
|
12843
12737
|
customer_id: stringType().min(1)
|
|
12844
12738
|
});
|
|
12739
|
+
const SalesChannel = () => {
|
|
12740
|
+
const { id } = reactRouterDom.useParams();
|
|
12741
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12742
|
+
id,
|
|
12743
|
+
{
|
|
12744
|
+
fields: "+sales_channel_id"
|
|
12745
|
+
},
|
|
12746
|
+
{
|
|
12747
|
+
enabled: !!id
|
|
12748
|
+
}
|
|
12749
|
+
);
|
|
12750
|
+
if (isError) {
|
|
12751
|
+
throw error;
|
|
12752
|
+
}
|
|
12753
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12754
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12755
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12756
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12757
|
+
/* @__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" }) })
|
|
12758
|
+
] }),
|
|
12759
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12760
|
+
] });
|
|
12761
|
+
};
|
|
12762
|
+
const SalesChannelForm = ({ order }) => {
|
|
12763
|
+
const form = reactHookForm.useForm({
|
|
12764
|
+
defaultValues: {
|
|
12765
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12766
|
+
},
|
|
12767
|
+
resolver: zod.zodResolver(schema$1)
|
|
12768
|
+
});
|
|
12769
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12770
|
+
const { handleSuccess } = useRouteModal();
|
|
12771
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12772
|
+
await mutateAsync(
|
|
12773
|
+
{
|
|
12774
|
+
sales_channel_id: data.sales_channel_id
|
|
12775
|
+
},
|
|
12776
|
+
{
|
|
12777
|
+
onSuccess: () => {
|
|
12778
|
+
ui.toast.success("Sales channel updated");
|
|
12779
|
+
handleSuccess();
|
|
12780
|
+
},
|
|
12781
|
+
onError: (error) => {
|
|
12782
|
+
ui.toast.error(error.message);
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
);
|
|
12786
|
+
});
|
|
12787
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12788
|
+
KeyboundForm,
|
|
12789
|
+
{
|
|
12790
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12791
|
+
onSubmit,
|
|
12792
|
+
children: [
|
|
12793
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12794
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12795
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12796
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12797
|
+
] }) })
|
|
12798
|
+
]
|
|
12799
|
+
}
|
|
12800
|
+
) });
|
|
12801
|
+
};
|
|
12802
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12803
|
+
const salesChannels = useComboboxData({
|
|
12804
|
+
queryFn: async (params) => {
|
|
12805
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12806
|
+
},
|
|
12807
|
+
queryKey: ["sales-channels"],
|
|
12808
|
+
getOptions: (data) => {
|
|
12809
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12810
|
+
label: salesChannel.name,
|
|
12811
|
+
value: salesChannel.id
|
|
12812
|
+
}));
|
|
12813
|
+
},
|
|
12814
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12815
|
+
});
|
|
12816
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12817
|
+
Form$2.Field,
|
|
12818
|
+
{
|
|
12819
|
+
control,
|
|
12820
|
+
name: "sales_channel_id",
|
|
12821
|
+
render: ({ field }) => {
|
|
12822
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12823
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12824
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12825
|
+
Combobox,
|
|
12826
|
+
{
|
|
12827
|
+
options: salesChannels.options,
|
|
12828
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12829
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12830
|
+
searchValue: salesChannels.searchValue,
|
|
12831
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12832
|
+
placeholder: "Select sales channel",
|
|
12833
|
+
...field
|
|
12834
|
+
}
|
|
12835
|
+
) }),
|
|
12836
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12837
|
+
] });
|
|
12838
|
+
}
|
|
12839
|
+
}
|
|
12840
|
+
);
|
|
12841
|
+
};
|
|
12842
|
+
const schema$1 = objectType({
|
|
12843
|
+
sales_channel_id: stringType().min(1)
|
|
12844
|
+
});
|
|
12845
12845
|
const ShippingAddress = () => {
|
|
12846
12846
|
const { id } = reactRouterDom.useParams();
|
|
12847
12847
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13065,17 +13065,13 @@ const routeModule = {
|
|
|
13065
13065
|
handle,
|
|
13066
13066
|
loader,
|
|
13067
13067
|
children: [
|
|
13068
|
-
{
|
|
13069
|
-
Component: CustomItems,
|
|
13070
|
-
path: "/draft-orders/:id/custom-items"
|
|
13071
|
-
},
|
|
13072
13068
|
{
|
|
13073
13069
|
Component: BillingAddress,
|
|
13074
13070
|
path: "/draft-orders/:id/billing-address"
|
|
13075
13071
|
},
|
|
13076
13072
|
{
|
|
13077
|
-
Component:
|
|
13078
|
-
path: "/draft-orders/:id/
|
|
13073
|
+
Component: CustomItems,
|
|
13074
|
+
path: "/draft-orders/:id/custom-items"
|
|
13079
13075
|
},
|
|
13080
13076
|
{
|
|
13081
13077
|
Component: Items,
|
|
@@ -13086,12 +13082,12 @@ const routeModule = {
|
|
|
13086
13082
|
path: "/draft-orders/:id/metadata"
|
|
13087
13083
|
},
|
|
13088
13084
|
{
|
|
13089
|
-
Component:
|
|
13090
|
-
path: "/draft-orders/:id/
|
|
13085
|
+
Component: Email,
|
|
13086
|
+
path: "/draft-orders/:id/email"
|
|
13091
13087
|
},
|
|
13092
13088
|
{
|
|
13093
|
-
Component:
|
|
13094
|
-
path: "/draft-orders/:id/
|
|
13089
|
+
Component: Promotions,
|
|
13090
|
+
path: "/draft-orders/:id/promotions"
|
|
13095
13091
|
},
|
|
13096
13092
|
{
|
|
13097
13093
|
Component: Shipping,
|
|
@@ -13101,6 +13097,10 @@ const routeModule = {
|
|
|
13101
13097
|
Component: TransferOwnership,
|
|
13102
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
13099
|
},
|
|
13100
|
+
{
|
|
13101
|
+
Component: SalesChannel,
|
|
13102
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13103
|
+
},
|
|
13104
13104
|
{
|
|
13105
13105
|
Component: ShippingAddress,
|
|
13106
13106
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -9567,27 +9567,6 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
-
const CustomItems = () => {
|
|
9571
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9572
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9574
|
-
] });
|
|
9575
|
-
};
|
|
9576
|
-
const CustomItemsForm = () => {
|
|
9577
|
-
const form = useForm({
|
|
9578
|
-
resolver: zodResolver(schema$5)
|
|
9579
|
-
});
|
|
9580
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
-
] }) })
|
|
9586
|
-
] }) });
|
|
9587
|
-
};
|
|
9588
|
-
const schema$5 = objectType({
|
|
9589
|
-
email: stringType().email()
|
|
9590
|
-
});
|
|
9591
9570
|
const BillingAddress = () => {
|
|
9592
9571
|
const { id } = useParams();
|
|
9593
9572
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9620,7 +9599,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9620
9599
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9621
9600
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9622
9601
|
},
|
|
9623
|
-
resolver: zodResolver(schema$
|
|
9602
|
+
resolver: zodResolver(schema$5)
|
|
9624
9603
|
});
|
|
9625
9604
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9626
9605
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9777,73 +9756,26 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9777
9756
|
}
|
|
9778
9757
|
) });
|
|
9779
9758
|
};
|
|
9780
|
-
const schema$
|
|
9781
|
-
const
|
|
9782
|
-
const { id } = useParams();
|
|
9783
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9784
|
-
fields: "+email"
|
|
9785
|
-
});
|
|
9786
|
-
if (isError) {
|
|
9787
|
-
throw error;
|
|
9788
|
-
}
|
|
9789
|
-
const isReady = !isPending && !!order;
|
|
9759
|
+
const schema$5 = addressSchema;
|
|
9760
|
+
const CustomItems = () => {
|
|
9790
9761
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9791
|
-
/* @__PURE__ */
|
|
9792
|
-
|
|
9793
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9794
|
-
] }),
|
|
9795
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9762
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9763
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9796
9764
|
] });
|
|
9797
9765
|
};
|
|
9798
|
-
const
|
|
9766
|
+
const CustomItemsForm = () => {
|
|
9799
9767
|
const form = useForm({
|
|
9800
|
-
|
|
9801
|
-
email: order.email ?? ""
|
|
9802
|
-
},
|
|
9803
|
-
resolver: zodResolver(schema$3)
|
|
9804
|
-
});
|
|
9805
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9806
|
-
const { handleSuccess } = useRouteModal();
|
|
9807
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9808
|
-
await mutateAsync(
|
|
9809
|
-
{ email: data.email },
|
|
9810
|
-
{
|
|
9811
|
-
onSuccess: () => {
|
|
9812
|
-
handleSuccess();
|
|
9813
|
-
},
|
|
9814
|
-
onError: (error) => {
|
|
9815
|
-
toast.error(error.message);
|
|
9816
|
-
}
|
|
9817
|
-
}
|
|
9818
|
-
);
|
|
9768
|
+
resolver: zodResolver(schema$4)
|
|
9819
9769
|
});
|
|
9820
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9821
|
-
|
|
9822
|
-
{
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
Form$2.Field,
|
|
9828
|
-
{
|
|
9829
|
-
control: form.control,
|
|
9830
|
-
name: "email",
|
|
9831
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9832
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9833
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9834
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9835
|
-
] })
|
|
9836
|
-
}
|
|
9837
|
-
) }),
|
|
9838
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9839
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9840
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9841
|
-
] }) })
|
|
9842
|
-
]
|
|
9843
|
-
}
|
|
9844
|
-
) });
|
|
9770
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9771
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9772
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9773
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9774
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9775
|
+
] }) })
|
|
9776
|
+
] }) });
|
|
9845
9777
|
};
|
|
9846
|
-
const schema$
|
|
9778
|
+
const schema$4 = objectType({
|
|
9847
9779
|
email: stringType().email()
|
|
9848
9780
|
});
|
|
9849
9781
|
const NumberInput = forwardRef(
|
|
@@ -11170,6 +11102,74 @@ function getHasUneditableRows(metadata) {
|
|
|
11170
11102
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11171
11103
|
);
|
|
11172
11104
|
}
|
|
11105
|
+
const Email = () => {
|
|
11106
|
+
const { id } = useParams();
|
|
11107
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11108
|
+
fields: "+email"
|
|
11109
|
+
});
|
|
11110
|
+
if (isError) {
|
|
11111
|
+
throw error;
|
|
11112
|
+
}
|
|
11113
|
+
const isReady = !isPending && !!order;
|
|
11114
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11115
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11116
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
11117
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11118
|
+
] }),
|
|
11119
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
11120
|
+
] });
|
|
11121
|
+
};
|
|
11122
|
+
const EmailForm = ({ order }) => {
|
|
11123
|
+
const form = useForm({
|
|
11124
|
+
defaultValues: {
|
|
11125
|
+
email: order.email ?? ""
|
|
11126
|
+
},
|
|
11127
|
+
resolver: zodResolver(schema$3)
|
|
11128
|
+
});
|
|
11129
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11130
|
+
const { handleSuccess } = useRouteModal();
|
|
11131
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11132
|
+
await mutateAsync(
|
|
11133
|
+
{ email: data.email },
|
|
11134
|
+
{
|
|
11135
|
+
onSuccess: () => {
|
|
11136
|
+
handleSuccess();
|
|
11137
|
+
},
|
|
11138
|
+
onError: (error) => {
|
|
11139
|
+
toast.error(error.message);
|
|
11140
|
+
}
|
|
11141
|
+
}
|
|
11142
|
+
);
|
|
11143
|
+
});
|
|
11144
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11145
|
+
KeyboundForm,
|
|
11146
|
+
{
|
|
11147
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11148
|
+
onSubmit,
|
|
11149
|
+
children: [
|
|
11150
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11151
|
+
Form$2.Field,
|
|
11152
|
+
{
|
|
11153
|
+
control: form.control,
|
|
11154
|
+
name: "email",
|
|
11155
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11156
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
11157
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11158
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11159
|
+
] })
|
|
11160
|
+
}
|
|
11161
|
+
) }),
|
|
11162
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11163
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11164
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11165
|
+
] }) })
|
|
11166
|
+
]
|
|
11167
|
+
}
|
|
11168
|
+
) });
|
|
11169
|
+
};
|
|
11170
|
+
const schema$3 = objectType({
|
|
11171
|
+
email: stringType().email()
|
|
11172
|
+
});
|
|
11173
11173
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
11174
11174
|
const promotionsQueryKeys = {
|
|
11175
11175
|
list: (query2) => [
|
|
@@ -11447,112 +11447,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11447
11447
|
}
|
|
11448
11448
|
return Array.from(promotionIds);
|
|
11449
11449
|
}
|
|
11450
|
-
const SalesChannel = () => {
|
|
11451
|
-
const { id } = useParams();
|
|
11452
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11453
|
-
id,
|
|
11454
|
-
{
|
|
11455
|
-
fields: "+sales_channel_id"
|
|
11456
|
-
},
|
|
11457
|
-
{
|
|
11458
|
-
enabled: !!id
|
|
11459
|
-
}
|
|
11460
|
-
);
|
|
11461
|
-
if (isError) {
|
|
11462
|
-
throw error;
|
|
11463
|
-
}
|
|
11464
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11465
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11466
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11467
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11468
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11469
|
-
] }),
|
|
11470
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11471
|
-
] });
|
|
11472
|
-
};
|
|
11473
|
-
const SalesChannelForm = ({ order }) => {
|
|
11474
|
-
const form = useForm({
|
|
11475
|
-
defaultValues: {
|
|
11476
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11477
|
-
},
|
|
11478
|
-
resolver: zodResolver(schema$2)
|
|
11479
|
-
});
|
|
11480
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11481
|
-
const { handleSuccess } = useRouteModal();
|
|
11482
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11483
|
-
await mutateAsync(
|
|
11484
|
-
{
|
|
11485
|
-
sales_channel_id: data.sales_channel_id
|
|
11486
|
-
},
|
|
11487
|
-
{
|
|
11488
|
-
onSuccess: () => {
|
|
11489
|
-
toast.success("Sales channel updated");
|
|
11490
|
-
handleSuccess();
|
|
11491
|
-
},
|
|
11492
|
-
onError: (error) => {
|
|
11493
|
-
toast.error(error.message);
|
|
11494
|
-
}
|
|
11495
|
-
}
|
|
11496
|
-
);
|
|
11497
|
-
});
|
|
11498
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11499
|
-
KeyboundForm,
|
|
11500
|
-
{
|
|
11501
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11502
|
-
onSubmit,
|
|
11503
|
-
children: [
|
|
11504
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11505
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11506
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11507
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11508
|
-
] }) })
|
|
11509
|
-
]
|
|
11510
|
-
}
|
|
11511
|
-
) });
|
|
11512
|
-
};
|
|
11513
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11514
|
-
const salesChannels = useComboboxData({
|
|
11515
|
-
queryFn: async (params) => {
|
|
11516
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11517
|
-
},
|
|
11518
|
-
queryKey: ["sales-channels"],
|
|
11519
|
-
getOptions: (data) => {
|
|
11520
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11521
|
-
label: salesChannel.name,
|
|
11522
|
-
value: salesChannel.id
|
|
11523
|
-
}));
|
|
11524
|
-
},
|
|
11525
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11526
|
-
});
|
|
11527
|
-
return /* @__PURE__ */ jsx(
|
|
11528
|
-
Form$2.Field,
|
|
11529
|
-
{
|
|
11530
|
-
control,
|
|
11531
|
-
name: "sales_channel_id",
|
|
11532
|
-
render: ({ field }) => {
|
|
11533
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11534
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11535
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11536
|
-
Combobox,
|
|
11537
|
-
{
|
|
11538
|
-
options: salesChannels.options,
|
|
11539
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11540
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11541
|
-
searchValue: salesChannels.searchValue,
|
|
11542
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11543
|
-
placeholder: "Select sales channel",
|
|
11544
|
-
...field
|
|
11545
|
-
}
|
|
11546
|
-
) }),
|
|
11547
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11548
|
-
] });
|
|
11549
|
-
}
|
|
11550
|
-
}
|
|
11551
|
-
);
|
|
11552
|
-
};
|
|
11553
|
-
const schema$2 = objectType({
|
|
11554
|
-
sales_channel_id: stringType().min(1)
|
|
11555
|
-
});
|
|
11556
11450
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11557
11451
|
const Shipping = () => {
|
|
11558
11452
|
var _a;
|
|
@@ -12383,7 +12277,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12383
12277
|
defaultValues: {
|
|
12384
12278
|
customer_id: order.customer_id || ""
|
|
12385
12279
|
},
|
|
12386
|
-
resolver: zodResolver(schema$
|
|
12280
|
+
resolver: zodResolver(schema$2)
|
|
12387
12281
|
});
|
|
12388
12282
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12389
12283
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12833,9 +12727,115 @@ const Illustration = () => {
|
|
|
12833
12727
|
}
|
|
12834
12728
|
);
|
|
12835
12729
|
};
|
|
12836
|
-
const schema$
|
|
12730
|
+
const schema$2 = objectType({
|
|
12837
12731
|
customer_id: stringType().min(1)
|
|
12838
12732
|
});
|
|
12733
|
+
const SalesChannel = () => {
|
|
12734
|
+
const { id } = useParams();
|
|
12735
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12736
|
+
id,
|
|
12737
|
+
{
|
|
12738
|
+
fields: "+sales_channel_id"
|
|
12739
|
+
},
|
|
12740
|
+
{
|
|
12741
|
+
enabled: !!id
|
|
12742
|
+
}
|
|
12743
|
+
);
|
|
12744
|
+
if (isError) {
|
|
12745
|
+
throw error;
|
|
12746
|
+
}
|
|
12747
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12748
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12749
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12750
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12751
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12752
|
+
] }),
|
|
12753
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12754
|
+
] });
|
|
12755
|
+
};
|
|
12756
|
+
const SalesChannelForm = ({ order }) => {
|
|
12757
|
+
const form = useForm({
|
|
12758
|
+
defaultValues: {
|
|
12759
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12760
|
+
},
|
|
12761
|
+
resolver: zodResolver(schema$1)
|
|
12762
|
+
});
|
|
12763
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12764
|
+
const { handleSuccess } = useRouteModal();
|
|
12765
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12766
|
+
await mutateAsync(
|
|
12767
|
+
{
|
|
12768
|
+
sales_channel_id: data.sales_channel_id
|
|
12769
|
+
},
|
|
12770
|
+
{
|
|
12771
|
+
onSuccess: () => {
|
|
12772
|
+
toast.success("Sales channel updated");
|
|
12773
|
+
handleSuccess();
|
|
12774
|
+
},
|
|
12775
|
+
onError: (error) => {
|
|
12776
|
+
toast.error(error.message);
|
|
12777
|
+
}
|
|
12778
|
+
}
|
|
12779
|
+
);
|
|
12780
|
+
});
|
|
12781
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12782
|
+
KeyboundForm,
|
|
12783
|
+
{
|
|
12784
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12785
|
+
onSubmit,
|
|
12786
|
+
children: [
|
|
12787
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12788
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12789
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12790
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12791
|
+
] }) })
|
|
12792
|
+
]
|
|
12793
|
+
}
|
|
12794
|
+
) });
|
|
12795
|
+
};
|
|
12796
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12797
|
+
const salesChannels = useComboboxData({
|
|
12798
|
+
queryFn: async (params) => {
|
|
12799
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12800
|
+
},
|
|
12801
|
+
queryKey: ["sales-channels"],
|
|
12802
|
+
getOptions: (data) => {
|
|
12803
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12804
|
+
label: salesChannel.name,
|
|
12805
|
+
value: salesChannel.id
|
|
12806
|
+
}));
|
|
12807
|
+
},
|
|
12808
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12809
|
+
});
|
|
12810
|
+
return /* @__PURE__ */ jsx(
|
|
12811
|
+
Form$2.Field,
|
|
12812
|
+
{
|
|
12813
|
+
control,
|
|
12814
|
+
name: "sales_channel_id",
|
|
12815
|
+
render: ({ field }) => {
|
|
12816
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12817
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12818
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12819
|
+
Combobox,
|
|
12820
|
+
{
|
|
12821
|
+
options: salesChannels.options,
|
|
12822
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12823
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12824
|
+
searchValue: salesChannels.searchValue,
|
|
12825
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12826
|
+
placeholder: "Select sales channel",
|
|
12827
|
+
...field
|
|
12828
|
+
}
|
|
12829
|
+
) }),
|
|
12830
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12831
|
+
] });
|
|
12832
|
+
}
|
|
12833
|
+
}
|
|
12834
|
+
);
|
|
12835
|
+
};
|
|
12836
|
+
const schema$1 = objectType({
|
|
12837
|
+
sales_channel_id: stringType().min(1)
|
|
12838
|
+
});
|
|
12839
12839
|
const ShippingAddress = () => {
|
|
12840
12840
|
const { id } = useParams();
|
|
12841
12841
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13059,17 +13059,13 @@ const routeModule = {
|
|
|
13059
13059
|
handle,
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
|
-
{
|
|
13063
|
-
Component: CustomItems,
|
|
13064
|
-
path: "/draft-orders/:id/custom-items"
|
|
13065
|
-
},
|
|
13066
13062
|
{
|
|
13067
13063
|
Component: BillingAddress,
|
|
13068
13064
|
path: "/draft-orders/:id/billing-address"
|
|
13069
13065
|
},
|
|
13070
13066
|
{
|
|
13071
|
-
Component:
|
|
13072
|
-
path: "/draft-orders/:id/
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13073
13069
|
},
|
|
13074
13070
|
{
|
|
13075
13071
|
Component: Items,
|
|
@@ -13080,12 +13076,12 @@ const routeModule = {
|
|
|
13080
13076
|
path: "/draft-orders/:id/metadata"
|
|
13081
13077
|
},
|
|
13082
13078
|
{
|
|
13083
|
-
Component:
|
|
13084
|
-
path: "/draft-orders/:id/
|
|
13079
|
+
Component: Email,
|
|
13080
|
+
path: "/draft-orders/:id/email"
|
|
13085
13081
|
},
|
|
13086
13082
|
{
|
|
13087
|
-
Component:
|
|
13088
|
-
path: "/draft-orders/:id/
|
|
13083
|
+
Component: Promotions,
|
|
13084
|
+
path: "/draft-orders/:id/promotions"
|
|
13089
13085
|
},
|
|
13090
13086
|
{
|
|
13091
13087
|
Component: Shipping,
|
|
@@ -13095,6 +13091,10 @@ const routeModule = {
|
|
|
13095
13091
|
Component: TransferOwnership,
|
|
13096
13092
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13093
|
},
|
|
13094
|
+
{
|
|
13095
|
+
Component: SalesChannel,
|
|
13096
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13097
|
+
},
|
|
13098
13098
|
{
|
|
13099
13099
|
Component: ShippingAddress,
|
|
13100
13100
|
path: "/draft-orders/:id/shipping-address"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.10.4-preview-
|
|
3
|
+
"version": "2.10.4-preview-20250929120206",
|
|
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.4-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.10.4-preview-20250929120206",
|
|
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.4-preview-
|
|
49
|
-
"@medusajs/cli": "2.10.4-preview-
|
|
50
|
-
"@medusajs/framework": "2.10.4-preview-
|
|
51
|
-
"@medusajs/icons": "2.10.4-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.10.4-preview-
|
|
53
|
-
"@medusajs/types": "2.10.4-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.10.4-preview-
|
|
48
|
+
"@medusajs/admin-sdk": "2.10.4-preview-20250929120206",
|
|
49
|
+
"@medusajs/cli": "2.10.4-preview-20250929120206",
|
|
50
|
+
"@medusajs/framework": "2.10.4-preview-20250929120206",
|
|
51
|
+
"@medusajs/icons": "2.10.4-preview-20250929120206",
|
|
52
|
+
"@medusajs/test-utils": "2.10.4-preview-20250929120206",
|
|
53
|
+
"@medusajs/types": "2.10.4-preview-20250929120206",
|
|
54
|
+
"@medusajs/ui": "4.0.24-preview-20250929120206",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.4-preview-20250929120206",
|
|
56
56
|
"@swc/core": "1.5.7",
|
|
57
57
|
"@types/lodash": "^4.17.15",
|
|
58
58
|
"@types/node": "^20.0.0",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"yalc": "^1.0.0-pre.53"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@medusajs/admin-sdk": "2.10.4-preview-
|
|
73
|
-
"@medusajs/cli": "2.10.4-preview-
|
|
74
|
-
"@medusajs/framework": "2.10.4-preview-
|
|
75
|
-
"@medusajs/icons": "2.10.4-preview-
|
|
76
|
-
"@medusajs/test-utils": "2.10.4-preview-
|
|
77
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
72
|
+
"@medusajs/admin-sdk": "2.10.4-preview-20250929120206",
|
|
73
|
+
"@medusajs/cli": "2.10.4-preview-20250929120206",
|
|
74
|
+
"@medusajs/framework": "2.10.4-preview-20250929120206",
|
|
75
|
+
"@medusajs/icons": "2.10.4-preview-20250929120206",
|
|
76
|
+
"@medusajs/test-utils": "2.10.4-preview-20250929120206",
|
|
77
|
+
"@medusajs/ui": "4.0.24-preview-20250929120206",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"react-router-dom": "6.20.1"
|
|
80
80
|
},
|