@medusajs/draft-order 2.11.0-preview-20251020150157 → 2.11.0-preview-20251020180200

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.
@@ -9571,217 +9571,6 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
- const BillingAddress = () => {
9575
- const { id } = reactRouterDom.useParams();
9576
- const { order, isPending, isError, error } = useOrder(id, {
9577
- fields: "+billing_address"
9578
- });
9579
- if (isError) {
9580
- throw error;
9581
- }
9582
- const isReady = !isPending && !!order;
9583
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9584
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9585
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9587
- ] }),
9588
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9589
- ] });
9590
- };
9591
- const BillingAddressForm = ({ order }) => {
9592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9593
- const form = reactHookForm.useForm({
9594
- defaultValues: {
9595
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9596
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9597
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9598
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9599
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9600
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9601
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9602
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9603
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
- },
9606
- resolver: zod.zodResolver(schema$5)
9607
- });
9608
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
- const { handleSuccess } = useRouteModal();
9610
- const onSubmit = form.handleSubmit(async (data) => {
9611
- await mutateAsync(
9612
- { billing_address: data },
9613
- {
9614
- onSuccess: () => {
9615
- handleSuccess();
9616
- },
9617
- onError: (error) => {
9618
- ui.toast.error(error.message);
9619
- }
9620
- }
9621
- );
9622
- });
9623
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9624
- KeyboundForm,
9625
- {
9626
- className: "flex flex-1 flex-col overflow-hidden",
9627
- onSubmit,
9628
- children: [
9629
- /* @__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: [
9630
- /* @__PURE__ */ jsxRuntime.jsx(
9631
- Form$2.Field,
9632
- {
9633
- control: form.control,
9634
- name: "country_code",
9635
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9636
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9637
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9639
- ] })
9640
- }
9641
- ),
9642
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9643
- /* @__PURE__ */ jsxRuntime.jsx(
9644
- Form$2.Field,
9645
- {
9646
- control: form.control,
9647
- name: "first_name",
9648
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9652
- ] })
9653
- }
9654
- ),
9655
- /* @__PURE__ */ jsxRuntime.jsx(
9656
- Form$2.Field,
9657
- {
9658
- control: form.control,
9659
- name: "last_name",
9660
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9661
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9662
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9664
- ] })
9665
- }
9666
- )
9667
- ] }),
9668
- /* @__PURE__ */ jsxRuntime.jsx(
9669
- Form$2.Field,
9670
- {
9671
- control: form.control,
9672
- name: "company",
9673
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9674
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9677
- ] })
9678
- }
9679
- ),
9680
- /* @__PURE__ */ jsxRuntime.jsx(
9681
- Form$2.Field,
9682
- {
9683
- control: form.control,
9684
- name: "address_1",
9685
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9686
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9689
- ] })
9690
- }
9691
- ),
9692
- /* @__PURE__ */ jsxRuntime.jsx(
9693
- Form$2.Field,
9694
- {
9695
- control: form.control,
9696
- name: "address_2",
9697
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9698
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9701
- ] })
9702
- }
9703
- ),
9704
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
- /* @__PURE__ */ jsxRuntime.jsx(
9706
- Form$2.Field,
9707
- {
9708
- control: form.control,
9709
- name: "postal_code",
9710
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9711
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9714
- ] })
9715
- }
9716
- ),
9717
- /* @__PURE__ */ jsxRuntime.jsx(
9718
- Form$2.Field,
9719
- {
9720
- control: form.control,
9721
- name: "city",
9722
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9723
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9724
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9726
- ] })
9727
- }
9728
- )
9729
- ] }),
9730
- /* @__PURE__ */ jsxRuntime.jsx(
9731
- Form$2.Field,
9732
- {
9733
- control: form.control,
9734
- name: "province",
9735
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9736
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9739
- ] })
9740
- }
9741
- ),
9742
- /* @__PURE__ */ jsxRuntime.jsx(
9743
- Form$2.Field,
9744
- {
9745
- control: form.control,
9746
- name: "phone",
9747
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9748
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9749
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9751
- ] })
9752
- }
9753
- )
9754
- ] }) }),
9755
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9756
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9757
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9758
- ] }) })
9759
- ]
9760
- }
9761
- ) });
9762
- };
9763
- const schema$5 = addressSchema;
9764
- const CustomItems = () => {
9765
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9766
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9767
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9768
- ] });
9769
- };
9770
- const CustomItemsForm = () => {
9771
- const form = reactHookForm.useForm({
9772
- resolver: zod.zodResolver(schema$4)
9773
- });
9774
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9775
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9776
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9778
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9779
- ] }) })
9780
- ] }) });
9781
- };
9782
- const schema$4 = objectType({
9783
- email: stringType().email()
9784
- });
9785
9574
  const Email = () => {
9786
9575
  const { id } = reactRouterDom.useParams();
9787
9576
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9804,7 +9593,7 @@ const EmailForm = ({ order }) => {
9804
9593
  defaultValues: {
9805
9594
  email: order.email ?? ""
9806
9595
  },
9807
- resolver: zod.zodResolver(schema$3)
9596
+ resolver: zod.zodResolver(schema$5)
9808
9597
  });
9809
9598
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9810
9599
  const { handleSuccess } = useRouteModal();
@@ -9847,7 +9636,7 @@ const EmailForm = ({ order }) => {
9847
9636
  }
9848
9637
  ) });
9849
9638
  };
9850
- const schema$3 = objectType({
9639
+ const schema$5 = objectType({
9851
9640
  email: stringType().email()
9852
9641
  });
9853
9642
  const NumberInput = React.forwardRef(
@@ -11451,127 +11240,21 @@ function getPromotionIds(items, shippingMethods) {
11451
11240
  }
11452
11241
  return Array.from(promotionIds);
11453
11242
  }
11454
- const SalesChannel = () => {
11243
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11244
+ const Shipping = () => {
11245
+ var _a;
11455
11246
  const { id } = reactRouterDom.useParams();
11456
- const { draft_order, isPending, isError, error } = useDraftOrder(
11457
- id,
11458
- {
11459
- fields: "+sales_channel_id"
11460
- },
11461
- {
11462
- enabled: !!id
11463
- }
11464
- );
11465
- if (isError) {
11466
- throw error;
11467
- }
11468
- const ISrEADY = !!draft_order && !isPending;
11469
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11470
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11471
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11472
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11473
- ] }),
11474
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11475
- ] });
11476
- };
11477
- const SalesChannelForm = ({ order }) => {
11478
- const form = reactHookForm.useForm({
11479
- defaultValues: {
11480
- sales_channel_id: order.sales_channel_id || ""
11481
- },
11482
- resolver: zod.zodResolver(schema$2)
11483
- });
11484
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
- const { handleSuccess } = useRouteModal();
11486
- const onSubmit = form.handleSubmit(async (data) => {
11487
- await mutateAsync(
11488
- {
11489
- sales_channel_id: data.sales_channel_id
11490
- },
11491
- {
11492
- onSuccess: () => {
11493
- ui.toast.success("Sales channel updated");
11494
- handleSuccess();
11495
- },
11496
- onError: (error) => {
11497
- ui.toast.error(error.message);
11498
- }
11499
- }
11500
- );
11501
- });
11502
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11503
- KeyboundForm,
11504
- {
11505
- className: "flex flex-1 flex-col overflow-hidden",
11506
- onSubmit,
11507
- children: [
11508
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11509
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11510
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11511
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11512
- ] }) })
11513
- ]
11514
- }
11515
- ) });
11516
- };
11517
- const SalesChannelField = ({ control, order }) => {
11518
- const salesChannels = useComboboxData({
11519
- queryFn: async (params) => {
11520
- return await sdk.admin.salesChannel.list(params);
11521
- },
11522
- queryKey: ["sales-channels"],
11523
- getOptions: (data) => {
11524
- return data.sales_channels.map((salesChannel) => ({
11525
- label: salesChannel.name,
11526
- value: salesChannel.id
11527
- }));
11528
- },
11529
- defaultValue: order.sales_channel_id || void 0
11530
- });
11531
- return /* @__PURE__ */ jsxRuntime.jsx(
11532
- Form$2.Field,
11533
- {
11534
- control,
11535
- name: "sales_channel_id",
11536
- render: ({ field }) => {
11537
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11538
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11539
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11540
- Combobox,
11541
- {
11542
- options: salesChannels.options,
11543
- fetchNextPage: salesChannels.fetchNextPage,
11544
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11545
- searchValue: salesChannels.searchValue,
11546
- onSearchValueChange: salesChannels.onSearchValueChange,
11547
- placeholder: "Select sales channel",
11548
- ...field
11549
- }
11550
- ) }),
11551
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11552
- ] });
11553
- }
11554
- }
11555
- );
11556
- };
11557
- const schema$2 = objectType({
11558
- sales_channel_id: stringType().min(1)
11559
- });
11560
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11561
- const Shipping = () => {
11562
- var _a;
11563
- const { id } = reactRouterDom.useParams();
11564
- const { order, isPending, isError, error } = useOrder(id, {
11565
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11566
- });
11567
- const {
11568
- order: preview,
11569
- isPending: isPreviewPending,
11570
- isError: isPreviewError,
11571
- error: previewError
11572
- } = useOrderPreview(id);
11573
- useInitiateOrderEdit({ preview });
11574
- const { onCancel } = useCancelOrderEdit({ preview });
11247
+ const { order, isPending, isError, error } = useOrder(id, {
11248
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11249
+ });
11250
+ const {
11251
+ order: preview,
11252
+ isPending: isPreviewPending,
11253
+ isError: isPreviewError,
11254
+ error: previewError
11255
+ } = useOrderPreview(id);
11256
+ useInitiateOrderEdit({ preview });
11257
+ const { onCancel } = useCancelOrderEdit({ preview });
11575
11258
  if (isError) {
11576
11259
  throw error;
11577
11260
  }
@@ -12396,7 +12079,7 @@ const ShippingAddressForm = ({ order }) => {
12396
12079
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12397
12080
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12398
12081
  },
12399
- resolver: zod.zodResolver(schema$1)
12082
+ resolver: zod.zodResolver(schema$4)
12400
12083
  });
12401
12084
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12402
12085
  const { handleSuccess } = useRouteModal();
@@ -12566,7 +12249,113 @@ const ShippingAddressForm = ({ order }) => {
12566
12249
  }
12567
12250
  ) });
12568
12251
  };
12569
- const schema$1 = addressSchema;
12252
+ const schema$4 = addressSchema;
12253
+ const SalesChannel = () => {
12254
+ const { id } = reactRouterDom.useParams();
12255
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12256
+ id,
12257
+ {
12258
+ fields: "+sales_channel_id"
12259
+ },
12260
+ {
12261
+ enabled: !!id
12262
+ }
12263
+ );
12264
+ if (isError) {
12265
+ throw error;
12266
+ }
12267
+ const ISrEADY = !!draft_order && !isPending;
12268
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12269
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12270
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12271
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12272
+ ] }),
12273
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12274
+ ] });
12275
+ };
12276
+ const SalesChannelForm = ({ order }) => {
12277
+ const form = reactHookForm.useForm({
12278
+ defaultValues: {
12279
+ sales_channel_id: order.sales_channel_id || ""
12280
+ },
12281
+ resolver: zod.zodResolver(schema$3)
12282
+ });
12283
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12284
+ const { handleSuccess } = useRouteModal();
12285
+ const onSubmit = form.handleSubmit(async (data) => {
12286
+ await mutateAsync(
12287
+ {
12288
+ sales_channel_id: data.sales_channel_id
12289
+ },
12290
+ {
12291
+ onSuccess: () => {
12292
+ ui.toast.success("Sales channel updated");
12293
+ handleSuccess();
12294
+ },
12295
+ onError: (error) => {
12296
+ ui.toast.error(error.message);
12297
+ }
12298
+ }
12299
+ );
12300
+ });
12301
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12302
+ KeyboundForm,
12303
+ {
12304
+ className: "flex flex-1 flex-col overflow-hidden",
12305
+ onSubmit,
12306
+ children: [
12307
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12308
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12309
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12310
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12311
+ ] }) })
12312
+ ]
12313
+ }
12314
+ ) });
12315
+ };
12316
+ const SalesChannelField = ({ control, order }) => {
12317
+ const salesChannels = useComboboxData({
12318
+ queryFn: async (params) => {
12319
+ return await sdk.admin.salesChannel.list(params);
12320
+ },
12321
+ queryKey: ["sales-channels"],
12322
+ getOptions: (data) => {
12323
+ return data.sales_channels.map((salesChannel) => ({
12324
+ label: salesChannel.name,
12325
+ value: salesChannel.id
12326
+ }));
12327
+ },
12328
+ defaultValue: order.sales_channel_id || void 0
12329
+ });
12330
+ return /* @__PURE__ */ jsxRuntime.jsx(
12331
+ Form$2.Field,
12332
+ {
12333
+ control,
12334
+ name: "sales_channel_id",
12335
+ render: ({ field }) => {
12336
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12337
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12338
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12339
+ Combobox,
12340
+ {
12341
+ options: salesChannels.options,
12342
+ fetchNextPage: salesChannels.fetchNextPage,
12343
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12344
+ searchValue: salesChannels.searchValue,
12345
+ onSearchValueChange: salesChannels.onSearchValueChange,
12346
+ placeholder: "Select sales channel",
12347
+ ...field
12348
+ }
12349
+ ) }),
12350
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12351
+ ] });
12352
+ }
12353
+ }
12354
+ );
12355
+ };
12356
+ const schema$3 = objectType({
12357
+ sales_channel_id: stringType().min(1)
12358
+ });
12570
12359
  const TransferOwnership = () => {
12571
12360
  const { id } = reactRouterDom.useParams();
12572
12361
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12590,7 +12379,7 @@ const TransferOwnershipForm = ({ order }) => {
12590
12379
  defaultValues: {
12591
12380
  customer_id: order.customer_id || ""
12592
12381
  },
12593
- resolver: zod.zodResolver(schema)
12382
+ resolver: zod.zodResolver(schema$2)
12594
12383
  });
12595
12384
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12596
12385
  const { handleSuccess } = useRouteModal();
@@ -13040,9 +12829,220 @@ const Illustration = () => {
13040
12829
  }
13041
12830
  );
13042
12831
  };
13043
- const schema = objectType({
12832
+ const schema$2 = objectType({
13044
12833
  customer_id: stringType().min(1)
13045
12834
  });
12835
+ const BillingAddress = () => {
12836
+ const { id } = reactRouterDom.useParams();
12837
+ const { order, isPending, isError, error } = useOrder(id, {
12838
+ fields: "+billing_address"
12839
+ });
12840
+ if (isError) {
12841
+ throw error;
12842
+ }
12843
+ const isReady = !isPending && !!order;
12844
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12845
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12848
+ ] }),
12849
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12850
+ ] });
12851
+ };
12852
+ const BillingAddressForm = ({ order }) => {
12853
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12854
+ const form = reactHookForm.useForm({
12855
+ defaultValues: {
12856
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12857
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12858
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12859
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12860
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12861
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12862
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12863
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12864
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12865
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12866
+ },
12867
+ resolver: zod.zodResolver(schema$1)
12868
+ });
12869
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12870
+ const { handleSuccess } = useRouteModal();
12871
+ const onSubmit = form.handleSubmit(async (data) => {
12872
+ await mutateAsync(
12873
+ { billing_address: data },
12874
+ {
12875
+ onSuccess: () => {
12876
+ handleSuccess();
12877
+ },
12878
+ onError: (error) => {
12879
+ ui.toast.error(error.message);
12880
+ }
12881
+ }
12882
+ );
12883
+ });
12884
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12885
+ KeyboundForm,
12886
+ {
12887
+ className: "flex flex-1 flex-col overflow-hidden",
12888
+ onSubmit,
12889
+ children: [
12890
+ /* @__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: [
12891
+ /* @__PURE__ */ jsxRuntime.jsx(
12892
+ Form$2.Field,
12893
+ {
12894
+ control: form.control,
12895
+ name: "country_code",
12896
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12897
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12898
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12899
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12900
+ ] })
12901
+ }
12902
+ ),
12903
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12904
+ /* @__PURE__ */ jsxRuntime.jsx(
12905
+ Form$2.Field,
12906
+ {
12907
+ control: form.control,
12908
+ name: "first_name",
12909
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12910
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12911
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12912
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12913
+ ] })
12914
+ }
12915
+ ),
12916
+ /* @__PURE__ */ jsxRuntime.jsx(
12917
+ Form$2.Field,
12918
+ {
12919
+ control: form.control,
12920
+ name: "last_name",
12921
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12922
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12923
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12924
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12925
+ ] })
12926
+ }
12927
+ )
12928
+ ] }),
12929
+ /* @__PURE__ */ jsxRuntime.jsx(
12930
+ Form$2.Field,
12931
+ {
12932
+ control: form.control,
12933
+ name: "company",
12934
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12935
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12936
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12937
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12938
+ ] })
12939
+ }
12940
+ ),
12941
+ /* @__PURE__ */ jsxRuntime.jsx(
12942
+ Form$2.Field,
12943
+ {
12944
+ control: form.control,
12945
+ name: "address_1",
12946
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12947
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12948
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12949
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12950
+ ] })
12951
+ }
12952
+ ),
12953
+ /* @__PURE__ */ jsxRuntime.jsx(
12954
+ Form$2.Field,
12955
+ {
12956
+ control: form.control,
12957
+ name: "address_2",
12958
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12959
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12960
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12961
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12962
+ ] })
12963
+ }
12964
+ ),
12965
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12966
+ /* @__PURE__ */ jsxRuntime.jsx(
12967
+ Form$2.Field,
12968
+ {
12969
+ control: form.control,
12970
+ name: "postal_code",
12971
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12972
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12973
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12974
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12975
+ ] })
12976
+ }
12977
+ ),
12978
+ /* @__PURE__ */ jsxRuntime.jsx(
12979
+ Form$2.Field,
12980
+ {
12981
+ control: form.control,
12982
+ name: "city",
12983
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12984
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12985
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12986
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12987
+ ] })
12988
+ }
12989
+ )
12990
+ ] }),
12991
+ /* @__PURE__ */ jsxRuntime.jsx(
12992
+ Form$2.Field,
12993
+ {
12994
+ control: form.control,
12995
+ name: "province",
12996
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12997
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12998
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12999
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13000
+ ] })
13001
+ }
13002
+ ),
13003
+ /* @__PURE__ */ jsxRuntime.jsx(
13004
+ Form$2.Field,
13005
+ {
13006
+ control: form.control,
13007
+ name: "phone",
13008
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13009
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13010
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13011
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13012
+ ] })
13013
+ }
13014
+ )
13015
+ ] }) }),
13016
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13017
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13018
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13019
+ ] }) })
13020
+ ]
13021
+ }
13022
+ ) });
13023
+ };
13024
+ const schema$1 = addressSchema;
13025
+ const CustomItems = () => {
13026
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13027
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13028
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13029
+ ] });
13030
+ };
13031
+ const CustomItemsForm = () => {
13032
+ const form = reactHookForm.useForm({
13033
+ resolver: zod.zodResolver(schema)
13034
+ });
13035
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13036
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13037
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13040
+ ] }) })
13041
+ ] }) });
13042
+ };
13043
+ const schema = objectType({
13044
+ email: stringType().email()
13045
+ });
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
13048
13048
  routes: [
@@ -13063,14 +13063,6 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
- {
13067
- Component: BillingAddress,
13068
- path: "/draft-orders/:id/billing-address"
13069
- },
13070
- {
13071
- Component: CustomItems,
13072
- path: "/draft-orders/:id/custom-items"
13073
- },
13074
13066
  {
13075
13067
  Component: Email,
13076
13068
  path: "/draft-orders/:id/email"
@@ -13087,10 +13079,6 @@ const routeModule = {
13087
13079
  Component: Promotions,
13088
13080
  path: "/draft-orders/:id/promotions"
13089
13081
  },
13090
- {
13091
- Component: SalesChannel,
13092
- path: "/draft-orders/:id/sales-channel"
13093
- },
13094
13082
  {
13095
13083
  Component: Shipping,
13096
13084
  path: "/draft-orders/:id/shipping"
@@ -13099,9 +13087,21 @@ const routeModule = {
13099
13087
  Component: ShippingAddress,
13100
13088
  path: "/draft-orders/:id/shipping-address"
13101
13089
  },
13090
+ {
13091
+ Component: SalesChannel,
13092
+ path: "/draft-orders/:id/sales-channel"
13093
+ },
13102
13094
  {
13103
13095
  Component: TransferOwnership,
13104
13096
  path: "/draft-orders/:id/transfer-ownership"
13097
+ },
13098
+ {
13099
+ Component: BillingAddress,
13100
+ path: "/draft-orders/:id/billing-address"
13101
+ },
13102
+ {
13103
+ Component: CustomItems,
13104
+ path: "/draft-orders/:id/custom-items"
13105
13105
  }
13106
13106
  ]
13107
13107
  }