@medusajs/draft-order 2.11.2-preview-20251029032258 → 2.11.2-preview-20251029060154

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.
@@ -9565,6 +9565,74 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
+ const Email = () => {
9569
+ const { id } = useParams();
9570
+ const { order, isPending, isError, error } = useOrder(id, {
9571
+ fields: "+email"
9572
+ });
9573
+ if (isError) {
9574
+ throw error;
9575
+ }
9576
+ const isReady = !isPending && !!order;
9577
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9579
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9580
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9581
+ ] }),
9582
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9583
+ ] });
9584
+ };
9585
+ const EmailForm = ({ order }) => {
9586
+ const form = useForm({
9587
+ defaultValues: {
9588
+ email: order.email ?? ""
9589
+ },
9590
+ resolver: zodResolver(schema$5)
9591
+ });
9592
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9593
+ const { handleSuccess } = useRouteModal();
9594
+ const onSubmit = form.handleSubmit(async (data) => {
9595
+ await mutateAsync(
9596
+ { email: data.email },
9597
+ {
9598
+ onSuccess: () => {
9599
+ handleSuccess();
9600
+ },
9601
+ onError: (error) => {
9602
+ toast.error(error.message);
9603
+ }
9604
+ }
9605
+ );
9606
+ });
9607
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9608
+ KeyboundForm,
9609
+ {
9610
+ className: "flex flex-1 flex-col overflow-hidden",
9611
+ onSubmit,
9612
+ children: [
9613
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9614
+ Form$2.Field,
9615
+ {
9616
+ control: form.control,
9617
+ name: "email",
9618
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9619
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9620
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9621
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9622
+ ] })
9623
+ }
9624
+ ) }),
9625
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9626
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9627
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9628
+ ] }) })
9629
+ ]
9630
+ }
9631
+ ) });
9632
+ };
9633
+ const schema$5 = objectType({
9634
+ email: stringType().email()
9635
+ });
9568
9636
  const BillingAddress = () => {
9569
9637
  const { id } = useParams();
9570
9638
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9597,7 +9665,7 @@ const BillingAddressForm = ({ order }) => {
9597
9665
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
9666
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9599
9667
  },
9600
- resolver: zodResolver(schema$5)
9668
+ resolver: zodResolver(schema$4)
9601
9669
  });
9602
9670
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9603
9671
  const { handleSuccess } = useRouteModal();
@@ -9754,96 +9822,7 @@ const BillingAddressForm = ({ order }) => {
9754
9822
  }
9755
9823
  ) });
9756
9824
  };
9757
- const schema$5 = addressSchema;
9758
- const CustomItems = () => {
9759
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
- ] });
9763
- };
9764
- const CustomItemsForm = () => {
9765
- const form = useForm({
9766
- resolver: zodResolver(schema$4)
9767
- });
9768
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
- ] }) })
9774
- ] }) });
9775
- };
9776
- const schema$4 = objectType({
9777
- email: stringType().email()
9778
- });
9779
- const Email = () => {
9780
- const { id } = useParams();
9781
- const { order, isPending, isError, error } = useOrder(id, {
9782
- fields: "+email"
9783
- });
9784
- if (isError) {
9785
- throw error;
9786
- }
9787
- const isReady = !isPending && !!order;
9788
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9789
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9790
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9791
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9792
- ] }),
9793
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9794
- ] });
9795
- };
9796
- const EmailForm = ({ order }) => {
9797
- const form = useForm({
9798
- defaultValues: {
9799
- email: order.email ?? ""
9800
- },
9801
- resolver: zodResolver(schema$3)
9802
- });
9803
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
- const { handleSuccess } = useRouteModal();
9805
- const onSubmit = form.handleSubmit(async (data) => {
9806
- await mutateAsync(
9807
- { email: data.email },
9808
- {
9809
- onSuccess: () => {
9810
- handleSuccess();
9811
- },
9812
- onError: (error) => {
9813
- toast.error(error.message);
9814
- }
9815
- }
9816
- );
9817
- });
9818
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9819
- KeyboundForm,
9820
- {
9821
- className: "flex flex-1 flex-col overflow-hidden",
9822
- onSubmit,
9823
- children: [
9824
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9825
- Form$2.Field,
9826
- {
9827
- control: form.control,
9828
- name: "email",
9829
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9830
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9831
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9832
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9833
- ] })
9834
- }
9835
- ) }),
9836
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9837
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9838
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9839
- ] }) })
9840
- ]
9841
- }
9842
- ) });
9843
- };
9844
- const schema$3 = objectType({
9845
- email: stringType().email()
9846
- });
9825
+ const schema$4 = addressSchema;
9847
9826
  const NumberInput = forwardRef(
9848
9827
  ({
9849
9828
  value,
@@ -11445,37 +11424,54 @@ function getPromotionIds(items, shippingMethods) {
11445
11424
  }
11446
11425
  return Array.from(promotionIds);
11447
11426
  }
11448
- const ShippingAddress = () => {
11449
- const { id } = useParams();
11450
- const { order, isPending, isError, error } = useOrder(id, {
11451
- fields: "+shipping_address"
11427
+ const CustomItems = () => {
11428
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11429
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
11430
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
11431
+ ] });
11432
+ };
11433
+ const CustomItemsForm = () => {
11434
+ const form = useForm({
11435
+ resolver: zodResolver(schema$3)
11452
11436
  });
11437
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11438
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
11439
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11440
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11441
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
11442
+ ] }) })
11443
+ ] }) });
11444
+ };
11445
+ const schema$3 = objectType({
11446
+ email: stringType().email()
11447
+ });
11448
+ const SalesChannel = () => {
11449
+ const { id } = useParams();
11450
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11451
+ id,
11452
+ {
11453
+ fields: "+sales_channel_id"
11454
+ },
11455
+ {
11456
+ enabled: !!id
11457
+ }
11458
+ );
11453
11459
  if (isError) {
11454
11460
  throw error;
11455
11461
  }
11456
- const isReady = !isPending && !!order;
11462
+ const ISrEADY = !!draft_order && !isPending;
11457
11463
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11458
11464
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11459
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11460
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11465
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11466
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11461
11467
  ] }),
11462
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11468
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11463
11469
  ] });
11464
11470
  };
11465
- const ShippingAddressForm = ({ order }) => {
11466
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11471
+ const SalesChannelForm = ({ order }) => {
11467
11472
  const form = useForm({
11468
11473
  defaultValues: {
11469
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11470
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11471
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11472
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11473
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11474
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11475
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11476
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11477
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11478
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11474
+ sales_channel_id: order.sales_channel_id || ""
11479
11475
  },
11480
11476
  resolver: zodResolver(schema$2)
11481
11477
  });
@@ -11484,21 +11480,11 @@ const ShippingAddressForm = ({ order }) => {
11484
11480
  const onSubmit = form.handleSubmit(async (data) => {
11485
11481
  await mutateAsync(
11486
11482
  {
11487
- shipping_address: {
11488
- first_name: data.first_name,
11489
- last_name: data.last_name,
11490
- company: data.company,
11491
- address_1: data.address_1,
11492
- address_2: data.address_2,
11493
- city: data.city,
11494
- province: data.province,
11495
- country_code: data.country_code,
11496
- postal_code: data.postal_code,
11497
- phone: data.phone
11498
- }
11483
+ sales_channel_id: data.sales_channel_id
11499
11484
  },
11500
11485
  {
11501
11486
  onSuccess: () => {
11487
+ toast.success("Sales channel updated");
11502
11488
  handleSuccess();
11503
11489
  },
11504
11490
  onError: (error) => {
@@ -11513,132 +11499,7 @@ const ShippingAddressForm = ({ order }) => {
11513
11499
  className: "flex flex-1 flex-col overflow-hidden",
11514
11500
  onSubmit,
11515
11501
  children: [
11516
- /* @__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: [
11517
- /* @__PURE__ */ jsx(
11518
- Form$2.Field,
11519
- {
11520
- control: form.control,
11521
- name: "country_code",
11522
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11523
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11524
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11525
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11526
- ] })
11527
- }
11528
- ),
11529
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11530
- /* @__PURE__ */ jsx(
11531
- Form$2.Field,
11532
- {
11533
- control: form.control,
11534
- name: "first_name",
11535
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11536
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11537
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11538
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11539
- ] })
11540
- }
11541
- ),
11542
- /* @__PURE__ */ jsx(
11543
- Form$2.Field,
11544
- {
11545
- control: form.control,
11546
- name: "last_name",
11547
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11548
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11549
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11550
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11551
- ] })
11552
- }
11553
- )
11554
- ] }),
11555
- /* @__PURE__ */ jsx(
11556
- Form$2.Field,
11557
- {
11558
- control: form.control,
11559
- name: "company",
11560
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11561
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11562
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11563
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11564
- ] })
11565
- }
11566
- ),
11567
- /* @__PURE__ */ jsx(
11568
- Form$2.Field,
11569
- {
11570
- control: form.control,
11571
- name: "address_1",
11572
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11573
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11574
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11575
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11576
- ] })
11577
- }
11578
- ),
11579
- /* @__PURE__ */ jsx(
11580
- Form$2.Field,
11581
- {
11582
- control: form.control,
11583
- name: "address_2",
11584
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11585
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11586
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11587
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11588
- ] })
11589
- }
11590
- ),
11591
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11592
- /* @__PURE__ */ jsx(
11593
- Form$2.Field,
11594
- {
11595
- control: form.control,
11596
- name: "postal_code",
11597
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11598
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11599
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11600
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11601
- ] })
11602
- }
11603
- ),
11604
- /* @__PURE__ */ jsx(
11605
- Form$2.Field,
11606
- {
11607
- control: form.control,
11608
- name: "city",
11609
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11610
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11611
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11612
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11613
- ] })
11614
- }
11615
- )
11616
- ] }),
11617
- /* @__PURE__ */ jsx(
11618
- Form$2.Field,
11619
- {
11620
- control: form.control,
11621
- name: "province",
11622
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11623
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11624
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11625
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11626
- ] })
11627
- }
11628
- ),
11629
- /* @__PURE__ */ jsx(
11630
- Form$2.Field,
11631
- {
11632
- control: form.control,
11633
- name: "phone",
11634
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11635
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11636
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11637
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11638
- ] })
11639
- }
11640
- )
11641
- ] }) }),
11502
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11642
11503
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11643
11504
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11644
11505
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -11647,7 +11508,49 @@ const ShippingAddressForm = ({ order }) => {
11647
11508
  }
11648
11509
  ) });
11649
11510
  };
11650
- const schema$2 = addressSchema;
11511
+ const SalesChannelField = ({ control, order }) => {
11512
+ const salesChannels = useComboboxData({
11513
+ queryFn: async (params) => {
11514
+ return await sdk.admin.salesChannel.list(params);
11515
+ },
11516
+ queryKey: ["sales-channels"],
11517
+ getOptions: (data) => {
11518
+ return data.sales_channels.map((salesChannel) => ({
11519
+ label: salesChannel.name,
11520
+ value: salesChannel.id
11521
+ }));
11522
+ },
11523
+ defaultValue: order.sales_channel_id || void 0
11524
+ });
11525
+ return /* @__PURE__ */ jsx(
11526
+ Form$2.Field,
11527
+ {
11528
+ control,
11529
+ name: "sales_channel_id",
11530
+ render: ({ field }) => {
11531
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11532
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11533
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11534
+ Combobox,
11535
+ {
11536
+ options: salesChannels.options,
11537
+ fetchNextPage: salesChannels.fetchNextPage,
11538
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11539
+ searchValue: salesChannels.searchValue,
11540
+ onSearchValueChange: salesChannels.onSearchValueChange,
11541
+ placeholder: "Select sales channel",
11542
+ ...field
11543
+ }
11544
+ ) }),
11545
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11546
+ ] });
11547
+ }
11548
+ }
11549
+ );
11550
+ };
11551
+ const schema$2 = objectType({
11552
+ sales_channel_id: stringType().min(1)
11553
+ });
11651
11554
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11652
11555
  const Shipping = () => {
11653
11556
  var _a;
@@ -12455,6 +12358,209 @@ const CustomAmountField = ({
12455
12358
  }
12456
12359
  );
12457
12360
  };
12361
+ const ShippingAddress = () => {
12362
+ const { id } = useParams();
12363
+ const { order, isPending, isError, error } = useOrder(id, {
12364
+ fields: "+shipping_address"
12365
+ });
12366
+ if (isError) {
12367
+ throw error;
12368
+ }
12369
+ const isReady = !isPending && !!order;
12370
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12371
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12372
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12373
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12374
+ ] }),
12375
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12376
+ ] });
12377
+ };
12378
+ const ShippingAddressForm = ({ order }) => {
12379
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12380
+ const form = useForm({
12381
+ defaultValues: {
12382
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12383
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12384
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12385
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12386
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12387
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12388
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12389
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12390
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12391
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12392
+ },
12393
+ resolver: zodResolver(schema$1)
12394
+ });
12395
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
+ const { handleSuccess } = useRouteModal();
12397
+ const onSubmit = form.handleSubmit(async (data) => {
12398
+ await mutateAsync(
12399
+ {
12400
+ shipping_address: {
12401
+ first_name: data.first_name,
12402
+ last_name: data.last_name,
12403
+ company: data.company,
12404
+ address_1: data.address_1,
12405
+ address_2: data.address_2,
12406
+ city: data.city,
12407
+ province: data.province,
12408
+ country_code: data.country_code,
12409
+ postal_code: data.postal_code,
12410
+ phone: data.phone
12411
+ }
12412
+ },
12413
+ {
12414
+ onSuccess: () => {
12415
+ handleSuccess();
12416
+ },
12417
+ onError: (error) => {
12418
+ toast.error(error.message);
12419
+ }
12420
+ }
12421
+ );
12422
+ });
12423
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12424
+ KeyboundForm,
12425
+ {
12426
+ className: "flex flex-1 flex-col overflow-hidden",
12427
+ onSubmit,
12428
+ children: [
12429
+ /* @__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: [
12430
+ /* @__PURE__ */ jsx(
12431
+ Form$2.Field,
12432
+ {
12433
+ control: form.control,
12434
+ name: "country_code",
12435
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12436
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12437
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12438
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12439
+ ] })
12440
+ }
12441
+ ),
12442
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12443
+ /* @__PURE__ */ jsx(
12444
+ Form$2.Field,
12445
+ {
12446
+ control: form.control,
12447
+ name: "first_name",
12448
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12449
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12450
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12451
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12452
+ ] })
12453
+ }
12454
+ ),
12455
+ /* @__PURE__ */ jsx(
12456
+ Form$2.Field,
12457
+ {
12458
+ control: form.control,
12459
+ name: "last_name",
12460
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12461
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12462
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12463
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12464
+ ] })
12465
+ }
12466
+ )
12467
+ ] }),
12468
+ /* @__PURE__ */ jsx(
12469
+ Form$2.Field,
12470
+ {
12471
+ control: form.control,
12472
+ name: "company",
12473
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12474
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12475
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12476
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12477
+ ] })
12478
+ }
12479
+ ),
12480
+ /* @__PURE__ */ jsx(
12481
+ Form$2.Field,
12482
+ {
12483
+ control: form.control,
12484
+ name: "address_1",
12485
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12486
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12487
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12488
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12489
+ ] })
12490
+ }
12491
+ ),
12492
+ /* @__PURE__ */ jsx(
12493
+ Form$2.Field,
12494
+ {
12495
+ control: form.control,
12496
+ name: "address_2",
12497
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12498
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12499
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12500
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12501
+ ] })
12502
+ }
12503
+ ),
12504
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12505
+ /* @__PURE__ */ jsx(
12506
+ Form$2.Field,
12507
+ {
12508
+ control: form.control,
12509
+ name: "postal_code",
12510
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12511
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12512
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12513
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12514
+ ] })
12515
+ }
12516
+ ),
12517
+ /* @__PURE__ */ jsx(
12518
+ Form$2.Field,
12519
+ {
12520
+ control: form.control,
12521
+ name: "city",
12522
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12523
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12524
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12525
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12526
+ ] })
12527
+ }
12528
+ )
12529
+ ] }),
12530
+ /* @__PURE__ */ jsx(
12531
+ Form$2.Field,
12532
+ {
12533
+ control: form.control,
12534
+ name: "province",
12535
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12536
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12537
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12538
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12539
+ ] })
12540
+ }
12541
+ ),
12542
+ /* @__PURE__ */ jsx(
12543
+ Form$2.Field,
12544
+ {
12545
+ control: form.control,
12546
+ name: "phone",
12547
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12548
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12549
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12550
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12551
+ ] })
12552
+ }
12553
+ )
12554
+ ] }) }),
12555
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12556
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12557
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12558
+ ] }) })
12559
+ ]
12560
+ }
12561
+ ) });
12562
+ };
12563
+ const schema$1 = addressSchema;
12458
12564
  const TransferOwnership = () => {
12459
12565
  const { id } = useParams();
12460
12566
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12478,7 +12584,7 @@ const TransferOwnershipForm = ({ order }) => {
12478
12584
  defaultValues: {
12479
12585
  customer_id: order.customer_id || ""
12480
12586
  },
12481
- resolver: zodResolver(schema$1)
12587
+ resolver: zodResolver(schema)
12482
12588
  });
12483
12589
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12484
12590
  const { handleSuccess } = useRouteModal();
@@ -12928,114 +13034,8 @@ const Illustration = () => {
12928
13034
  }
12929
13035
  );
12930
13036
  };
12931
- const schema$1 = objectType({
12932
- customer_id: stringType().min(1)
12933
- });
12934
- const SalesChannel = () => {
12935
- const { id } = useParams();
12936
- const { draft_order, isPending, isError, error } = useDraftOrder(
12937
- id,
12938
- {
12939
- fields: "+sales_channel_id"
12940
- },
12941
- {
12942
- enabled: !!id
12943
- }
12944
- );
12945
- if (isError) {
12946
- throw error;
12947
- }
12948
- const ISrEADY = !!draft_order && !isPending;
12949
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12950
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12951
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12952
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12953
- ] }),
12954
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12955
- ] });
12956
- };
12957
- const SalesChannelForm = ({ order }) => {
12958
- const form = useForm({
12959
- defaultValues: {
12960
- sales_channel_id: order.sales_channel_id || ""
12961
- },
12962
- resolver: zodResolver(schema)
12963
- });
12964
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12965
- const { handleSuccess } = useRouteModal();
12966
- const onSubmit = form.handleSubmit(async (data) => {
12967
- await mutateAsync(
12968
- {
12969
- sales_channel_id: data.sales_channel_id
12970
- },
12971
- {
12972
- onSuccess: () => {
12973
- toast.success("Sales channel updated");
12974
- handleSuccess();
12975
- },
12976
- onError: (error) => {
12977
- toast.error(error.message);
12978
- }
12979
- }
12980
- );
12981
- });
12982
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12983
- KeyboundForm,
12984
- {
12985
- className: "flex flex-1 flex-col overflow-hidden",
12986
- onSubmit,
12987
- children: [
12988
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12989
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12990
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12991
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12992
- ] }) })
12993
- ]
12994
- }
12995
- ) });
12996
- };
12997
- const SalesChannelField = ({ control, order }) => {
12998
- const salesChannels = useComboboxData({
12999
- queryFn: async (params) => {
13000
- return await sdk.admin.salesChannel.list(params);
13001
- },
13002
- queryKey: ["sales-channels"],
13003
- getOptions: (data) => {
13004
- return data.sales_channels.map((salesChannel) => ({
13005
- label: salesChannel.name,
13006
- value: salesChannel.id
13007
- }));
13008
- },
13009
- defaultValue: order.sales_channel_id || void 0
13010
- });
13011
- return /* @__PURE__ */ jsx(
13012
- Form$2.Field,
13013
- {
13014
- control,
13015
- name: "sales_channel_id",
13016
- render: ({ field }) => {
13017
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13018
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13019
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13020
- Combobox,
13021
- {
13022
- options: salesChannels.options,
13023
- fetchNextPage: salesChannels.fetchNextPage,
13024
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13025
- searchValue: salesChannels.searchValue,
13026
- onSearchValueChange: salesChannels.onSearchValueChange,
13027
- placeholder: "Select sales channel",
13028
- ...field
13029
- }
13030
- ) }),
13031
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13032
- ] });
13033
- }
13034
- }
13035
- );
13036
- };
13037
13037
  const schema = objectType({
13038
- sales_channel_id: stringType().min(1)
13038
+ customer_id: stringType().min(1)
13039
13039
  });
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
@@ -13057,18 +13057,14 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
- {
13061
- Component: BillingAddress,
13062
- path: "/draft-orders/:id/billing-address"
13063
- },
13064
- {
13065
- Component: CustomItems,
13066
- path: "/draft-orders/:id/custom-items"
13067
- },
13068
13060
  {
13069
13061
  Component: Email,
13070
13062
  path: "/draft-orders/:id/email"
13071
13063
  },
13064
+ {
13065
+ Component: BillingAddress,
13066
+ path: "/draft-orders/:id/billing-address"
13067
+ },
13072
13068
  {
13073
13069
  Component: Items,
13074
13070
  path: "/draft-orders/:id/items"
@@ -13082,20 +13078,24 @@ const routeModule = {
13082
13078
  path: "/draft-orders/:id/promotions"
13083
13079
  },
13084
13080
  {
13085
- Component: ShippingAddress,
13086
- path: "/draft-orders/:id/shipping-address"
13081
+ Component: CustomItems,
13082
+ path: "/draft-orders/:id/custom-items"
13083
+ },
13084
+ {
13085
+ Component: SalesChannel,
13086
+ path: "/draft-orders/:id/sales-channel"
13087
13087
  },
13088
13088
  {
13089
13089
  Component: Shipping,
13090
13090
  path: "/draft-orders/:id/shipping"
13091
13091
  },
13092
13092
  {
13093
- Component: TransferOwnership,
13094
- path: "/draft-orders/:id/transfer-ownership"
13093
+ Component: ShippingAddress,
13094
+ path: "/draft-orders/:id/shipping-address"
13095
13095
  },
13096
13096
  {
13097
- Component: SalesChannel,
13098
- path: "/draft-orders/:id/sales-channel"
13097
+ Component: TransferOwnership,
13098
+ path: "/draft-orders/:id/transfer-ownership"
13099
13099
  }
13100
13100
  ]
13101
13101
  }