@medusajs/draft-order 2.11.1-preview-20251022180207 → 2.11.1-preview-20251023000334

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.
@@ -10628,6 +10628,196 @@ const customItemSchema = objectType({
10628
10628
  quantity: numberType(),
10629
10629
  unit_price: unionType([numberType(), stringType()])
10630
10630
  });
10631
+ const BillingAddress = () => {
10632
+ const { id } = useParams();
10633
+ const { order, isPending, isError, error } = useOrder(id, {
10634
+ fields: "+billing_address"
10635
+ });
10636
+ if (isError) {
10637
+ throw error;
10638
+ }
10639
+ const isReady = !isPending && !!order;
10640
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10641
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10642
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
10643
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10644
+ ] }),
10645
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
10646
+ ] });
10647
+ };
10648
+ const BillingAddressForm = ({ order }) => {
10649
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10650
+ const form = useForm({
10651
+ defaultValues: {
10652
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10653
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10654
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10655
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10656
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10657
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10658
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10659
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10660
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10661
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10662
+ },
10663
+ resolver: zodResolver(schema$3)
10664
+ });
10665
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10666
+ const { handleSuccess } = useRouteModal();
10667
+ const onSubmit = form.handleSubmit(async (data) => {
10668
+ await mutateAsync(
10669
+ { billing_address: data },
10670
+ {
10671
+ onSuccess: () => {
10672
+ handleSuccess();
10673
+ },
10674
+ onError: (error) => {
10675
+ toast.error(error.message);
10676
+ }
10677
+ }
10678
+ );
10679
+ });
10680
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10681
+ KeyboundForm,
10682
+ {
10683
+ className: "flex flex-1 flex-col overflow-hidden",
10684
+ onSubmit,
10685
+ children: [
10686
+ /* @__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: [
10687
+ /* @__PURE__ */ jsx(
10688
+ Form$2.Field,
10689
+ {
10690
+ control: form.control,
10691
+ name: "country_code",
10692
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10693
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
10694
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
10695
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10696
+ ] })
10697
+ }
10698
+ ),
10699
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10700
+ /* @__PURE__ */ jsx(
10701
+ Form$2.Field,
10702
+ {
10703
+ control: form.control,
10704
+ name: "first_name",
10705
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10706
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
10707
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10708
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10709
+ ] })
10710
+ }
10711
+ ),
10712
+ /* @__PURE__ */ jsx(
10713
+ Form$2.Field,
10714
+ {
10715
+ control: form.control,
10716
+ name: "last_name",
10717
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10718
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
10719
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10720
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10721
+ ] })
10722
+ }
10723
+ )
10724
+ ] }),
10725
+ /* @__PURE__ */ jsx(
10726
+ Form$2.Field,
10727
+ {
10728
+ control: form.control,
10729
+ name: "company",
10730
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10731
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
10732
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10733
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10734
+ ] })
10735
+ }
10736
+ ),
10737
+ /* @__PURE__ */ jsx(
10738
+ Form$2.Field,
10739
+ {
10740
+ control: form.control,
10741
+ name: "address_1",
10742
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10743
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
10744
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10745
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10746
+ ] })
10747
+ }
10748
+ ),
10749
+ /* @__PURE__ */ jsx(
10750
+ Form$2.Field,
10751
+ {
10752
+ control: form.control,
10753
+ name: "address_2",
10754
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10755
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10756
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10757
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10758
+ ] })
10759
+ }
10760
+ ),
10761
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10762
+ /* @__PURE__ */ jsx(
10763
+ Form$2.Field,
10764
+ {
10765
+ control: form.control,
10766
+ name: "postal_code",
10767
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10768
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
10769
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10770
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10771
+ ] })
10772
+ }
10773
+ ),
10774
+ /* @__PURE__ */ jsx(
10775
+ Form$2.Field,
10776
+ {
10777
+ control: form.control,
10778
+ name: "city",
10779
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10780
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
10781
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10782
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10783
+ ] })
10784
+ }
10785
+ )
10786
+ ] }),
10787
+ /* @__PURE__ */ jsx(
10788
+ Form$2.Field,
10789
+ {
10790
+ control: form.control,
10791
+ name: "province",
10792
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10793
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10794
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10795
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10796
+ ] })
10797
+ }
10798
+ ),
10799
+ /* @__PURE__ */ jsx(
10800
+ Form$2.Field,
10801
+ {
10802
+ control: form.control,
10803
+ name: "phone",
10804
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10805
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
10806
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10807
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10808
+ ] })
10809
+ }
10810
+ )
10811
+ ] }) }),
10812
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10813
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10814
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10815
+ ] }) })
10816
+ ]
10817
+ }
10818
+ ) });
10819
+ };
10820
+ const schema$3 = addressSchema;
10631
10821
  const InlineTip = forwardRef(
10632
10822
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10633
10823
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11283,7 +11473,7 @@ const SalesChannelForm = ({ order }) => {
11283
11473
  defaultValues: {
11284
11474
  sales_channel_id: order.sales_channel_id || ""
11285
11475
  },
11286
- resolver: zodResolver(schema$3)
11476
+ resolver: zodResolver(schema$2)
11287
11477
  });
11288
11478
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11289
11479
  const { handleSuccess } = useRouteModal();
@@ -11358,58 +11548,261 @@ const SalesChannelField = ({ control, order }) => {
11358
11548
  }
11359
11549
  );
11360
11550
  };
11361
- const schema$3 = objectType({
11551
+ const schema$2 = objectType({
11362
11552
  sales_channel_id: stringType().min(1)
11363
11553
  });
11364
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11365
- const Shipping = () => {
11366
- var _a;
11554
+ const ShippingAddress = () => {
11367
11555
  const { id } = useParams();
11368
11556
  const { order, isPending, isError, error } = useOrder(id, {
11369
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11557
+ fields: "+shipping_address"
11370
11558
  });
11371
- const {
11372
- order: preview,
11373
- isPending: isPreviewPending,
11374
- isError: isPreviewError,
11375
- error: previewError
11376
- } = useOrderPreview(id);
11377
- useInitiateOrderEdit({ preview });
11378
- const { onCancel } = useCancelOrderEdit({ preview });
11379
11559
  if (isError) {
11380
11560
  throw error;
11381
11561
  }
11382
- if (isPreviewError) {
11383
- throw previewError;
11384
- }
11385
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11386
- const isReady = preview && !isPreviewPending && order && !isPending;
11387
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11388
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11389
- /* @__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: [
11390
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11391
- /* @__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." }) })
11392
- ] }) }) }),
11393
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11394
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11395
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11396
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11397
- ] }) });
11562
+ const isReady = !isPending && !!order;
11563
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11564
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11565
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11566
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11567
+ ] }),
11568
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11569
+ ] });
11398
11570
  };
11399
- const ShippingForm = ({ preview, order }) => {
11400
- var _a;
11401
- const { setIsOpen } = useStackedModal();
11402
- const [isSubmitting, setIsSubmitting] = useState(false);
11403
- const [data, setData] = useState(null);
11404
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11405
- const { shipping_options } = useShippingOptions(
11406
- {
11407
- id: appliedShippingOptionIds,
11408
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11571
+ const ShippingAddressForm = ({ order }) => {
11572
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11573
+ const form = useForm({
11574
+ defaultValues: {
11575
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11576
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11577
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11578
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11579
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11580
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11581
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11582
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11583
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11584
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11409
11585
  },
11410
- {
11411
- enabled: appliedShippingOptionIds.length > 0
11412
- }
11586
+ resolver: zodResolver(schema$1)
11587
+ });
11588
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11589
+ const { handleSuccess } = useRouteModal();
11590
+ const onSubmit = form.handleSubmit(async (data) => {
11591
+ await mutateAsync(
11592
+ {
11593
+ shipping_address: {
11594
+ first_name: data.first_name,
11595
+ last_name: data.last_name,
11596
+ company: data.company,
11597
+ address_1: data.address_1,
11598
+ address_2: data.address_2,
11599
+ city: data.city,
11600
+ province: data.province,
11601
+ country_code: data.country_code,
11602
+ postal_code: data.postal_code,
11603
+ phone: data.phone
11604
+ }
11605
+ },
11606
+ {
11607
+ onSuccess: () => {
11608
+ handleSuccess();
11609
+ },
11610
+ onError: (error) => {
11611
+ toast.error(error.message);
11612
+ }
11613
+ }
11614
+ );
11615
+ });
11616
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11617
+ KeyboundForm,
11618
+ {
11619
+ className: "flex flex-1 flex-col overflow-hidden",
11620
+ onSubmit,
11621
+ children: [
11622
+ /* @__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: [
11623
+ /* @__PURE__ */ jsx(
11624
+ Form$2.Field,
11625
+ {
11626
+ control: form.control,
11627
+ name: "country_code",
11628
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11629
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11630
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11631
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11632
+ ] })
11633
+ }
11634
+ ),
11635
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11636
+ /* @__PURE__ */ jsx(
11637
+ Form$2.Field,
11638
+ {
11639
+ control: form.control,
11640
+ name: "first_name",
11641
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11642
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11643
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11644
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11645
+ ] })
11646
+ }
11647
+ ),
11648
+ /* @__PURE__ */ jsx(
11649
+ Form$2.Field,
11650
+ {
11651
+ control: form.control,
11652
+ name: "last_name",
11653
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11654
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11655
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11656
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11657
+ ] })
11658
+ }
11659
+ )
11660
+ ] }),
11661
+ /* @__PURE__ */ jsx(
11662
+ Form$2.Field,
11663
+ {
11664
+ control: form.control,
11665
+ name: "company",
11666
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11667
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11668
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11669
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11670
+ ] })
11671
+ }
11672
+ ),
11673
+ /* @__PURE__ */ jsx(
11674
+ Form$2.Field,
11675
+ {
11676
+ control: form.control,
11677
+ name: "address_1",
11678
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11679
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11680
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11681
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11682
+ ] })
11683
+ }
11684
+ ),
11685
+ /* @__PURE__ */ jsx(
11686
+ Form$2.Field,
11687
+ {
11688
+ control: form.control,
11689
+ name: "address_2",
11690
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11691
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11692
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11693
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11694
+ ] })
11695
+ }
11696
+ ),
11697
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11698
+ /* @__PURE__ */ jsx(
11699
+ Form$2.Field,
11700
+ {
11701
+ control: form.control,
11702
+ name: "postal_code",
11703
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11704
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11705
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11706
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11707
+ ] })
11708
+ }
11709
+ ),
11710
+ /* @__PURE__ */ jsx(
11711
+ Form$2.Field,
11712
+ {
11713
+ control: form.control,
11714
+ name: "city",
11715
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11716
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11717
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11718
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11719
+ ] })
11720
+ }
11721
+ )
11722
+ ] }),
11723
+ /* @__PURE__ */ jsx(
11724
+ Form$2.Field,
11725
+ {
11726
+ control: form.control,
11727
+ name: "province",
11728
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11729
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11730
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11731
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11732
+ ] })
11733
+ }
11734
+ ),
11735
+ /* @__PURE__ */ jsx(
11736
+ Form$2.Field,
11737
+ {
11738
+ control: form.control,
11739
+ name: "phone",
11740
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11741
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11742
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11743
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11744
+ ] })
11745
+ }
11746
+ )
11747
+ ] }) }),
11748
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11749
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11750
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11751
+ ] }) })
11752
+ ]
11753
+ }
11754
+ ) });
11755
+ };
11756
+ const schema$1 = addressSchema;
11757
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11758
+ const Shipping = () => {
11759
+ var _a;
11760
+ const { id } = useParams();
11761
+ const { order, isPending, isError, error } = useOrder(id, {
11762
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11763
+ });
11764
+ const {
11765
+ order: preview,
11766
+ isPending: isPreviewPending,
11767
+ isError: isPreviewError,
11768
+ error: previewError
11769
+ } = useOrderPreview(id);
11770
+ useInitiateOrderEdit({ preview });
11771
+ const { onCancel } = useCancelOrderEdit({ preview });
11772
+ if (isError) {
11773
+ throw error;
11774
+ }
11775
+ if (isPreviewError) {
11776
+ throw previewError;
11777
+ }
11778
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11779
+ const isReady = preview && !isPreviewPending && order && !isPending;
11780
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11781
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11782
+ /* @__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: [
11783
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11784
+ /* @__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." }) })
11785
+ ] }) }) }),
11786
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11787
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11788
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11789
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11790
+ ] }) });
11791
+ };
11792
+ const ShippingForm = ({ preview, order }) => {
11793
+ var _a;
11794
+ const { setIsOpen } = useStackedModal();
11795
+ const [isSubmitting, setIsSubmitting] = useState(false);
11796
+ const [data, setData] = useState(null);
11797
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11798
+ const { shipping_options } = useShippingOptions(
11799
+ {
11800
+ id: appliedShippingOptionIds,
11801
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11802
+ },
11803
+ {
11804
+ enabled: appliedShippingOptionIds.length > 0
11805
+ }
11413
11806
  );
11414
11807
  const uniqueShippingProfiles = useMemo(() => {
11415
11808
  const profiles = /* @__PURE__ */ new Map();
@@ -12168,244 +12561,41 @@ const CustomAmountField = ({
12168
12561
  }
12169
12562
  );
12170
12563
  };
12171
- const ShippingAddress = () => {
12564
+ const TransferOwnership = () => {
12172
12565
  const { id } = useParams();
12173
- const { order, isPending, isError, error } = useOrder(id, {
12174
- fields: "+shipping_address"
12566
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12567
+ fields: "id,customer_id,customer.*"
12175
12568
  });
12176
12569
  if (isError) {
12177
12570
  throw error;
12178
12571
  }
12179
- const isReady = !isPending && !!order;
12572
+ const isReady = !isPending && !!draft_order;
12180
12573
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12181
12574
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12182
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12183
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
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" }) })
12184
12577
  ] }),
12185
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12578
+ isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12186
12579
  ] });
12187
12580
  };
12188
- const ShippingAddressForm = ({ order }) => {
12189
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12581
+ const TransferOwnershipForm = ({ order }) => {
12582
+ var _a, _b;
12190
12583
  const form = useForm({
12191
12584
  defaultValues: {
12192
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12193
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12194
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12195
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12196
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12197
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12198
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12199
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12200
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12201
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12585
+ customer_id: order.customer_id || ""
12202
12586
  },
12203
- resolver: zodResolver(schema$2)
12587
+ resolver: zodResolver(schema)
12204
12588
  });
12205
12589
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12206
12590
  const { handleSuccess } = useRouteModal();
12591
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12592
+ const currentCustomer = order.customer ? {
12593
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12594
+ value: order.customer.id
12595
+ } : null;
12207
12596
  const onSubmit = form.handleSubmit(async (data) => {
12208
12597
  await mutateAsync(
12209
- {
12210
- shipping_address: {
12211
- first_name: data.first_name,
12212
- last_name: data.last_name,
12213
- company: data.company,
12214
- address_1: data.address_1,
12215
- address_2: data.address_2,
12216
- city: data.city,
12217
- province: data.province,
12218
- country_code: data.country_code,
12219
- postal_code: data.postal_code,
12220
- phone: data.phone
12221
- }
12222
- },
12223
- {
12224
- onSuccess: () => {
12225
- handleSuccess();
12226
- },
12227
- onError: (error) => {
12228
- toast.error(error.message);
12229
- }
12230
- }
12231
- );
12232
- });
12233
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12234
- KeyboundForm,
12235
- {
12236
- className: "flex flex-1 flex-col overflow-hidden",
12237
- onSubmit,
12238
- children: [
12239
- /* @__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: [
12240
- /* @__PURE__ */ jsx(
12241
- Form$2.Field,
12242
- {
12243
- control: form.control,
12244
- name: "country_code",
12245
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12246
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12247
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12248
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12249
- ] })
12250
- }
12251
- ),
12252
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12253
- /* @__PURE__ */ jsx(
12254
- Form$2.Field,
12255
- {
12256
- control: form.control,
12257
- name: "first_name",
12258
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12259
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12260
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12261
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12262
- ] })
12263
- }
12264
- ),
12265
- /* @__PURE__ */ jsx(
12266
- Form$2.Field,
12267
- {
12268
- control: form.control,
12269
- name: "last_name",
12270
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12271
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12272
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12273
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12274
- ] })
12275
- }
12276
- )
12277
- ] }),
12278
- /* @__PURE__ */ jsx(
12279
- Form$2.Field,
12280
- {
12281
- control: form.control,
12282
- name: "company",
12283
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12284
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12285
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12286
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12287
- ] })
12288
- }
12289
- ),
12290
- /* @__PURE__ */ jsx(
12291
- Form$2.Field,
12292
- {
12293
- control: form.control,
12294
- name: "address_1",
12295
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12296
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12297
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12298
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12299
- ] })
12300
- }
12301
- ),
12302
- /* @__PURE__ */ jsx(
12303
- Form$2.Field,
12304
- {
12305
- control: form.control,
12306
- name: "address_2",
12307
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12308
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12309
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12310
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12311
- ] })
12312
- }
12313
- ),
12314
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12315
- /* @__PURE__ */ jsx(
12316
- Form$2.Field,
12317
- {
12318
- control: form.control,
12319
- name: "postal_code",
12320
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12321
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12322
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12323
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12324
- ] })
12325
- }
12326
- ),
12327
- /* @__PURE__ */ jsx(
12328
- Form$2.Field,
12329
- {
12330
- control: form.control,
12331
- name: "city",
12332
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12333
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12334
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12335
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12336
- ] })
12337
- }
12338
- )
12339
- ] }),
12340
- /* @__PURE__ */ jsx(
12341
- Form$2.Field,
12342
- {
12343
- control: form.control,
12344
- name: "province",
12345
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12346
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12347
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12348
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12349
- ] })
12350
- }
12351
- ),
12352
- /* @__PURE__ */ jsx(
12353
- Form$2.Field,
12354
- {
12355
- control: form.control,
12356
- name: "phone",
12357
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12358
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12359
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12360
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12361
- ] })
12362
- }
12363
- )
12364
- ] }) }),
12365
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12366
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12367
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12368
- ] }) })
12369
- ]
12370
- }
12371
- ) });
12372
- };
12373
- const schema$2 = addressSchema;
12374
- const TransferOwnership = () => {
12375
- const { id } = useParams();
12376
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12377
- fields: "id,customer_id,customer.*"
12378
- });
12379
- if (isError) {
12380
- throw error;
12381
- }
12382
- const isReady = !isPending && !!draft_order;
12383
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12384
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
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" }) })
12387
- ] }),
12388
- isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12389
- ] });
12390
- };
12391
- const TransferOwnershipForm = ({ order }) => {
12392
- var _a, _b;
12393
- const form = useForm({
12394
- defaultValues: {
12395
- customer_id: order.customer_id || ""
12396
- },
12397
- resolver: zodResolver(schema$1)
12398
- });
12399
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12400
- const { handleSuccess } = useRouteModal();
12401
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12402
- const currentCustomer = order.customer ? {
12403
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12404
- value: order.customer.id
12405
- } : null;
12406
- const onSubmit = form.handleSubmit(async (data) => {
12407
- await mutateAsync(
12408
- { customer_id: data.customer_id },
12598
+ { customer_id: data.customer_id },
12409
12599
  {
12410
12600
  onSuccess: () => {
12411
12601
  toast.success("Customer updated");
@@ -12844,199 +13034,9 @@ const Illustration = () => {
12844
13034
  }
12845
13035
  );
12846
13036
  };
12847
- const schema$1 = objectType({
13037
+ const schema = objectType({
12848
13038
  customer_id: stringType().min(1)
12849
13039
  });
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: [
@@ -13069,6 +13069,10 @@ const routeModule = {
13069
13069
  Component: Items,
13070
13070
  path: "/draft-orders/:id/items"
13071
13071
  },
13072
+ {
13073
+ Component: BillingAddress,
13074
+ path: "/draft-orders/:id/billing-address"
13075
+ },
13072
13076
  {
13073
13077
  Component: Metadata,
13074
13078
  path: "/draft-orders/:id/metadata"
@@ -13081,21 +13085,17 @@ const routeModule = {
13081
13085
  Component: SalesChannel,
13082
13086
  path: "/draft-orders/:id/sales-channel"
13083
13087
  },
13084
- {
13085
- Component: Shipping,
13086
- path: "/draft-orders/:id/shipping"
13087
- },
13088
13088
  {
13089
13089
  Component: ShippingAddress,
13090
13090
  path: "/draft-orders/:id/shipping-address"
13091
13091
  },
13092
13092
  {
13093
- Component: TransferOwnership,
13094
- path: "/draft-orders/:id/transfer-ownership"
13093
+ Component: Shipping,
13094
+ path: "/draft-orders/:id/shipping"
13095
13095
  },
13096
13096
  {
13097
- Component: BillingAddress,
13098
- path: "/draft-orders/:id/billing-address"
13097
+ Component: TransferOwnership,
13098
+ path: "/draft-orders/:id/transfer-ownership"
13099
13099
  }
13100
13100
  ]
13101
13101
  }