@medusajs/draft-order 2.10.4-preview-20251013090155 → 2.10.4-preview-20251013180156
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 +199 -199
- package/.medusa/server/src/admin/index.mjs +199 -199
- package/package.json +16 -16
|
@@ -9763,70 +9763,23 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9763
9763
|
) });
|
|
9764
9764
|
};
|
|
9765
9765
|
const schema$5 = addressSchema;
|
|
9766
|
-
const
|
|
9767
|
-
const { id } = reactRouterDom.useParams();
|
|
9768
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9769
|
-
fields: "+email"
|
|
9770
|
-
});
|
|
9771
|
-
if (isError) {
|
|
9772
|
-
throw error;
|
|
9773
|
-
}
|
|
9774
|
-
const isReady = !isPending && !!order;
|
|
9766
|
+
const CustomItems = () => {
|
|
9775
9767
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9777
|
-
|
|
9778
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9779
|
-
] }),
|
|
9780
|
-
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, {})
|
|
9781
9770
|
] });
|
|
9782
9771
|
};
|
|
9783
|
-
const
|
|
9772
|
+
const CustomItemsForm = () => {
|
|
9784
9773
|
const form = reactHookForm.useForm({
|
|
9785
|
-
defaultValues: {
|
|
9786
|
-
email: order.email ?? ""
|
|
9787
|
-
},
|
|
9788
9774
|
resolver: zod.zodResolver(schema$4)
|
|
9789
9775
|
});
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
{
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
handleSuccess();
|
|
9798
|
-
},
|
|
9799
|
-
onError: (error) => {
|
|
9800
|
-
ui.toast.error(error.message);
|
|
9801
|
-
}
|
|
9802
|
-
}
|
|
9803
|
-
);
|
|
9804
|
-
});
|
|
9805
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9806
|
-
KeyboundForm,
|
|
9807
|
-
{
|
|
9808
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9809
|
-
onSubmit,
|
|
9810
|
-
children: [
|
|
9811
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9812
|
-
Form$2.Field,
|
|
9813
|
-
{
|
|
9814
|
-
control: form.control,
|
|
9815
|
-
name: "email",
|
|
9816
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9817
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9818
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9819
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9820
|
-
] })
|
|
9821
|
-
}
|
|
9822
|
-
) }),
|
|
9823
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9824
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9825
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9826
|
-
] }) })
|
|
9827
|
-
]
|
|
9828
|
-
}
|
|
9829
|
-
) });
|
|
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
|
+
] }) });
|
|
9830
9783
|
};
|
|
9831
9784
|
const schema$4 = objectType({
|
|
9832
9785
|
email: stringType().email()
|
|
@@ -11432,133 +11385,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11432
11385
|
}
|
|
11433
11386
|
return Array.from(promotionIds);
|
|
11434
11387
|
}
|
|
11435
|
-
const CustomItems = () => {
|
|
11436
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11437
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
11438
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
11439
|
-
] });
|
|
11440
|
-
};
|
|
11441
|
-
const CustomItemsForm = () => {
|
|
11442
|
-
const form = reactHookForm.useForm({
|
|
11443
|
-
resolver: zod.zodResolver(schema$3)
|
|
11444
|
-
});
|
|
11445
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
11446
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
11447
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11448
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11449
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
11450
|
-
] }) })
|
|
11451
|
-
] }) });
|
|
11452
|
-
};
|
|
11453
|
-
const schema$3 = objectType({
|
|
11454
|
-
email: stringType().email()
|
|
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
11388
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11563
11389
|
const Shipping = () => {
|
|
11564
11390
|
var _a;
|
|
@@ -12398,7 +12224,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12398
12224
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12399
12225
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12400
12226
|
},
|
|
12401
|
-
resolver: zod.zodResolver(schema$
|
|
12227
|
+
resolver: zod.zodResolver(schema$3)
|
|
12402
12228
|
});
|
|
12403
12229
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12404
12230
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12568,7 +12394,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12568
12394
|
}
|
|
12569
12395
|
) });
|
|
12570
12396
|
};
|
|
12571
|
-
const schema$
|
|
12397
|
+
const schema$3 = addressSchema;
|
|
12572
12398
|
const TransferOwnership = () => {
|
|
12573
12399
|
const { id } = reactRouterDom.useParams();
|
|
12574
12400
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12592,7 +12418,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12592
12418
|
defaultValues: {
|
|
12593
12419
|
customer_id: order.customer_id || ""
|
|
12594
12420
|
},
|
|
12595
|
-
resolver: zod.zodResolver(schema)
|
|
12421
|
+
resolver: zod.zodResolver(schema$2)
|
|
12596
12422
|
});
|
|
12597
12423
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12598
12424
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13042,9 +12868,183 @@ const Illustration = () => {
|
|
|
13042
12868
|
}
|
|
13043
12869
|
);
|
|
13044
12870
|
};
|
|
13045
|
-
const schema = objectType({
|
|
12871
|
+
const schema$2 = objectType({
|
|
13046
12872
|
customer_id: stringType().min(1)
|
|
13047
12873
|
});
|
|
12874
|
+
const SalesChannel = () => {
|
|
12875
|
+
const { id } = reactRouterDom.useParams();
|
|
12876
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12877
|
+
id,
|
|
12878
|
+
{
|
|
12879
|
+
fields: "+sales_channel_id"
|
|
12880
|
+
},
|
|
12881
|
+
{
|
|
12882
|
+
enabled: !!id
|
|
12883
|
+
}
|
|
12884
|
+
);
|
|
12885
|
+
if (isError) {
|
|
12886
|
+
throw error;
|
|
12887
|
+
}
|
|
12888
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12889
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12890
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12891
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12892
|
+
/* @__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" }) })
|
|
12893
|
+
] }),
|
|
12894
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12895
|
+
] });
|
|
12896
|
+
};
|
|
12897
|
+
const SalesChannelForm = ({ order }) => {
|
|
12898
|
+
const form = reactHookForm.useForm({
|
|
12899
|
+
defaultValues: {
|
|
12900
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12901
|
+
},
|
|
12902
|
+
resolver: zod.zodResolver(schema$1)
|
|
12903
|
+
});
|
|
12904
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12905
|
+
const { handleSuccess } = useRouteModal();
|
|
12906
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12907
|
+
await mutateAsync(
|
|
12908
|
+
{
|
|
12909
|
+
sales_channel_id: data.sales_channel_id
|
|
12910
|
+
},
|
|
12911
|
+
{
|
|
12912
|
+
onSuccess: () => {
|
|
12913
|
+
ui.toast.success("Sales channel updated");
|
|
12914
|
+
handleSuccess();
|
|
12915
|
+
},
|
|
12916
|
+
onError: (error) => {
|
|
12917
|
+
ui.toast.error(error.message);
|
|
12918
|
+
}
|
|
12919
|
+
}
|
|
12920
|
+
);
|
|
12921
|
+
});
|
|
12922
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12923
|
+
KeyboundForm,
|
|
12924
|
+
{
|
|
12925
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12926
|
+
onSubmit,
|
|
12927
|
+
children: [
|
|
12928
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12929
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12930
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12931
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12932
|
+
] }) })
|
|
12933
|
+
]
|
|
12934
|
+
}
|
|
12935
|
+
) });
|
|
12936
|
+
};
|
|
12937
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12938
|
+
const salesChannels = useComboboxData({
|
|
12939
|
+
queryFn: async (params) => {
|
|
12940
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12941
|
+
},
|
|
12942
|
+
queryKey: ["sales-channels"],
|
|
12943
|
+
getOptions: (data) => {
|
|
12944
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12945
|
+
label: salesChannel.name,
|
|
12946
|
+
value: salesChannel.id
|
|
12947
|
+
}));
|
|
12948
|
+
},
|
|
12949
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12950
|
+
});
|
|
12951
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12952
|
+
Form$2.Field,
|
|
12953
|
+
{
|
|
12954
|
+
control,
|
|
12955
|
+
name: "sales_channel_id",
|
|
12956
|
+
render: ({ field }) => {
|
|
12957
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12960
|
+
Combobox,
|
|
12961
|
+
{
|
|
12962
|
+
options: salesChannels.options,
|
|
12963
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12964
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12965
|
+
searchValue: salesChannels.searchValue,
|
|
12966
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12967
|
+
placeholder: "Select sales channel",
|
|
12968
|
+
...field
|
|
12969
|
+
}
|
|
12970
|
+
) }),
|
|
12971
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12972
|
+
] });
|
|
12973
|
+
}
|
|
12974
|
+
}
|
|
12975
|
+
);
|
|
12976
|
+
};
|
|
12977
|
+
const schema$1 = objectType({
|
|
12978
|
+
sales_channel_id: stringType().min(1)
|
|
12979
|
+
});
|
|
12980
|
+
const Email = () => {
|
|
12981
|
+
const { id } = reactRouterDom.useParams();
|
|
12982
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12983
|
+
fields: "+email"
|
|
12984
|
+
});
|
|
12985
|
+
if (isError) {
|
|
12986
|
+
throw error;
|
|
12987
|
+
}
|
|
12988
|
+
const isReady = !isPending && !!order;
|
|
12989
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12990
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12991
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12992
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12993
|
+
] }),
|
|
12994
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12995
|
+
] });
|
|
12996
|
+
};
|
|
12997
|
+
const EmailForm = ({ order }) => {
|
|
12998
|
+
const form = reactHookForm.useForm({
|
|
12999
|
+
defaultValues: {
|
|
13000
|
+
email: order.email ?? ""
|
|
13001
|
+
},
|
|
13002
|
+
resolver: zod.zodResolver(schema)
|
|
13003
|
+
});
|
|
13004
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
13005
|
+
const { handleSuccess } = useRouteModal();
|
|
13006
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
13007
|
+
await mutateAsync(
|
|
13008
|
+
{ email: data.email },
|
|
13009
|
+
{
|
|
13010
|
+
onSuccess: () => {
|
|
13011
|
+
handleSuccess();
|
|
13012
|
+
},
|
|
13013
|
+
onError: (error) => {
|
|
13014
|
+
ui.toast.error(error.message);
|
|
13015
|
+
}
|
|
13016
|
+
}
|
|
13017
|
+
);
|
|
13018
|
+
});
|
|
13019
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
13020
|
+
KeyboundForm,
|
|
13021
|
+
{
|
|
13022
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13023
|
+
onSubmit,
|
|
13024
|
+
children: [
|
|
13025
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13026
|
+
Form$2.Field,
|
|
13027
|
+
{
|
|
13028
|
+
control: form.control,
|
|
13029
|
+
name: "email",
|
|
13030
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13031
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
13032
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13033
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13034
|
+
] })
|
|
13035
|
+
}
|
|
13036
|
+
) }),
|
|
13037
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13038
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13039
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13040
|
+
] }) })
|
|
13041
|
+
]
|
|
13042
|
+
}
|
|
13043
|
+
) });
|
|
13044
|
+
};
|
|
13045
|
+
const schema = objectType({
|
|
13046
|
+
email: stringType().email()
|
|
13047
|
+
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -13070,8 +13070,8 @@ const routeModule = {
|
|
|
13070
13070
|
path: "/draft-orders/:id/billing-address"
|
|
13071
13071
|
},
|
|
13072
13072
|
{
|
|
13073
|
-
Component:
|
|
13074
|
-
path: "/draft-orders/:id/
|
|
13073
|
+
Component: CustomItems,
|
|
13074
|
+
path: "/draft-orders/:id/custom-items"
|
|
13075
13075
|
},
|
|
13076
13076
|
{
|
|
13077
13077
|
Component: Items,
|
|
@@ -13085,14 +13085,6 @@ const routeModule = {
|
|
|
13085
13085
|
Component: Promotions,
|
|
13086
13086
|
path: "/draft-orders/:id/promotions"
|
|
13087
13087
|
},
|
|
13088
|
-
{
|
|
13089
|
-
Component: CustomItems,
|
|
13090
|
-
path: "/draft-orders/:id/custom-items"
|
|
13091
|
-
},
|
|
13092
|
-
{
|
|
13093
|
-
Component: SalesChannel,
|
|
13094
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13095
|
-
},
|
|
13096
13088
|
{
|
|
13097
13089
|
Component: Shipping,
|
|
13098
13090
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13104,6 +13096,14 @@ const routeModule = {
|
|
|
13104
13096
|
{
|
|
13105
13097
|
Component: TransferOwnership,
|
|
13106
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13099
|
+
},
|
|
13100
|
+
{
|
|
13101
|
+
Component: SalesChannel,
|
|
13102
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13103
|
+
},
|
|
13104
|
+
{
|
|
13105
|
+
Component: Email,
|
|
13106
|
+
path: "/draft-orders/:id/email"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|
|
@@ -9757,70 +9757,23 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9757
9757
|
) });
|
|
9758
9758
|
};
|
|
9759
9759
|
const schema$5 = addressSchema;
|
|
9760
|
-
const
|
|
9761
|
-
const { id } = useParams();
|
|
9762
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9763
|
-
fields: "+email"
|
|
9764
|
-
});
|
|
9765
|
-
if (isError) {
|
|
9766
|
-
throw error;
|
|
9767
|
-
}
|
|
9768
|
-
const isReady = !isPending && !!order;
|
|
9760
|
+
const CustomItems = () => {
|
|
9769
9761
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9770
|
-
/* @__PURE__ */
|
|
9771
|
-
|
|
9772
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9773
|
-
] }),
|
|
9774
|
-
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, {})
|
|
9775
9764
|
] });
|
|
9776
9765
|
};
|
|
9777
|
-
const
|
|
9766
|
+
const CustomItemsForm = () => {
|
|
9778
9767
|
const form = useForm({
|
|
9779
|
-
defaultValues: {
|
|
9780
|
-
email: order.email ?? ""
|
|
9781
|
-
},
|
|
9782
9768
|
resolver: zodResolver(schema$4)
|
|
9783
9769
|
});
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
{
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
handleSuccess();
|
|
9792
|
-
},
|
|
9793
|
-
onError: (error) => {
|
|
9794
|
-
toast.error(error.message);
|
|
9795
|
-
}
|
|
9796
|
-
}
|
|
9797
|
-
);
|
|
9798
|
-
});
|
|
9799
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9800
|
-
KeyboundForm,
|
|
9801
|
-
{
|
|
9802
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9803
|
-
onSubmit,
|
|
9804
|
-
children: [
|
|
9805
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9806
|
-
Form$2.Field,
|
|
9807
|
-
{
|
|
9808
|
-
control: form.control,
|
|
9809
|
-
name: "email",
|
|
9810
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9811
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9812
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9813
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9814
|
-
] })
|
|
9815
|
-
}
|
|
9816
|
-
) }),
|
|
9817
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9818
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9819
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9820
|
-
] }) })
|
|
9821
|
-
]
|
|
9822
|
-
}
|
|
9823
|
-
) });
|
|
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
|
+
] }) });
|
|
9824
9777
|
};
|
|
9825
9778
|
const schema$4 = objectType({
|
|
9826
9779
|
email: stringType().email()
|
|
@@ -11426,133 +11379,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11426
11379
|
}
|
|
11427
11380
|
return Array.from(promotionIds);
|
|
11428
11381
|
}
|
|
11429
|
-
const CustomItems = () => {
|
|
11430
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11431
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
11432
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
11433
|
-
] });
|
|
11434
|
-
};
|
|
11435
|
-
const CustomItemsForm = () => {
|
|
11436
|
-
const form = useForm({
|
|
11437
|
-
resolver: zodResolver(schema$3)
|
|
11438
|
-
});
|
|
11439
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
11440
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
11441
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11442
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11443
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
11444
|
-
] }) })
|
|
11445
|
-
] }) });
|
|
11446
|
-
};
|
|
11447
|
-
const schema$3 = objectType({
|
|
11448
|
-
email: stringType().email()
|
|
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
11382
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11557
11383
|
const Shipping = () => {
|
|
11558
11384
|
var _a;
|
|
@@ -12392,7 +12218,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12392
12218
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12393
12219
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12394
12220
|
},
|
|
12395
|
-
resolver: zodResolver(schema$
|
|
12221
|
+
resolver: zodResolver(schema$3)
|
|
12396
12222
|
});
|
|
12397
12223
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12398
12224
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12562,7 +12388,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12562
12388
|
}
|
|
12563
12389
|
) });
|
|
12564
12390
|
};
|
|
12565
|
-
const schema$
|
|
12391
|
+
const schema$3 = addressSchema;
|
|
12566
12392
|
const TransferOwnership = () => {
|
|
12567
12393
|
const { id } = useParams();
|
|
12568
12394
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12586,7 +12412,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12586
12412
|
defaultValues: {
|
|
12587
12413
|
customer_id: order.customer_id || ""
|
|
12588
12414
|
},
|
|
12589
|
-
resolver: zodResolver(schema)
|
|
12415
|
+
resolver: zodResolver(schema$2)
|
|
12590
12416
|
});
|
|
12591
12417
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12592
12418
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13036,9 +12862,183 @@ const Illustration = () => {
|
|
|
13036
12862
|
}
|
|
13037
12863
|
);
|
|
13038
12864
|
};
|
|
13039
|
-
const schema = objectType({
|
|
12865
|
+
const schema$2 = objectType({
|
|
13040
12866
|
customer_id: stringType().min(1)
|
|
13041
12867
|
});
|
|
12868
|
+
const SalesChannel = () => {
|
|
12869
|
+
const { id } = useParams();
|
|
12870
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12871
|
+
id,
|
|
12872
|
+
{
|
|
12873
|
+
fields: "+sales_channel_id"
|
|
12874
|
+
},
|
|
12875
|
+
{
|
|
12876
|
+
enabled: !!id
|
|
12877
|
+
}
|
|
12878
|
+
);
|
|
12879
|
+
if (isError) {
|
|
12880
|
+
throw error;
|
|
12881
|
+
}
|
|
12882
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12883
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12884
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12885
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12886
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12887
|
+
] }),
|
|
12888
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12889
|
+
] });
|
|
12890
|
+
};
|
|
12891
|
+
const SalesChannelForm = ({ order }) => {
|
|
12892
|
+
const form = useForm({
|
|
12893
|
+
defaultValues: {
|
|
12894
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12895
|
+
},
|
|
12896
|
+
resolver: zodResolver(schema$1)
|
|
12897
|
+
});
|
|
12898
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12899
|
+
const { handleSuccess } = useRouteModal();
|
|
12900
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12901
|
+
await mutateAsync(
|
|
12902
|
+
{
|
|
12903
|
+
sales_channel_id: data.sales_channel_id
|
|
12904
|
+
},
|
|
12905
|
+
{
|
|
12906
|
+
onSuccess: () => {
|
|
12907
|
+
toast.success("Sales channel updated");
|
|
12908
|
+
handleSuccess();
|
|
12909
|
+
},
|
|
12910
|
+
onError: (error) => {
|
|
12911
|
+
toast.error(error.message);
|
|
12912
|
+
}
|
|
12913
|
+
}
|
|
12914
|
+
);
|
|
12915
|
+
});
|
|
12916
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12917
|
+
KeyboundForm,
|
|
12918
|
+
{
|
|
12919
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12920
|
+
onSubmit,
|
|
12921
|
+
children: [
|
|
12922
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12923
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12924
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12925
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12926
|
+
] }) })
|
|
12927
|
+
]
|
|
12928
|
+
}
|
|
12929
|
+
) });
|
|
12930
|
+
};
|
|
12931
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12932
|
+
const salesChannels = useComboboxData({
|
|
12933
|
+
queryFn: async (params) => {
|
|
12934
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12935
|
+
},
|
|
12936
|
+
queryKey: ["sales-channels"],
|
|
12937
|
+
getOptions: (data) => {
|
|
12938
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12939
|
+
label: salesChannel.name,
|
|
12940
|
+
value: salesChannel.id
|
|
12941
|
+
}));
|
|
12942
|
+
},
|
|
12943
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12944
|
+
});
|
|
12945
|
+
return /* @__PURE__ */ jsx(
|
|
12946
|
+
Form$2.Field,
|
|
12947
|
+
{
|
|
12948
|
+
control,
|
|
12949
|
+
name: "sales_channel_id",
|
|
12950
|
+
render: ({ field }) => {
|
|
12951
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12953
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12954
|
+
Combobox,
|
|
12955
|
+
{
|
|
12956
|
+
options: salesChannels.options,
|
|
12957
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12958
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12959
|
+
searchValue: salesChannels.searchValue,
|
|
12960
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12961
|
+
placeholder: "Select sales channel",
|
|
12962
|
+
...field
|
|
12963
|
+
}
|
|
12964
|
+
) }),
|
|
12965
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12966
|
+
] });
|
|
12967
|
+
}
|
|
12968
|
+
}
|
|
12969
|
+
);
|
|
12970
|
+
};
|
|
12971
|
+
const schema$1 = objectType({
|
|
12972
|
+
sales_channel_id: stringType().min(1)
|
|
12973
|
+
});
|
|
12974
|
+
const Email = () => {
|
|
12975
|
+
const { id } = useParams();
|
|
12976
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12977
|
+
fields: "+email"
|
|
12978
|
+
});
|
|
12979
|
+
if (isError) {
|
|
12980
|
+
throw error;
|
|
12981
|
+
}
|
|
12982
|
+
const isReady = !isPending && !!order;
|
|
12983
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12984
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12985
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
12986
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12987
|
+
] }),
|
|
12988
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
12989
|
+
] });
|
|
12990
|
+
};
|
|
12991
|
+
const EmailForm = ({ order }) => {
|
|
12992
|
+
const form = useForm({
|
|
12993
|
+
defaultValues: {
|
|
12994
|
+
email: order.email ?? ""
|
|
12995
|
+
},
|
|
12996
|
+
resolver: zodResolver(schema)
|
|
12997
|
+
});
|
|
12998
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12999
|
+
const { handleSuccess } = useRouteModal();
|
|
13000
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
13001
|
+
await mutateAsync(
|
|
13002
|
+
{ email: data.email },
|
|
13003
|
+
{
|
|
13004
|
+
onSuccess: () => {
|
|
13005
|
+
handleSuccess();
|
|
13006
|
+
},
|
|
13007
|
+
onError: (error) => {
|
|
13008
|
+
toast.error(error.message);
|
|
13009
|
+
}
|
|
13010
|
+
}
|
|
13011
|
+
);
|
|
13012
|
+
});
|
|
13013
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
13014
|
+
KeyboundForm,
|
|
13015
|
+
{
|
|
13016
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13017
|
+
onSubmit,
|
|
13018
|
+
children: [
|
|
13019
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
13020
|
+
Form$2.Field,
|
|
13021
|
+
{
|
|
13022
|
+
control: form.control,
|
|
13023
|
+
name: "email",
|
|
13024
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13025
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13027
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13028
|
+
] })
|
|
13029
|
+
}
|
|
13030
|
+
) }),
|
|
13031
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13032
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13034
|
+
] }) })
|
|
13035
|
+
]
|
|
13036
|
+
}
|
|
13037
|
+
) });
|
|
13038
|
+
};
|
|
13039
|
+
const schema = objectType({
|
|
13040
|
+
email: stringType().email()
|
|
13041
|
+
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13064,8 +13064,8 @@ const routeModule = {
|
|
|
13064
13064
|
path: "/draft-orders/:id/billing-address"
|
|
13065
13065
|
},
|
|
13066
13066
|
{
|
|
13067
|
-
Component:
|
|
13068
|
-
path: "/draft-orders/:id/
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13069
13069
|
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Items,
|
|
@@ -13079,14 +13079,6 @@ const routeModule = {
|
|
|
13079
13079
|
Component: Promotions,
|
|
13080
13080
|
path: "/draft-orders/:id/promotions"
|
|
13081
13081
|
},
|
|
13082
|
-
{
|
|
13083
|
-
Component: CustomItems,
|
|
13084
|
-
path: "/draft-orders/:id/custom-items"
|
|
13085
|
-
},
|
|
13086
|
-
{
|
|
13087
|
-
Component: SalesChannel,
|
|
13088
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13089
|
-
},
|
|
13090
13082
|
{
|
|
13091
13083
|
Component: Shipping,
|
|
13092
13084
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13098,6 +13090,14 @@ const routeModule = {
|
|
|
13098
13090
|
{
|
|
13099
13091
|
Component: TransferOwnership,
|
|
13100
13092
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13093
|
+
},
|
|
13094
|
+
{
|
|
13095
|
+
Component: SalesChannel,
|
|
13096
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: Email,
|
|
13100
|
+
path: "/draft-orders/:id/email"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|
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-20251013180156",
|
|
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-20251013180156",
|
|
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-20251013180156",
|
|
49
|
+
"@medusajs/cli": "2.10.4-preview-20251013180156",
|
|
50
|
+
"@medusajs/framework": "2.10.4-preview-20251013180156",
|
|
51
|
+
"@medusajs/icons": "2.10.4-preview-20251013180156",
|
|
52
|
+
"@medusajs/test-utils": "2.10.4-preview-20251013180156",
|
|
53
|
+
"@medusajs/types": "2.10.4-preview-20251013180156",
|
|
54
|
+
"@medusajs/ui": "4.0.24-preview-20251013180156",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.4-preview-20251013180156",
|
|
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-20251013180156",
|
|
73
|
+
"@medusajs/cli": "2.10.4-preview-20251013180156",
|
|
74
|
+
"@medusajs/framework": "2.10.4-preview-20251013180156",
|
|
75
|
+
"@medusajs/icons": "2.10.4-preview-20251013180156",
|
|
76
|
+
"@medusajs/test-utils": "2.10.4-preview-20251013180156",
|
|
77
|
+
"@medusajs/ui": "4.0.24-preview-20251013180156",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"react-router-dom": "6.20.1"
|
|
80
80
|
},
|