@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.
@@ -9565,217 +9565,6 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
- const BillingAddress = () => {
9569
- const { id } = useParams();
9570
- const { order, isPending, isError, error } = useOrder(id, {
9571
- fields: "+billing_address"
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 Billing Address" }) }),
9580
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9581
- ] }),
9582
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9583
- ] });
9584
- };
9585
- const BillingAddressForm = ({ order }) => {
9586
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9587
- const form = useForm({
9588
- defaultValues: {
9589
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9590
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9591
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9592
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9593
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9594
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9595
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9596
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9597
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9599
- },
9600
- resolver: zodResolver(schema$5)
9601
- });
9602
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9603
- const { handleSuccess } = useRouteModal();
9604
- const onSubmit = form.handleSubmit(async (data) => {
9605
- await mutateAsync(
9606
- { billing_address: data },
9607
- {
9608
- onSuccess: () => {
9609
- handleSuccess();
9610
- },
9611
- onError: (error) => {
9612
- toast.error(error.message);
9613
- }
9614
- }
9615
- );
9616
- });
9617
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9618
- KeyboundForm,
9619
- {
9620
- className: "flex flex-1 flex-col overflow-hidden",
9621
- onSubmit,
9622
- children: [
9623
- /* @__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: [
9624
- /* @__PURE__ */ jsx(
9625
- Form$2.Field,
9626
- {
9627
- control: form.control,
9628
- name: "country_code",
9629
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9630
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9631
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9632
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9633
- ] })
9634
- }
9635
- ),
9636
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9637
- /* @__PURE__ */ jsx(
9638
- Form$2.Field,
9639
- {
9640
- control: form.control,
9641
- name: "first_name",
9642
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9643
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9644
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9645
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9646
- ] })
9647
- }
9648
- ),
9649
- /* @__PURE__ */ jsx(
9650
- Form$2.Field,
9651
- {
9652
- control: form.control,
9653
- name: "last_name",
9654
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9655
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9656
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9657
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9658
- ] })
9659
- }
9660
- )
9661
- ] }),
9662
- /* @__PURE__ */ jsx(
9663
- Form$2.Field,
9664
- {
9665
- control: form.control,
9666
- name: "company",
9667
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9668
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9669
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9670
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9671
- ] })
9672
- }
9673
- ),
9674
- /* @__PURE__ */ jsx(
9675
- Form$2.Field,
9676
- {
9677
- control: form.control,
9678
- name: "address_1",
9679
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9680
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9681
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9682
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9683
- ] })
9684
- }
9685
- ),
9686
- /* @__PURE__ */ jsx(
9687
- Form$2.Field,
9688
- {
9689
- control: form.control,
9690
- name: "address_2",
9691
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9692
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9693
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9694
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9695
- ] })
9696
- }
9697
- ),
9698
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9699
- /* @__PURE__ */ jsx(
9700
- Form$2.Field,
9701
- {
9702
- control: form.control,
9703
- name: "postal_code",
9704
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9705
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9706
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9707
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9708
- ] })
9709
- }
9710
- ),
9711
- /* @__PURE__ */ jsx(
9712
- Form$2.Field,
9713
- {
9714
- control: form.control,
9715
- name: "city",
9716
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9717
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9718
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9719
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9720
- ] })
9721
- }
9722
- )
9723
- ] }),
9724
- /* @__PURE__ */ jsx(
9725
- Form$2.Field,
9726
- {
9727
- control: form.control,
9728
- name: "province",
9729
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9730
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9731
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9732
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9733
- ] })
9734
- }
9735
- ),
9736
- /* @__PURE__ */ jsx(
9737
- Form$2.Field,
9738
- {
9739
- control: form.control,
9740
- name: "phone",
9741
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9742
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9743
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9744
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9745
- ] })
9746
- }
9747
- )
9748
- ] }) }),
9749
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9750
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9751
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9752
- ] }) })
9753
- ]
9754
- }
9755
- ) });
9756
- };
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
9568
  const Email = () => {
9780
9569
  const { id } = useParams();
9781
9570
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9798,7 +9587,7 @@ const EmailForm = ({ order }) => {
9798
9587
  defaultValues: {
9799
9588
  email: order.email ?? ""
9800
9589
  },
9801
- resolver: zodResolver(schema$3)
9590
+ resolver: zodResolver(schema$5)
9802
9591
  });
9803
9592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
9593
  const { handleSuccess } = useRouteModal();
@@ -9841,7 +9630,7 @@ const EmailForm = ({ order }) => {
9841
9630
  }
9842
9631
  ) });
9843
9632
  };
9844
- const schema$3 = objectType({
9633
+ const schema$5 = objectType({
9845
9634
  email: stringType().email()
9846
9635
  });
9847
9636
  const NumberInput = forwardRef(
@@ -11445,127 +11234,21 @@ function getPromotionIds(items, shippingMethods) {
11445
11234
  }
11446
11235
  return Array.from(promotionIds);
11447
11236
  }
11448
- const SalesChannel = () => {
11237
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11238
+ const Shipping = () => {
11239
+ var _a;
11449
11240
  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
- );
11459
- if (isError) {
11460
- throw error;
11461
- }
11462
- const ISrEADY = !!draft_order && !isPending;
11463
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11464
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
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" }) })
11467
- ] }),
11468
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11469
- ] });
11470
- };
11471
- const SalesChannelForm = ({ order }) => {
11472
- const form = useForm({
11473
- defaultValues: {
11474
- sales_channel_id: order.sales_channel_id || ""
11475
- },
11476
- resolver: zodResolver(schema$2)
11477
- });
11478
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11479
- const { handleSuccess } = useRouteModal();
11480
- const onSubmit = form.handleSubmit(async (data) => {
11481
- await mutateAsync(
11482
- {
11483
- sales_channel_id: data.sales_channel_id
11484
- },
11485
- {
11486
- onSuccess: () => {
11487
- toast.success("Sales channel updated");
11488
- handleSuccess();
11489
- },
11490
- onError: (error) => {
11491
- toast.error(error.message);
11492
- }
11493
- }
11494
- );
11495
- });
11496
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11497
- KeyboundForm,
11498
- {
11499
- className: "flex flex-1 flex-col overflow-hidden",
11500
- onSubmit,
11501
- children: [
11502
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11503
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11504
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11505
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11506
- ] }) })
11507
- ]
11508
- }
11509
- ) });
11510
- };
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
- });
11554
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11555
- const Shipping = () => {
11556
- var _a;
11557
- const { id } = useParams();
11558
- const { order, isPending, isError, error } = useOrder(id, {
11559
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11560
- });
11561
- const {
11562
- order: preview,
11563
- isPending: isPreviewPending,
11564
- isError: isPreviewError,
11565
- error: previewError
11566
- } = useOrderPreview(id);
11567
- useInitiateOrderEdit({ preview });
11568
- const { onCancel } = useCancelOrderEdit({ preview });
11241
+ const { order, isPending, isError, error } = useOrder(id, {
11242
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11243
+ });
11244
+ const {
11245
+ order: preview,
11246
+ isPending: isPreviewPending,
11247
+ isError: isPreviewError,
11248
+ error: previewError
11249
+ } = useOrderPreview(id);
11250
+ useInitiateOrderEdit({ preview });
11251
+ const { onCancel } = useCancelOrderEdit({ preview });
11569
11252
  if (isError) {
11570
11253
  throw error;
11571
11254
  }
@@ -12390,7 +12073,7 @@ const ShippingAddressForm = ({ order }) => {
12390
12073
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12391
12074
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12392
12075
  },
12393
- resolver: zodResolver(schema$1)
12076
+ resolver: zodResolver(schema$4)
12394
12077
  });
12395
12078
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
12079
  const { handleSuccess } = useRouteModal();
@@ -12560,7 +12243,113 @@ const ShippingAddressForm = ({ order }) => {
12560
12243
  }
12561
12244
  ) });
12562
12245
  };
12563
- const schema$1 = addressSchema;
12246
+ const schema$4 = addressSchema;
12247
+ const SalesChannel = () => {
12248
+ const { id } = useParams();
12249
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12250
+ id,
12251
+ {
12252
+ fields: "+sales_channel_id"
12253
+ },
12254
+ {
12255
+ enabled: !!id
12256
+ }
12257
+ );
12258
+ if (isError) {
12259
+ throw error;
12260
+ }
12261
+ const ISrEADY = !!draft_order && !isPending;
12262
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12263
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12264
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12265
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12266
+ ] }),
12267
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12268
+ ] });
12269
+ };
12270
+ const SalesChannelForm = ({ order }) => {
12271
+ const form = useForm({
12272
+ defaultValues: {
12273
+ sales_channel_id: order.sales_channel_id || ""
12274
+ },
12275
+ resolver: zodResolver(schema$3)
12276
+ });
12277
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12278
+ const { handleSuccess } = useRouteModal();
12279
+ const onSubmit = form.handleSubmit(async (data) => {
12280
+ await mutateAsync(
12281
+ {
12282
+ sales_channel_id: data.sales_channel_id
12283
+ },
12284
+ {
12285
+ onSuccess: () => {
12286
+ toast.success("Sales channel updated");
12287
+ handleSuccess();
12288
+ },
12289
+ onError: (error) => {
12290
+ toast.error(error.message);
12291
+ }
12292
+ }
12293
+ );
12294
+ });
12295
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12296
+ KeyboundForm,
12297
+ {
12298
+ className: "flex flex-1 flex-col overflow-hidden",
12299
+ onSubmit,
12300
+ children: [
12301
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12302
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12303
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12304
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12305
+ ] }) })
12306
+ ]
12307
+ }
12308
+ ) });
12309
+ };
12310
+ const SalesChannelField = ({ control, order }) => {
12311
+ const salesChannels = useComboboxData({
12312
+ queryFn: async (params) => {
12313
+ return await sdk.admin.salesChannel.list(params);
12314
+ },
12315
+ queryKey: ["sales-channels"],
12316
+ getOptions: (data) => {
12317
+ return data.sales_channels.map((salesChannel) => ({
12318
+ label: salesChannel.name,
12319
+ value: salesChannel.id
12320
+ }));
12321
+ },
12322
+ defaultValue: order.sales_channel_id || void 0
12323
+ });
12324
+ return /* @__PURE__ */ jsx(
12325
+ Form$2.Field,
12326
+ {
12327
+ control,
12328
+ name: "sales_channel_id",
12329
+ render: ({ field }) => {
12330
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12331
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12332
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12333
+ Combobox,
12334
+ {
12335
+ options: salesChannels.options,
12336
+ fetchNextPage: salesChannels.fetchNextPage,
12337
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12338
+ searchValue: salesChannels.searchValue,
12339
+ onSearchValueChange: salesChannels.onSearchValueChange,
12340
+ placeholder: "Select sales channel",
12341
+ ...field
12342
+ }
12343
+ ) }),
12344
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12345
+ ] });
12346
+ }
12347
+ }
12348
+ );
12349
+ };
12350
+ const schema$3 = objectType({
12351
+ sales_channel_id: stringType().min(1)
12352
+ });
12564
12353
  const TransferOwnership = () => {
12565
12354
  const { id } = useParams();
12566
12355
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12584,7 +12373,7 @@ const TransferOwnershipForm = ({ order }) => {
12584
12373
  defaultValues: {
12585
12374
  customer_id: order.customer_id || ""
12586
12375
  },
12587
- resolver: zodResolver(schema)
12376
+ resolver: zodResolver(schema$2)
12588
12377
  });
12589
12378
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12590
12379
  const { handleSuccess } = useRouteModal();
@@ -13034,9 +12823,220 @@ const Illustration = () => {
13034
12823
  }
13035
12824
  );
13036
12825
  };
13037
- const schema = objectType({
12826
+ const schema$2 = objectType({
13038
12827
  customer_id: stringType().min(1)
13039
12828
  });
12829
+ const BillingAddress = () => {
12830
+ const { id } = useParams();
12831
+ const { order, isPending, isError, error } = useOrder(id, {
12832
+ fields: "+billing_address"
12833
+ });
12834
+ if (isError) {
12835
+ throw error;
12836
+ }
12837
+ const isReady = !isPending && !!order;
12838
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12839
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12840
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12841
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12842
+ ] }),
12843
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12844
+ ] });
12845
+ };
12846
+ const BillingAddressForm = ({ order }) => {
12847
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12848
+ const form = useForm({
12849
+ defaultValues: {
12850
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12851
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12852
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12853
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12854
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12855
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12856
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12857
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12858
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12859
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12860
+ },
12861
+ resolver: zodResolver(schema$1)
12862
+ });
12863
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12864
+ const { handleSuccess } = useRouteModal();
12865
+ const onSubmit = form.handleSubmit(async (data) => {
12866
+ await mutateAsync(
12867
+ { billing_address: data },
12868
+ {
12869
+ onSuccess: () => {
12870
+ handleSuccess();
12871
+ },
12872
+ onError: (error) => {
12873
+ toast.error(error.message);
12874
+ }
12875
+ }
12876
+ );
12877
+ });
12878
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12879
+ KeyboundForm,
12880
+ {
12881
+ className: "flex flex-1 flex-col overflow-hidden",
12882
+ onSubmit,
12883
+ children: [
12884
+ /* @__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: [
12885
+ /* @__PURE__ */ jsx(
12886
+ Form$2.Field,
12887
+ {
12888
+ control: form.control,
12889
+ name: "country_code",
12890
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12891
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12892
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12893
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12894
+ ] })
12895
+ }
12896
+ ),
12897
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12898
+ /* @__PURE__ */ jsx(
12899
+ Form$2.Field,
12900
+ {
12901
+ control: form.control,
12902
+ name: "first_name",
12903
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12904
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12905
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12906
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12907
+ ] })
12908
+ }
12909
+ ),
12910
+ /* @__PURE__ */ jsx(
12911
+ Form$2.Field,
12912
+ {
12913
+ control: form.control,
12914
+ name: "last_name",
12915
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12916
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12917
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12918
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12919
+ ] })
12920
+ }
12921
+ )
12922
+ ] }),
12923
+ /* @__PURE__ */ jsx(
12924
+ Form$2.Field,
12925
+ {
12926
+ control: form.control,
12927
+ name: "company",
12928
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12929
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12930
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12931
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12932
+ ] })
12933
+ }
12934
+ ),
12935
+ /* @__PURE__ */ jsx(
12936
+ Form$2.Field,
12937
+ {
12938
+ control: form.control,
12939
+ name: "address_1",
12940
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12941
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12942
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12943
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12944
+ ] })
12945
+ }
12946
+ ),
12947
+ /* @__PURE__ */ jsx(
12948
+ Form$2.Field,
12949
+ {
12950
+ control: form.control,
12951
+ name: "address_2",
12952
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12953
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12954
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12955
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12956
+ ] })
12957
+ }
12958
+ ),
12959
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12960
+ /* @__PURE__ */ jsx(
12961
+ Form$2.Field,
12962
+ {
12963
+ control: form.control,
12964
+ name: "postal_code",
12965
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12966
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12967
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12968
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12969
+ ] })
12970
+ }
12971
+ ),
12972
+ /* @__PURE__ */ jsx(
12973
+ Form$2.Field,
12974
+ {
12975
+ control: form.control,
12976
+ name: "city",
12977
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12978
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12979
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12980
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12981
+ ] })
12982
+ }
12983
+ )
12984
+ ] }),
12985
+ /* @__PURE__ */ jsx(
12986
+ Form$2.Field,
12987
+ {
12988
+ control: form.control,
12989
+ name: "province",
12990
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12991
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12992
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12993
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12994
+ ] })
12995
+ }
12996
+ ),
12997
+ /* @__PURE__ */ jsx(
12998
+ Form$2.Field,
12999
+ {
13000
+ control: form.control,
13001
+ name: "phone",
13002
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13003
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13004
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13005
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13006
+ ] })
13007
+ }
13008
+ )
13009
+ ] }) }),
13010
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13011
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13012
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13013
+ ] }) })
13014
+ ]
13015
+ }
13016
+ ) });
13017
+ };
13018
+ const schema$1 = addressSchema;
13019
+ const CustomItems = () => {
13020
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13021
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13022
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
13023
+ ] });
13024
+ };
13025
+ const CustomItemsForm = () => {
13026
+ const form = useForm({
13027
+ resolver: zodResolver(schema)
13028
+ });
13029
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13030
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13031
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13034
+ ] }) })
13035
+ ] }) });
13036
+ };
13037
+ const schema = objectType({
13038
+ email: stringType().email()
13039
+ });
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,14 +13057,6 @@ 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"
@@ -13081,10 +13073,6 @@ const routeModule = {
13081
13073
  Component: Promotions,
13082
13074
  path: "/draft-orders/:id/promotions"
13083
13075
  },
13084
- {
13085
- Component: SalesChannel,
13086
- path: "/draft-orders/:id/sales-channel"
13087
- },
13088
13076
  {
13089
13077
  Component: Shipping,
13090
13078
  path: "/draft-orders/:id/shipping"
@@ -13093,9 +13081,21 @@ const routeModule = {
13093
13081
  Component: ShippingAddress,
13094
13082
  path: "/draft-orders/:id/shipping-address"
13095
13083
  },
13084
+ {
13085
+ Component: SalesChannel,
13086
+ path: "/draft-orders/:id/sales-channel"
13087
+ },
13096
13088
  {
13097
13089
  Component: TransferOwnership,
13098
13090
  path: "/draft-orders/:id/transfer-ownership"
13091
+ },
13092
+ {
13093
+ Component: BillingAddress,
13094
+ path: "/draft-orders/:id/billing-address"
13095
+ },
13096
+ {
13097
+ Component: CustomItems,
13098
+ path: "/draft-orders/:id/custom-items"
13099
13099
  }
13100
13100
  ]
13101
13101
  }