@medusajs/draft-order 2.11.4-snapshot-20251105174837 → 2.11.4-snapshot-20251106122834
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
|
@@ -12361,6 +12361,209 @@ const CustomAmountField = ({
|
|
|
12361
12361
|
}
|
|
12362
12362
|
);
|
|
12363
12363
|
};
|
|
12364
|
+
const ShippingAddress = () => {
|
|
12365
|
+
const { id } = reactRouterDom.useParams();
|
|
12366
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12367
|
+
fields: "+shipping_address"
|
|
12368
|
+
});
|
|
12369
|
+
if (isError) {
|
|
12370
|
+
throw error;
|
|
12371
|
+
}
|
|
12372
|
+
const isReady = !isPending && !!order;
|
|
12373
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12374
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12375
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12376
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12377
|
+
] }),
|
|
12378
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12379
|
+
] });
|
|
12380
|
+
};
|
|
12381
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12382
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12383
|
+
const form = reactHookForm.useForm({
|
|
12384
|
+
defaultValues: {
|
|
12385
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12386
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12387
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12388
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12389
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12390
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12391
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12392
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12393
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12394
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12395
|
+
},
|
|
12396
|
+
resolver: zod.zodResolver(schema$1)
|
|
12397
|
+
});
|
|
12398
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12399
|
+
const { handleSuccess } = useRouteModal();
|
|
12400
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12401
|
+
await mutateAsync(
|
|
12402
|
+
{
|
|
12403
|
+
shipping_address: {
|
|
12404
|
+
first_name: data.first_name,
|
|
12405
|
+
last_name: data.last_name,
|
|
12406
|
+
company: data.company,
|
|
12407
|
+
address_1: data.address_1,
|
|
12408
|
+
address_2: data.address_2,
|
|
12409
|
+
city: data.city,
|
|
12410
|
+
province: data.province,
|
|
12411
|
+
country_code: data.country_code,
|
|
12412
|
+
postal_code: data.postal_code,
|
|
12413
|
+
phone: data.phone
|
|
12414
|
+
}
|
|
12415
|
+
},
|
|
12416
|
+
{
|
|
12417
|
+
onSuccess: () => {
|
|
12418
|
+
handleSuccess();
|
|
12419
|
+
},
|
|
12420
|
+
onError: (error) => {
|
|
12421
|
+
ui.toast.error(error.message);
|
|
12422
|
+
}
|
|
12423
|
+
}
|
|
12424
|
+
);
|
|
12425
|
+
});
|
|
12426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12427
|
+
KeyboundForm,
|
|
12428
|
+
{
|
|
12429
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12430
|
+
onSubmit,
|
|
12431
|
+
children: [
|
|
12432
|
+
/* @__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: [
|
|
12433
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12434
|
+
Form$2.Field,
|
|
12435
|
+
{
|
|
12436
|
+
control: form.control,
|
|
12437
|
+
name: "country_code",
|
|
12438
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12439
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12440
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12441
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12442
|
+
] })
|
|
12443
|
+
}
|
|
12444
|
+
),
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12446
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12447
|
+
Form$2.Field,
|
|
12448
|
+
{
|
|
12449
|
+
control: form.control,
|
|
12450
|
+
name: "first_name",
|
|
12451
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12452
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12453
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12454
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12455
|
+
] })
|
|
12456
|
+
}
|
|
12457
|
+
),
|
|
12458
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12459
|
+
Form$2.Field,
|
|
12460
|
+
{
|
|
12461
|
+
control: form.control,
|
|
12462
|
+
name: "last_name",
|
|
12463
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12464
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12465
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12466
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12467
|
+
] })
|
|
12468
|
+
}
|
|
12469
|
+
)
|
|
12470
|
+
] }),
|
|
12471
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12472
|
+
Form$2.Field,
|
|
12473
|
+
{
|
|
12474
|
+
control: form.control,
|
|
12475
|
+
name: "company",
|
|
12476
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12477
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12478
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12479
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12480
|
+
] })
|
|
12481
|
+
}
|
|
12482
|
+
),
|
|
12483
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12484
|
+
Form$2.Field,
|
|
12485
|
+
{
|
|
12486
|
+
control: form.control,
|
|
12487
|
+
name: "address_1",
|
|
12488
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12489
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12490
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12491
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12492
|
+
] })
|
|
12493
|
+
}
|
|
12494
|
+
),
|
|
12495
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12496
|
+
Form$2.Field,
|
|
12497
|
+
{
|
|
12498
|
+
control: form.control,
|
|
12499
|
+
name: "address_2",
|
|
12500
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12501
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12502
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12503
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12504
|
+
] })
|
|
12505
|
+
}
|
|
12506
|
+
),
|
|
12507
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12508
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12509
|
+
Form$2.Field,
|
|
12510
|
+
{
|
|
12511
|
+
control: form.control,
|
|
12512
|
+
name: "postal_code",
|
|
12513
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12514
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12515
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12516
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12517
|
+
] })
|
|
12518
|
+
}
|
|
12519
|
+
),
|
|
12520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12521
|
+
Form$2.Field,
|
|
12522
|
+
{
|
|
12523
|
+
control: form.control,
|
|
12524
|
+
name: "city",
|
|
12525
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12526
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12527
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12528
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12529
|
+
] })
|
|
12530
|
+
}
|
|
12531
|
+
)
|
|
12532
|
+
] }),
|
|
12533
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12534
|
+
Form$2.Field,
|
|
12535
|
+
{
|
|
12536
|
+
control: form.control,
|
|
12537
|
+
name: "province",
|
|
12538
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12540
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12541
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12542
|
+
] })
|
|
12543
|
+
}
|
|
12544
|
+
),
|
|
12545
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12546
|
+
Form$2.Field,
|
|
12547
|
+
{
|
|
12548
|
+
control: form.control,
|
|
12549
|
+
name: "phone",
|
|
12550
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12551
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12552
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12553
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12554
|
+
] })
|
|
12555
|
+
}
|
|
12556
|
+
)
|
|
12557
|
+
] }) }),
|
|
12558
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12559
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12560
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12561
|
+
] }) })
|
|
12562
|
+
]
|
|
12563
|
+
}
|
|
12564
|
+
) });
|
|
12565
|
+
};
|
|
12566
|
+
const schema$1 = addressSchema;
|
|
12364
12567
|
const TransferOwnership = () => {
|
|
12365
12568
|
const { id } = reactRouterDom.useParams();
|
|
12366
12569
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12384,7 +12587,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12384
12587
|
defaultValues: {
|
|
12385
12588
|
customer_id: order.customer_id || ""
|
|
12386
12589
|
},
|
|
12387
|
-
resolver: zod.zodResolver(schema
|
|
12590
|
+
resolver: zod.zodResolver(schema)
|
|
12388
12591
|
});
|
|
12389
12592
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12390
12593
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12834,212 +13037,9 @@ const Illustration = () => {
|
|
|
12834
13037
|
}
|
|
12835
13038
|
);
|
|
12836
13039
|
};
|
|
12837
|
-
const schema
|
|
13040
|
+
const schema = objectType({
|
|
12838
13041
|
customer_id: stringType().min(1)
|
|
12839
13042
|
});
|
|
12840
|
-
const ShippingAddress = () => {
|
|
12841
|
-
const { id } = reactRouterDom.useParams();
|
|
12842
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12843
|
-
fields: "+shipping_address"
|
|
12844
|
-
});
|
|
12845
|
-
if (isError) {
|
|
12846
|
-
throw error;
|
|
12847
|
-
}
|
|
12848
|
-
const isReady = !isPending && !!order;
|
|
12849
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12850
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12851
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12852
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12853
|
-
] }),
|
|
12854
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12855
|
-
] });
|
|
12856
|
-
};
|
|
12857
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12858
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12859
|
-
const form = reactHookForm.useForm({
|
|
12860
|
-
defaultValues: {
|
|
12861
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12862
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12863
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12864
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12865
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12866
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12867
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12868
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12869
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12870
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12871
|
-
},
|
|
12872
|
-
resolver: zod.zodResolver(schema)
|
|
12873
|
-
});
|
|
12874
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12875
|
-
const { handleSuccess } = useRouteModal();
|
|
12876
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12877
|
-
await mutateAsync(
|
|
12878
|
-
{
|
|
12879
|
-
shipping_address: {
|
|
12880
|
-
first_name: data.first_name,
|
|
12881
|
-
last_name: data.last_name,
|
|
12882
|
-
company: data.company,
|
|
12883
|
-
address_1: data.address_1,
|
|
12884
|
-
address_2: data.address_2,
|
|
12885
|
-
city: data.city,
|
|
12886
|
-
province: data.province,
|
|
12887
|
-
country_code: data.country_code,
|
|
12888
|
-
postal_code: data.postal_code,
|
|
12889
|
-
phone: data.phone
|
|
12890
|
-
}
|
|
12891
|
-
},
|
|
12892
|
-
{
|
|
12893
|
-
onSuccess: () => {
|
|
12894
|
-
handleSuccess();
|
|
12895
|
-
},
|
|
12896
|
-
onError: (error) => {
|
|
12897
|
-
ui.toast.error(error.message);
|
|
12898
|
-
}
|
|
12899
|
-
}
|
|
12900
|
-
);
|
|
12901
|
-
});
|
|
12902
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12903
|
-
KeyboundForm,
|
|
12904
|
-
{
|
|
12905
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12906
|
-
onSubmit,
|
|
12907
|
-
children: [
|
|
12908
|
-
/* @__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: [
|
|
12909
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12910
|
-
Form$2.Field,
|
|
12911
|
-
{
|
|
12912
|
-
control: form.control,
|
|
12913
|
-
name: "country_code",
|
|
12914
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12915
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12916
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12917
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12918
|
-
] })
|
|
12919
|
-
}
|
|
12920
|
-
),
|
|
12921
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12922
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12923
|
-
Form$2.Field,
|
|
12924
|
-
{
|
|
12925
|
-
control: form.control,
|
|
12926
|
-
name: "first_name",
|
|
12927
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12928
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12929
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12930
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12931
|
-
] })
|
|
12932
|
-
}
|
|
12933
|
-
),
|
|
12934
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12935
|
-
Form$2.Field,
|
|
12936
|
-
{
|
|
12937
|
-
control: form.control,
|
|
12938
|
-
name: "last_name",
|
|
12939
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12940
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12941
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12942
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12943
|
-
] })
|
|
12944
|
-
}
|
|
12945
|
-
)
|
|
12946
|
-
] }),
|
|
12947
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12948
|
-
Form$2.Field,
|
|
12949
|
-
{
|
|
12950
|
-
control: form.control,
|
|
12951
|
-
name: "company",
|
|
12952
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12953
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12954
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12955
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12956
|
-
] })
|
|
12957
|
-
}
|
|
12958
|
-
),
|
|
12959
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12960
|
-
Form$2.Field,
|
|
12961
|
-
{
|
|
12962
|
-
control: form.control,
|
|
12963
|
-
name: "address_1",
|
|
12964
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12965
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12966
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12967
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12968
|
-
] })
|
|
12969
|
-
}
|
|
12970
|
-
),
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12972
|
-
Form$2.Field,
|
|
12973
|
-
{
|
|
12974
|
-
control: form.control,
|
|
12975
|
-
name: "address_2",
|
|
12976
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12977
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12978
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12979
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12980
|
-
] })
|
|
12981
|
-
}
|
|
12982
|
-
),
|
|
12983
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12984
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12985
|
-
Form$2.Field,
|
|
12986
|
-
{
|
|
12987
|
-
control: form.control,
|
|
12988
|
-
name: "postal_code",
|
|
12989
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12990
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12991
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12992
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12993
|
-
] })
|
|
12994
|
-
}
|
|
12995
|
-
),
|
|
12996
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12997
|
-
Form$2.Field,
|
|
12998
|
-
{
|
|
12999
|
-
control: form.control,
|
|
13000
|
-
name: "city",
|
|
13001
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13002
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13003
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13004
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13005
|
-
] })
|
|
13006
|
-
}
|
|
13007
|
-
)
|
|
13008
|
-
] }),
|
|
13009
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13010
|
-
Form$2.Field,
|
|
13011
|
-
{
|
|
13012
|
-
control: form.control,
|
|
13013
|
-
name: "province",
|
|
13014
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13015
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13016
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13017
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13018
|
-
] })
|
|
13019
|
-
}
|
|
13020
|
-
),
|
|
13021
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
-
Form$2.Field,
|
|
13023
|
-
{
|
|
13024
|
-
control: form.control,
|
|
13025
|
-
name: "phone",
|
|
13026
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13027
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13028
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13029
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13030
|
-
] })
|
|
13031
|
-
}
|
|
13032
|
-
)
|
|
13033
|
-
] }) }),
|
|
13034
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13035
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13036
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13037
|
-
] }) })
|
|
13038
|
-
]
|
|
13039
|
-
}
|
|
13040
|
-
) });
|
|
13041
|
-
};
|
|
13042
|
-
const schema = addressSchema;
|
|
13043
13043
|
const widgetModule = { widgets: [] };
|
|
13044
13044
|
const routeModule = {
|
|
13045
13045
|
routes: [
|
|
@@ -13092,13 +13092,13 @@ const routeModule = {
|
|
|
13092
13092
|
Component: Shipping,
|
|
13093
13093
|
path: "/draft-orders/:id/shipping"
|
|
13094
13094
|
},
|
|
13095
|
-
{
|
|
13096
|
-
Component: TransferOwnership,
|
|
13097
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13098
|
-
},
|
|
13099
13095
|
{
|
|
13100
13096
|
Component: ShippingAddress,
|
|
13101
13097
|
path: "/draft-orders/:id/shipping-address"
|
|
13098
|
+
},
|
|
13099
|
+
{
|
|
13100
|
+
Component: TransferOwnership,
|
|
13101
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13102
13102
|
}
|
|
13103
13103
|
]
|
|
13104
13104
|
}
|
|
@@ -12354,6 +12354,209 @@ const CustomAmountField = ({
|
|
|
12354
12354
|
}
|
|
12355
12355
|
);
|
|
12356
12356
|
};
|
|
12357
|
+
const ShippingAddress = () => {
|
|
12358
|
+
const { id } = useParams();
|
|
12359
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12360
|
+
fields: "+shipping_address"
|
|
12361
|
+
});
|
|
12362
|
+
if (isError) {
|
|
12363
|
+
throw error;
|
|
12364
|
+
}
|
|
12365
|
+
const isReady = !isPending && !!order;
|
|
12366
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12367
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12368
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12369
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12370
|
+
] }),
|
|
12371
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12372
|
+
] });
|
|
12373
|
+
};
|
|
12374
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12375
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12376
|
+
const form = useForm({
|
|
12377
|
+
defaultValues: {
|
|
12378
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12379
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12380
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12381
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12382
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12383
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12384
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12385
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12386
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12387
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12388
|
+
},
|
|
12389
|
+
resolver: zodResolver(schema$1)
|
|
12390
|
+
});
|
|
12391
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12392
|
+
const { handleSuccess } = useRouteModal();
|
|
12393
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12394
|
+
await mutateAsync(
|
|
12395
|
+
{
|
|
12396
|
+
shipping_address: {
|
|
12397
|
+
first_name: data.first_name,
|
|
12398
|
+
last_name: data.last_name,
|
|
12399
|
+
company: data.company,
|
|
12400
|
+
address_1: data.address_1,
|
|
12401
|
+
address_2: data.address_2,
|
|
12402
|
+
city: data.city,
|
|
12403
|
+
province: data.province,
|
|
12404
|
+
country_code: data.country_code,
|
|
12405
|
+
postal_code: data.postal_code,
|
|
12406
|
+
phone: data.phone
|
|
12407
|
+
}
|
|
12408
|
+
},
|
|
12409
|
+
{
|
|
12410
|
+
onSuccess: () => {
|
|
12411
|
+
handleSuccess();
|
|
12412
|
+
},
|
|
12413
|
+
onError: (error) => {
|
|
12414
|
+
toast.error(error.message);
|
|
12415
|
+
}
|
|
12416
|
+
}
|
|
12417
|
+
);
|
|
12418
|
+
});
|
|
12419
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12420
|
+
KeyboundForm,
|
|
12421
|
+
{
|
|
12422
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12423
|
+
onSubmit,
|
|
12424
|
+
children: [
|
|
12425
|
+
/* @__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: [
|
|
12426
|
+
/* @__PURE__ */ jsx(
|
|
12427
|
+
Form$2.Field,
|
|
12428
|
+
{
|
|
12429
|
+
control: form.control,
|
|
12430
|
+
name: "country_code",
|
|
12431
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12432
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12433
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12434
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12435
|
+
] })
|
|
12436
|
+
}
|
|
12437
|
+
),
|
|
12438
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12439
|
+
/* @__PURE__ */ jsx(
|
|
12440
|
+
Form$2.Field,
|
|
12441
|
+
{
|
|
12442
|
+
control: form.control,
|
|
12443
|
+
name: "first_name",
|
|
12444
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12445
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12446
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12447
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12448
|
+
] })
|
|
12449
|
+
}
|
|
12450
|
+
),
|
|
12451
|
+
/* @__PURE__ */ jsx(
|
|
12452
|
+
Form$2.Field,
|
|
12453
|
+
{
|
|
12454
|
+
control: form.control,
|
|
12455
|
+
name: "last_name",
|
|
12456
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12457
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12458
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12459
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12460
|
+
] })
|
|
12461
|
+
}
|
|
12462
|
+
)
|
|
12463
|
+
] }),
|
|
12464
|
+
/* @__PURE__ */ jsx(
|
|
12465
|
+
Form$2.Field,
|
|
12466
|
+
{
|
|
12467
|
+
control: form.control,
|
|
12468
|
+
name: "company",
|
|
12469
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12470
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12471
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12472
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12473
|
+
] })
|
|
12474
|
+
}
|
|
12475
|
+
),
|
|
12476
|
+
/* @__PURE__ */ jsx(
|
|
12477
|
+
Form$2.Field,
|
|
12478
|
+
{
|
|
12479
|
+
control: form.control,
|
|
12480
|
+
name: "address_1",
|
|
12481
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12482
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12483
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12484
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12485
|
+
] })
|
|
12486
|
+
}
|
|
12487
|
+
),
|
|
12488
|
+
/* @__PURE__ */ jsx(
|
|
12489
|
+
Form$2.Field,
|
|
12490
|
+
{
|
|
12491
|
+
control: form.control,
|
|
12492
|
+
name: "address_2",
|
|
12493
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12494
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12495
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12496
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12497
|
+
] })
|
|
12498
|
+
}
|
|
12499
|
+
),
|
|
12500
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12501
|
+
/* @__PURE__ */ jsx(
|
|
12502
|
+
Form$2.Field,
|
|
12503
|
+
{
|
|
12504
|
+
control: form.control,
|
|
12505
|
+
name: "postal_code",
|
|
12506
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12507
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12508
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12509
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12510
|
+
] })
|
|
12511
|
+
}
|
|
12512
|
+
),
|
|
12513
|
+
/* @__PURE__ */ jsx(
|
|
12514
|
+
Form$2.Field,
|
|
12515
|
+
{
|
|
12516
|
+
control: form.control,
|
|
12517
|
+
name: "city",
|
|
12518
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12519
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12520
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12521
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12522
|
+
] })
|
|
12523
|
+
}
|
|
12524
|
+
)
|
|
12525
|
+
] }),
|
|
12526
|
+
/* @__PURE__ */ jsx(
|
|
12527
|
+
Form$2.Field,
|
|
12528
|
+
{
|
|
12529
|
+
control: form.control,
|
|
12530
|
+
name: "province",
|
|
12531
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12532
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12533
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12534
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12535
|
+
] })
|
|
12536
|
+
}
|
|
12537
|
+
),
|
|
12538
|
+
/* @__PURE__ */ jsx(
|
|
12539
|
+
Form$2.Field,
|
|
12540
|
+
{
|
|
12541
|
+
control: form.control,
|
|
12542
|
+
name: "phone",
|
|
12543
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12544
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12545
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12546
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12547
|
+
] })
|
|
12548
|
+
}
|
|
12549
|
+
)
|
|
12550
|
+
] }) }),
|
|
12551
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12552
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12553
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12554
|
+
] }) })
|
|
12555
|
+
]
|
|
12556
|
+
}
|
|
12557
|
+
) });
|
|
12558
|
+
};
|
|
12559
|
+
const schema$1 = addressSchema;
|
|
12357
12560
|
const TransferOwnership = () => {
|
|
12358
12561
|
const { id } = useParams();
|
|
12359
12562
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12377,7 +12580,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12377
12580
|
defaultValues: {
|
|
12378
12581
|
customer_id: order.customer_id || ""
|
|
12379
12582
|
},
|
|
12380
|
-
resolver: zodResolver(schema
|
|
12583
|
+
resolver: zodResolver(schema)
|
|
12381
12584
|
});
|
|
12382
12585
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12383
12586
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12827,212 +13030,9 @@ const Illustration = () => {
|
|
|
12827
13030
|
}
|
|
12828
13031
|
);
|
|
12829
13032
|
};
|
|
12830
|
-
const schema
|
|
13033
|
+
const schema = objectType({
|
|
12831
13034
|
customer_id: stringType().min(1)
|
|
12832
13035
|
});
|
|
12833
|
-
const ShippingAddress = () => {
|
|
12834
|
-
const { id } = useParams();
|
|
12835
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12836
|
-
fields: "+shipping_address"
|
|
12837
|
-
});
|
|
12838
|
-
if (isError) {
|
|
12839
|
-
throw error;
|
|
12840
|
-
}
|
|
12841
|
-
const isReady = !isPending && !!order;
|
|
12842
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12843
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12844
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12845
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12846
|
-
] }),
|
|
12847
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12848
|
-
] });
|
|
12849
|
-
};
|
|
12850
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12851
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12852
|
-
const form = useForm({
|
|
12853
|
-
defaultValues: {
|
|
12854
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12855
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12856
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12857
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12858
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12859
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12860
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12861
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12862
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12863
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12864
|
-
},
|
|
12865
|
-
resolver: zodResolver(schema)
|
|
12866
|
-
});
|
|
12867
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12868
|
-
const { handleSuccess } = useRouteModal();
|
|
12869
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12870
|
-
await mutateAsync(
|
|
12871
|
-
{
|
|
12872
|
-
shipping_address: {
|
|
12873
|
-
first_name: data.first_name,
|
|
12874
|
-
last_name: data.last_name,
|
|
12875
|
-
company: data.company,
|
|
12876
|
-
address_1: data.address_1,
|
|
12877
|
-
address_2: data.address_2,
|
|
12878
|
-
city: data.city,
|
|
12879
|
-
province: data.province,
|
|
12880
|
-
country_code: data.country_code,
|
|
12881
|
-
postal_code: data.postal_code,
|
|
12882
|
-
phone: data.phone
|
|
12883
|
-
}
|
|
12884
|
-
},
|
|
12885
|
-
{
|
|
12886
|
-
onSuccess: () => {
|
|
12887
|
-
handleSuccess();
|
|
12888
|
-
},
|
|
12889
|
-
onError: (error) => {
|
|
12890
|
-
toast.error(error.message);
|
|
12891
|
-
}
|
|
12892
|
-
}
|
|
12893
|
-
);
|
|
12894
|
-
});
|
|
12895
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12896
|
-
KeyboundForm,
|
|
12897
|
-
{
|
|
12898
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12899
|
-
onSubmit,
|
|
12900
|
-
children: [
|
|
12901
|
-
/* @__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: [
|
|
12902
|
-
/* @__PURE__ */ jsx(
|
|
12903
|
-
Form$2.Field,
|
|
12904
|
-
{
|
|
12905
|
-
control: form.control,
|
|
12906
|
-
name: "country_code",
|
|
12907
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12908
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12909
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12910
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12911
|
-
] })
|
|
12912
|
-
}
|
|
12913
|
-
),
|
|
12914
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12915
|
-
/* @__PURE__ */ jsx(
|
|
12916
|
-
Form$2.Field,
|
|
12917
|
-
{
|
|
12918
|
-
control: form.control,
|
|
12919
|
-
name: "first_name",
|
|
12920
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12921
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12922
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12923
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12924
|
-
] })
|
|
12925
|
-
}
|
|
12926
|
-
),
|
|
12927
|
-
/* @__PURE__ */ jsx(
|
|
12928
|
-
Form$2.Field,
|
|
12929
|
-
{
|
|
12930
|
-
control: form.control,
|
|
12931
|
-
name: "last_name",
|
|
12932
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12933
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12934
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12935
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12936
|
-
] })
|
|
12937
|
-
}
|
|
12938
|
-
)
|
|
12939
|
-
] }),
|
|
12940
|
-
/* @__PURE__ */ jsx(
|
|
12941
|
-
Form$2.Field,
|
|
12942
|
-
{
|
|
12943
|
-
control: form.control,
|
|
12944
|
-
name: "company",
|
|
12945
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12946
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12947
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12948
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12949
|
-
] })
|
|
12950
|
-
}
|
|
12951
|
-
),
|
|
12952
|
-
/* @__PURE__ */ jsx(
|
|
12953
|
-
Form$2.Field,
|
|
12954
|
-
{
|
|
12955
|
-
control: form.control,
|
|
12956
|
-
name: "address_1",
|
|
12957
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12958
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12959
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12960
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12961
|
-
] })
|
|
12962
|
-
}
|
|
12963
|
-
),
|
|
12964
|
-
/* @__PURE__ */ jsx(
|
|
12965
|
-
Form$2.Field,
|
|
12966
|
-
{
|
|
12967
|
-
control: form.control,
|
|
12968
|
-
name: "address_2",
|
|
12969
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12970
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12971
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12972
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12973
|
-
] })
|
|
12974
|
-
}
|
|
12975
|
-
),
|
|
12976
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12977
|
-
/* @__PURE__ */ jsx(
|
|
12978
|
-
Form$2.Field,
|
|
12979
|
-
{
|
|
12980
|
-
control: form.control,
|
|
12981
|
-
name: "postal_code",
|
|
12982
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12983
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12984
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12985
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12986
|
-
] })
|
|
12987
|
-
}
|
|
12988
|
-
),
|
|
12989
|
-
/* @__PURE__ */ jsx(
|
|
12990
|
-
Form$2.Field,
|
|
12991
|
-
{
|
|
12992
|
-
control: form.control,
|
|
12993
|
-
name: "city",
|
|
12994
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12995
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12996
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12997
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12998
|
-
] })
|
|
12999
|
-
}
|
|
13000
|
-
)
|
|
13001
|
-
] }),
|
|
13002
|
-
/* @__PURE__ */ jsx(
|
|
13003
|
-
Form$2.Field,
|
|
13004
|
-
{
|
|
13005
|
-
control: form.control,
|
|
13006
|
-
name: "province",
|
|
13007
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13008
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13009
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13010
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13011
|
-
] })
|
|
13012
|
-
}
|
|
13013
|
-
),
|
|
13014
|
-
/* @__PURE__ */ jsx(
|
|
13015
|
-
Form$2.Field,
|
|
13016
|
-
{
|
|
13017
|
-
control: form.control,
|
|
13018
|
-
name: "phone",
|
|
13019
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13020
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13021
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13022
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13023
|
-
] })
|
|
13024
|
-
}
|
|
13025
|
-
)
|
|
13026
|
-
] }) }),
|
|
13027
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13028
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13029
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13030
|
-
] }) })
|
|
13031
|
-
]
|
|
13032
|
-
}
|
|
13033
|
-
) });
|
|
13034
|
-
};
|
|
13035
|
-
const schema = addressSchema;
|
|
13036
13036
|
const widgetModule = { widgets: [] };
|
|
13037
13037
|
const routeModule = {
|
|
13038
13038
|
routes: [
|
|
@@ -13085,13 +13085,13 @@ const routeModule = {
|
|
|
13085
13085
|
Component: Shipping,
|
|
13086
13086
|
path: "/draft-orders/:id/shipping"
|
|
13087
13087
|
},
|
|
13088
|
-
{
|
|
13089
|
-
Component: TransferOwnership,
|
|
13090
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13091
|
-
},
|
|
13092
13088
|
{
|
|
13093
13089
|
Component: ShippingAddress,
|
|
13094
13090
|
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
},
|
|
13092
|
+
{
|
|
13093
|
+
Component: TransferOwnership,
|
|
13094
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
13095
|
}
|
|
13096
13096
|
]
|
|
13097
13097
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.11.4-snapshot-
|
|
3
|
+
"version": "2.11.4-snapshot-20251106122834",
|
|
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-snapshot-
|
|
40
|
+
"@medusajs/js-sdk": "2.11.4-snapshot-20251106122834",
|
|
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-snapshot-
|
|
52
|
-
"@medusajs/cli": "2.11.4-snapshot-
|
|
53
|
-
"@medusajs/framework": "2.11.4-snapshot-
|
|
54
|
-
"@medusajs/icons": "2.11.4-snapshot-
|
|
55
|
-
"@medusajs/test-utils": "2.11.4-snapshot-
|
|
56
|
-
"@medusajs/types": "2.11.4-snapshot-
|
|
57
|
-
"@medusajs/ui": "4.0.28-snapshot-
|
|
58
|
-
"@medusajs/ui-preset": "2.11.4-snapshot-
|
|
51
|
+
"@medusajs/admin-sdk": "2.11.4-snapshot-20251106122834",
|
|
52
|
+
"@medusajs/cli": "2.11.4-snapshot-20251106122834",
|
|
53
|
+
"@medusajs/framework": "2.11.4-snapshot-20251106122834",
|
|
54
|
+
"@medusajs/icons": "2.11.4-snapshot-20251106122834",
|
|
55
|
+
"@medusajs/test-utils": "2.11.4-snapshot-20251106122834",
|
|
56
|
+
"@medusajs/types": "2.11.4-snapshot-20251106122834",
|
|
57
|
+
"@medusajs/ui": "4.0.28-snapshot-20251106122834",
|
|
58
|
+
"@medusajs/ui-preset": "2.11.4-snapshot-20251106122834"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@medusajs/admin-sdk": "2.11.4-snapshot-
|
|
62
|
-
"@medusajs/cli": "2.11.4-snapshot-
|
|
63
|
-
"@medusajs/framework": "2.11.4-snapshot-
|
|
64
|
-
"@medusajs/icons": "2.11.4-snapshot-
|
|
65
|
-
"@medusajs/test-utils": "2.11.4-snapshot-
|
|
66
|
-
"@medusajs/ui": "4.0.28-snapshot-
|
|
61
|
+
"@medusajs/admin-sdk": "2.11.4-snapshot-20251106122834",
|
|
62
|
+
"@medusajs/cli": "2.11.4-snapshot-20251106122834",
|
|
63
|
+
"@medusajs/framework": "2.11.4-snapshot-20251106122834",
|
|
64
|
+
"@medusajs/icons": "2.11.4-snapshot-20251106122834",
|
|
65
|
+
"@medusajs/test-utils": "2.11.4-snapshot-20251106122834",
|
|
66
|
+
"@medusajs/ui": "4.0.28-snapshot-20251106122834",
|
|
67
67
|
"react": "^18.3.1",
|
|
68
68
|
"react-dom": "^18.3.1",
|
|
69
69
|
"react-router-dom": "6.20.1"
|