@medusajs/draft-order 2.10.2-preview-20250901180147 → 2.10.2-preview-20250902000306

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.
@@ -9750,6 +9750,27 @@ const BillingAddressForm = ({ order }) => {
9750
9750
  ) });
9751
9751
  };
9752
9752
  const schema$5 = addressSchema;
9753
+ const CustomItems = () => {
9754
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9755
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9757
+ ] });
9758
+ };
9759
+ const CustomItemsForm = () => {
9760
+ const form = reactHookForm.useForm({
9761
+ resolver: zod.zodResolver(schema$4)
9762
+ });
9763
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9764
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9765
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9766
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9767
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9768
+ ] }) })
9769
+ ] }) });
9770
+ };
9771
+ const schema$4 = objectType({
9772
+ email: stringType().email()
9773
+ });
9753
9774
  const Email = () => {
9754
9775
  const { id } = reactRouterDom.useParams();
9755
9776
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9772,7 +9793,7 @@ const EmailForm = ({ order }) => {
9772
9793
  defaultValues: {
9773
9794
  email: order.email ?? ""
9774
9795
  },
9775
- resolver: zod.zodResolver(schema$4)
9796
+ resolver: zod.zodResolver(schema$3)
9776
9797
  });
9777
9798
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9778
9799
  const { handleSuccess } = useRouteModal();
@@ -9815,7 +9836,7 @@ const EmailForm = ({ order }) => {
9815
9836
  }
9816
9837
  ) });
9817
9838
  };
9818
- const schema$4 = objectType({
9839
+ const schema$3 = objectType({
9819
9840
  email: stringType().email()
9820
9841
  });
9821
9842
  const NumberInput = React.forwardRef(
@@ -11447,7 +11468,7 @@ const SalesChannelForm = ({ order }) => {
11447
11468
  defaultValues: {
11448
11469
  sales_channel_id: order.sales_channel_id || ""
11449
11470
  },
11450
- resolver: zod.zodResolver(schema$3)
11471
+ resolver: zod.zodResolver(schema$2)
11451
11472
  });
11452
11473
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11453
11474
  const { handleSuccess } = useRouteModal();
@@ -11522,7 +11543,7 @@ const SalesChannelField = ({ control, order }) => {
11522
11543
  }
11523
11544
  );
11524
11545
  };
11525
- const schema$3 = objectType({
11546
+ const schema$2 = objectType({
11526
11547
  sales_channel_id: stringType().min(1)
11527
11548
  });
11528
11549
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12332,6 +12353,209 @@ const CustomAmountField = ({
12332
12353
  }
12333
12354
  );
12334
12355
  };
12356
+ const ShippingAddress = () => {
12357
+ const { id } = reactRouterDom.useParams();
12358
+ const { order, isPending, isError, error } = useOrder(id, {
12359
+ fields: "+shipping_address"
12360
+ });
12361
+ if (isError) {
12362
+ throw error;
12363
+ }
12364
+ const isReady = !isPending && !!order;
12365
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12366
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12367
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12368
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12369
+ ] }),
12370
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12371
+ ] });
12372
+ };
12373
+ const ShippingAddressForm = ({ order }) => {
12374
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12375
+ const form = reactHookForm.useForm({
12376
+ defaultValues: {
12377
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12378
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12379
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12380
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12381
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12382
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12383
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12384
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12385
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12386
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12387
+ },
12388
+ resolver: zod.zodResolver(schema$1)
12389
+ });
12390
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12391
+ const { handleSuccess } = useRouteModal();
12392
+ const onSubmit = form.handleSubmit(async (data) => {
12393
+ await mutateAsync(
12394
+ {
12395
+ shipping_address: {
12396
+ first_name: data.first_name,
12397
+ last_name: data.last_name,
12398
+ company: data.company,
12399
+ address_1: data.address_1,
12400
+ address_2: data.address_2,
12401
+ city: data.city,
12402
+ province: data.province,
12403
+ country_code: data.country_code,
12404
+ postal_code: data.postal_code,
12405
+ phone: data.phone
12406
+ }
12407
+ },
12408
+ {
12409
+ onSuccess: () => {
12410
+ handleSuccess();
12411
+ },
12412
+ onError: (error) => {
12413
+ ui.toast.error(error.message);
12414
+ }
12415
+ }
12416
+ );
12417
+ });
12418
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12419
+ KeyboundForm,
12420
+ {
12421
+ className: "flex flex-1 flex-col overflow-hidden",
12422
+ onSubmit,
12423
+ children: [
12424
+ /* @__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: [
12425
+ /* @__PURE__ */ jsxRuntime.jsx(
12426
+ Form$2.Field,
12427
+ {
12428
+ control: form.control,
12429
+ name: "country_code",
12430
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12431
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12432
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12433
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12434
+ ] })
12435
+ }
12436
+ ),
12437
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12438
+ /* @__PURE__ */ jsxRuntime.jsx(
12439
+ Form$2.Field,
12440
+ {
12441
+ control: form.control,
12442
+ name: "first_name",
12443
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12445
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12446
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12447
+ ] })
12448
+ }
12449
+ ),
12450
+ /* @__PURE__ */ jsxRuntime.jsx(
12451
+ Form$2.Field,
12452
+ {
12453
+ control: form.control,
12454
+ name: "last_name",
12455
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12456
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12458
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12459
+ ] })
12460
+ }
12461
+ )
12462
+ ] }),
12463
+ /* @__PURE__ */ jsxRuntime.jsx(
12464
+ Form$2.Field,
12465
+ {
12466
+ control: form.control,
12467
+ name: "company",
12468
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12469
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12470
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12471
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12472
+ ] })
12473
+ }
12474
+ ),
12475
+ /* @__PURE__ */ jsxRuntime.jsx(
12476
+ Form$2.Field,
12477
+ {
12478
+ control: form.control,
12479
+ name: "address_1",
12480
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12481
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12482
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12483
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12484
+ ] })
12485
+ }
12486
+ ),
12487
+ /* @__PURE__ */ jsxRuntime.jsx(
12488
+ Form$2.Field,
12489
+ {
12490
+ control: form.control,
12491
+ name: "address_2",
12492
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12493
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12494
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12495
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12496
+ ] })
12497
+ }
12498
+ ),
12499
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12500
+ /* @__PURE__ */ jsxRuntime.jsx(
12501
+ Form$2.Field,
12502
+ {
12503
+ control: form.control,
12504
+ name: "postal_code",
12505
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12506
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12507
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12508
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12509
+ ] })
12510
+ }
12511
+ ),
12512
+ /* @__PURE__ */ jsxRuntime.jsx(
12513
+ Form$2.Field,
12514
+ {
12515
+ control: form.control,
12516
+ name: "city",
12517
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12518
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12519
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12521
+ ] })
12522
+ }
12523
+ )
12524
+ ] }),
12525
+ /* @__PURE__ */ jsxRuntime.jsx(
12526
+ Form$2.Field,
12527
+ {
12528
+ control: form.control,
12529
+ name: "province",
12530
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12531
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12532
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12533
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12534
+ ] })
12535
+ }
12536
+ ),
12537
+ /* @__PURE__ */ jsxRuntime.jsx(
12538
+ Form$2.Field,
12539
+ {
12540
+ control: form.control,
12541
+ name: "phone",
12542
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12543
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12544
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12545
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12546
+ ] })
12547
+ }
12548
+ )
12549
+ ] }) }),
12550
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12551
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12552
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12553
+ ] }) })
12554
+ ]
12555
+ }
12556
+ ) });
12557
+ };
12558
+ const schema$1 = addressSchema;
12335
12559
  const TransferOwnership = () => {
12336
12560
  const { id } = reactRouterDom.useParams();
12337
12561
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12355,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
12355
12579
  defaultValues: {
12356
12580
  customer_id: order.customer_id || ""
12357
12581
  },
12358
- resolver: zod.zodResolver(schema$2)
12582
+ resolver: zod.zodResolver(schema)
12359
12583
  });
12360
12584
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12361
12585
  const { handleSuccess } = useRouteModal();
@@ -12805,232 +13029,8 @@ const Illustration = () => {
12805
13029
  }
12806
13030
  );
12807
13031
  };
12808
- const schema$2 = objectType({
12809
- customer_id: stringType().min(1)
12810
- });
12811
- const ShippingAddress = () => {
12812
- const { id } = reactRouterDom.useParams();
12813
- const { order, isPending, isError, error } = useOrder(id, {
12814
- fields: "+shipping_address"
12815
- });
12816
- if (isError) {
12817
- throw error;
12818
- }
12819
- const isReady = !isPending && !!order;
12820
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12821
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12822
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12823
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12824
- ] }),
12825
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12826
- ] });
12827
- };
12828
- const ShippingAddressForm = ({ order }) => {
12829
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12830
- const form = reactHookForm.useForm({
12831
- defaultValues: {
12832
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12833
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12834
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12835
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12836
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12837
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12838
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12839
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12840
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12841
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12842
- },
12843
- resolver: zod.zodResolver(schema$1)
12844
- });
12845
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12846
- const { handleSuccess } = useRouteModal();
12847
- const onSubmit = form.handleSubmit(async (data) => {
12848
- await mutateAsync(
12849
- {
12850
- shipping_address: {
12851
- first_name: data.first_name,
12852
- last_name: data.last_name,
12853
- company: data.company,
12854
- address_1: data.address_1,
12855
- address_2: data.address_2,
12856
- city: data.city,
12857
- province: data.province,
12858
- country_code: data.country_code,
12859
- postal_code: data.postal_code,
12860
- phone: data.phone
12861
- }
12862
- },
12863
- {
12864
- onSuccess: () => {
12865
- handleSuccess();
12866
- },
12867
- onError: (error) => {
12868
- ui.toast.error(error.message);
12869
- }
12870
- }
12871
- );
12872
- });
12873
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12874
- KeyboundForm,
12875
- {
12876
- className: "flex flex-1 flex-col overflow-hidden",
12877
- onSubmit,
12878
- children: [
12879
- /* @__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: [
12880
- /* @__PURE__ */ jsxRuntime.jsx(
12881
- Form$2.Field,
12882
- {
12883
- control: form.control,
12884
- name: "country_code",
12885
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12886
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12887
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12888
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12889
- ] })
12890
- }
12891
- ),
12892
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12893
- /* @__PURE__ */ jsxRuntime.jsx(
12894
- Form$2.Field,
12895
- {
12896
- control: form.control,
12897
- name: "first_name",
12898
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12899
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12900
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12901
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12902
- ] })
12903
- }
12904
- ),
12905
- /* @__PURE__ */ jsxRuntime.jsx(
12906
- Form$2.Field,
12907
- {
12908
- control: form.control,
12909
- name: "last_name",
12910
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12911
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12912
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12914
- ] })
12915
- }
12916
- )
12917
- ] }),
12918
- /* @__PURE__ */ jsxRuntime.jsx(
12919
- Form$2.Field,
12920
- {
12921
- control: form.control,
12922
- name: "company",
12923
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12924
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12925
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12926
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12927
- ] })
12928
- }
12929
- ),
12930
- /* @__PURE__ */ jsxRuntime.jsx(
12931
- Form$2.Field,
12932
- {
12933
- control: form.control,
12934
- name: "address_1",
12935
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12936
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12937
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12938
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12939
- ] })
12940
- }
12941
- ),
12942
- /* @__PURE__ */ jsxRuntime.jsx(
12943
- Form$2.Field,
12944
- {
12945
- control: form.control,
12946
- name: "address_2",
12947
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12948
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12949
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12950
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12951
- ] })
12952
- }
12953
- ),
12954
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12955
- /* @__PURE__ */ jsxRuntime.jsx(
12956
- Form$2.Field,
12957
- {
12958
- control: form.control,
12959
- name: "postal_code",
12960
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12961
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12962
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12963
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12964
- ] })
12965
- }
12966
- ),
12967
- /* @__PURE__ */ jsxRuntime.jsx(
12968
- Form$2.Field,
12969
- {
12970
- control: form.control,
12971
- name: "city",
12972
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12973
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12974
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12975
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12976
- ] })
12977
- }
12978
- )
12979
- ] }),
12980
- /* @__PURE__ */ jsxRuntime.jsx(
12981
- Form$2.Field,
12982
- {
12983
- control: form.control,
12984
- name: "province",
12985
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12986
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12987
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12988
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12989
- ] })
12990
- }
12991
- ),
12992
- /* @__PURE__ */ jsxRuntime.jsx(
12993
- Form$2.Field,
12994
- {
12995
- control: form.control,
12996
- name: "phone",
12997
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12998
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12999
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13000
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13001
- ] })
13002
- }
13003
- )
13004
- ] }) }),
13005
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13006
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13007
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13008
- ] }) })
13009
- ]
13010
- }
13011
- ) });
13012
- };
13013
- const schema$1 = addressSchema;
13014
- const CustomItems = () => {
13015
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13016
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13017
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13018
- ] });
13019
- };
13020
- const CustomItemsForm = () => {
13021
- const form = reactHookForm.useForm({
13022
- resolver: zod.zodResolver(schema)
13023
- });
13024
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13025
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13026
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13028
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13029
- ] }) })
13030
- ] }) });
13031
- };
13032
13032
  const schema = objectType({
13033
- email: stringType().email()
13033
+ customer_id: stringType().min(1)
13034
13034
  });
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
@@ -13056,6 +13056,10 @@ const routeModule = {
13056
13056
  Component: BillingAddress,
13057
13057
  path: "/draft-orders/:id/billing-address"
13058
13058
  },
13059
+ {
13060
+ Component: CustomItems,
13061
+ path: "/draft-orders/:id/custom-items"
13062
+ },
13059
13063
  {
13060
13064
  Component: Email,
13061
13065
  path: "/draft-orders/:id/email"
@@ -13080,17 +13084,13 @@ const routeModule = {
13080
13084
  Component: Shipping,
13081
13085
  path: "/draft-orders/:id/shipping"
13082
13086
  },
13083
- {
13084
- Component: TransferOwnership,
13085
- path: "/draft-orders/:id/transfer-ownership"
13086
- },
13087
13087
  {
13088
13088
  Component: ShippingAddress,
13089
13089
  path: "/draft-orders/:id/shipping-address"
13090
13090
  },
13091
13091
  {
13092
- Component: CustomItems,
13093
- path: "/draft-orders/:id/custom-items"
13092
+ Component: TransferOwnership,
13093
+ path: "/draft-orders/:id/transfer-ownership"
13094
13094
  }
13095
13095
  ]
13096
13096
  }
@@ -9744,6 +9744,27 @@ const BillingAddressForm = ({ order }) => {
9744
9744
  ) });
9745
9745
  };
9746
9746
  const schema$5 = addressSchema;
9747
+ const CustomItems = () => {
9748
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9749
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9750
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9751
+ ] });
9752
+ };
9753
+ const CustomItemsForm = () => {
9754
+ const form = useForm({
9755
+ resolver: zodResolver(schema$4)
9756
+ });
9757
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9758
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9759
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9760
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9761
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9762
+ ] }) })
9763
+ ] }) });
9764
+ };
9765
+ const schema$4 = objectType({
9766
+ email: stringType().email()
9767
+ });
9747
9768
  const Email = () => {
9748
9769
  const { id } = useParams();
9749
9770
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9766,7 +9787,7 @@ const EmailForm = ({ order }) => {
9766
9787
  defaultValues: {
9767
9788
  email: order.email ?? ""
9768
9789
  },
9769
- resolver: zodResolver(schema$4)
9790
+ resolver: zodResolver(schema$3)
9770
9791
  });
9771
9792
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9772
9793
  const { handleSuccess } = useRouteModal();
@@ -9809,7 +9830,7 @@ const EmailForm = ({ order }) => {
9809
9830
  }
9810
9831
  ) });
9811
9832
  };
9812
- const schema$4 = objectType({
9833
+ const schema$3 = objectType({
9813
9834
  email: stringType().email()
9814
9835
  });
9815
9836
  const NumberInput = forwardRef(
@@ -11441,7 +11462,7 @@ const SalesChannelForm = ({ order }) => {
11441
11462
  defaultValues: {
11442
11463
  sales_channel_id: order.sales_channel_id || ""
11443
11464
  },
11444
- resolver: zodResolver(schema$3)
11465
+ resolver: zodResolver(schema$2)
11445
11466
  });
11446
11467
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11447
11468
  const { handleSuccess } = useRouteModal();
@@ -11516,7 +11537,7 @@ const SalesChannelField = ({ control, order }) => {
11516
11537
  }
11517
11538
  );
11518
11539
  };
11519
- const schema$3 = objectType({
11540
+ const schema$2 = objectType({
11520
11541
  sales_channel_id: stringType().min(1)
11521
11542
  });
11522
11543
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12326,6 +12347,209 @@ const CustomAmountField = ({
12326
12347
  }
12327
12348
  );
12328
12349
  };
12350
+ const ShippingAddress = () => {
12351
+ const { id } = useParams();
12352
+ const { order, isPending, isError, error } = useOrder(id, {
12353
+ fields: "+shipping_address"
12354
+ });
12355
+ if (isError) {
12356
+ throw error;
12357
+ }
12358
+ const isReady = !isPending && !!order;
12359
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12360
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12361
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12362
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12363
+ ] }),
12364
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12365
+ ] });
12366
+ };
12367
+ const ShippingAddressForm = ({ order }) => {
12368
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12369
+ const form = useForm({
12370
+ defaultValues: {
12371
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12372
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12373
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12374
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12375
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12376
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12377
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12378
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12379
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12380
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12381
+ },
12382
+ resolver: zodResolver(schema$1)
12383
+ });
12384
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12385
+ const { handleSuccess } = useRouteModal();
12386
+ const onSubmit = form.handleSubmit(async (data) => {
12387
+ await mutateAsync(
12388
+ {
12389
+ shipping_address: {
12390
+ first_name: data.first_name,
12391
+ last_name: data.last_name,
12392
+ company: data.company,
12393
+ address_1: data.address_1,
12394
+ address_2: data.address_2,
12395
+ city: data.city,
12396
+ province: data.province,
12397
+ country_code: data.country_code,
12398
+ postal_code: data.postal_code,
12399
+ phone: data.phone
12400
+ }
12401
+ },
12402
+ {
12403
+ onSuccess: () => {
12404
+ handleSuccess();
12405
+ },
12406
+ onError: (error) => {
12407
+ toast.error(error.message);
12408
+ }
12409
+ }
12410
+ );
12411
+ });
12412
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12413
+ KeyboundForm,
12414
+ {
12415
+ className: "flex flex-1 flex-col overflow-hidden",
12416
+ onSubmit,
12417
+ children: [
12418
+ /* @__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: [
12419
+ /* @__PURE__ */ jsx(
12420
+ Form$2.Field,
12421
+ {
12422
+ control: form.control,
12423
+ name: "country_code",
12424
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12425
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12426
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12427
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12428
+ ] })
12429
+ }
12430
+ ),
12431
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12432
+ /* @__PURE__ */ jsx(
12433
+ Form$2.Field,
12434
+ {
12435
+ control: form.control,
12436
+ name: "first_name",
12437
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12438
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12439
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12440
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12441
+ ] })
12442
+ }
12443
+ ),
12444
+ /* @__PURE__ */ jsx(
12445
+ Form$2.Field,
12446
+ {
12447
+ control: form.control,
12448
+ name: "last_name",
12449
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12450
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12451
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12452
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12453
+ ] })
12454
+ }
12455
+ )
12456
+ ] }),
12457
+ /* @__PURE__ */ jsx(
12458
+ Form$2.Field,
12459
+ {
12460
+ control: form.control,
12461
+ name: "company",
12462
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12463
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12464
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12465
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12466
+ ] })
12467
+ }
12468
+ ),
12469
+ /* @__PURE__ */ jsx(
12470
+ Form$2.Field,
12471
+ {
12472
+ control: form.control,
12473
+ name: "address_1",
12474
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12475
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12476
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12477
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12478
+ ] })
12479
+ }
12480
+ ),
12481
+ /* @__PURE__ */ jsx(
12482
+ Form$2.Field,
12483
+ {
12484
+ control: form.control,
12485
+ name: "address_2",
12486
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12487
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12488
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12489
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12490
+ ] })
12491
+ }
12492
+ ),
12493
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12494
+ /* @__PURE__ */ jsx(
12495
+ Form$2.Field,
12496
+ {
12497
+ control: form.control,
12498
+ name: "postal_code",
12499
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12500
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12501
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12502
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12503
+ ] })
12504
+ }
12505
+ ),
12506
+ /* @__PURE__ */ jsx(
12507
+ Form$2.Field,
12508
+ {
12509
+ control: form.control,
12510
+ name: "city",
12511
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12512
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12513
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12514
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12515
+ ] })
12516
+ }
12517
+ )
12518
+ ] }),
12519
+ /* @__PURE__ */ jsx(
12520
+ Form$2.Field,
12521
+ {
12522
+ control: form.control,
12523
+ name: "province",
12524
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12525
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12526
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12527
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12528
+ ] })
12529
+ }
12530
+ ),
12531
+ /* @__PURE__ */ jsx(
12532
+ Form$2.Field,
12533
+ {
12534
+ control: form.control,
12535
+ name: "phone",
12536
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12537
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12538
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12539
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12540
+ ] })
12541
+ }
12542
+ )
12543
+ ] }) }),
12544
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12545
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12546
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12547
+ ] }) })
12548
+ ]
12549
+ }
12550
+ ) });
12551
+ };
12552
+ const schema$1 = addressSchema;
12329
12553
  const TransferOwnership = () => {
12330
12554
  const { id } = useParams();
12331
12555
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12349,7 +12573,7 @@ const TransferOwnershipForm = ({ order }) => {
12349
12573
  defaultValues: {
12350
12574
  customer_id: order.customer_id || ""
12351
12575
  },
12352
- resolver: zodResolver(schema$2)
12576
+ resolver: zodResolver(schema)
12353
12577
  });
12354
12578
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12355
12579
  const { handleSuccess } = useRouteModal();
@@ -12799,232 +13023,8 @@ const Illustration = () => {
12799
13023
  }
12800
13024
  );
12801
13025
  };
12802
- const schema$2 = objectType({
12803
- customer_id: stringType().min(1)
12804
- });
12805
- const ShippingAddress = () => {
12806
- const { id } = useParams();
12807
- const { order, isPending, isError, error } = useOrder(id, {
12808
- fields: "+shipping_address"
12809
- });
12810
- if (isError) {
12811
- throw error;
12812
- }
12813
- const isReady = !isPending && !!order;
12814
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12815
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12816
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12817
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12818
- ] }),
12819
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12820
- ] });
12821
- };
12822
- const ShippingAddressForm = ({ order }) => {
12823
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12824
- const form = useForm({
12825
- defaultValues: {
12826
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12827
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12828
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12829
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12830
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12831
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12832
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12833
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12834
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12835
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12836
- },
12837
- resolver: zodResolver(schema$1)
12838
- });
12839
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12840
- const { handleSuccess } = useRouteModal();
12841
- const onSubmit = form.handleSubmit(async (data) => {
12842
- await mutateAsync(
12843
- {
12844
- shipping_address: {
12845
- first_name: data.first_name,
12846
- last_name: data.last_name,
12847
- company: data.company,
12848
- address_1: data.address_1,
12849
- address_2: data.address_2,
12850
- city: data.city,
12851
- province: data.province,
12852
- country_code: data.country_code,
12853
- postal_code: data.postal_code,
12854
- phone: data.phone
12855
- }
12856
- },
12857
- {
12858
- onSuccess: () => {
12859
- handleSuccess();
12860
- },
12861
- onError: (error) => {
12862
- toast.error(error.message);
12863
- }
12864
- }
12865
- );
12866
- });
12867
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12868
- KeyboundForm,
12869
- {
12870
- className: "flex flex-1 flex-col overflow-hidden",
12871
- onSubmit,
12872
- children: [
12873
- /* @__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: [
12874
- /* @__PURE__ */ jsx(
12875
- Form$2.Field,
12876
- {
12877
- control: form.control,
12878
- name: "country_code",
12879
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12880
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12881
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12882
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12883
- ] })
12884
- }
12885
- ),
12886
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12887
- /* @__PURE__ */ jsx(
12888
- Form$2.Field,
12889
- {
12890
- control: form.control,
12891
- name: "first_name",
12892
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12893
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12894
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12895
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12896
- ] })
12897
- }
12898
- ),
12899
- /* @__PURE__ */ jsx(
12900
- Form$2.Field,
12901
- {
12902
- control: form.control,
12903
- name: "last_name",
12904
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12905
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12906
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12907
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12908
- ] })
12909
- }
12910
- )
12911
- ] }),
12912
- /* @__PURE__ */ jsx(
12913
- Form$2.Field,
12914
- {
12915
- control: form.control,
12916
- name: "company",
12917
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12918
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12919
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12920
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12921
- ] })
12922
- }
12923
- ),
12924
- /* @__PURE__ */ jsx(
12925
- Form$2.Field,
12926
- {
12927
- control: form.control,
12928
- name: "address_1",
12929
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12930
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12931
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12932
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12933
- ] })
12934
- }
12935
- ),
12936
- /* @__PURE__ */ jsx(
12937
- Form$2.Field,
12938
- {
12939
- control: form.control,
12940
- name: "address_2",
12941
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12942
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12943
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12944
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12945
- ] })
12946
- }
12947
- ),
12948
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12949
- /* @__PURE__ */ jsx(
12950
- Form$2.Field,
12951
- {
12952
- control: form.control,
12953
- name: "postal_code",
12954
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12955
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12956
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12957
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12958
- ] })
12959
- }
12960
- ),
12961
- /* @__PURE__ */ jsx(
12962
- Form$2.Field,
12963
- {
12964
- control: form.control,
12965
- name: "city",
12966
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12967
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12968
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12969
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12970
- ] })
12971
- }
12972
- )
12973
- ] }),
12974
- /* @__PURE__ */ jsx(
12975
- Form$2.Field,
12976
- {
12977
- control: form.control,
12978
- name: "province",
12979
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12980
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12981
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12982
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12983
- ] })
12984
- }
12985
- ),
12986
- /* @__PURE__ */ jsx(
12987
- Form$2.Field,
12988
- {
12989
- control: form.control,
12990
- name: "phone",
12991
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12992
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12993
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12994
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12995
- ] })
12996
- }
12997
- )
12998
- ] }) }),
12999
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13000
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13001
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13002
- ] }) })
13003
- ]
13004
- }
13005
- ) });
13006
- };
13007
- const schema$1 = addressSchema;
13008
- const CustomItems = () => {
13009
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13010
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13011
- /* @__PURE__ */ jsx(CustomItemsForm, {})
13012
- ] });
13013
- };
13014
- const CustomItemsForm = () => {
13015
- const form = useForm({
13016
- resolver: zodResolver(schema)
13017
- });
13018
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13019
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13020
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13021
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13022
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13023
- ] }) })
13024
- ] }) });
13025
- };
13026
13026
  const schema = objectType({
13027
- email: stringType().email()
13027
+ customer_id: stringType().min(1)
13028
13028
  });
13029
13029
  const widgetModule = { widgets: [] };
13030
13030
  const routeModule = {
@@ -13050,6 +13050,10 @@ const routeModule = {
13050
13050
  Component: BillingAddress,
13051
13051
  path: "/draft-orders/:id/billing-address"
13052
13052
  },
13053
+ {
13054
+ Component: CustomItems,
13055
+ path: "/draft-orders/:id/custom-items"
13056
+ },
13053
13057
  {
13054
13058
  Component: Email,
13055
13059
  path: "/draft-orders/:id/email"
@@ -13074,17 +13078,13 @@ const routeModule = {
13074
13078
  Component: Shipping,
13075
13079
  path: "/draft-orders/:id/shipping"
13076
13080
  },
13077
- {
13078
- Component: TransferOwnership,
13079
- path: "/draft-orders/:id/transfer-ownership"
13080
- },
13081
13081
  {
13082
13082
  Component: ShippingAddress,
13083
13083
  path: "/draft-orders/:id/shipping-address"
13084
13084
  },
13085
13085
  {
13086
- Component: CustomItems,
13087
- path: "/draft-orders/:id/custom-items"
13086
+ Component: TransferOwnership,
13087
+ path: "/draft-orders/:id/transfer-ownership"
13088
13088
  }
13089
13089
  ]
13090
13090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.2-preview-20250901180147",
3
+ "version": "2.10.2-preview-20250902000306",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.10.2-preview-20250901180147",
39
+ "@medusajs/js-sdk": "2.10.2-preview-20250902000306",
40
40
  "@tanstack/react-query": "5.64.2",
41
41
  "@uiw/react-json-view": "^2.0.0-alpha.17",
42
42
  "date-fns": "^3.6.0",
@@ -45,14 +45,14 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.2-preview-20250901180147",
49
- "@medusajs/cli": "2.10.2-preview-20250901180147",
50
- "@medusajs/framework": "2.10.2-preview-20250901180147",
51
- "@medusajs/icons": "2.10.2-preview-20250901180147",
52
- "@medusajs/test-utils": "2.10.2-preview-20250901180147",
53
- "@medusajs/types": "2.10.2-preview-20250901180147",
54
- "@medusajs/ui": "4.0.22-preview-20250901180147",
55
- "@medusajs/ui-preset": "2.10.2-preview-20250901180147",
48
+ "@medusajs/admin-sdk": "2.10.2-preview-20250902000306",
49
+ "@medusajs/cli": "2.10.2-preview-20250902000306",
50
+ "@medusajs/framework": "2.10.2-preview-20250902000306",
51
+ "@medusajs/icons": "2.10.2-preview-20250902000306",
52
+ "@medusajs/test-utils": "2.10.2-preview-20250902000306",
53
+ "@medusajs/types": "2.10.2-preview-20250902000306",
54
+ "@medusajs/ui": "4.0.22-preview-20250902000306",
55
+ "@medusajs/ui-preset": "2.10.2-preview-20250902000306",
56
56
  "@mikro-orm/cli": "6.4.3",
57
57
  "@mikro-orm/core": "6.4.3",
58
58
  "@mikro-orm/knex": "6.4.3",
@@ -76,12 +76,12 @@
76
76
  "yalc": "^1.0.0-pre.53"
77
77
  },
78
78
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.10.2-preview-20250901180147",
80
- "@medusajs/cli": "2.10.2-preview-20250901180147",
81
- "@medusajs/framework": "2.10.2-preview-20250901180147",
82
- "@medusajs/icons": "2.10.2-preview-20250901180147",
83
- "@medusajs/test-utils": "2.10.2-preview-20250901180147",
84
- "@medusajs/ui": "4.0.22-preview-20250901180147",
79
+ "@medusajs/admin-sdk": "2.10.2-preview-20250902000306",
80
+ "@medusajs/cli": "2.10.2-preview-20250902000306",
81
+ "@medusajs/framework": "2.10.2-preview-20250902000306",
82
+ "@medusajs/icons": "2.10.2-preview-20250902000306",
83
+ "@medusajs/test-utils": "2.10.2-preview-20250902000306",
84
+ "@medusajs/ui": "4.0.22-preview-20250902000306",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",