@medusajs/draft-order 2.11.3-preview-20251102000316 → 2.11.3-preview-20251102060143
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 +209 -209
- package/.medusa/server/src/admin/index.mjs +209 -209
- package/package.json +16 -16
|
@@ -11558,6 +11558,209 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11558
11558
|
const schema$2 = objectType({
|
|
11559
11559
|
sales_channel_id: stringType().min(1)
|
|
11560
11560
|
});
|
|
11561
|
+
const ShippingAddress = () => {
|
|
11562
|
+
const { id } = reactRouterDom.useParams();
|
|
11563
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11564
|
+
fields: "+shipping_address"
|
|
11565
|
+
});
|
|
11566
|
+
if (isError) {
|
|
11567
|
+
throw error;
|
|
11568
|
+
}
|
|
11569
|
+
const isReady = !isPending && !!order;
|
|
11570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11571
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11572
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11573
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11574
|
+
] }),
|
|
11575
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11576
|
+
] });
|
|
11577
|
+
};
|
|
11578
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11579
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11580
|
+
const form = reactHookForm.useForm({
|
|
11581
|
+
defaultValues: {
|
|
11582
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11583
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11584
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11585
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11586
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11587
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11588
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11589
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11590
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11591
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11592
|
+
},
|
|
11593
|
+
resolver: zod.zodResolver(schema$1)
|
|
11594
|
+
});
|
|
11595
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11596
|
+
const { handleSuccess } = useRouteModal();
|
|
11597
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11598
|
+
await mutateAsync(
|
|
11599
|
+
{
|
|
11600
|
+
shipping_address: {
|
|
11601
|
+
first_name: data.first_name,
|
|
11602
|
+
last_name: data.last_name,
|
|
11603
|
+
company: data.company,
|
|
11604
|
+
address_1: data.address_1,
|
|
11605
|
+
address_2: data.address_2,
|
|
11606
|
+
city: data.city,
|
|
11607
|
+
province: data.province,
|
|
11608
|
+
country_code: data.country_code,
|
|
11609
|
+
postal_code: data.postal_code,
|
|
11610
|
+
phone: data.phone
|
|
11611
|
+
}
|
|
11612
|
+
},
|
|
11613
|
+
{
|
|
11614
|
+
onSuccess: () => {
|
|
11615
|
+
handleSuccess();
|
|
11616
|
+
},
|
|
11617
|
+
onError: (error) => {
|
|
11618
|
+
ui.toast.error(error.message);
|
|
11619
|
+
}
|
|
11620
|
+
}
|
|
11621
|
+
);
|
|
11622
|
+
});
|
|
11623
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11624
|
+
KeyboundForm,
|
|
11625
|
+
{
|
|
11626
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11627
|
+
onSubmit,
|
|
11628
|
+
children: [
|
|
11629
|
+
/* @__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: [
|
|
11630
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11631
|
+
Form$2.Field,
|
|
11632
|
+
{
|
|
11633
|
+
control: form.control,
|
|
11634
|
+
name: "country_code",
|
|
11635
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11636
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11637
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11639
|
+
] })
|
|
11640
|
+
}
|
|
11641
|
+
),
|
|
11642
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11643
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11644
|
+
Form$2.Field,
|
|
11645
|
+
{
|
|
11646
|
+
control: form.control,
|
|
11647
|
+
name: "first_name",
|
|
11648
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11649
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11652
|
+
] })
|
|
11653
|
+
}
|
|
11654
|
+
),
|
|
11655
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11656
|
+
Form$2.Field,
|
|
11657
|
+
{
|
|
11658
|
+
control: form.control,
|
|
11659
|
+
name: "last_name",
|
|
11660
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11661
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11662
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11664
|
+
] })
|
|
11665
|
+
}
|
|
11666
|
+
)
|
|
11667
|
+
] }),
|
|
11668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11669
|
+
Form$2.Field,
|
|
11670
|
+
{
|
|
11671
|
+
control: form.control,
|
|
11672
|
+
name: "company",
|
|
11673
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11674
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11677
|
+
] })
|
|
11678
|
+
}
|
|
11679
|
+
),
|
|
11680
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11681
|
+
Form$2.Field,
|
|
11682
|
+
{
|
|
11683
|
+
control: form.control,
|
|
11684
|
+
name: "address_1",
|
|
11685
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11686
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11689
|
+
] })
|
|
11690
|
+
}
|
|
11691
|
+
),
|
|
11692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11693
|
+
Form$2.Field,
|
|
11694
|
+
{
|
|
11695
|
+
control: form.control,
|
|
11696
|
+
name: "address_2",
|
|
11697
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11698
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11699
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11701
|
+
] })
|
|
11702
|
+
}
|
|
11703
|
+
),
|
|
11704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11706
|
+
Form$2.Field,
|
|
11707
|
+
{
|
|
11708
|
+
control: form.control,
|
|
11709
|
+
name: "postal_code",
|
|
11710
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11711
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11714
|
+
] })
|
|
11715
|
+
}
|
|
11716
|
+
),
|
|
11717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11718
|
+
Form$2.Field,
|
|
11719
|
+
{
|
|
11720
|
+
control: form.control,
|
|
11721
|
+
name: "city",
|
|
11722
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11723
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11724
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11726
|
+
] })
|
|
11727
|
+
}
|
|
11728
|
+
)
|
|
11729
|
+
] }),
|
|
11730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11731
|
+
Form$2.Field,
|
|
11732
|
+
{
|
|
11733
|
+
control: form.control,
|
|
11734
|
+
name: "province",
|
|
11735
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11736
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11739
|
+
] })
|
|
11740
|
+
}
|
|
11741
|
+
),
|
|
11742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11743
|
+
Form$2.Field,
|
|
11744
|
+
{
|
|
11745
|
+
control: form.control,
|
|
11746
|
+
name: "phone",
|
|
11747
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11748
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11749
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11750
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11751
|
+
] })
|
|
11752
|
+
}
|
|
11753
|
+
)
|
|
11754
|
+
] }) }),
|
|
11755
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11756
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11757
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11758
|
+
] }) })
|
|
11759
|
+
]
|
|
11760
|
+
}
|
|
11761
|
+
) });
|
|
11762
|
+
};
|
|
11763
|
+
const schema$1 = addressSchema;
|
|
11561
11764
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11562
11765
|
const Shipping = () => {
|
|
11563
11766
|
var _a;
|
|
@@ -12388,7 +12591,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12388
12591
|
defaultValues: {
|
|
12389
12592
|
customer_id: order.customer_id || ""
|
|
12390
12593
|
},
|
|
12391
|
-
resolver: zod.zodResolver(schema
|
|
12594
|
+
resolver: zod.zodResolver(schema)
|
|
12392
12595
|
});
|
|
12393
12596
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12394
12597
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12838,212 +13041,9 @@ const Illustration = () => {
|
|
|
12838
13041
|
}
|
|
12839
13042
|
);
|
|
12840
13043
|
};
|
|
12841
|
-
const schema
|
|
13044
|
+
const schema = objectType({
|
|
12842
13045
|
customer_id: stringType().min(1)
|
|
12843
13046
|
});
|
|
12844
|
-
const ShippingAddress = () => {
|
|
12845
|
-
const { id } = reactRouterDom.useParams();
|
|
12846
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12847
|
-
fields: "+shipping_address"
|
|
12848
|
-
});
|
|
12849
|
-
if (isError) {
|
|
12850
|
-
throw error;
|
|
12851
|
-
}
|
|
12852
|
-
const isReady = !isPending && !!order;
|
|
12853
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12854
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12855
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12856
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12857
|
-
] }),
|
|
12858
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12859
|
-
] });
|
|
12860
|
-
};
|
|
12861
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12862
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12863
|
-
const form = reactHookForm.useForm({
|
|
12864
|
-
defaultValues: {
|
|
12865
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12866
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12867
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12868
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12869
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12870
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12871
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12872
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12873
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12874
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12875
|
-
},
|
|
12876
|
-
resolver: zod.zodResolver(schema)
|
|
12877
|
-
});
|
|
12878
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12879
|
-
const { handleSuccess } = useRouteModal();
|
|
12880
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12881
|
-
await mutateAsync(
|
|
12882
|
-
{
|
|
12883
|
-
shipping_address: {
|
|
12884
|
-
first_name: data.first_name,
|
|
12885
|
-
last_name: data.last_name,
|
|
12886
|
-
company: data.company,
|
|
12887
|
-
address_1: data.address_1,
|
|
12888
|
-
address_2: data.address_2,
|
|
12889
|
-
city: data.city,
|
|
12890
|
-
province: data.province,
|
|
12891
|
-
country_code: data.country_code,
|
|
12892
|
-
postal_code: data.postal_code,
|
|
12893
|
-
phone: data.phone
|
|
12894
|
-
}
|
|
12895
|
-
},
|
|
12896
|
-
{
|
|
12897
|
-
onSuccess: () => {
|
|
12898
|
-
handleSuccess();
|
|
12899
|
-
},
|
|
12900
|
-
onError: (error) => {
|
|
12901
|
-
ui.toast.error(error.message);
|
|
12902
|
-
}
|
|
12903
|
-
}
|
|
12904
|
-
);
|
|
12905
|
-
});
|
|
12906
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12907
|
-
KeyboundForm,
|
|
12908
|
-
{
|
|
12909
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12910
|
-
onSubmit,
|
|
12911
|
-
children: [
|
|
12912
|
-
/* @__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: [
|
|
12913
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12914
|
-
Form$2.Field,
|
|
12915
|
-
{
|
|
12916
|
-
control: form.control,
|
|
12917
|
-
name: "country_code",
|
|
12918
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12919
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12920
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12921
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12922
|
-
] })
|
|
12923
|
-
}
|
|
12924
|
-
),
|
|
12925
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12926
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12927
|
-
Form$2.Field,
|
|
12928
|
-
{
|
|
12929
|
-
control: form.control,
|
|
12930
|
-
name: "first_name",
|
|
12931
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12932
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12933
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12934
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12935
|
-
] })
|
|
12936
|
-
}
|
|
12937
|
-
),
|
|
12938
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12939
|
-
Form$2.Field,
|
|
12940
|
-
{
|
|
12941
|
-
control: form.control,
|
|
12942
|
-
name: "last_name",
|
|
12943
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12944
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12945
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12946
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12947
|
-
] })
|
|
12948
|
-
}
|
|
12949
|
-
)
|
|
12950
|
-
] }),
|
|
12951
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12952
|
-
Form$2.Field,
|
|
12953
|
-
{
|
|
12954
|
-
control: form.control,
|
|
12955
|
-
name: "company",
|
|
12956
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12957
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12959
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12960
|
-
] })
|
|
12961
|
-
}
|
|
12962
|
-
),
|
|
12963
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12964
|
-
Form$2.Field,
|
|
12965
|
-
{
|
|
12966
|
-
control: form.control,
|
|
12967
|
-
name: "address_1",
|
|
12968
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12969
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12972
|
-
] })
|
|
12973
|
-
}
|
|
12974
|
-
),
|
|
12975
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12976
|
-
Form$2.Field,
|
|
12977
|
-
{
|
|
12978
|
-
control: form.control,
|
|
12979
|
-
name: "address_2",
|
|
12980
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12981
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12982
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12983
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12984
|
-
] })
|
|
12985
|
-
}
|
|
12986
|
-
),
|
|
12987
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12988
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12989
|
-
Form$2.Field,
|
|
12990
|
-
{
|
|
12991
|
-
control: form.control,
|
|
12992
|
-
name: "postal_code",
|
|
12993
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12995
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12996
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12997
|
-
] })
|
|
12998
|
-
}
|
|
12999
|
-
),
|
|
13000
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13001
|
-
Form$2.Field,
|
|
13002
|
-
{
|
|
13003
|
-
control: form.control,
|
|
13004
|
-
name: "city",
|
|
13005
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13006
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13007
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13008
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13009
|
-
] })
|
|
13010
|
-
}
|
|
13011
|
-
)
|
|
13012
|
-
] }),
|
|
13013
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
-
Form$2.Field,
|
|
13015
|
-
{
|
|
13016
|
-
control: form.control,
|
|
13017
|
-
name: "province",
|
|
13018
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13019
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13020
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13021
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13022
|
-
] })
|
|
13023
|
-
}
|
|
13024
|
-
),
|
|
13025
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13026
|
-
Form$2.Field,
|
|
13027
|
-
{
|
|
13028
|
-
control: form.control,
|
|
13029
|
-
name: "phone",
|
|
13030
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13031
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13033
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13034
|
-
] })
|
|
13035
|
-
}
|
|
13036
|
-
)
|
|
13037
|
-
] }) }),
|
|
13038
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13039
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13040
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13041
|
-
] }) })
|
|
13042
|
-
]
|
|
13043
|
-
}
|
|
13044
|
-
) });
|
|
13045
|
-
};
|
|
13046
|
-
const schema = addressSchema;
|
|
13047
13047
|
const widgetModule = { widgets: [] };
|
|
13048
13048
|
const routeModule = {
|
|
13049
13049
|
routes: [
|
|
@@ -13092,6 +13092,10 @@ const routeModule = {
|
|
|
13092
13092
|
Component: SalesChannel,
|
|
13093
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
13094
13094
|
},
|
|
13095
|
+
{
|
|
13096
|
+
Component: ShippingAddress,
|
|
13097
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13098
|
+
},
|
|
13095
13099
|
{
|
|
13096
13100
|
Component: Shipping,
|
|
13097
13101
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13099,10 +13103,6 @@ const routeModule = {
|
|
|
13099
13103
|
{
|
|
13100
13104
|
Component: TransferOwnership,
|
|
13101
13105
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13102
|
-
},
|
|
13103
|
-
{
|
|
13104
|
-
Component: ShippingAddress,
|
|
13105
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13106
13106
|
}
|
|
13107
13107
|
]
|
|
13108
13108
|
}
|
|
@@ -11551,6 +11551,209 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11551
11551
|
const schema$2 = objectType({
|
|
11552
11552
|
sales_channel_id: stringType().min(1)
|
|
11553
11553
|
});
|
|
11554
|
+
const ShippingAddress = () => {
|
|
11555
|
+
const { id } = useParams();
|
|
11556
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11557
|
+
fields: "+shipping_address"
|
|
11558
|
+
});
|
|
11559
|
+
if (isError) {
|
|
11560
|
+
throw error;
|
|
11561
|
+
}
|
|
11562
|
+
const isReady = !isPending && !!order;
|
|
11563
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11564
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11565
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
11566
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11567
|
+
] }),
|
|
11568
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
11569
|
+
] });
|
|
11570
|
+
};
|
|
11571
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11572
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11573
|
+
const form = useForm({
|
|
11574
|
+
defaultValues: {
|
|
11575
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11576
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11577
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11578
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11579
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11580
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11581
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11582
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11583
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11584
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11585
|
+
},
|
|
11586
|
+
resolver: zodResolver(schema$1)
|
|
11587
|
+
});
|
|
11588
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11589
|
+
const { handleSuccess } = useRouteModal();
|
|
11590
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11591
|
+
await mutateAsync(
|
|
11592
|
+
{
|
|
11593
|
+
shipping_address: {
|
|
11594
|
+
first_name: data.first_name,
|
|
11595
|
+
last_name: data.last_name,
|
|
11596
|
+
company: data.company,
|
|
11597
|
+
address_1: data.address_1,
|
|
11598
|
+
address_2: data.address_2,
|
|
11599
|
+
city: data.city,
|
|
11600
|
+
province: data.province,
|
|
11601
|
+
country_code: data.country_code,
|
|
11602
|
+
postal_code: data.postal_code,
|
|
11603
|
+
phone: data.phone
|
|
11604
|
+
}
|
|
11605
|
+
},
|
|
11606
|
+
{
|
|
11607
|
+
onSuccess: () => {
|
|
11608
|
+
handleSuccess();
|
|
11609
|
+
},
|
|
11610
|
+
onError: (error) => {
|
|
11611
|
+
toast.error(error.message);
|
|
11612
|
+
}
|
|
11613
|
+
}
|
|
11614
|
+
);
|
|
11615
|
+
});
|
|
11616
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11617
|
+
KeyboundForm,
|
|
11618
|
+
{
|
|
11619
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11620
|
+
onSubmit,
|
|
11621
|
+
children: [
|
|
11622
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
11623
|
+
/* @__PURE__ */ jsx(
|
|
11624
|
+
Form$2.Field,
|
|
11625
|
+
{
|
|
11626
|
+
control: form.control,
|
|
11627
|
+
name: "country_code",
|
|
11628
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11629
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11630
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11631
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11632
|
+
] })
|
|
11633
|
+
}
|
|
11634
|
+
),
|
|
11635
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11636
|
+
/* @__PURE__ */ jsx(
|
|
11637
|
+
Form$2.Field,
|
|
11638
|
+
{
|
|
11639
|
+
control: form.control,
|
|
11640
|
+
name: "first_name",
|
|
11641
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11642
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11643
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11644
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11645
|
+
] })
|
|
11646
|
+
}
|
|
11647
|
+
),
|
|
11648
|
+
/* @__PURE__ */ jsx(
|
|
11649
|
+
Form$2.Field,
|
|
11650
|
+
{
|
|
11651
|
+
control: form.control,
|
|
11652
|
+
name: "last_name",
|
|
11653
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11654
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11655
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11656
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11657
|
+
] })
|
|
11658
|
+
}
|
|
11659
|
+
)
|
|
11660
|
+
] }),
|
|
11661
|
+
/* @__PURE__ */ jsx(
|
|
11662
|
+
Form$2.Field,
|
|
11663
|
+
{
|
|
11664
|
+
control: form.control,
|
|
11665
|
+
name: "company",
|
|
11666
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11667
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11668
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11669
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11670
|
+
] })
|
|
11671
|
+
}
|
|
11672
|
+
),
|
|
11673
|
+
/* @__PURE__ */ jsx(
|
|
11674
|
+
Form$2.Field,
|
|
11675
|
+
{
|
|
11676
|
+
control: form.control,
|
|
11677
|
+
name: "address_1",
|
|
11678
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11679
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11680
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11681
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11682
|
+
] })
|
|
11683
|
+
}
|
|
11684
|
+
),
|
|
11685
|
+
/* @__PURE__ */ jsx(
|
|
11686
|
+
Form$2.Field,
|
|
11687
|
+
{
|
|
11688
|
+
control: form.control,
|
|
11689
|
+
name: "address_2",
|
|
11690
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11691
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11692
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11693
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11694
|
+
] })
|
|
11695
|
+
}
|
|
11696
|
+
),
|
|
11697
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11698
|
+
/* @__PURE__ */ jsx(
|
|
11699
|
+
Form$2.Field,
|
|
11700
|
+
{
|
|
11701
|
+
control: form.control,
|
|
11702
|
+
name: "postal_code",
|
|
11703
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11704
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11705
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11706
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11707
|
+
] })
|
|
11708
|
+
}
|
|
11709
|
+
),
|
|
11710
|
+
/* @__PURE__ */ jsx(
|
|
11711
|
+
Form$2.Field,
|
|
11712
|
+
{
|
|
11713
|
+
control: form.control,
|
|
11714
|
+
name: "city",
|
|
11715
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11716
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11717
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11718
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11719
|
+
] })
|
|
11720
|
+
}
|
|
11721
|
+
)
|
|
11722
|
+
] }),
|
|
11723
|
+
/* @__PURE__ */ jsx(
|
|
11724
|
+
Form$2.Field,
|
|
11725
|
+
{
|
|
11726
|
+
control: form.control,
|
|
11727
|
+
name: "province",
|
|
11728
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11729
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11730
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11731
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11732
|
+
] })
|
|
11733
|
+
}
|
|
11734
|
+
),
|
|
11735
|
+
/* @__PURE__ */ jsx(
|
|
11736
|
+
Form$2.Field,
|
|
11737
|
+
{
|
|
11738
|
+
control: form.control,
|
|
11739
|
+
name: "phone",
|
|
11740
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11741
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11742
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11743
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11744
|
+
] })
|
|
11745
|
+
}
|
|
11746
|
+
)
|
|
11747
|
+
] }) }),
|
|
11748
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11749
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11750
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11751
|
+
] }) })
|
|
11752
|
+
]
|
|
11753
|
+
}
|
|
11754
|
+
) });
|
|
11755
|
+
};
|
|
11756
|
+
const schema$1 = addressSchema;
|
|
11554
11757
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11555
11758
|
const Shipping = () => {
|
|
11556
11759
|
var _a;
|
|
@@ -12381,7 +12584,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12381
12584
|
defaultValues: {
|
|
12382
12585
|
customer_id: order.customer_id || ""
|
|
12383
12586
|
},
|
|
12384
|
-
resolver: zodResolver(schema
|
|
12587
|
+
resolver: zodResolver(schema)
|
|
12385
12588
|
});
|
|
12386
12589
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12387
12590
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12831,212 +13034,9 @@ const Illustration = () => {
|
|
|
12831
13034
|
}
|
|
12832
13035
|
);
|
|
12833
13036
|
};
|
|
12834
|
-
const schema
|
|
13037
|
+
const schema = objectType({
|
|
12835
13038
|
customer_id: stringType().min(1)
|
|
12836
13039
|
});
|
|
12837
|
-
const ShippingAddress = () => {
|
|
12838
|
-
const { id } = useParams();
|
|
12839
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12840
|
-
fields: "+shipping_address"
|
|
12841
|
-
});
|
|
12842
|
-
if (isError) {
|
|
12843
|
-
throw error;
|
|
12844
|
-
}
|
|
12845
|
-
const isReady = !isPending && !!order;
|
|
12846
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12847
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12848
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12849
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12850
|
-
] }),
|
|
12851
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12852
|
-
] });
|
|
12853
|
-
};
|
|
12854
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12855
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12856
|
-
const form = useForm({
|
|
12857
|
-
defaultValues: {
|
|
12858
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12859
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12860
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12861
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12862
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12863
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12864
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12865
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12866
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12867
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12868
|
-
},
|
|
12869
|
-
resolver: zodResolver(schema)
|
|
12870
|
-
});
|
|
12871
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12872
|
-
const { handleSuccess } = useRouteModal();
|
|
12873
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12874
|
-
await mutateAsync(
|
|
12875
|
-
{
|
|
12876
|
-
shipping_address: {
|
|
12877
|
-
first_name: data.first_name,
|
|
12878
|
-
last_name: data.last_name,
|
|
12879
|
-
company: data.company,
|
|
12880
|
-
address_1: data.address_1,
|
|
12881
|
-
address_2: data.address_2,
|
|
12882
|
-
city: data.city,
|
|
12883
|
-
province: data.province,
|
|
12884
|
-
country_code: data.country_code,
|
|
12885
|
-
postal_code: data.postal_code,
|
|
12886
|
-
phone: data.phone
|
|
12887
|
-
}
|
|
12888
|
-
},
|
|
12889
|
-
{
|
|
12890
|
-
onSuccess: () => {
|
|
12891
|
-
handleSuccess();
|
|
12892
|
-
},
|
|
12893
|
-
onError: (error) => {
|
|
12894
|
-
toast.error(error.message);
|
|
12895
|
-
}
|
|
12896
|
-
}
|
|
12897
|
-
);
|
|
12898
|
-
});
|
|
12899
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12900
|
-
KeyboundForm,
|
|
12901
|
-
{
|
|
12902
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12903
|
-
onSubmit,
|
|
12904
|
-
children: [
|
|
12905
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12906
|
-
/* @__PURE__ */ jsx(
|
|
12907
|
-
Form$2.Field,
|
|
12908
|
-
{
|
|
12909
|
-
control: form.control,
|
|
12910
|
-
name: "country_code",
|
|
12911
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12912
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12913
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12914
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12915
|
-
] })
|
|
12916
|
-
}
|
|
12917
|
-
),
|
|
12918
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12919
|
-
/* @__PURE__ */ jsx(
|
|
12920
|
-
Form$2.Field,
|
|
12921
|
-
{
|
|
12922
|
-
control: form.control,
|
|
12923
|
-
name: "first_name",
|
|
12924
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12925
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12926
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12927
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12928
|
-
] })
|
|
12929
|
-
}
|
|
12930
|
-
),
|
|
12931
|
-
/* @__PURE__ */ jsx(
|
|
12932
|
-
Form$2.Field,
|
|
12933
|
-
{
|
|
12934
|
-
control: form.control,
|
|
12935
|
-
name: "last_name",
|
|
12936
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12937
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12938
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12939
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12940
|
-
] })
|
|
12941
|
-
}
|
|
12942
|
-
)
|
|
12943
|
-
] }),
|
|
12944
|
-
/* @__PURE__ */ jsx(
|
|
12945
|
-
Form$2.Field,
|
|
12946
|
-
{
|
|
12947
|
-
control: form.control,
|
|
12948
|
-
name: "company",
|
|
12949
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12950
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12951
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12952
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12953
|
-
] })
|
|
12954
|
-
}
|
|
12955
|
-
),
|
|
12956
|
-
/* @__PURE__ */ jsx(
|
|
12957
|
-
Form$2.Field,
|
|
12958
|
-
{
|
|
12959
|
-
control: form.control,
|
|
12960
|
-
name: "address_1",
|
|
12961
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12962
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12963
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12964
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12965
|
-
] })
|
|
12966
|
-
}
|
|
12967
|
-
),
|
|
12968
|
-
/* @__PURE__ */ jsx(
|
|
12969
|
-
Form$2.Field,
|
|
12970
|
-
{
|
|
12971
|
-
control: form.control,
|
|
12972
|
-
name: "address_2",
|
|
12973
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12974
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12975
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12976
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12977
|
-
] })
|
|
12978
|
-
}
|
|
12979
|
-
),
|
|
12980
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12981
|
-
/* @__PURE__ */ jsx(
|
|
12982
|
-
Form$2.Field,
|
|
12983
|
-
{
|
|
12984
|
-
control: form.control,
|
|
12985
|
-
name: "postal_code",
|
|
12986
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12987
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12988
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12989
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12990
|
-
] })
|
|
12991
|
-
}
|
|
12992
|
-
),
|
|
12993
|
-
/* @__PURE__ */ jsx(
|
|
12994
|
-
Form$2.Field,
|
|
12995
|
-
{
|
|
12996
|
-
control: form.control,
|
|
12997
|
-
name: "city",
|
|
12998
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12999
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13000
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13001
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13002
|
-
] })
|
|
13003
|
-
}
|
|
13004
|
-
)
|
|
13005
|
-
] }),
|
|
13006
|
-
/* @__PURE__ */ jsx(
|
|
13007
|
-
Form$2.Field,
|
|
13008
|
-
{
|
|
13009
|
-
control: form.control,
|
|
13010
|
-
name: "province",
|
|
13011
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13013
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
-
] })
|
|
13016
|
-
}
|
|
13017
|
-
),
|
|
13018
|
-
/* @__PURE__ */ jsx(
|
|
13019
|
-
Form$2.Field,
|
|
13020
|
-
{
|
|
13021
|
-
control: form.control,
|
|
13022
|
-
name: "phone",
|
|
13023
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13024
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13025
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13026
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13027
|
-
] })
|
|
13028
|
-
}
|
|
13029
|
-
)
|
|
13030
|
-
] }) }),
|
|
13031
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13032
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13033
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13034
|
-
] }) })
|
|
13035
|
-
]
|
|
13036
|
-
}
|
|
13037
|
-
) });
|
|
13038
|
-
};
|
|
13039
|
-
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13085,6 +13085,10 @@ const routeModule = {
|
|
|
13085
13085
|
Component: SalesChannel,
|
|
13086
13086
|
path: "/draft-orders/:id/sales-channel"
|
|
13087
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: ShippingAddress,
|
|
13090
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
},
|
|
13088
13092
|
{
|
|
13089
13093
|
Component: Shipping,
|
|
13090
13094
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13092,10 +13096,6 @@ const routeModule = {
|
|
|
13092
13096
|
{
|
|
13093
13097
|
Component: TransferOwnership,
|
|
13094
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
-
},
|
|
13096
|
-
{
|
|
13097
|
-
Component: ShippingAddress,
|
|
13098
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.11.3-preview-
|
|
3
|
+
"version": "2.11.3-preview-20251102060143",
|
|
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.3-preview-
|
|
40
|
+
"@medusajs/js-sdk": "2.11.3-preview-20251102060143",
|
|
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,14 +48,14 @@
|
|
|
48
48
|
"react-hook-form": "7.49.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@medusajs/admin-sdk": "2.11.3-preview-
|
|
52
|
-
"@medusajs/cli": "2.11.3-preview-
|
|
53
|
-
"@medusajs/framework": "2.11.3-preview-
|
|
54
|
-
"@medusajs/icons": "2.11.3-preview-
|
|
55
|
-
"@medusajs/test-utils": "2.11.3-preview-
|
|
56
|
-
"@medusajs/types": "2.11.3-preview-
|
|
57
|
-
"@medusajs/ui": "4.0.27-preview-
|
|
58
|
-
"@medusajs/ui-preset": "2.11.3-preview-
|
|
51
|
+
"@medusajs/admin-sdk": "2.11.3-preview-20251102060143",
|
|
52
|
+
"@medusajs/cli": "2.11.3-preview-20251102060143",
|
|
53
|
+
"@medusajs/framework": "2.11.3-preview-20251102060143",
|
|
54
|
+
"@medusajs/icons": "2.11.3-preview-20251102060143",
|
|
55
|
+
"@medusajs/test-utils": "2.11.3-preview-20251102060143",
|
|
56
|
+
"@medusajs/types": "2.11.3-preview-20251102060143",
|
|
57
|
+
"@medusajs/ui": "4.0.27-preview-20251102060143",
|
|
58
|
+
"@medusajs/ui-preset": "2.11.3-preview-20251102060143",
|
|
59
59
|
"@swc/core": "^1.7.28",
|
|
60
60
|
"@types/lodash": "^4.17.15",
|
|
61
61
|
"@types/lodash.debounce": "^4.0.9",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
"yalc": "^1.0.0-pre.53"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@medusajs/admin-sdk": "2.11.3-preview-
|
|
77
|
-
"@medusajs/cli": "2.11.3-preview-
|
|
78
|
-
"@medusajs/framework": "2.11.3-preview-
|
|
79
|
-
"@medusajs/icons": "2.11.3-preview-
|
|
80
|
-
"@medusajs/test-utils": "2.11.3-preview-
|
|
81
|
-
"@medusajs/ui": "4.0.27-preview-
|
|
76
|
+
"@medusajs/admin-sdk": "2.11.3-preview-20251102060143",
|
|
77
|
+
"@medusajs/cli": "2.11.3-preview-20251102060143",
|
|
78
|
+
"@medusajs/framework": "2.11.3-preview-20251102060143",
|
|
79
|
+
"@medusajs/icons": "2.11.3-preview-20251102060143",
|
|
80
|
+
"@medusajs/test-utils": "2.11.3-preview-20251102060143",
|
|
81
|
+
"@medusajs/ui": "4.0.27-preview-20251102060143",
|
|
82
82
|
"react": "^18.3.1",
|
|
83
83
|
"react-dom": "^18.3.1",
|
|
84
84
|
"react-router-dom": "6.20.1"
|