@medusajs/draft-order 2.11.4-preview-20251110090143 → 2.11.4-preview-20251110150136
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 +205 -205
- package/.medusa/server/src/admin/index.mjs +205 -205
- package/package.json +16 -16
|
@@ -9568,6 +9568,95 @@ const ID = () => {
|
|
|
9568
9568
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9569
9569
|
] });
|
|
9570
9570
|
};
|
|
9571
|
+
const CustomItems = () => {
|
|
9572
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9573
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9574
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9575
|
+
] });
|
|
9576
|
+
};
|
|
9577
|
+
const CustomItemsForm = () => {
|
|
9578
|
+
const form = reactHookForm.useForm({
|
|
9579
|
+
resolver: zod.zodResolver(schema$5)
|
|
9580
|
+
});
|
|
9581
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9582
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9583
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9584
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9585
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9586
|
+
] }) })
|
|
9587
|
+
] }) });
|
|
9588
|
+
};
|
|
9589
|
+
const schema$5 = objectType({
|
|
9590
|
+
email: stringType().email()
|
|
9591
|
+
});
|
|
9592
|
+
const Email = () => {
|
|
9593
|
+
const { id } = reactRouterDom.useParams();
|
|
9594
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9595
|
+
fields: "+email"
|
|
9596
|
+
});
|
|
9597
|
+
if (isError) {
|
|
9598
|
+
throw error;
|
|
9599
|
+
}
|
|
9600
|
+
const isReady = !isPending && !!order;
|
|
9601
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9602
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9603
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9604
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9605
|
+
] }),
|
|
9606
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9607
|
+
] });
|
|
9608
|
+
};
|
|
9609
|
+
const EmailForm = ({ order }) => {
|
|
9610
|
+
const form = reactHookForm.useForm({
|
|
9611
|
+
defaultValues: {
|
|
9612
|
+
email: order.email ?? ""
|
|
9613
|
+
},
|
|
9614
|
+
resolver: zod.zodResolver(schema$4)
|
|
9615
|
+
});
|
|
9616
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9617
|
+
const { handleSuccess } = useRouteModal();
|
|
9618
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9619
|
+
await mutateAsync(
|
|
9620
|
+
{ email: data.email },
|
|
9621
|
+
{
|
|
9622
|
+
onSuccess: () => {
|
|
9623
|
+
handleSuccess();
|
|
9624
|
+
},
|
|
9625
|
+
onError: (error) => {
|
|
9626
|
+
ui.toast.error(error.message);
|
|
9627
|
+
}
|
|
9628
|
+
}
|
|
9629
|
+
);
|
|
9630
|
+
});
|
|
9631
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9632
|
+
KeyboundForm,
|
|
9633
|
+
{
|
|
9634
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9635
|
+
onSubmit,
|
|
9636
|
+
children: [
|
|
9637
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9638
|
+
Form$2.Field,
|
|
9639
|
+
{
|
|
9640
|
+
control: form.control,
|
|
9641
|
+
name: "email",
|
|
9642
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9643
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9644
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9645
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9646
|
+
] })
|
|
9647
|
+
}
|
|
9648
|
+
) }),
|
|
9649
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9650
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9651
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9652
|
+
] }) })
|
|
9653
|
+
]
|
|
9654
|
+
}
|
|
9655
|
+
) });
|
|
9656
|
+
};
|
|
9657
|
+
const schema$4 = objectType({
|
|
9658
|
+
email: stringType().email()
|
|
9659
|
+
});
|
|
9571
9660
|
const BillingAddress = () => {
|
|
9572
9661
|
const { id } = reactRouterDom.useParams();
|
|
9573
9662
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9600,7 +9689,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9600
9689
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9601
9690
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9602
9691
|
},
|
|
9603
|
-
resolver: zod.zodResolver(schema$
|
|
9692
|
+
resolver: zod.zodResolver(schema$3)
|
|
9604
9693
|
});
|
|
9605
9694
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9606
9695
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9757,96 +9846,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9757
9846
|
}
|
|
9758
9847
|
) });
|
|
9759
9848
|
};
|
|
9760
|
-
const schema$
|
|
9761
|
-
const CustomItems = () => {
|
|
9762
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9763
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9764
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9765
|
-
] });
|
|
9766
|
-
};
|
|
9767
|
-
const CustomItemsForm = () => {
|
|
9768
|
-
const form = reactHookForm.useForm({
|
|
9769
|
-
resolver: zod.zodResolver(schema$4)
|
|
9770
|
-
});
|
|
9771
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9772
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9773
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9774
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9775
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9776
|
-
] }) })
|
|
9777
|
-
] }) });
|
|
9778
|
-
};
|
|
9779
|
-
const schema$4 = objectType({
|
|
9780
|
-
email: stringType().email()
|
|
9781
|
-
});
|
|
9782
|
-
const Email = () => {
|
|
9783
|
-
const { id } = reactRouterDom.useParams();
|
|
9784
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9785
|
-
fields: "+email"
|
|
9786
|
-
});
|
|
9787
|
-
if (isError) {
|
|
9788
|
-
throw error;
|
|
9789
|
-
}
|
|
9790
|
-
const isReady = !isPending && !!order;
|
|
9791
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9792
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9793
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9794
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9795
|
-
] }),
|
|
9796
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9797
|
-
] });
|
|
9798
|
-
};
|
|
9799
|
-
const EmailForm = ({ order }) => {
|
|
9800
|
-
const form = reactHookForm.useForm({
|
|
9801
|
-
defaultValues: {
|
|
9802
|
-
email: order.email ?? ""
|
|
9803
|
-
},
|
|
9804
|
-
resolver: zod.zodResolver(schema$3)
|
|
9805
|
-
});
|
|
9806
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9807
|
-
const { handleSuccess } = useRouteModal();
|
|
9808
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9809
|
-
await mutateAsync(
|
|
9810
|
-
{ email: data.email },
|
|
9811
|
-
{
|
|
9812
|
-
onSuccess: () => {
|
|
9813
|
-
handleSuccess();
|
|
9814
|
-
},
|
|
9815
|
-
onError: (error) => {
|
|
9816
|
-
ui.toast.error(error.message);
|
|
9817
|
-
}
|
|
9818
|
-
}
|
|
9819
|
-
);
|
|
9820
|
-
});
|
|
9821
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9822
|
-
KeyboundForm,
|
|
9823
|
-
{
|
|
9824
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9825
|
-
onSubmit,
|
|
9826
|
-
children: [
|
|
9827
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9828
|
-
Form$2.Field,
|
|
9829
|
-
{
|
|
9830
|
-
control: form.control,
|
|
9831
|
-
name: "email",
|
|
9832
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9833
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9834
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9835
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9836
|
-
] })
|
|
9837
|
-
}
|
|
9838
|
-
) }),
|
|
9839
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9840
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9841
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9842
|
-
] }) })
|
|
9843
|
-
]
|
|
9844
|
-
}
|
|
9845
|
-
) });
|
|
9846
|
-
};
|
|
9847
|
-
const schema$3 = objectType({
|
|
9848
|
-
email: stringType().email()
|
|
9849
|
-
});
|
|
9849
|
+
const schema$3 = addressSchema;
|
|
9850
9850
|
const NumberInput = React.forwardRef(
|
|
9851
9851
|
({
|
|
9852
9852
|
value,
|
|
@@ -11448,6 +11448,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11448
11448
|
}
|
|
11449
11449
|
return Array.from(promotionIds);
|
|
11450
11450
|
}
|
|
11451
|
+
const SalesChannel = () => {
|
|
11452
|
+
const { id } = reactRouterDom.useParams();
|
|
11453
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11454
|
+
id,
|
|
11455
|
+
{
|
|
11456
|
+
fields: "+sales_channel_id"
|
|
11457
|
+
},
|
|
11458
|
+
{
|
|
11459
|
+
enabled: !!id
|
|
11460
|
+
}
|
|
11461
|
+
);
|
|
11462
|
+
if (isError) {
|
|
11463
|
+
throw error;
|
|
11464
|
+
}
|
|
11465
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11466
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11467
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11468
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11469
|
+
/* @__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" }) })
|
|
11470
|
+
] }),
|
|
11471
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11472
|
+
] });
|
|
11473
|
+
};
|
|
11474
|
+
const SalesChannelForm = ({ order }) => {
|
|
11475
|
+
const form = reactHookForm.useForm({
|
|
11476
|
+
defaultValues: {
|
|
11477
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11478
|
+
},
|
|
11479
|
+
resolver: zod.zodResolver(schema$2)
|
|
11480
|
+
});
|
|
11481
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11482
|
+
const { handleSuccess } = useRouteModal();
|
|
11483
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11484
|
+
await mutateAsync(
|
|
11485
|
+
{
|
|
11486
|
+
sales_channel_id: data.sales_channel_id
|
|
11487
|
+
},
|
|
11488
|
+
{
|
|
11489
|
+
onSuccess: () => {
|
|
11490
|
+
ui.toast.success("Sales channel updated");
|
|
11491
|
+
handleSuccess();
|
|
11492
|
+
},
|
|
11493
|
+
onError: (error) => {
|
|
11494
|
+
ui.toast.error(error.message);
|
|
11495
|
+
}
|
|
11496
|
+
}
|
|
11497
|
+
);
|
|
11498
|
+
});
|
|
11499
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11500
|
+
KeyboundForm,
|
|
11501
|
+
{
|
|
11502
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11503
|
+
onSubmit,
|
|
11504
|
+
children: [
|
|
11505
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11506
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11507
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11508
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11509
|
+
] }) })
|
|
11510
|
+
]
|
|
11511
|
+
}
|
|
11512
|
+
) });
|
|
11513
|
+
};
|
|
11514
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11515
|
+
const salesChannels = useComboboxData({
|
|
11516
|
+
queryFn: async (params) => {
|
|
11517
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11518
|
+
},
|
|
11519
|
+
queryKey: ["sales-channels"],
|
|
11520
|
+
getOptions: (data) => {
|
|
11521
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11522
|
+
label: salesChannel.name,
|
|
11523
|
+
value: salesChannel.id
|
|
11524
|
+
}));
|
|
11525
|
+
},
|
|
11526
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11527
|
+
});
|
|
11528
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
+
Form$2.Field,
|
|
11530
|
+
{
|
|
11531
|
+
control,
|
|
11532
|
+
name: "sales_channel_id",
|
|
11533
|
+
render: ({ field }) => {
|
|
11534
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11535
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11536
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11537
|
+
Combobox,
|
|
11538
|
+
{
|
|
11539
|
+
options: salesChannels.options,
|
|
11540
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11541
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11542
|
+
searchValue: salesChannels.searchValue,
|
|
11543
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11544
|
+
placeholder: "Select sales channel",
|
|
11545
|
+
...field
|
|
11546
|
+
}
|
|
11547
|
+
) }),
|
|
11548
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11549
|
+
] });
|
|
11550
|
+
}
|
|
11551
|
+
}
|
|
11552
|
+
);
|
|
11553
|
+
};
|
|
11554
|
+
const schema$2 = objectType({
|
|
11555
|
+
sales_channel_id: stringType().min(1)
|
|
11556
|
+
});
|
|
11451
11557
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11452
11558
|
const Shipping = () => {
|
|
11453
11559
|
var _a;
|
|
@@ -12255,112 +12361,6 @@ const CustomAmountField = ({
|
|
|
12255
12361
|
}
|
|
12256
12362
|
);
|
|
12257
12363
|
};
|
|
12258
|
-
const SalesChannel = () => {
|
|
12259
|
-
const { id } = reactRouterDom.useParams();
|
|
12260
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12261
|
-
id,
|
|
12262
|
-
{
|
|
12263
|
-
fields: "+sales_channel_id"
|
|
12264
|
-
},
|
|
12265
|
-
{
|
|
12266
|
-
enabled: !!id
|
|
12267
|
-
}
|
|
12268
|
-
);
|
|
12269
|
-
if (isError) {
|
|
12270
|
-
throw error;
|
|
12271
|
-
}
|
|
12272
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12273
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12274
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12275
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12276
|
-
/* @__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" }) })
|
|
12277
|
-
] }),
|
|
12278
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12279
|
-
] });
|
|
12280
|
-
};
|
|
12281
|
-
const SalesChannelForm = ({ order }) => {
|
|
12282
|
-
const form = reactHookForm.useForm({
|
|
12283
|
-
defaultValues: {
|
|
12284
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12285
|
-
},
|
|
12286
|
-
resolver: zod.zodResolver(schema$2)
|
|
12287
|
-
});
|
|
12288
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12289
|
-
const { handleSuccess } = useRouteModal();
|
|
12290
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12291
|
-
await mutateAsync(
|
|
12292
|
-
{
|
|
12293
|
-
sales_channel_id: data.sales_channel_id
|
|
12294
|
-
},
|
|
12295
|
-
{
|
|
12296
|
-
onSuccess: () => {
|
|
12297
|
-
ui.toast.success("Sales channel updated");
|
|
12298
|
-
handleSuccess();
|
|
12299
|
-
},
|
|
12300
|
-
onError: (error) => {
|
|
12301
|
-
ui.toast.error(error.message);
|
|
12302
|
-
}
|
|
12303
|
-
}
|
|
12304
|
-
);
|
|
12305
|
-
});
|
|
12306
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12307
|
-
KeyboundForm,
|
|
12308
|
-
{
|
|
12309
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12310
|
-
onSubmit,
|
|
12311
|
-
children: [
|
|
12312
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12313
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12314
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12315
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12316
|
-
] }) })
|
|
12317
|
-
]
|
|
12318
|
-
}
|
|
12319
|
-
) });
|
|
12320
|
-
};
|
|
12321
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12322
|
-
const salesChannels = useComboboxData({
|
|
12323
|
-
queryFn: async (params) => {
|
|
12324
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12325
|
-
},
|
|
12326
|
-
queryKey: ["sales-channels"],
|
|
12327
|
-
getOptions: (data) => {
|
|
12328
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12329
|
-
label: salesChannel.name,
|
|
12330
|
-
value: salesChannel.id
|
|
12331
|
-
}));
|
|
12332
|
-
},
|
|
12333
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12334
|
-
});
|
|
12335
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12336
|
-
Form$2.Field,
|
|
12337
|
-
{
|
|
12338
|
-
control,
|
|
12339
|
-
name: "sales_channel_id",
|
|
12340
|
-
render: ({ field }) => {
|
|
12341
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12342
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12343
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12344
|
-
Combobox,
|
|
12345
|
-
{
|
|
12346
|
-
options: salesChannels.options,
|
|
12347
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12348
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12349
|
-
searchValue: salesChannels.searchValue,
|
|
12350
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12351
|
-
placeholder: "Select sales channel",
|
|
12352
|
-
...field
|
|
12353
|
-
}
|
|
12354
|
-
) }),
|
|
12355
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12356
|
-
] });
|
|
12357
|
-
}
|
|
12358
|
-
}
|
|
12359
|
-
);
|
|
12360
|
-
};
|
|
12361
|
-
const schema$2 = objectType({
|
|
12362
|
-
sales_channel_id: stringType().min(1)
|
|
12363
|
-
});
|
|
12364
12364
|
const ShippingAddress = () => {
|
|
12365
12365
|
const { id } = reactRouterDom.useParams();
|
|
12366
12366
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13060,10 +13060,6 @@ const routeModule = {
|
|
|
13060
13060
|
handle,
|
|
13061
13061
|
loader,
|
|
13062
13062
|
children: [
|
|
13063
|
-
{
|
|
13064
|
-
Component: BillingAddress,
|
|
13065
|
-
path: "/draft-orders/:id/billing-address"
|
|
13066
|
-
},
|
|
13067
13063
|
{
|
|
13068
13064
|
Component: CustomItems,
|
|
13069
13065
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13072,6 +13068,10 @@ const routeModule = {
|
|
|
13072
13068
|
Component: Email,
|
|
13073
13069
|
path: "/draft-orders/:id/email"
|
|
13074
13070
|
},
|
|
13071
|
+
{
|
|
13072
|
+
Component: BillingAddress,
|
|
13073
|
+
path: "/draft-orders/:id/billing-address"
|
|
13074
|
+
},
|
|
13075
13075
|
{
|
|
13076
13076
|
Component: Items,
|
|
13077
13077
|
path: "/draft-orders/:id/items"
|
|
@@ -13084,14 +13084,14 @@ const routeModule = {
|
|
|
13084
13084
|
Component: Promotions,
|
|
13085
13085
|
path: "/draft-orders/:id/promotions"
|
|
13086
13086
|
},
|
|
13087
|
-
{
|
|
13088
|
-
Component: Shipping,
|
|
13089
|
-
path: "/draft-orders/:id/shipping"
|
|
13090
|
-
},
|
|
13091
13087
|
{
|
|
13092
13088
|
Component: SalesChannel,
|
|
13093
13089
|
path: "/draft-orders/:id/sales-channel"
|
|
13094
13090
|
},
|
|
13091
|
+
{
|
|
13092
|
+
Component: Shipping,
|
|
13093
|
+
path: "/draft-orders/:id/shipping"
|
|
13094
|
+
},
|
|
13095
13095
|
{
|
|
13096
13096
|
Component: ShippingAddress,
|
|
13097
13097
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -9561,6 +9561,95 @@ const ID = () => {
|
|
|
9561
9561
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9562
9562
|
] });
|
|
9563
9563
|
};
|
|
9564
|
+
const CustomItems = () => {
|
|
9565
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9566
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9567
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9568
|
+
] });
|
|
9569
|
+
};
|
|
9570
|
+
const CustomItemsForm = () => {
|
|
9571
|
+
const form = useForm({
|
|
9572
|
+
resolver: zodResolver(schema$5)
|
|
9573
|
+
});
|
|
9574
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9575
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9576
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9577
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9578
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9579
|
+
] }) })
|
|
9580
|
+
] }) });
|
|
9581
|
+
};
|
|
9582
|
+
const schema$5 = objectType({
|
|
9583
|
+
email: stringType().email()
|
|
9584
|
+
});
|
|
9585
|
+
const Email = () => {
|
|
9586
|
+
const { id } = useParams();
|
|
9587
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9588
|
+
fields: "+email"
|
|
9589
|
+
});
|
|
9590
|
+
if (isError) {
|
|
9591
|
+
throw error;
|
|
9592
|
+
}
|
|
9593
|
+
const isReady = !isPending && !!order;
|
|
9594
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9595
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9596
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9597
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9598
|
+
] }),
|
|
9599
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9600
|
+
] });
|
|
9601
|
+
};
|
|
9602
|
+
const EmailForm = ({ order }) => {
|
|
9603
|
+
const form = useForm({
|
|
9604
|
+
defaultValues: {
|
|
9605
|
+
email: order.email ?? ""
|
|
9606
|
+
},
|
|
9607
|
+
resolver: zodResolver(schema$4)
|
|
9608
|
+
});
|
|
9609
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9610
|
+
const { handleSuccess } = useRouteModal();
|
|
9611
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9612
|
+
await mutateAsync(
|
|
9613
|
+
{ email: data.email },
|
|
9614
|
+
{
|
|
9615
|
+
onSuccess: () => {
|
|
9616
|
+
handleSuccess();
|
|
9617
|
+
},
|
|
9618
|
+
onError: (error) => {
|
|
9619
|
+
toast.error(error.message);
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
9622
|
+
);
|
|
9623
|
+
});
|
|
9624
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9625
|
+
KeyboundForm,
|
|
9626
|
+
{
|
|
9627
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9628
|
+
onSubmit,
|
|
9629
|
+
children: [
|
|
9630
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9631
|
+
Form$2.Field,
|
|
9632
|
+
{
|
|
9633
|
+
control: form.control,
|
|
9634
|
+
name: "email",
|
|
9635
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9636
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9637
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9638
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9639
|
+
] })
|
|
9640
|
+
}
|
|
9641
|
+
) }),
|
|
9642
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9643
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9644
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9645
|
+
] }) })
|
|
9646
|
+
]
|
|
9647
|
+
}
|
|
9648
|
+
) });
|
|
9649
|
+
};
|
|
9650
|
+
const schema$4 = objectType({
|
|
9651
|
+
email: stringType().email()
|
|
9652
|
+
});
|
|
9564
9653
|
const BillingAddress = () => {
|
|
9565
9654
|
const { id } = useParams();
|
|
9566
9655
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9593,7 +9682,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9593
9682
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9594
9683
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9595
9684
|
},
|
|
9596
|
-
resolver: zodResolver(schema$
|
|
9685
|
+
resolver: zodResolver(schema$3)
|
|
9597
9686
|
});
|
|
9598
9687
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9599
9688
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9750,96 +9839,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9750
9839
|
}
|
|
9751
9840
|
) });
|
|
9752
9841
|
};
|
|
9753
|
-
const schema$
|
|
9754
|
-
const CustomItems = () => {
|
|
9755
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9756
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9757
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9758
|
-
] });
|
|
9759
|
-
};
|
|
9760
|
-
const CustomItemsForm = () => {
|
|
9761
|
-
const form = useForm({
|
|
9762
|
-
resolver: zodResolver(schema$4)
|
|
9763
|
-
});
|
|
9764
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9765
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9766
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9767
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9768
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9769
|
-
] }) })
|
|
9770
|
-
] }) });
|
|
9771
|
-
};
|
|
9772
|
-
const schema$4 = objectType({
|
|
9773
|
-
email: stringType().email()
|
|
9774
|
-
});
|
|
9775
|
-
const Email = () => {
|
|
9776
|
-
const { id } = useParams();
|
|
9777
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9778
|
-
fields: "+email"
|
|
9779
|
-
});
|
|
9780
|
-
if (isError) {
|
|
9781
|
-
throw error;
|
|
9782
|
-
}
|
|
9783
|
-
const isReady = !isPending && !!order;
|
|
9784
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9785
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9786
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9787
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9788
|
-
] }),
|
|
9789
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9790
|
-
] });
|
|
9791
|
-
};
|
|
9792
|
-
const EmailForm = ({ order }) => {
|
|
9793
|
-
const form = useForm({
|
|
9794
|
-
defaultValues: {
|
|
9795
|
-
email: order.email ?? ""
|
|
9796
|
-
},
|
|
9797
|
-
resolver: zodResolver(schema$3)
|
|
9798
|
-
});
|
|
9799
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9800
|
-
const { handleSuccess } = useRouteModal();
|
|
9801
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9802
|
-
await mutateAsync(
|
|
9803
|
-
{ email: data.email },
|
|
9804
|
-
{
|
|
9805
|
-
onSuccess: () => {
|
|
9806
|
-
handleSuccess();
|
|
9807
|
-
},
|
|
9808
|
-
onError: (error) => {
|
|
9809
|
-
toast.error(error.message);
|
|
9810
|
-
}
|
|
9811
|
-
}
|
|
9812
|
-
);
|
|
9813
|
-
});
|
|
9814
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9815
|
-
KeyboundForm,
|
|
9816
|
-
{
|
|
9817
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9818
|
-
onSubmit,
|
|
9819
|
-
children: [
|
|
9820
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9821
|
-
Form$2.Field,
|
|
9822
|
-
{
|
|
9823
|
-
control: form.control,
|
|
9824
|
-
name: "email",
|
|
9825
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9826
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9827
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9828
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9829
|
-
] })
|
|
9830
|
-
}
|
|
9831
|
-
) }),
|
|
9832
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9833
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9834
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9835
|
-
] }) })
|
|
9836
|
-
]
|
|
9837
|
-
}
|
|
9838
|
-
) });
|
|
9839
|
-
};
|
|
9840
|
-
const schema$3 = objectType({
|
|
9841
|
-
email: stringType().email()
|
|
9842
|
-
});
|
|
9842
|
+
const schema$3 = addressSchema;
|
|
9843
9843
|
const NumberInput = forwardRef(
|
|
9844
9844
|
({
|
|
9845
9845
|
value,
|
|
@@ -11441,6 +11441,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11441
11441
|
}
|
|
11442
11442
|
return Array.from(promotionIds);
|
|
11443
11443
|
}
|
|
11444
|
+
const SalesChannel = () => {
|
|
11445
|
+
const { id } = useParams();
|
|
11446
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11447
|
+
id,
|
|
11448
|
+
{
|
|
11449
|
+
fields: "+sales_channel_id"
|
|
11450
|
+
},
|
|
11451
|
+
{
|
|
11452
|
+
enabled: !!id
|
|
11453
|
+
}
|
|
11454
|
+
);
|
|
11455
|
+
if (isError) {
|
|
11456
|
+
throw error;
|
|
11457
|
+
}
|
|
11458
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11459
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11460
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11461
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11462
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11463
|
+
] }),
|
|
11464
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11465
|
+
] });
|
|
11466
|
+
};
|
|
11467
|
+
const SalesChannelForm = ({ order }) => {
|
|
11468
|
+
const form = useForm({
|
|
11469
|
+
defaultValues: {
|
|
11470
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11471
|
+
},
|
|
11472
|
+
resolver: zodResolver(schema$2)
|
|
11473
|
+
});
|
|
11474
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11475
|
+
const { handleSuccess } = useRouteModal();
|
|
11476
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11477
|
+
await mutateAsync(
|
|
11478
|
+
{
|
|
11479
|
+
sales_channel_id: data.sales_channel_id
|
|
11480
|
+
},
|
|
11481
|
+
{
|
|
11482
|
+
onSuccess: () => {
|
|
11483
|
+
toast.success("Sales channel updated");
|
|
11484
|
+
handleSuccess();
|
|
11485
|
+
},
|
|
11486
|
+
onError: (error) => {
|
|
11487
|
+
toast.error(error.message);
|
|
11488
|
+
}
|
|
11489
|
+
}
|
|
11490
|
+
);
|
|
11491
|
+
});
|
|
11492
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11493
|
+
KeyboundForm,
|
|
11494
|
+
{
|
|
11495
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11496
|
+
onSubmit,
|
|
11497
|
+
children: [
|
|
11498
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11499
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11500
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11501
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11502
|
+
] }) })
|
|
11503
|
+
]
|
|
11504
|
+
}
|
|
11505
|
+
) });
|
|
11506
|
+
};
|
|
11507
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11508
|
+
const salesChannels = useComboboxData({
|
|
11509
|
+
queryFn: async (params) => {
|
|
11510
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11511
|
+
},
|
|
11512
|
+
queryKey: ["sales-channels"],
|
|
11513
|
+
getOptions: (data) => {
|
|
11514
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11515
|
+
label: salesChannel.name,
|
|
11516
|
+
value: salesChannel.id
|
|
11517
|
+
}));
|
|
11518
|
+
},
|
|
11519
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11520
|
+
});
|
|
11521
|
+
return /* @__PURE__ */ jsx(
|
|
11522
|
+
Form$2.Field,
|
|
11523
|
+
{
|
|
11524
|
+
control,
|
|
11525
|
+
name: "sales_channel_id",
|
|
11526
|
+
render: ({ field }) => {
|
|
11527
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11528
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11529
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11530
|
+
Combobox,
|
|
11531
|
+
{
|
|
11532
|
+
options: salesChannels.options,
|
|
11533
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11534
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11535
|
+
searchValue: salesChannels.searchValue,
|
|
11536
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11537
|
+
placeholder: "Select sales channel",
|
|
11538
|
+
...field
|
|
11539
|
+
}
|
|
11540
|
+
) }),
|
|
11541
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11542
|
+
] });
|
|
11543
|
+
}
|
|
11544
|
+
}
|
|
11545
|
+
);
|
|
11546
|
+
};
|
|
11547
|
+
const schema$2 = objectType({
|
|
11548
|
+
sales_channel_id: stringType().min(1)
|
|
11549
|
+
});
|
|
11444
11550
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11445
11551
|
const Shipping = () => {
|
|
11446
11552
|
var _a;
|
|
@@ -12248,112 +12354,6 @@ const CustomAmountField = ({
|
|
|
12248
12354
|
}
|
|
12249
12355
|
);
|
|
12250
12356
|
};
|
|
12251
|
-
const SalesChannel = () => {
|
|
12252
|
-
const { id } = useParams();
|
|
12253
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12254
|
-
id,
|
|
12255
|
-
{
|
|
12256
|
-
fields: "+sales_channel_id"
|
|
12257
|
-
},
|
|
12258
|
-
{
|
|
12259
|
-
enabled: !!id
|
|
12260
|
-
}
|
|
12261
|
-
);
|
|
12262
|
-
if (isError) {
|
|
12263
|
-
throw error;
|
|
12264
|
-
}
|
|
12265
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12266
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12267
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12268
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12269
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12270
|
-
] }),
|
|
12271
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12272
|
-
] });
|
|
12273
|
-
};
|
|
12274
|
-
const SalesChannelForm = ({ order }) => {
|
|
12275
|
-
const form = useForm({
|
|
12276
|
-
defaultValues: {
|
|
12277
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12278
|
-
},
|
|
12279
|
-
resolver: zodResolver(schema$2)
|
|
12280
|
-
});
|
|
12281
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12282
|
-
const { handleSuccess } = useRouteModal();
|
|
12283
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12284
|
-
await mutateAsync(
|
|
12285
|
-
{
|
|
12286
|
-
sales_channel_id: data.sales_channel_id
|
|
12287
|
-
},
|
|
12288
|
-
{
|
|
12289
|
-
onSuccess: () => {
|
|
12290
|
-
toast.success("Sales channel updated");
|
|
12291
|
-
handleSuccess();
|
|
12292
|
-
},
|
|
12293
|
-
onError: (error) => {
|
|
12294
|
-
toast.error(error.message);
|
|
12295
|
-
}
|
|
12296
|
-
}
|
|
12297
|
-
);
|
|
12298
|
-
});
|
|
12299
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12300
|
-
KeyboundForm,
|
|
12301
|
-
{
|
|
12302
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12303
|
-
onSubmit,
|
|
12304
|
-
children: [
|
|
12305
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12306
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12307
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12308
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12309
|
-
] }) })
|
|
12310
|
-
]
|
|
12311
|
-
}
|
|
12312
|
-
) });
|
|
12313
|
-
};
|
|
12314
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12315
|
-
const salesChannels = useComboboxData({
|
|
12316
|
-
queryFn: async (params) => {
|
|
12317
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12318
|
-
},
|
|
12319
|
-
queryKey: ["sales-channels"],
|
|
12320
|
-
getOptions: (data) => {
|
|
12321
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12322
|
-
label: salesChannel.name,
|
|
12323
|
-
value: salesChannel.id
|
|
12324
|
-
}));
|
|
12325
|
-
},
|
|
12326
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12327
|
-
});
|
|
12328
|
-
return /* @__PURE__ */ jsx(
|
|
12329
|
-
Form$2.Field,
|
|
12330
|
-
{
|
|
12331
|
-
control,
|
|
12332
|
-
name: "sales_channel_id",
|
|
12333
|
-
render: ({ field }) => {
|
|
12334
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12335
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12336
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12337
|
-
Combobox,
|
|
12338
|
-
{
|
|
12339
|
-
options: salesChannels.options,
|
|
12340
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12341
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12342
|
-
searchValue: salesChannels.searchValue,
|
|
12343
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12344
|
-
placeholder: "Select sales channel",
|
|
12345
|
-
...field
|
|
12346
|
-
}
|
|
12347
|
-
) }),
|
|
12348
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12349
|
-
] });
|
|
12350
|
-
}
|
|
12351
|
-
}
|
|
12352
|
-
);
|
|
12353
|
-
};
|
|
12354
|
-
const schema$2 = objectType({
|
|
12355
|
-
sales_channel_id: stringType().min(1)
|
|
12356
|
-
});
|
|
12357
12357
|
const ShippingAddress = () => {
|
|
12358
12358
|
const { id } = useParams();
|
|
12359
12359
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13053,10 +13053,6 @@ const routeModule = {
|
|
|
13053
13053
|
handle,
|
|
13054
13054
|
loader,
|
|
13055
13055
|
children: [
|
|
13056
|
-
{
|
|
13057
|
-
Component: BillingAddress,
|
|
13058
|
-
path: "/draft-orders/:id/billing-address"
|
|
13059
|
-
},
|
|
13060
13056
|
{
|
|
13061
13057
|
Component: CustomItems,
|
|
13062
13058
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13065,6 +13061,10 @@ const routeModule = {
|
|
|
13065
13061
|
Component: Email,
|
|
13066
13062
|
path: "/draft-orders/:id/email"
|
|
13067
13063
|
},
|
|
13064
|
+
{
|
|
13065
|
+
Component: BillingAddress,
|
|
13066
|
+
path: "/draft-orders/:id/billing-address"
|
|
13067
|
+
},
|
|
13068
13068
|
{
|
|
13069
13069
|
Component: Items,
|
|
13070
13070
|
path: "/draft-orders/:id/items"
|
|
@@ -13077,14 +13077,14 @@ const routeModule = {
|
|
|
13077
13077
|
Component: Promotions,
|
|
13078
13078
|
path: "/draft-orders/:id/promotions"
|
|
13079
13079
|
},
|
|
13080
|
-
{
|
|
13081
|
-
Component: Shipping,
|
|
13082
|
-
path: "/draft-orders/:id/shipping"
|
|
13083
|
-
},
|
|
13084
13080
|
{
|
|
13085
13081
|
Component: SalesChannel,
|
|
13086
13082
|
path: "/draft-orders/:id/sales-channel"
|
|
13087
13083
|
},
|
|
13084
|
+
{
|
|
13085
|
+
Component: Shipping,
|
|
13086
|
+
path: "/draft-orders/:id/shipping"
|
|
13087
|
+
},
|
|
13088
13088
|
{
|
|
13089
13089
|
Component: ShippingAddress,
|
|
13090
13090
|
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.11.4-preview-
|
|
3
|
+
"version": "2.11.4-preview-20251110150136",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@babel/runtime": "^7.26.10",
|
|
39
39
|
"@hookform/resolvers": "3.4.2",
|
|
40
|
-
"@medusajs/js-sdk": "2.11.4-preview-
|
|
40
|
+
"@medusajs/js-sdk": "2.11.4-preview-20251110150136",
|
|
41
41
|
"@tanstack/react-query": "5.64.2",
|
|
42
42
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
43
43
|
"date-fns": "^3.6.0",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"react-hook-form": "7.49.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@medusajs/admin-sdk": "2.11.4-preview-
|
|
52
|
-
"@medusajs/cli": "2.11.4-preview-
|
|
53
|
-
"@medusajs/framework": "2.11.4-preview-
|
|
54
|
-
"@medusajs/icons": "2.11.4-preview-
|
|
55
|
-
"@medusajs/test-utils": "2.11.4-preview-
|
|
56
|
-
"@medusajs/types": "2.11.4-preview-
|
|
57
|
-
"@medusajs/ui": "4.0.28-preview-
|
|
58
|
-
"@medusajs/ui-preset": "2.11.4-preview-
|
|
51
|
+
"@medusajs/admin-sdk": "2.11.4-preview-20251110150136",
|
|
52
|
+
"@medusajs/cli": "2.11.4-preview-20251110150136",
|
|
53
|
+
"@medusajs/framework": "2.11.4-preview-20251110150136",
|
|
54
|
+
"@medusajs/icons": "2.11.4-preview-20251110150136",
|
|
55
|
+
"@medusajs/test-utils": "2.11.4-preview-20251110150136",
|
|
56
|
+
"@medusajs/types": "2.11.4-preview-20251110150136",
|
|
57
|
+
"@medusajs/ui": "4.0.28-preview-20251110150136",
|
|
58
|
+
"@medusajs/ui-preset": "2.11.4-preview-20251110150136"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@medusajs/admin-sdk": "2.11.4-preview-
|
|
62
|
-
"@medusajs/cli": "2.11.4-preview-
|
|
63
|
-
"@medusajs/framework": "2.11.4-preview-
|
|
64
|
-
"@medusajs/icons": "2.11.4-preview-
|
|
65
|
-
"@medusajs/test-utils": "2.11.4-preview-
|
|
66
|
-
"@medusajs/ui": "4.0.28-preview-
|
|
61
|
+
"@medusajs/admin-sdk": "2.11.4-preview-20251110150136",
|
|
62
|
+
"@medusajs/cli": "2.11.4-preview-20251110150136",
|
|
63
|
+
"@medusajs/framework": "2.11.4-preview-20251110150136",
|
|
64
|
+
"@medusajs/icons": "2.11.4-preview-20251110150136",
|
|
65
|
+
"@medusajs/test-utils": "2.11.4-preview-20251110150136",
|
|
66
|
+
"@medusajs/ui": "4.0.28-preview-20251110150136",
|
|
67
67
|
"react": "^18.3.1",
|
|
68
68
|
"react-dom": "^18.3.1",
|
|
69
69
|
"react-router-dom": "6.20.1"
|