@medusajs/draft-order 2.10.4-preview-20251012090156 → 2.10.4-preview-20251012120155
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 +384 -384
- package/.medusa/server/src/admin/index.mjs +384 -384
- package/package.json +16 -16
|
@@ -9573,217 +9573,6 @@ const ID = () => {
|
|
|
9573
9573
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9574
9574
|
] });
|
|
9575
9575
|
};
|
|
9576
|
-
const BillingAddress = () => {
|
|
9577
|
-
const { id } = reactRouterDom.useParams();
|
|
9578
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9579
|
-
fields: "+billing_address"
|
|
9580
|
-
});
|
|
9581
|
-
if (isError) {
|
|
9582
|
-
throw error;
|
|
9583
|
-
}
|
|
9584
|
-
const isReady = !isPending && !!order;
|
|
9585
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9586
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9587
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9588
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9589
|
-
] }),
|
|
9590
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9591
|
-
] });
|
|
9592
|
-
};
|
|
9593
|
-
const BillingAddressForm = ({ order }) => {
|
|
9594
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9595
|
-
const form = reactHookForm.useForm({
|
|
9596
|
-
defaultValues: {
|
|
9597
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9598
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9599
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9600
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9601
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9602
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9603
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9604
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9605
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9606
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9607
|
-
},
|
|
9608
|
-
resolver: zod.zodResolver(schema$5)
|
|
9609
|
-
});
|
|
9610
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9611
|
-
const { handleSuccess } = useRouteModal();
|
|
9612
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9613
|
-
await mutateAsync(
|
|
9614
|
-
{ billing_address: data },
|
|
9615
|
-
{
|
|
9616
|
-
onSuccess: () => {
|
|
9617
|
-
handleSuccess();
|
|
9618
|
-
},
|
|
9619
|
-
onError: (error) => {
|
|
9620
|
-
ui.toast.error(error.message);
|
|
9621
|
-
}
|
|
9622
|
-
}
|
|
9623
|
-
);
|
|
9624
|
-
});
|
|
9625
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9626
|
-
KeyboundForm,
|
|
9627
|
-
{
|
|
9628
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9629
|
-
onSubmit,
|
|
9630
|
-
children: [
|
|
9631
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9632
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9633
|
-
Form$2.Field,
|
|
9634
|
-
{
|
|
9635
|
-
control: form.control,
|
|
9636
|
-
name: "country_code",
|
|
9637
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9638
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9639
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9640
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9641
|
-
] })
|
|
9642
|
-
}
|
|
9643
|
-
),
|
|
9644
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9645
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9646
|
-
Form$2.Field,
|
|
9647
|
-
{
|
|
9648
|
-
control: form.control,
|
|
9649
|
-
name: "first_name",
|
|
9650
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9651
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9652
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9653
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9654
|
-
] })
|
|
9655
|
-
}
|
|
9656
|
-
),
|
|
9657
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
|
-
Form$2.Field,
|
|
9659
|
-
{
|
|
9660
|
-
control: form.control,
|
|
9661
|
-
name: "last_name",
|
|
9662
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9663
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9664
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9665
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9666
|
-
] })
|
|
9667
|
-
}
|
|
9668
|
-
)
|
|
9669
|
-
] }),
|
|
9670
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9671
|
-
Form$2.Field,
|
|
9672
|
-
{
|
|
9673
|
-
control: form.control,
|
|
9674
|
-
name: "company",
|
|
9675
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9676
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9677
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9678
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9679
|
-
] })
|
|
9680
|
-
}
|
|
9681
|
-
),
|
|
9682
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9683
|
-
Form$2.Field,
|
|
9684
|
-
{
|
|
9685
|
-
control: form.control,
|
|
9686
|
-
name: "address_1",
|
|
9687
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9688
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9689
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9690
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9691
|
-
] })
|
|
9692
|
-
}
|
|
9693
|
-
),
|
|
9694
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
-
Form$2.Field,
|
|
9696
|
-
{
|
|
9697
|
-
control: form.control,
|
|
9698
|
-
name: "address_2",
|
|
9699
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9700
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9701
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9702
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9703
|
-
] })
|
|
9704
|
-
}
|
|
9705
|
-
),
|
|
9706
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9707
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9708
|
-
Form$2.Field,
|
|
9709
|
-
{
|
|
9710
|
-
control: form.control,
|
|
9711
|
-
name: "postal_code",
|
|
9712
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9713
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9714
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9715
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9716
|
-
] })
|
|
9717
|
-
}
|
|
9718
|
-
),
|
|
9719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
-
Form$2.Field,
|
|
9721
|
-
{
|
|
9722
|
-
control: form.control,
|
|
9723
|
-
name: "city",
|
|
9724
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9726
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9727
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9728
|
-
] })
|
|
9729
|
-
}
|
|
9730
|
-
)
|
|
9731
|
-
] }),
|
|
9732
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9733
|
-
Form$2.Field,
|
|
9734
|
-
{
|
|
9735
|
-
control: form.control,
|
|
9736
|
-
name: "province",
|
|
9737
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9738
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9739
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9740
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9741
|
-
] })
|
|
9742
|
-
}
|
|
9743
|
-
),
|
|
9744
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9745
|
-
Form$2.Field,
|
|
9746
|
-
{
|
|
9747
|
-
control: form.control,
|
|
9748
|
-
name: "phone",
|
|
9749
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9750
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9751
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9752
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9753
|
-
] })
|
|
9754
|
-
}
|
|
9755
|
-
)
|
|
9756
|
-
] }) }),
|
|
9757
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9758
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9759
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9760
|
-
] }) })
|
|
9761
|
-
]
|
|
9762
|
-
}
|
|
9763
|
-
) });
|
|
9764
|
-
};
|
|
9765
|
-
const schema$5 = addressSchema;
|
|
9766
|
-
const CustomItems = () => {
|
|
9767
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
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, {})
|
|
9770
|
-
] });
|
|
9771
|
-
};
|
|
9772
|
-
const CustomItemsForm = () => {
|
|
9773
|
-
const form = reactHookForm.useForm({
|
|
9774
|
-
resolver: zod.zodResolver(schema$4)
|
|
9775
|
-
});
|
|
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
|
-
] }) });
|
|
9783
|
-
};
|
|
9784
|
-
const schema$4 = objectType({
|
|
9785
|
-
email: stringType().email()
|
|
9786
|
-
});
|
|
9787
9576
|
const Email = () => {
|
|
9788
9577
|
const { id } = reactRouterDom.useParams();
|
|
9789
9578
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9806,7 +9595,7 @@ const EmailForm = ({ order }) => {
|
|
|
9806
9595
|
defaultValues: {
|
|
9807
9596
|
email: order.email ?? ""
|
|
9808
9597
|
},
|
|
9809
|
-
resolver: zod.zodResolver(schema$
|
|
9598
|
+
resolver: zod.zodResolver(schema$5)
|
|
9810
9599
|
});
|
|
9811
9600
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9812
9601
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9849,7 +9638,28 @@ const EmailForm = ({ order }) => {
|
|
|
9849
9638
|
}
|
|
9850
9639
|
) });
|
|
9851
9640
|
};
|
|
9852
|
-
const schema$
|
|
9641
|
+
const schema$5 = objectType({
|
|
9642
|
+
email: stringType().email()
|
|
9643
|
+
});
|
|
9644
|
+
const CustomItems = () => {
|
|
9645
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9646
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9647
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9648
|
+
] });
|
|
9649
|
+
};
|
|
9650
|
+
const CustomItemsForm = () => {
|
|
9651
|
+
const form = reactHookForm.useForm({
|
|
9652
|
+
resolver: zod.zodResolver(schema$4)
|
|
9653
|
+
});
|
|
9654
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9655
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9656
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9657
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9658
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9659
|
+
] }) })
|
|
9660
|
+
] }) });
|
|
9661
|
+
};
|
|
9662
|
+
const schema$4 = objectType({
|
|
9853
9663
|
email: stringType().email()
|
|
9854
9664
|
});
|
|
9855
9665
|
const NumberInput = React.forwardRef(
|
|
@@ -11453,28 +11263,337 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11453
11263
|
}
|
|
11454
11264
|
return Array.from(promotionIds);
|
|
11455
11265
|
}
|
|
11456
|
-
const
|
|
11457
|
-
const Shipping = () => {
|
|
11458
|
-
var _a;
|
|
11266
|
+
const SalesChannel = () => {
|
|
11459
11267
|
const { id } = reactRouterDom.useParams();
|
|
11460
|
-
const {
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11268
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11269
|
+
id,
|
|
11270
|
+
{
|
|
11271
|
+
fields: "+sales_channel_id"
|
|
11272
|
+
},
|
|
11273
|
+
{
|
|
11274
|
+
enabled: !!id
|
|
11275
|
+
}
|
|
11276
|
+
);
|
|
11277
|
+
if (isError) {
|
|
11278
|
+
throw error;
|
|
11279
|
+
}
|
|
11280
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11281
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11282
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11283
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11284
|
+
/* @__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" }) })
|
|
11285
|
+
] }),
|
|
11286
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11287
|
+
] });
|
|
11288
|
+
};
|
|
11289
|
+
const SalesChannelForm = ({ order }) => {
|
|
11290
|
+
const form = reactHookForm.useForm({
|
|
11291
|
+
defaultValues: {
|
|
11292
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11293
|
+
},
|
|
11294
|
+
resolver: zod.zodResolver(schema$3)
|
|
11295
|
+
});
|
|
11296
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11297
|
+
const { handleSuccess } = useRouteModal();
|
|
11298
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11299
|
+
await mutateAsync(
|
|
11300
|
+
{
|
|
11301
|
+
sales_channel_id: data.sales_channel_id
|
|
11302
|
+
},
|
|
11303
|
+
{
|
|
11304
|
+
onSuccess: () => {
|
|
11305
|
+
ui.toast.success("Sales channel updated");
|
|
11306
|
+
handleSuccess();
|
|
11307
|
+
},
|
|
11308
|
+
onError: (error) => {
|
|
11309
|
+
ui.toast.error(error.message);
|
|
11310
|
+
}
|
|
11311
|
+
}
|
|
11312
|
+
);
|
|
11313
|
+
});
|
|
11314
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11315
|
+
KeyboundForm,
|
|
11316
|
+
{
|
|
11317
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11318
|
+
onSubmit,
|
|
11319
|
+
children: [
|
|
11320
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11321
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11322
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11323
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11324
|
+
] }) })
|
|
11325
|
+
]
|
|
11326
|
+
}
|
|
11327
|
+
) });
|
|
11328
|
+
};
|
|
11329
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11330
|
+
const salesChannels = useComboboxData({
|
|
11331
|
+
queryFn: async (params) => {
|
|
11332
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11333
|
+
},
|
|
11334
|
+
queryKey: ["sales-channels"],
|
|
11335
|
+
getOptions: (data) => {
|
|
11336
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11337
|
+
label: salesChannel.name,
|
|
11338
|
+
value: salesChannel.id
|
|
11339
|
+
}));
|
|
11340
|
+
},
|
|
11341
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11342
|
+
});
|
|
11343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11344
|
+
Form$2.Field,
|
|
11345
|
+
{
|
|
11346
|
+
control,
|
|
11347
|
+
name: "sales_channel_id",
|
|
11348
|
+
render: ({ field }) => {
|
|
11349
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11350
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11351
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11352
|
+
Combobox,
|
|
11353
|
+
{
|
|
11354
|
+
options: salesChannels.options,
|
|
11355
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11356
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11357
|
+
searchValue: salesChannels.searchValue,
|
|
11358
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11359
|
+
placeholder: "Select sales channel",
|
|
11360
|
+
...field
|
|
11361
|
+
}
|
|
11362
|
+
) }),
|
|
11363
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11364
|
+
] });
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
);
|
|
11368
|
+
};
|
|
11369
|
+
const schema$3 = objectType({
|
|
11370
|
+
sales_channel_id: stringType().min(1)
|
|
11371
|
+
});
|
|
11372
|
+
const ShippingAddress = () => {
|
|
11373
|
+
const { id } = reactRouterDom.useParams();
|
|
11374
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11375
|
+
fields: "+shipping_address"
|
|
11376
|
+
});
|
|
11377
|
+
if (isError) {
|
|
11378
|
+
throw error;
|
|
11379
|
+
}
|
|
11380
|
+
const isReady = !isPending && !!order;
|
|
11381
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11382
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11383
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11384
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11385
|
+
] }),
|
|
11386
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11387
|
+
] });
|
|
11388
|
+
};
|
|
11389
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11390
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11391
|
+
const form = reactHookForm.useForm({
|
|
11392
|
+
defaultValues: {
|
|
11393
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11394
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11395
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11396
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11397
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11398
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11399
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11400
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11401
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11402
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11403
|
+
},
|
|
11404
|
+
resolver: zod.zodResolver(schema$2)
|
|
11405
|
+
});
|
|
11406
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11407
|
+
const { handleSuccess } = useRouteModal();
|
|
11408
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11409
|
+
await mutateAsync(
|
|
11410
|
+
{
|
|
11411
|
+
shipping_address: {
|
|
11412
|
+
first_name: data.first_name,
|
|
11413
|
+
last_name: data.last_name,
|
|
11414
|
+
company: data.company,
|
|
11415
|
+
address_1: data.address_1,
|
|
11416
|
+
address_2: data.address_2,
|
|
11417
|
+
city: data.city,
|
|
11418
|
+
province: data.province,
|
|
11419
|
+
country_code: data.country_code,
|
|
11420
|
+
postal_code: data.postal_code,
|
|
11421
|
+
phone: data.phone
|
|
11422
|
+
}
|
|
11423
|
+
},
|
|
11424
|
+
{
|
|
11425
|
+
onSuccess: () => {
|
|
11426
|
+
handleSuccess();
|
|
11427
|
+
},
|
|
11428
|
+
onError: (error) => {
|
|
11429
|
+
ui.toast.error(error.message);
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
);
|
|
11433
|
+
});
|
|
11434
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11435
|
+
KeyboundForm,
|
|
11436
|
+
{
|
|
11437
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11438
|
+
onSubmit,
|
|
11439
|
+
children: [
|
|
11440
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
11441
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11442
|
+
Form$2.Field,
|
|
11443
|
+
{
|
|
11444
|
+
control: form.control,
|
|
11445
|
+
name: "country_code",
|
|
11446
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11447
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11448
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11449
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11450
|
+
] })
|
|
11451
|
+
}
|
|
11452
|
+
),
|
|
11453
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11454
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11455
|
+
Form$2.Field,
|
|
11456
|
+
{
|
|
11457
|
+
control: form.control,
|
|
11458
|
+
name: "first_name",
|
|
11459
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11460
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11461
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11462
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11463
|
+
] })
|
|
11464
|
+
}
|
|
11465
|
+
),
|
|
11466
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11467
|
+
Form$2.Field,
|
|
11468
|
+
{
|
|
11469
|
+
control: form.control,
|
|
11470
|
+
name: "last_name",
|
|
11471
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11472
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11473
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11474
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11475
|
+
] })
|
|
11476
|
+
}
|
|
11477
|
+
)
|
|
11478
|
+
] }),
|
|
11479
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11480
|
+
Form$2.Field,
|
|
11481
|
+
{
|
|
11482
|
+
control: form.control,
|
|
11483
|
+
name: "company",
|
|
11484
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11485
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11486
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11487
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11488
|
+
] })
|
|
11489
|
+
}
|
|
11490
|
+
),
|
|
11491
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11492
|
+
Form$2.Field,
|
|
11493
|
+
{
|
|
11494
|
+
control: form.control,
|
|
11495
|
+
name: "address_1",
|
|
11496
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11497
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11498
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11499
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11500
|
+
] })
|
|
11501
|
+
}
|
|
11502
|
+
),
|
|
11503
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11504
|
+
Form$2.Field,
|
|
11505
|
+
{
|
|
11506
|
+
control: form.control,
|
|
11507
|
+
name: "address_2",
|
|
11508
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11509
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11510
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11511
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11512
|
+
] })
|
|
11513
|
+
}
|
|
11514
|
+
),
|
|
11515
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11516
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11517
|
+
Form$2.Field,
|
|
11518
|
+
{
|
|
11519
|
+
control: form.control,
|
|
11520
|
+
name: "postal_code",
|
|
11521
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11522
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11523
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11524
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11525
|
+
] })
|
|
11526
|
+
}
|
|
11527
|
+
),
|
|
11528
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
+
Form$2.Field,
|
|
11530
|
+
{
|
|
11531
|
+
control: form.control,
|
|
11532
|
+
name: "city",
|
|
11533
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11534
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11535
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11536
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11537
|
+
] })
|
|
11538
|
+
}
|
|
11539
|
+
)
|
|
11540
|
+
] }),
|
|
11541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11542
|
+
Form$2.Field,
|
|
11543
|
+
{
|
|
11544
|
+
control: form.control,
|
|
11545
|
+
name: "province",
|
|
11546
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11547
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11548
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11549
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11550
|
+
] })
|
|
11551
|
+
}
|
|
11552
|
+
),
|
|
11553
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11554
|
+
Form$2.Field,
|
|
11555
|
+
{
|
|
11556
|
+
control: form.control,
|
|
11557
|
+
name: "phone",
|
|
11558
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11559
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11560
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11561
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11562
|
+
] })
|
|
11563
|
+
}
|
|
11564
|
+
)
|
|
11565
|
+
] }) }),
|
|
11566
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11567
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11568
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11569
|
+
] }) })
|
|
11570
|
+
]
|
|
11571
|
+
}
|
|
11572
|
+
) });
|
|
11573
|
+
};
|
|
11574
|
+
const schema$2 = addressSchema;
|
|
11575
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11576
|
+
const Shipping = () => {
|
|
11577
|
+
var _a;
|
|
11578
|
+
const { id } = reactRouterDom.useParams();
|
|
11579
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11580
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11581
|
+
});
|
|
11582
|
+
const {
|
|
11583
|
+
order: preview,
|
|
11584
|
+
isPending: isPreviewPending,
|
|
11585
|
+
isError: isPreviewError,
|
|
11586
|
+
error: previewError
|
|
11587
|
+
} = useOrderPreview(id);
|
|
11588
|
+
useInitiateOrderEdit({ preview });
|
|
11589
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11590
|
+
if (isError) {
|
|
11591
|
+
throw error;
|
|
11592
|
+
}
|
|
11593
|
+
if (isPreviewError) {
|
|
11594
|
+
throw previewError;
|
|
11595
|
+
}
|
|
11596
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11478
11597
|
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11479
11598
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11480
11599
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
@@ -12283,7 +12402,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12283
12402
|
defaultValues: {
|
|
12284
12403
|
customer_id: order.customer_id || ""
|
|
12285
12404
|
},
|
|
12286
|
-
resolver: zod.zodResolver(schema$
|
|
12405
|
+
resolver: zod.zodResolver(schema$1)
|
|
12287
12406
|
});
|
|
12288
12407
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12289
12408
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12733,119 +12852,13 @@ const Illustration = () => {
|
|
|
12733
12852
|
}
|
|
12734
12853
|
);
|
|
12735
12854
|
};
|
|
12736
|
-
const schema$2 = objectType({
|
|
12737
|
-
customer_id: stringType().min(1)
|
|
12738
|
-
});
|
|
12739
|
-
const SalesChannel = () => {
|
|
12740
|
-
const { id } = reactRouterDom.useParams();
|
|
12741
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12742
|
-
id,
|
|
12743
|
-
{
|
|
12744
|
-
fields: "+sales_channel_id"
|
|
12745
|
-
},
|
|
12746
|
-
{
|
|
12747
|
-
enabled: !!id
|
|
12748
|
-
}
|
|
12749
|
-
);
|
|
12750
|
-
if (isError) {
|
|
12751
|
-
throw error;
|
|
12752
|
-
}
|
|
12753
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12754
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12755
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12756
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12757
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12758
|
-
] }),
|
|
12759
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12760
|
-
] });
|
|
12761
|
-
};
|
|
12762
|
-
const SalesChannelForm = ({ order }) => {
|
|
12763
|
-
const form = reactHookForm.useForm({
|
|
12764
|
-
defaultValues: {
|
|
12765
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12766
|
-
},
|
|
12767
|
-
resolver: zod.zodResolver(schema$1)
|
|
12768
|
-
});
|
|
12769
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12770
|
-
const { handleSuccess } = useRouteModal();
|
|
12771
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12772
|
-
await mutateAsync(
|
|
12773
|
-
{
|
|
12774
|
-
sales_channel_id: data.sales_channel_id
|
|
12775
|
-
},
|
|
12776
|
-
{
|
|
12777
|
-
onSuccess: () => {
|
|
12778
|
-
ui.toast.success("Sales channel updated");
|
|
12779
|
-
handleSuccess();
|
|
12780
|
-
},
|
|
12781
|
-
onError: (error) => {
|
|
12782
|
-
ui.toast.error(error.message);
|
|
12783
|
-
}
|
|
12784
|
-
}
|
|
12785
|
-
);
|
|
12786
|
-
});
|
|
12787
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12788
|
-
KeyboundForm,
|
|
12789
|
-
{
|
|
12790
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12791
|
-
onSubmit,
|
|
12792
|
-
children: [
|
|
12793
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12794
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12795
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12796
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12797
|
-
] }) })
|
|
12798
|
-
]
|
|
12799
|
-
}
|
|
12800
|
-
) });
|
|
12801
|
-
};
|
|
12802
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12803
|
-
const salesChannels = useComboboxData({
|
|
12804
|
-
queryFn: async (params) => {
|
|
12805
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12806
|
-
},
|
|
12807
|
-
queryKey: ["sales-channels"],
|
|
12808
|
-
getOptions: (data) => {
|
|
12809
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12810
|
-
label: salesChannel.name,
|
|
12811
|
-
value: salesChannel.id
|
|
12812
|
-
}));
|
|
12813
|
-
},
|
|
12814
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12815
|
-
});
|
|
12816
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12817
|
-
Form$2.Field,
|
|
12818
|
-
{
|
|
12819
|
-
control,
|
|
12820
|
-
name: "sales_channel_id",
|
|
12821
|
-
render: ({ field }) => {
|
|
12822
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12823
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12824
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12825
|
-
Combobox,
|
|
12826
|
-
{
|
|
12827
|
-
options: salesChannels.options,
|
|
12828
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12829
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12830
|
-
searchValue: salesChannels.searchValue,
|
|
12831
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12832
|
-
placeholder: "Select sales channel",
|
|
12833
|
-
...field
|
|
12834
|
-
}
|
|
12835
|
-
) }),
|
|
12836
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12837
|
-
] });
|
|
12838
|
-
}
|
|
12839
|
-
}
|
|
12840
|
-
);
|
|
12841
|
-
};
|
|
12842
12855
|
const schema$1 = objectType({
|
|
12843
|
-
|
|
12856
|
+
customer_id: stringType().min(1)
|
|
12844
12857
|
});
|
|
12845
|
-
const
|
|
12858
|
+
const BillingAddress = () => {
|
|
12846
12859
|
const { id } = reactRouterDom.useParams();
|
|
12847
12860
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12848
|
-
fields: "+
|
|
12861
|
+
fields: "+billing_address"
|
|
12849
12862
|
});
|
|
12850
12863
|
if (isError) {
|
|
12851
12864
|
throw error;
|
|
@@ -12853,26 +12866,26 @@ const ShippingAddress = () => {
|
|
|
12853
12866
|
const isReady = !isPending && !!order;
|
|
12854
12867
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12855
12868
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12856
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit
|
|
12857
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the
|
|
12869
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
12870
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12858
12871
|
] }),
|
|
12859
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12872
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
12860
12873
|
] });
|
|
12861
12874
|
};
|
|
12862
|
-
const
|
|
12875
|
+
const BillingAddressForm = ({ order }) => {
|
|
12863
12876
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12864
12877
|
const form = reactHookForm.useForm({
|
|
12865
12878
|
defaultValues: {
|
|
12866
|
-
first_name: ((_a = order.
|
|
12867
|
-
last_name: ((_b = order.
|
|
12868
|
-
company: ((_c = order.
|
|
12869
|
-
address_1: ((_d = order.
|
|
12870
|
-
address_2: ((_e = order.
|
|
12871
|
-
city: ((_f = order.
|
|
12872
|
-
province: ((_g = order.
|
|
12873
|
-
country_code: ((_h = order.
|
|
12874
|
-
postal_code: ((_i = order.
|
|
12875
|
-
phone: ((_j = order.
|
|
12879
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12880
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12881
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12882
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12883
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12884
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12885
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12886
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12887
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12888
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12876
12889
|
},
|
|
12877
12890
|
resolver: zod.zodResolver(schema)
|
|
12878
12891
|
});
|
|
@@ -12880,20 +12893,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12880
12893
|
const { handleSuccess } = useRouteModal();
|
|
12881
12894
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12882
12895
|
await mutateAsync(
|
|
12883
|
-
{
|
|
12884
|
-
shipping_address: {
|
|
12885
|
-
first_name: data.first_name,
|
|
12886
|
-
last_name: data.last_name,
|
|
12887
|
-
company: data.company,
|
|
12888
|
-
address_1: data.address_1,
|
|
12889
|
-
address_2: data.address_2,
|
|
12890
|
-
city: data.city,
|
|
12891
|
-
province: data.province,
|
|
12892
|
-
country_code: data.country_code,
|
|
12893
|
-
postal_code: data.postal_code,
|
|
12894
|
-
phone: data.phone
|
|
12895
|
-
}
|
|
12896
|
-
},
|
|
12896
|
+
{ billing_address: data },
|
|
12897
12897
|
{
|
|
12898
12898
|
onSuccess: () => {
|
|
12899
12899
|
handleSuccess();
|
|
@@ -13066,17 +13066,13 @@ const routeModule = {
|
|
|
13066
13066
|
loader,
|
|
13067
13067
|
children: [
|
|
13068
13068
|
{
|
|
13069
|
-
Component:
|
|
13070
|
-
path: "/draft-orders/:id/
|
|
13069
|
+
Component: Email,
|
|
13070
|
+
path: "/draft-orders/:id/email"
|
|
13071
13071
|
},
|
|
13072
13072
|
{
|
|
13073
13073
|
Component: CustomItems,
|
|
13074
13074
|
path: "/draft-orders/:id/custom-items"
|
|
13075
13075
|
},
|
|
13076
|
-
{
|
|
13077
|
-
Component: Email,
|
|
13078
|
-
path: "/draft-orders/:id/email"
|
|
13079
|
-
},
|
|
13080
13076
|
{
|
|
13081
13077
|
Component: Items,
|
|
13082
13078
|
path: "/draft-orders/:id/items"
|
|
@@ -13089,6 +13085,14 @@ const routeModule = {
|
|
|
13089
13085
|
Component: Promotions,
|
|
13090
13086
|
path: "/draft-orders/:id/promotions"
|
|
13091
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: SalesChannel,
|
|
13090
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13091
|
+
},
|
|
13092
|
+
{
|
|
13093
|
+
Component: ShippingAddress,
|
|
13094
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13095
|
+
},
|
|
13092
13096
|
{
|
|
13093
13097
|
Component: Shipping,
|
|
13094
13098
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13098,12 +13102,8 @@ const routeModule = {
|
|
|
13098
13102
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13099
13103
|
},
|
|
13100
13104
|
{
|
|
13101
|
-
Component:
|
|
13102
|
-
path: "/draft-orders/:id/
|
|
13103
|
-
},
|
|
13104
|
-
{
|
|
13105
|
-
Component: ShippingAddress,
|
|
13106
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13105
|
+
Component: BillingAddress,
|
|
13106
|
+
path: "/draft-orders/:id/billing-address"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|