@medusajs/draft-order 2.10.4-snapshot-20250925190227 → 2.10.4-snapshot-20250925200335
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 +159 -159
- package/.medusa/server/src/admin/index.mjs +159 -159
- 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(
|
|
@@ -11453,46 +11385,37 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11453
11385
|
}
|
|
11454
11386
|
return Array.from(promotionIds);
|
|
11455
11387
|
}
|
|
11456
|
-
const
|
|
11388
|
+
const Email = () => {
|
|
11457
11389
|
const { id } = reactRouterDom.useParams();
|
|
11458
|
-
const {
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
fields: "+sales_channel_id"
|
|
11462
|
-
},
|
|
11463
|
-
{
|
|
11464
|
-
enabled: !!id
|
|
11465
|
-
}
|
|
11466
|
-
);
|
|
11390
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11391
|
+
fields: "+email"
|
|
11392
|
+
});
|
|
11467
11393
|
if (isError) {
|
|
11468
11394
|
throw error;
|
|
11469
11395
|
}
|
|
11470
|
-
const
|
|
11396
|
+
const isReady = !isPending && !!order;
|
|
11471
11397
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11472
11398
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11473
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit
|
|
11474
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
11399
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
11400
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11475
11401
|
] }),
|
|
11476
|
-
|
|
11402
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
11477
11403
|
] });
|
|
11478
11404
|
};
|
|
11479
|
-
const
|
|
11405
|
+
const EmailForm = ({ order }) => {
|
|
11480
11406
|
const form = reactHookForm.useForm({
|
|
11481
11407
|
defaultValues: {
|
|
11482
|
-
|
|
11408
|
+
email: order.email ?? ""
|
|
11483
11409
|
},
|
|
11484
|
-
resolver: zod.zodResolver(schema$
|
|
11410
|
+
resolver: zod.zodResolver(schema$3)
|
|
11485
11411
|
});
|
|
11486
11412
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11487
11413
|
const { handleSuccess } = useRouteModal();
|
|
11488
11414
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11489
11415
|
await mutateAsync(
|
|
11490
|
-
{
|
|
11491
|
-
sales_channel_id: data.sales_channel_id
|
|
11492
|
-
},
|
|
11416
|
+
{ email: data.email },
|
|
11493
11417
|
{
|
|
11494
11418
|
onSuccess: () => {
|
|
11495
|
-
ui.toast.success("Sales channel updated");
|
|
11496
11419
|
handleSuccess();
|
|
11497
11420
|
},
|
|
11498
11421
|
onError: (error) => {
|
|
@@ -11507,7 +11430,18 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11507
11430
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11508
11431
|
onSubmit,
|
|
11509
11432
|
children: [
|
|
11510
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11433
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11434
|
+
Form$2.Field,
|
|
11435
|
+
{
|
|
11436
|
+
control: form.control,
|
|
11437
|
+
name: "email",
|
|
11438
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11439
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
11440
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11441
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11442
|
+
] })
|
|
11443
|
+
}
|
|
11444
|
+
) }),
|
|
11511
11445
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11512
11446
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11513
11447
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -11516,48 +11450,8 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11516
11450
|
}
|
|
11517
11451
|
) });
|
|
11518
11452
|
};
|
|
11519
|
-
const
|
|
11520
|
-
|
|
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)
|
|
11453
|
+
const schema$3 = objectType({
|
|
11454
|
+
email: stringType().email()
|
|
11561
11455
|
});
|
|
11562
11456
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11563
11457
|
const Shipping = () => {
|
|
@@ -12398,7 +12292,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12398
12292
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12399
12293
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12400
12294
|
},
|
|
12401
|
-
resolver: zod.zodResolver(schema$
|
|
12295
|
+
resolver: zod.zodResolver(schema$2)
|
|
12402
12296
|
});
|
|
12403
12297
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12404
12298
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12568,7 +12462,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12568
12462
|
}
|
|
12569
12463
|
) });
|
|
12570
12464
|
};
|
|
12571
|
-
const schema$
|
|
12465
|
+
const schema$2 = addressSchema;
|
|
12572
12466
|
const TransferOwnership = () => {
|
|
12573
12467
|
const { id } = reactRouterDom.useParams();
|
|
12574
12468
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12592,7 +12486,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12592
12486
|
defaultValues: {
|
|
12593
12487
|
customer_id: order.customer_id || ""
|
|
12594
12488
|
},
|
|
12595
|
-
resolver: zod.zodResolver(schema)
|
|
12489
|
+
resolver: zod.zodResolver(schema$1)
|
|
12596
12490
|
});
|
|
12597
12491
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12598
12492
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13042,9 +12936,115 @@ const Illustration = () => {
|
|
|
13042
12936
|
}
|
|
13043
12937
|
);
|
|
13044
12938
|
};
|
|
13045
|
-
const schema = objectType({
|
|
12939
|
+
const schema$1 = objectType({
|
|
13046
12940
|
customer_id: stringType().min(1)
|
|
13047
12941
|
});
|
|
12942
|
+
const SalesChannel = () => {
|
|
12943
|
+
const { id } = reactRouterDom.useParams();
|
|
12944
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12945
|
+
id,
|
|
12946
|
+
{
|
|
12947
|
+
fields: "+sales_channel_id"
|
|
12948
|
+
},
|
|
12949
|
+
{
|
|
12950
|
+
enabled: !!id
|
|
12951
|
+
}
|
|
12952
|
+
);
|
|
12953
|
+
if (isError) {
|
|
12954
|
+
throw error;
|
|
12955
|
+
}
|
|
12956
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12957
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12960
|
+
/* @__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" }) })
|
|
12961
|
+
] }),
|
|
12962
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12963
|
+
] });
|
|
12964
|
+
};
|
|
12965
|
+
const SalesChannelForm = ({ order }) => {
|
|
12966
|
+
const form = reactHookForm.useForm({
|
|
12967
|
+
defaultValues: {
|
|
12968
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12969
|
+
},
|
|
12970
|
+
resolver: zod.zodResolver(schema)
|
|
12971
|
+
});
|
|
12972
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12973
|
+
const { handleSuccess } = useRouteModal();
|
|
12974
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12975
|
+
await mutateAsync(
|
|
12976
|
+
{
|
|
12977
|
+
sales_channel_id: data.sales_channel_id
|
|
12978
|
+
},
|
|
12979
|
+
{
|
|
12980
|
+
onSuccess: () => {
|
|
12981
|
+
ui.toast.success("Sales channel updated");
|
|
12982
|
+
handleSuccess();
|
|
12983
|
+
},
|
|
12984
|
+
onError: (error) => {
|
|
12985
|
+
ui.toast.error(error.message);
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
);
|
|
12989
|
+
});
|
|
12990
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12991
|
+
KeyboundForm,
|
|
12992
|
+
{
|
|
12993
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12994
|
+
onSubmit,
|
|
12995
|
+
children: [
|
|
12996
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12997
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12998
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12999
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13000
|
+
] }) })
|
|
13001
|
+
]
|
|
13002
|
+
}
|
|
13003
|
+
) });
|
|
13004
|
+
};
|
|
13005
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13006
|
+
const salesChannels = useComboboxData({
|
|
13007
|
+
queryFn: async (params) => {
|
|
13008
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13009
|
+
},
|
|
13010
|
+
queryKey: ["sales-channels"],
|
|
13011
|
+
getOptions: (data) => {
|
|
13012
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13013
|
+
label: salesChannel.name,
|
|
13014
|
+
value: salesChannel.id
|
|
13015
|
+
}));
|
|
13016
|
+
},
|
|
13017
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13018
|
+
});
|
|
13019
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13020
|
+
Form$2.Field,
|
|
13021
|
+
{
|
|
13022
|
+
control,
|
|
13023
|
+
name: "sales_channel_id",
|
|
13024
|
+
render: ({ field }) => {
|
|
13025
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13027
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13028
|
+
Combobox,
|
|
13029
|
+
{
|
|
13030
|
+
options: salesChannels.options,
|
|
13031
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13032
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13033
|
+
searchValue: salesChannels.searchValue,
|
|
13034
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13035
|
+
placeholder: "Select sales channel",
|
|
13036
|
+
...field
|
|
13037
|
+
}
|
|
13038
|
+
) }),
|
|
13039
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13040
|
+
] });
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
13043
|
+
);
|
|
13044
|
+
};
|
|
13045
|
+
const schema = objectType({
|
|
13046
|
+
sales_channel_id: stringType().min(1)
|
|
13047
|
+
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -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,
|
|
@@ -13090,8 +13086,8 @@ const routeModule = {
|
|
|
13090
13086
|
path: "/draft-orders/:id/promotions"
|
|
13091
13087
|
},
|
|
13092
13088
|
{
|
|
13093
|
-
Component:
|
|
13094
|
-
path: "/draft-orders/:id/
|
|
13089
|
+
Component: Email,
|
|
13090
|
+
path: "/draft-orders/:id/email"
|
|
13095
13091
|
},
|
|
13096
13092
|
{
|
|
13097
13093
|
Component: Shipping,
|
|
@@ -13104,6 +13100,10 @@ const routeModule = {
|
|
|
13104
13100
|
{
|
|
13105
13101
|
Component: TransferOwnership,
|
|
13106
13102
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
|
+
},
|
|
13104
|
+
{
|
|
13105
|
+
Component: SalesChannel,
|
|
13106
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|
|
@@ -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(
|
|
@@ -11447,46 +11379,37 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11447
11379
|
}
|
|
11448
11380
|
return Array.from(promotionIds);
|
|
11449
11381
|
}
|
|
11450
|
-
const
|
|
11382
|
+
const Email = () => {
|
|
11451
11383
|
const { id } = useParams();
|
|
11452
|
-
const {
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
fields: "+sales_channel_id"
|
|
11456
|
-
},
|
|
11457
|
-
{
|
|
11458
|
-
enabled: !!id
|
|
11459
|
-
}
|
|
11460
|
-
);
|
|
11384
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11385
|
+
fields: "+email"
|
|
11386
|
+
});
|
|
11461
11387
|
if (isError) {
|
|
11462
11388
|
throw error;
|
|
11463
11389
|
}
|
|
11464
|
-
const
|
|
11390
|
+
const isReady = !isPending && !!order;
|
|
11465
11391
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11466
11392
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11467
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
11468
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
11393
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
11394
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11469
11395
|
] }),
|
|
11470
|
-
|
|
11396
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
11471
11397
|
] });
|
|
11472
11398
|
};
|
|
11473
|
-
const
|
|
11399
|
+
const EmailForm = ({ order }) => {
|
|
11474
11400
|
const form = useForm({
|
|
11475
11401
|
defaultValues: {
|
|
11476
|
-
|
|
11402
|
+
email: order.email ?? ""
|
|
11477
11403
|
},
|
|
11478
|
-
resolver: zodResolver(schema$
|
|
11404
|
+
resolver: zodResolver(schema$3)
|
|
11479
11405
|
});
|
|
11480
11406
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11481
11407
|
const { handleSuccess } = useRouteModal();
|
|
11482
11408
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11483
11409
|
await mutateAsync(
|
|
11484
|
-
{
|
|
11485
|
-
sales_channel_id: data.sales_channel_id
|
|
11486
|
-
},
|
|
11410
|
+
{ email: data.email },
|
|
11487
11411
|
{
|
|
11488
11412
|
onSuccess: () => {
|
|
11489
|
-
toast.success("Sales channel updated");
|
|
11490
11413
|
handleSuccess();
|
|
11491
11414
|
},
|
|
11492
11415
|
onError: (error) => {
|
|
@@ -11501,7 +11424,18 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11501
11424
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11502
11425
|
onSubmit,
|
|
11503
11426
|
children: [
|
|
11504
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11427
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11428
|
+
Form$2.Field,
|
|
11429
|
+
{
|
|
11430
|
+
control: form.control,
|
|
11431
|
+
name: "email",
|
|
11432
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11433
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
11434
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11435
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11436
|
+
] })
|
|
11437
|
+
}
|
|
11438
|
+
) }),
|
|
11505
11439
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11506
11440
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11507
11441
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -11510,48 +11444,8 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11510
11444
|
}
|
|
11511
11445
|
) });
|
|
11512
11446
|
};
|
|
11513
|
-
const
|
|
11514
|
-
|
|
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)
|
|
11447
|
+
const schema$3 = objectType({
|
|
11448
|
+
email: stringType().email()
|
|
11555
11449
|
});
|
|
11556
11450
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11557
11451
|
const Shipping = () => {
|
|
@@ -12392,7 +12286,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12392
12286
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12393
12287
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12394
12288
|
},
|
|
12395
|
-
resolver: zodResolver(schema$
|
|
12289
|
+
resolver: zodResolver(schema$2)
|
|
12396
12290
|
});
|
|
12397
12291
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12398
12292
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12562,7 +12456,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12562
12456
|
}
|
|
12563
12457
|
) });
|
|
12564
12458
|
};
|
|
12565
|
-
const schema$
|
|
12459
|
+
const schema$2 = addressSchema;
|
|
12566
12460
|
const TransferOwnership = () => {
|
|
12567
12461
|
const { id } = useParams();
|
|
12568
12462
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12586,7 +12480,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12586
12480
|
defaultValues: {
|
|
12587
12481
|
customer_id: order.customer_id || ""
|
|
12588
12482
|
},
|
|
12589
|
-
resolver: zodResolver(schema)
|
|
12483
|
+
resolver: zodResolver(schema$1)
|
|
12590
12484
|
});
|
|
12591
12485
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12592
12486
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13036,9 +12930,115 @@ const Illustration = () => {
|
|
|
13036
12930
|
}
|
|
13037
12931
|
);
|
|
13038
12932
|
};
|
|
13039
|
-
const schema = objectType({
|
|
12933
|
+
const schema$1 = objectType({
|
|
13040
12934
|
customer_id: stringType().min(1)
|
|
13041
12935
|
});
|
|
12936
|
+
const SalesChannel = () => {
|
|
12937
|
+
const { id } = useParams();
|
|
12938
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12939
|
+
id,
|
|
12940
|
+
{
|
|
12941
|
+
fields: "+sales_channel_id"
|
|
12942
|
+
},
|
|
12943
|
+
{
|
|
12944
|
+
enabled: !!id
|
|
12945
|
+
}
|
|
12946
|
+
);
|
|
12947
|
+
if (isError) {
|
|
12948
|
+
throw error;
|
|
12949
|
+
}
|
|
12950
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12951
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12953
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12955
|
+
] }),
|
|
12956
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12957
|
+
] });
|
|
12958
|
+
};
|
|
12959
|
+
const SalesChannelForm = ({ order }) => {
|
|
12960
|
+
const form = useForm({
|
|
12961
|
+
defaultValues: {
|
|
12962
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12963
|
+
},
|
|
12964
|
+
resolver: zodResolver(schema)
|
|
12965
|
+
});
|
|
12966
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12967
|
+
const { handleSuccess } = useRouteModal();
|
|
12968
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12969
|
+
await mutateAsync(
|
|
12970
|
+
{
|
|
12971
|
+
sales_channel_id: data.sales_channel_id
|
|
12972
|
+
},
|
|
12973
|
+
{
|
|
12974
|
+
onSuccess: () => {
|
|
12975
|
+
toast.success("Sales channel updated");
|
|
12976
|
+
handleSuccess();
|
|
12977
|
+
},
|
|
12978
|
+
onError: (error) => {
|
|
12979
|
+
toast.error(error.message);
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
);
|
|
12983
|
+
});
|
|
12984
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12985
|
+
KeyboundForm,
|
|
12986
|
+
{
|
|
12987
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12988
|
+
onSubmit,
|
|
12989
|
+
children: [
|
|
12990
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12993
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12994
|
+
] }) })
|
|
12995
|
+
]
|
|
12996
|
+
}
|
|
12997
|
+
) });
|
|
12998
|
+
};
|
|
12999
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13000
|
+
const salesChannels = useComboboxData({
|
|
13001
|
+
queryFn: async (params) => {
|
|
13002
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13003
|
+
},
|
|
13004
|
+
queryKey: ["sales-channels"],
|
|
13005
|
+
getOptions: (data) => {
|
|
13006
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13007
|
+
label: salesChannel.name,
|
|
13008
|
+
value: salesChannel.id
|
|
13009
|
+
}));
|
|
13010
|
+
},
|
|
13011
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13012
|
+
});
|
|
13013
|
+
return /* @__PURE__ */ jsx(
|
|
13014
|
+
Form$2.Field,
|
|
13015
|
+
{
|
|
13016
|
+
control,
|
|
13017
|
+
name: "sales_channel_id",
|
|
13018
|
+
render: ({ field }) => {
|
|
13019
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13020
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13021
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13022
|
+
Combobox,
|
|
13023
|
+
{
|
|
13024
|
+
options: salesChannels.options,
|
|
13025
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13026
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13027
|
+
searchValue: salesChannels.searchValue,
|
|
13028
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13029
|
+
placeholder: "Select sales channel",
|
|
13030
|
+
...field
|
|
13031
|
+
}
|
|
13032
|
+
) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13034
|
+
] });
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
);
|
|
13038
|
+
};
|
|
13039
|
+
const schema = objectType({
|
|
13040
|
+
sales_channel_id: stringType().min(1)
|
|
13041
|
+
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -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,
|
|
@@ -13084,8 +13080,8 @@ const routeModule = {
|
|
|
13084
13080
|
path: "/draft-orders/:id/promotions"
|
|
13085
13081
|
},
|
|
13086
13082
|
{
|
|
13087
|
-
Component:
|
|
13088
|
-
path: "/draft-orders/:id/
|
|
13083
|
+
Component: Email,
|
|
13084
|
+
path: "/draft-orders/:id/email"
|
|
13089
13085
|
},
|
|
13090
13086
|
{
|
|
13091
13087
|
Component: Shipping,
|
|
@@ -13098,6 +13094,10 @@ const routeModule = {
|
|
|
13098
13094
|
{
|
|
13099
13095
|
Component: TransferOwnership,
|
|
13100
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: SalesChannel,
|
|
13100
|
+
path: "/draft-orders/:id/sales-channel"
|
|
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-snapshot-
|
|
3
|
+
"version": "2.10.4-snapshot-20250925200335",
|
|
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-snapshot-
|
|
39
|
+
"@medusajs/js-sdk": "2.10.4-snapshot-20250925200335",
|
|
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-snapshot-
|
|
49
|
-
"@medusajs/cli": "2.10.4-snapshot-
|
|
50
|
-
"@medusajs/framework": "2.10.4-snapshot-
|
|
51
|
-
"@medusajs/icons": "2.10.4-snapshot-
|
|
52
|
-
"@medusajs/test-utils": "2.10.4-snapshot-
|
|
53
|
-
"@medusajs/types": "2.10.4-snapshot-
|
|
54
|
-
"@medusajs/ui": "4.0.24-snapshot-
|
|
55
|
-
"@medusajs/ui-preset": "2.10.4-snapshot-
|
|
48
|
+
"@medusajs/admin-sdk": "2.10.4-snapshot-20250925200335",
|
|
49
|
+
"@medusajs/cli": "2.10.4-snapshot-20250925200335",
|
|
50
|
+
"@medusajs/framework": "2.10.4-snapshot-20250925200335",
|
|
51
|
+
"@medusajs/icons": "2.10.4-snapshot-20250925200335",
|
|
52
|
+
"@medusajs/test-utils": "2.10.4-snapshot-20250925200335",
|
|
53
|
+
"@medusajs/types": "2.10.4-snapshot-20250925200335",
|
|
54
|
+
"@medusajs/ui": "4.0.24-snapshot-20250925200335",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.4-snapshot-20250925200335",
|
|
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-snapshot-
|
|
73
|
-
"@medusajs/cli": "2.10.4-snapshot-
|
|
74
|
-
"@medusajs/framework": "2.10.4-snapshot-
|
|
75
|
-
"@medusajs/icons": "2.10.4-snapshot-
|
|
76
|
-
"@medusajs/test-utils": "2.10.4-snapshot-
|
|
77
|
-
"@medusajs/ui": "4.0.24-snapshot-
|
|
72
|
+
"@medusajs/admin-sdk": "2.10.4-snapshot-20250925200335",
|
|
73
|
+
"@medusajs/cli": "2.10.4-snapshot-20250925200335",
|
|
74
|
+
"@medusajs/framework": "2.10.4-snapshot-20250925200335",
|
|
75
|
+
"@medusajs/icons": "2.10.4-snapshot-20250925200335",
|
|
76
|
+
"@medusajs/test-utils": "2.10.4-snapshot-20250925200335",
|
|
77
|
+
"@medusajs/ui": "4.0.24-snapshot-20250925200335",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"react-router-dom": "6.20.1"
|
|
80
80
|
},
|