@medusajs/draft-order 2.11.1-preview-20251023210200 → 2.11.1-preview-20251024031436

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,196 +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
9568
  const CustomItems = () => {
9759
9569
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
9570
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -9763,7 +9573,7 @@ const CustomItems = () => {
9763
9573
  };
9764
9574
  const CustomItemsForm = () => {
9765
9575
  const form = useForm({
9766
- resolver: zodResolver(schema$4)
9576
+ resolver: zodResolver(schema$5)
9767
9577
  });
9768
9578
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
9579
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -9773,7 +9583,7 @@ const CustomItemsForm = () => {
9773
9583
  ] }) })
9774
9584
  ] }) });
9775
9585
  };
9776
- const schema$4 = objectType({
9586
+ const schema$5 = objectType({
9777
9587
  email: stringType().email()
9778
9588
  });
9779
9589
  const Email = () => {
@@ -9798,7 +9608,7 @@ const EmailForm = ({ order }) => {
9798
9608
  defaultValues: {
9799
9609
  email: order.email ?? ""
9800
9610
  },
9801
- resolver: zodResolver(schema$3)
9611
+ resolver: zodResolver(schema$4)
9802
9612
  });
9803
9613
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
9614
  const { handleSuccess } = useRouteModal();
@@ -9841,7 +9651,7 @@ const EmailForm = ({ order }) => {
9841
9651
  }
9842
9652
  ) });
9843
9653
  };
9844
- const schema$3 = objectType({
9654
+ const schema$4 = objectType({
9845
9655
  email: stringType().email()
9846
9656
  });
9847
9657
  const NumberInput = forwardRef(
@@ -11473,7 +11283,7 @@ const SalesChannelForm = ({ order }) => {
11473
11283
  defaultValues: {
11474
11284
  sales_channel_id: order.sales_channel_id || ""
11475
11285
  },
11476
- resolver: zodResolver(schema$2)
11286
+ resolver: zodResolver(schema$3)
11477
11287
  });
11478
11288
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11479
11289
  const { handleSuccess } = useRouteModal();
@@ -11548,63 +11358,266 @@ const SalesChannelField = ({ control, order }) => {
11548
11358
  }
11549
11359
  );
11550
11360
  };
11551
- const schema$2 = objectType({
11361
+ const schema$3 = objectType({
11552
11362
  sales_channel_id: stringType().min(1)
11553
11363
  });
11554
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11555
- const Shipping = () => {
11556
- var _a;
11364
+ const ShippingAddress = () => {
11557
11365
  const { id } = useParams();
11558
11366
  const { order, isPending, isError, error } = useOrder(id, {
11559
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11367
+ fields: "+shipping_address"
11560
11368
  });
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 });
11569
11369
  if (isError) {
11570
11370
  throw error;
11571
11371
  }
11572
- if (isPreviewError) {
11573
- throw previewError;
11574
- }
11575
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11576
- const isReady = preview && !isPreviewPending && order && !isPending;
11577
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11578
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11579
- /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11580
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11581
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11582
- ] }) }) }),
11583
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11584
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11585
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11586
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11587
- ] }) });
11372
+ const isReady = !isPending && !!order;
11373
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11374
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11375
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11376
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11377
+ ] }),
11378
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11379
+ ] });
11588
11380
  };
11589
- const ShippingForm = ({ preview, order }) => {
11590
- var _a;
11591
- const { setIsOpen } = useStackedModal();
11592
- const [isSubmitting, setIsSubmitting] = useState(false);
11593
- const [data, setData] = useState(null);
11594
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11595
- const { shipping_options } = useShippingOptions(
11596
- {
11597
- id: appliedShippingOptionIds,
11598
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11599
- },
11600
- {
11601
- enabled: appliedShippingOptionIds.length > 0
11602
- }
11603
- );
11604
- const uniqueShippingProfiles = useMemo(() => {
11605
- const profiles = /* @__PURE__ */ new Map();
11606
- getUniqueShippingProfiles(order.items).forEach((profile) => {
11607
- profiles.set(profile.id, profile);
11381
+ const ShippingAddressForm = ({ order }) => {
11382
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11383
+ const form = useForm({
11384
+ defaultValues: {
11385
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11386
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11387
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11388
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11389
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11390
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11391
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11392
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11393
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11394
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11395
+ },
11396
+ resolver: zodResolver(schema$2)
11397
+ });
11398
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11399
+ const { handleSuccess } = useRouteModal();
11400
+ const onSubmit = form.handleSubmit(async (data) => {
11401
+ await mutateAsync(
11402
+ {
11403
+ shipping_address: {
11404
+ first_name: data.first_name,
11405
+ last_name: data.last_name,
11406
+ company: data.company,
11407
+ address_1: data.address_1,
11408
+ address_2: data.address_2,
11409
+ city: data.city,
11410
+ province: data.province,
11411
+ country_code: data.country_code,
11412
+ postal_code: data.postal_code,
11413
+ phone: data.phone
11414
+ }
11415
+ },
11416
+ {
11417
+ onSuccess: () => {
11418
+ handleSuccess();
11419
+ },
11420
+ onError: (error) => {
11421
+ toast.error(error.message);
11422
+ }
11423
+ }
11424
+ );
11425
+ });
11426
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11427
+ KeyboundForm,
11428
+ {
11429
+ className: "flex flex-1 flex-col overflow-hidden",
11430
+ onSubmit,
11431
+ children: [
11432
+ /* @__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: [
11433
+ /* @__PURE__ */ jsx(
11434
+ Form$2.Field,
11435
+ {
11436
+ control: form.control,
11437
+ name: "country_code",
11438
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11439
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11440
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11441
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11442
+ ] })
11443
+ }
11444
+ ),
11445
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11446
+ /* @__PURE__ */ jsx(
11447
+ Form$2.Field,
11448
+ {
11449
+ control: form.control,
11450
+ name: "first_name",
11451
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11452
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11453
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11454
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11455
+ ] })
11456
+ }
11457
+ ),
11458
+ /* @__PURE__ */ jsx(
11459
+ Form$2.Field,
11460
+ {
11461
+ control: form.control,
11462
+ name: "last_name",
11463
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11464
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11465
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11466
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11467
+ ] })
11468
+ }
11469
+ )
11470
+ ] }),
11471
+ /* @__PURE__ */ jsx(
11472
+ Form$2.Field,
11473
+ {
11474
+ control: form.control,
11475
+ name: "company",
11476
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11477
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11478
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11479
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11480
+ ] })
11481
+ }
11482
+ ),
11483
+ /* @__PURE__ */ jsx(
11484
+ Form$2.Field,
11485
+ {
11486
+ control: form.control,
11487
+ name: "address_1",
11488
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11489
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11490
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11491
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11492
+ ] })
11493
+ }
11494
+ ),
11495
+ /* @__PURE__ */ jsx(
11496
+ Form$2.Field,
11497
+ {
11498
+ control: form.control,
11499
+ name: "address_2",
11500
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11501
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11502
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11503
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11504
+ ] })
11505
+ }
11506
+ ),
11507
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11508
+ /* @__PURE__ */ jsx(
11509
+ Form$2.Field,
11510
+ {
11511
+ control: form.control,
11512
+ name: "postal_code",
11513
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11514
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11515
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11516
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11517
+ ] })
11518
+ }
11519
+ ),
11520
+ /* @__PURE__ */ jsx(
11521
+ Form$2.Field,
11522
+ {
11523
+ control: form.control,
11524
+ name: "city",
11525
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11526
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11527
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11528
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11529
+ ] })
11530
+ }
11531
+ )
11532
+ ] }),
11533
+ /* @__PURE__ */ jsx(
11534
+ Form$2.Field,
11535
+ {
11536
+ control: form.control,
11537
+ name: "province",
11538
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11539
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11540
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11541
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11542
+ ] })
11543
+ }
11544
+ ),
11545
+ /* @__PURE__ */ jsx(
11546
+ Form$2.Field,
11547
+ {
11548
+ control: form.control,
11549
+ name: "phone",
11550
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11551
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11552
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11553
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11554
+ ] })
11555
+ }
11556
+ )
11557
+ ] }) }),
11558
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11559
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11560
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11561
+ ] }) })
11562
+ ]
11563
+ }
11564
+ ) });
11565
+ };
11566
+ const schema$2 = addressSchema;
11567
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11568
+ const Shipping = () => {
11569
+ var _a;
11570
+ const { id } = useParams();
11571
+ const { order, isPending, isError, error } = useOrder(id, {
11572
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11573
+ });
11574
+ const {
11575
+ order: preview,
11576
+ isPending: isPreviewPending,
11577
+ isError: isPreviewError,
11578
+ error: previewError
11579
+ } = useOrderPreview(id);
11580
+ useInitiateOrderEdit({ preview });
11581
+ const { onCancel } = useCancelOrderEdit({ preview });
11582
+ if (isError) {
11583
+ throw error;
11584
+ }
11585
+ if (isPreviewError) {
11586
+ throw previewError;
11587
+ }
11588
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11589
+ const isReady = preview && !isPreviewPending && order && !isPending;
11590
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11591
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11592
+ /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11593
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11594
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11595
+ ] }) }) }),
11596
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11597
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11598
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11599
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11600
+ ] }) });
11601
+ };
11602
+ const ShippingForm = ({ preview, order }) => {
11603
+ var _a;
11604
+ const { setIsOpen } = useStackedModal();
11605
+ const [isSubmitting, setIsSubmitting] = useState(false);
11606
+ const [data, setData] = useState(null);
11607
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11608
+ const { shipping_options } = useShippingOptions(
11609
+ {
11610
+ id: appliedShippingOptionIds,
11611
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11612
+ },
11613
+ {
11614
+ enabled: appliedShippingOptionIds.length > 0
11615
+ }
11616
+ );
11617
+ const uniqueShippingProfiles = useMemo(() => {
11618
+ const profiles = /* @__PURE__ */ new Map();
11619
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
11620
+ profiles.set(profile.id, profile);
11608
11621
  });
11609
11622
  shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11610
11623
  profiles.set(option.shipping_profile_id, option.shipping_profile);
@@ -12358,224 +12371,21 @@ const CustomAmountField = ({
12358
12371
  }
12359
12372
  );
12360
12373
  };
12361
- const ShippingAddress = () => {
12374
+ const TransferOwnership = () => {
12362
12375
  const { id } = useParams();
12363
- const { order, isPending, isError, error } = useOrder(id, {
12364
- fields: "+shipping_address"
12376
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12377
+ fields: "id,customer_id,customer.*"
12365
12378
  });
12366
12379
  if (isError) {
12367
12380
  throw error;
12368
12381
  }
12369
- const isReady = !isPending && !!order;
12382
+ const isReady = !isPending && !!draft_order;
12370
12383
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12371
12384
  /* @__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" }) })
12385
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12386
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12374
12387
  ] }),
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;
12564
- const TransferOwnership = () => {
12565
- const { id } = useParams();
12566
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12567
- fields: "id,customer_id,customer.*"
12568
- });
12569
- if (isError) {
12570
- throw error;
12571
- }
12572
- const isReady = !isPending && !!draft_order;
12573
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12574
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12575
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12576
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12577
- ] }),
12578
- isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12388
+ isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12579
12389
  ] });
12580
12390
  };
12581
12391
  const TransferOwnershipForm = ({ order }) => {
@@ -12584,7 +12394,7 @@ const TransferOwnershipForm = ({ order }) => {
12584
12394
  defaultValues: {
12585
12395
  customer_id: order.customer_id || ""
12586
12396
  },
12587
- resolver: zodResolver(schema)
12397
+ resolver: zodResolver(schema$1)
12588
12398
  });
12589
12399
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12590
12400
  const { handleSuccess } = useRouteModal();
@@ -13034,9 +12844,199 @@ const Illustration = () => {
13034
12844
  }
13035
12845
  );
13036
12846
  };
13037
- const schema = objectType({
12847
+ const schema$1 = objectType({
13038
12848
  customer_id: stringType().min(1)
13039
12849
  });
12850
+ const BillingAddress = () => {
12851
+ const { id } = useParams();
12852
+ const { order, isPending, isError, error } = useOrder(id, {
12853
+ fields: "+billing_address"
12854
+ });
12855
+ if (isError) {
12856
+ throw error;
12857
+ }
12858
+ const isReady = !isPending && !!order;
12859
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12860
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12861
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12862
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12863
+ ] }),
12864
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12865
+ ] });
12866
+ };
12867
+ const BillingAddressForm = ({ order }) => {
12868
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12869
+ const form = useForm({
12870
+ defaultValues: {
12871
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12872
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12873
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12874
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12875
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12876
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12877
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12878
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12879
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12880
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12881
+ },
12882
+ resolver: zodResolver(schema)
12883
+ });
12884
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12885
+ const { handleSuccess } = useRouteModal();
12886
+ const onSubmit = form.handleSubmit(async (data) => {
12887
+ await mutateAsync(
12888
+ { billing_address: data },
12889
+ {
12890
+ onSuccess: () => {
12891
+ handleSuccess();
12892
+ },
12893
+ onError: (error) => {
12894
+ toast.error(error.message);
12895
+ }
12896
+ }
12897
+ );
12898
+ });
12899
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12900
+ KeyboundForm,
12901
+ {
12902
+ className: "flex flex-1 flex-col overflow-hidden",
12903
+ onSubmit,
12904
+ children: [
12905
+ /* @__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: [
12906
+ /* @__PURE__ */ jsx(
12907
+ Form$2.Field,
12908
+ {
12909
+ control: form.control,
12910
+ name: "country_code",
12911
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12912
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12913
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12914
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12915
+ ] })
12916
+ }
12917
+ ),
12918
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12919
+ /* @__PURE__ */ jsx(
12920
+ Form$2.Field,
12921
+ {
12922
+ control: form.control,
12923
+ name: "first_name",
12924
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12925
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12926
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12927
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12928
+ ] })
12929
+ }
12930
+ ),
12931
+ /* @__PURE__ */ jsx(
12932
+ Form$2.Field,
12933
+ {
12934
+ control: form.control,
12935
+ name: "last_name",
12936
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12937
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12938
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12939
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12940
+ ] })
12941
+ }
12942
+ )
12943
+ ] }),
12944
+ /* @__PURE__ */ jsx(
12945
+ Form$2.Field,
12946
+ {
12947
+ control: form.control,
12948
+ name: "company",
12949
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12950
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12951
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12952
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12953
+ ] })
12954
+ }
12955
+ ),
12956
+ /* @__PURE__ */ jsx(
12957
+ Form$2.Field,
12958
+ {
12959
+ control: form.control,
12960
+ name: "address_1",
12961
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12962
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12963
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12964
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12965
+ ] })
12966
+ }
12967
+ ),
12968
+ /* @__PURE__ */ jsx(
12969
+ Form$2.Field,
12970
+ {
12971
+ control: form.control,
12972
+ name: "address_2",
12973
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12974
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12975
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12976
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12977
+ ] })
12978
+ }
12979
+ ),
12980
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12981
+ /* @__PURE__ */ jsx(
12982
+ Form$2.Field,
12983
+ {
12984
+ control: form.control,
12985
+ name: "postal_code",
12986
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12987
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12988
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12989
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12990
+ ] })
12991
+ }
12992
+ ),
12993
+ /* @__PURE__ */ jsx(
12994
+ Form$2.Field,
12995
+ {
12996
+ control: form.control,
12997
+ name: "city",
12998
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12999
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13000
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13001
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13002
+ ] })
13003
+ }
13004
+ )
13005
+ ] }),
13006
+ /* @__PURE__ */ jsx(
13007
+ Form$2.Field,
13008
+ {
13009
+ control: form.control,
13010
+ name: "province",
13011
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13012
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13013
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13014
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13015
+ ] })
13016
+ }
13017
+ ),
13018
+ /* @__PURE__ */ jsx(
13019
+ Form$2.Field,
13020
+ {
13021
+ control: form.control,
13022
+ name: "phone",
13023
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13024
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13025
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13026
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13027
+ ] })
13028
+ }
13029
+ )
13030
+ ] }) }),
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", isLoading: isPending, children: "Save" })
13034
+ ] }) })
13035
+ ]
13036
+ }
13037
+ ) });
13038
+ };
13039
+ const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,10 +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
13060
  {
13065
13061
  Component: CustomItems,
13066
13062
  path: "/draft-orders/:id/custom-items"
@@ -13085,17 +13081,21 @@ const routeModule = {
13085
13081
  Component: SalesChannel,
13086
13082
  path: "/draft-orders/:id/sales-channel"
13087
13083
  },
13088
- {
13089
- Component: Shipping,
13090
- path: "/draft-orders/:id/shipping"
13091
- },
13092
13084
  {
13093
13085
  Component: ShippingAddress,
13094
13086
  path: "/draft-orders/:id/shipping-address"
13095
13087
  },
13088
+ {
13089
+ Component: Shipping,
13090
+ path: "/draft-orders/:id/shipping"
13091
+ },
13096
13092
  {
13097
13093
  Component: TransferOwnership,
13098
13094
  path: "/draft-orders/:id/transfer-ownership"
13095
+ },
13096
+ {
13097
+ Component: BillingAddress,
13098
+ path: "/draft-orders/:id/billing-address"
13099
13099
  }
13100
13100
  ]
13101
13101
  }