@medusajs/draft-order 2.10.4-snapshot-20250922090257 → 2.10.4-snapshot-20250922165717

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.
@@ -9567,6 +9567,27 @@ const ID = () => {
9567
9567
  /* @__PURE__ */ jsx(Outlet, {})
9568
9568
  ] });
9569
9569
  };
9570
+ const CustomItems = () => {
9571
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9572
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9573
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9574
+ ] });
9575
+ };
9576
+ const CustomItemsForm = () => {
9577
+ const form = useForm({
9578
+ resolver: zodResolver(schema$5)
9579
+ });
9580
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9581
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9582
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9583
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9584
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9585
+ ] }) })
9586
+ ] }) });
9587
+ };
9588
+ const schema$5 = objectType({
9589
+ email: stringType().email()
9590
+ });
9570
9591
  const Email = () => {
9571
9592
  const { id } = useParams();
9572
9593
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9589,7 +9610,7 @@ const EmailForm = ({ order }) => {
9589
9610
  defaultValues: {
9590
9611
  email: order.email ?? ""
9591
9612
  },
9592
- resolver: zodResolver(schema$5)
9613
+ resolver: zodResolver(schema$4)
9593
9614
  });
9594
9615
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9595
9616
  const { handleSuccess } = useRouteModal();
@@ -9632,9 +9653,199 @@ const EmailForm = ({ order }) => {
9632
9653
  }
9633
9654
  ) });
9634
9655
  };
9635
- const schema$5 = objectType({
9656
+ const schema$4 = objectType({
9636
9657
  email: stringType().email()
9637
9658
  });
9659
+ const BillingAddress = () => {
9660
+ const { id } = useParams();
9661
+ const { order, isPending, isError, error } = useOrder(id, {
9662
+ fields: "+billing_address"
9663
+ });
9664
+ if (isError) {
9665
+ throw error;
9666
+ }
9667
+ const isReady = !isPending && !!order;
9668
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9669
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9670
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9671
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9672
+ ] }),
9673
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9674
+ ] });
9675
+ };
9676
+ const BillingAddressForm = ({ order }) => {
9677
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9678
+ const form = useForm({
9679
+ defaultValues: {
9680
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9681
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9682
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9683
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9684
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9685
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9686
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9687
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9688
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9689
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9690
+ },
9691
+ resolver: zodResolver(schema$3)
9692
+ });
9693
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9694
+ const { handleSuccess } = useRouteModal();
9695
+ const onSubmit = form.handleSubmit(async (data) => {
9696
+ await mutateAsync(
9697
+ { billing_address: data },
9698
+ {
9699
+ onSuccess: () => {
9700
+ handleSuccess();
9701
+ },
9702
+ onError: (error) => {
9703
+ toast.error(error.message);
9704
+ }
9705
+ }
9706
+ );
9707
+ });
9708
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9709
+ KeyboundForm,
9710
+ {
9711
+ className: "flex flex-1 flex-col overflow-hidden",
9712
+ onSubmit,
9713
+ children: [
9714
+ /* @__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: [
9715
+ /* @__PURE__ */ jsx(
9716
+ Form$2.Field,
9717
+ {
9718
+ control: form.control,
9719
+ name: "country_code",
9720
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9721
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9722
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9723
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9724
+ ] })
9725
+ }
9726
+ ),
9727
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9728
+ /* @__PURE__ */ jsx(
9729
+ Form$2.Field,
9730
+ {
9731
+ control: form.control,
9732
+ name: "first_name",
9733
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9734
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9735
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9736
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9737
+ ] })
9738
+ }
9739
+ ),
9740
+ /* @__PURE__ */ jsx(
9741
+ Form$2.Field,
9742
+ {
9743
+ control: form.control,
9744
+ name: "last_name",
9745
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9746
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9747
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9748
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9749
+ ] })
9750
+ }
9751
+ )
9752
+ ] }),
9753
+ /* @__PURE__ */ jsx(
9754
+ Form$2.Field,
9755
+ {
9756
+ control: form.control,
9757
+ name: "company",
9758
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9759
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9760
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9761
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9762
+ ] })
9763
+ }
9764
+ ),
9765
+ /* @__PURE__ */ jsx(
9766
+ Form$2.Field,
9767
+ {
9768
+ control: form.control,
9769
+ name: "address_1",
9770
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9771
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9772
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9773
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9774
+ ] })
9775
+ }
9776
+ ),
9777
+ /* @__PURE__ */ jsx(
9778
+ Form$2.Field,
9779
+ {
9780
+ control: form.control,
9781
+ name: "address_2",
9782
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9783
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9784
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9785
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9786
+ ] })
9787
+ }
9788
+ ),
9789
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9790
+ /* @__PURE__ */ jsx(
9791
+ Form$2.Field,
9792
+ {
9793
+ control: form.control,
9794
+ name: "postal_code",
9795
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9796
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9797
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9798
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9799
+ ] })
9800
+ }
9801
+ ),
9802
+ /* @__PURE__ */ jsx(
9803
+ Form$2.Field,
9804
+ {
9805
+ control: form.control,
9806
+ name: "city",
9807
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9808
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9809
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9810
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9811
+ ] })
9812
+ }
9813
+ )
9814
+ ] }),
9815
+ /* @__PURE__ */ jsx(
9816
+ Form$2.Field,
9817
+ {
9818
+ control: form.control,
9819
+ name: "province",
9820
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9821
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9822
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9823
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9824
+ ] })
9825
+ }
9826
+ ),
9827
+ /* @__PURE__ */ jsx(
9828
+ Form$2.Field,
9829
+ {
9830
+ control: form.control,
9831
+ name: "phone",
9832
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9833
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9834
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9835
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9836
+ ] })
9837
+ }
9838
+ )
9839
+ ] }) }),
9840
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9841
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9842
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9843
+ ] }) })
9844
+ ]
9845
+ }
9846
+ ) });
9847
+ };
9848
+ const schema$3 = addressSchema;
9638
9849
  const NumberInput = forwardRef(
9639
9850
  ({
9640
9851
  value,
@@ -11264,7 +11475,7 @@ const SalesChannelForm = ({ order }) => {
11264
11475
  defaultValues: {
11265
11476
  sales_channel_id: order.sales_channel_id || ""
11266
11477
  },
11267
- resolver: zodResolver(schema$4)
11478
+ resolver: zodResolver(schema$2)
11268
11479
  });
11269
11480
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11270
11481
  const { handleSuccess } = useRouteModal();
@@ -11339,50 +11550,253 @@ const SalesChannelField = ({ control, order }) => {
11339
11550
  }
11340
11551
  );
11341
11552
  };
11342
- const schema$4 = objectType({
11553
+ const schema$2 = objectType({
11343
11554
  sales_channel_id: stringType().min(1)
11344
11555
  });
11345
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11346
- const Shipping = () => {
11347
- var _a;
11556
+ const ShippingAddress = () => {
11348
11557
  const { id } = useParams();
11349
11558
  const { order, isPending, isError, error } = useOrder(id, {
11350
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11559
+ fields: "+shipping_address"
11351
11560
  });
11352
- const {
11353
- order: preview,
11354
- isPending: isPreviewPending,
11355
- isError: isPreviewError,
11356
- error: previewError
11357
- } = useOrderPreview(id);
11358
- useInitiateOrderEdit({ preview });
11359
- const { onCancel } = useCancelOrderEdit({ preview });
11360
11561
  if (isError) {
11361
11562
  throw error;
11362
11563
  }
11363
- if (isPreviewError) {
11364
- throw previewError;
11365
- }
11366
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11367
- const isReady = preview && !isPreviewPending && order && !isPending;
11368
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11369
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11370
- /* @__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: [
11371
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11372
- /* @__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." }) })
11373
- ] }) }) }),
11374
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11375
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11376
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11377
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11378
- ] }) });
11379
- };
11380
- const ShippingForm = ({ preview, order }) => {
11381
- var _a;
11382
- const { setIsOpen } = useStackedModal();
11383
- const [isSubmitting, setIsSubmitting] = useState(false);
11384
- const [data, setData] = useState(null);
11385
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11564
+ const isReady = !isPending && !!order;
11565
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11566
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11567
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11568
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11569
+ ] }),
11570
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11571
+ ] });
11572
+ };
11573
+ const ShippingAddressForm = ({ order }) => {
11574
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11575
+ const form = useForm({
11576
+ defaultValues: {
11577
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11578
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11579
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11580
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11581
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11582
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11583
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11584
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11585
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11586
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11587
+ },
11588
+ resolver: zodResolver(schema$1)
11589
+ });
11590
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11591
+ const { handleSuccess } = useRouteModal();
11592
+ const onSubmit = form.handleSubmit(async (data) => {
11593
+ await mutateAsync(
11594
+ {
11595
+ shipping_address: {
11596
+ first_name: data.first_name,
11597
+ last_name: data.last_name,
11598
+ company: data.company,
11599
+ address_1: data.address_1,
11600
+ address_2: data.address_2,
11601
+ city: data.city,
11602
+ province: data.province,
11603
+ country_code: data.country_code,
11604
+ postal_code: data.postal_code,
11605
+ phone: data.phone
11606
+ }
11607
+ },
11608
+ {
11609
+ onSuccess: () => {
11610
+ handleSuccess();
11611
+ },
11612
+ onError: (error) => {
11613
+ toast.error(error.message);
11614
+ }
11615
+ }
11616
+ );
11617
+ });
11618
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11619
+ KeyboundForm,
11620
+ {
11621
+ className: "flex flex-1 flex-col overflow-hidden",
11622
+ onSubmit,
11623
+ children: [
11624
+ /* @__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: [
11625
+ /* @__PURE__ */ jsx(
11626
+ Form$2.Field,
11627
+ {
11628
+ control: form.control,
11629
+ name: "country_code",
11630
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11631
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11632
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11633
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11634
+ ] })
11635
+ }
11636
+ ),
11637
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11638
+ /* @__PURE__ */ jsx(
11639
+ Form$2.Field,
11640
+ {
11641
+ control: form.control,
11642
+ name: "first_name",
11643
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11644
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11645
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11646
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11647
+ ] })
11648
+ }
11649
+ ),
11650
+ /* @__PURE__ */ jsx(
11651
+ Form$2.Field,
11652
+ {
11653
+ control: form.control,
11654
+ name: "last_name",
11655
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11656
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11657
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11658
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11659
+ ] })
11660
+ }
11661
+ )
11662
+ ] }),
11663
+ /* @__PURE__ */ jsx(
11664
+ Form$2.Field,
11665
+ {
11666
+ control: form.control,
11667
+ name: "company",
11668
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11669
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11670
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11671
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11672
+ ] })
11673
+ }
11674
+ ),
11675
+ /* @__PURE__ */ jsx(
11676
+ Form$2.Field,
11677
+ {
11678
+ control: form.control,
11679
+ name: "address_1",
11680
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11681
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11682
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11683
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11684
+ ] })
11685
+ }
11686
+ ),
11687
+ /* @__PURE__ */ jsx(
11688
+ Form$2.Field,
11689
+ {
11690
+ control: form.control,
11691
+ name: "address_2",
11692
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11693
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11694
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11695
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11696
+ ] })
11697
+ }
11698
+ ),
11699
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11700
+ /* @__PURE__ */ jsx(
11701
+ Form$2.Field,
11702
+ {
11703
+ control: form.control,
11704
+ name: "postal_code",
11705
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11706
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11707
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11708
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11709
+ ] })
11710
+ }
11711
+ ),
11712
+ /* @__PURE__ */ jsx(
11713
+ Form$2.Field,
11714
+ {
11715
+ control: form.control,
11716
+ name: "city",
11717
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11718
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11719
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11720
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11721
+ ] })
11722
+ }
11723
+ )
11724
+ ] }),
11725
+ /* @__PURE__ */ jsx(
11726
+ Form$2.Field,
11727
+ {
11728
+ control: form.control,
11729
+ name: "province",
11730
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11731
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11732
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11733
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11734
+ ] })
11735
+ }
11736
+ ),
11737
+ /* @__PURE__ */ jsx(
11738
+ Form$2.Field,
11739
+ {
11740
+ control: form.control,
11741
+ name: "phone",
11742
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11743
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11744
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11745
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11746
+ ] })
11747
+ }
11748
+ )
11749
+ ] }) }),
11750
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11751
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11752
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11753
+ ] }) })
11754
+ ]
11755
+ }
11756
+ ) });
11757
+ };
11758
+ const schema$1 = addressSchema;
11759
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11760
+ const Shipping = () => {
11761
+ var _a;
11762
+ const { id } = useParams();
11763
+ const { order, isPending, isError, error } = useOrder(id, {
11764
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11765
+ });
11766
+ const {
11767
+ order: preview,
11768
+ isPending: isPreviewPending,
11769
+ isError: isPreviewError,
11770
+ error: previewError
11771
+ } = useOrderPreview(id);
11772
+ useInitiateOrderEdit({ preview });
11773
+ const { onCancel } = useCancelOrderEdit({ preview });
11774
+ if (isError) {
11775
+ throw error;
11776
+ }
11777
+ if (isPreviewError) {
11778
+ throw previewError;
11779
+ }
11780
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11781
+ const isReady = preview && !isPreviewPending && order && !isPending;
11782
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11783
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11784
+ /* @__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: [
11785
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11786
+ /* @__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." }) })
11787
+ ] }) }) }),
11788
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11789
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11790
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11791
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11792
+ ] }) });
11793
+ };
11794
+ const ShippingForm = ({ preview, order }) => {
11795
+ var _a;
11796
+ const { setIsOpen } = useStackedModal();
11797
+ const [isSubmitting, setIsSubmitting] = useState(false);
11798
+ const [data, setData] = useState(null);
11799
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11386
11800
  const { shipping_options } = useShippingOptions(
11387
11801
  {
11388
11802
  id: appliedShippingOptionIds,
@@ -12149,233 +12563,30 @@ const CustomAmountField = ({
12149
12563
  }
12150
12564
  );
12151
12565
  };
12152
- const ShippingAddress = () => {
12566
+ const TransferOwnership = () => {
12153
12567
  const { id } = useParams();
12154
- const { order, isPending, isError, error } = useOrder(id, {
12155
- fields: "+shipping_address"
12568
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12569
+ fields: "id,customer_id,customer.*"
12156
12570
  });
12157
12571
  if (isError) {
12158
12572
  throw error;
12159
12573
  }
12160
- const isReady = !isPending && !!order;
12574
+ const isReady = !isPending && !!draft_order;
12161
12575
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12162
12576
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12163
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12164
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12577
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12578
+ /* @__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" }) })
12165
12579
  ] }),
12166
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12580
+ isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12167
12581
  ] });
12168
12582
  };
12169
- const ShippingAddressForm = ({ order }) => {
12170
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12171
- const form = useForm({
12172
- defaultValues: {
12173
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12174
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12175
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12176
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12177
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12178
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12179
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12180
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12181
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12182
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12183
- },
12184
- resolver: zodResolver(schema$3)
12185
- });
12186
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12187
- const { handleSuccess } = useRouteModal();
12188
- const onSubmit = form.handleSubmit(async (data) => {
12189
- await mutateAsync(
12190
- {
12191
- shipping_address: {
12192
- first_name: data.first_name,
12193
- last_name: data.last_name,
12194
- company: data.company,
12195
- address_1: data.address_1,
12196
- address_2: data.address_2,
12197
- city: data.city,
12198
- province: data.province,
12199
- country_code: data.country_code,
12200
- postal_code: data.postal_code,
12201
- phone: data.phone
12202
- }
12203
- },
12204
- {
12205
- onSuccess: () => {
12206
- handleSuccess();
12207
- },
12208
- onError: (error) => {
12209
- toast.error(error.message);
12210
- }
12211
- }
12212
- );
12213
- });
12214
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12215
- KeyboundForm,
12216
- {
12217
- className: "flex flex-1 flex-col overflow-hidden",
12218
- onSubmit,
12219
- children: [
12220
- /* @__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: [
12221
- /* @__PURE__ */ jsx(
12222
- Form$2.Field,
12223
- {
12224
- control: form.control,
12225
- name: "country_code",
12226
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12227
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12228
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12229
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12230
- ] })
12231
- }
12232
- ),
12233
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12234
- /* @__PURE__ */ jsx(
12235
- Form$2.Field,
12236
- {
12237
- control: form.control,
12238
- name: "first_name",
12239
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12240
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12241
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12242
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12243
- ] })
12244
- }
12245
- ),
12246
- /* @__PURE__ */ jsx(
12247
- Form$2.Field,
12248
- {
12249
- control: form.control,
12250
- name: "last_name",
12251
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12252
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12253
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12254
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12255
- ] })
12256
- }
12257
- )
12258
- ] }),
12259
- /* @__PURE__ */ jsx(
12260
- Form$2.Field,
12261
- {
12262
- control: form.control,
12263
- name: "company",
12264
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12265
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12266
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12267
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12268
- ] })
12269
- }
12270
- ),
12271
- /* @__PURE__ */ jsx(
12272
- Form$2.Field,
12273
- {
12274
- control: form.control,
12275
- name: "address_1",
12276
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12277
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12278
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12279
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12280
- ] })
12281
- }
12282
- ),
12283
- /* @__PURE__ */ jsx(
12284
- Form$2.Field,
12285
- {
12286
- control: form.control,
12287
- name: "address_2",
12288
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12289
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12290
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12291
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12292
- ] })
12293
- }
12294
- ),
12295
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12296
- /* @__PURE__ */ jsx(
12297
- Form$2.Field,
12298
- {
12299
- control: form.control,
12300
- name: "postal_code",
12301
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12302
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12303
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12304
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12305
- ] })
12306
- }
12307
- ),
12308
- /* @__PURE__ */ jsx(
12309
- Form$2.Field,
12310
- {
12311
- control: form.control,
12312
- name: "city",
12313
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12314
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12315
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12316
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12317
- ] })
12318
- }
12319
- )
12320
- ] }),
12321
- /* @__PURE__ */ jsx(
12322
- Form$2.Field,
12323
- {
12324
- control: form.control,
12325
- name: "province",
12326
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12327
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12328
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12329
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12330
- ] })
12331
- }
12332
- ),
12333
- /* @__PURE__ */ jsx(
12334
- Form$2.Field,
12335
- {
12336
- control: form.control,
12337
- name: "phone",
12338
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12339
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12340
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12341
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12342
- ] })
12343
- }
12344
- )
12345
- ] }) }),
12346
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12347
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12348
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12349
- ] }) })
12350
- ]
12351
- }
12352
- ) });
12353
- };
12354
- const schema$3 = addressSchema;
12355
- const TransferOwnership = () => {
12356
- const { id } = useParams();
12357
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12358
- fields: "id,customer_id,customer.*"
12359
- });
12360
- if (isError) {
12361
- throw error;
12362
- }
12363
- const isReady = !isPending && !!draft_order;
12364
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12365
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12366
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12367
- /* @__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" }) })
12368
- ] }),
12369
- isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12370
- ] });
12371
- };
12372
- const TransferOwnershipForm = ({ order }) => {
12373
- var _a, _b;
12583
+ const TransferOwnershipForm = ({ order }) => {
12584
+ var _a, _b;
12374
12585
  const form = useForm({
12375
12586
  defaultValues: {
12376
12587
  customer_id: order.customer_id || ""
12377
12588
  },
12378
- resolver: zodResolver(schema$2)
12589
+ resolver: zodResolver(schema)
12379
12590
  });
12380
12591
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12381
12592
  const { handleSuccess } = useRouteModal();
@@ -12825,219 +13036,8 @@ const Illustration = () => {
12825
13036
  }
12826
13037
  );
12827
13038
  };
12828
- const schema$2 = objectType({
12829
- customer_id: stringType().min(1)
12830
- });
12831
- const BillingAddress = () => {
12832
- const { id } = useParams();
12833
- const { order, isPending, isError, error } = useOrder(id, {
12834
- fields: "+billing_address"
12835
- });
12836
- if (isError) {
12837
- throw error;
12838
- }
12839
- const isReady = !isPending && !!order;
12840
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12841
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12842
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12843
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12844
- ] }),
12845
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12846
- ] });
12847
- };
12848
- const BillingAddressForm = ({ order }) => {
12849
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12850
- const form = useForm({
12851
- defaultValues: {
12852
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12853
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12854
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12855
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12856
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12857
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12858
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12859
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12860
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12861
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12862
- },
12863
- resolver: zodResolver(schema$1)
12864
- });
12865
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12866
- const { handleSuccess } = useRouteModal();
12867
- const onSubmit = form.handleSubmit(async (data) => {
12868
- await mutateAsync(
12869
- { billing_address: data },
12870
- {
12871
- onSuccess: () => {
12872
- handleSuccess();
12873
- },
12874
- onError: (error) => {
12875
- toast.error(error.message);
12876
- }
12877
- }
12878
- );
12879
- });
12880
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12881
- KeyboundForm,
12882
- {
12883
- className: "flex flex-1 flex-col overflow-hidden",
12884
- onSubmit,
12885
- children: [
12886
- /* @__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: [
12887
- /* @__PURE__ */ jsx(
12888
- Form$2.Field,
12889
- {
12890
- control: form.control,
12891
- name: "country_code",
12892
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12893
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12894
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12895
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12896
- ] })
12897
- }
12898
- ),
12899
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12900
- /* @__PURE__ */ jsx(
12901
- Form$2.Field,
12902
- {
12903
- control: form.control,
12904
- name: "first_name",
12905
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12906
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12907
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12908
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12909
- ] })
12910
- }
12911
- ),
12912
- /* @__PURE__ */ jsx(
12913
- Form$2.Field,
12914
- {
12915
- control: form.control,
12916
- name: "last_name",
12917
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12918
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12919
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12920
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12921
- ] })
12922
- }
12923
- )
12924
- ] }),
12925
- /* @__PURE__ */ jsx(
12926
- Form$2.Field,
12927
- {
12928
- control: form.control,
12929
- name: "company",
12930
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12931
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12932
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12933
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12934
- ] })
12935
- }
12936
- ),
12937
- /* @__PURE__ */ jsx(
12938
- Form$2.Field,
12939
- {
12940
- control: form.control,
12941
- name: "address_1",
12942
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12943
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12944
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12945
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12946
- ] })
12947
- }
12948
- ),
12949
- /* @__PURE__ */ jsx(
12950
- Form$2.Field,
12951
- {
12952
- control: form.control,
12953
- name: "address_2",
12954
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12955
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12956
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12957
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12958
- ] })
12959
- }
12960
- ),
12961
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12962
- /* @__PURE__ */ jsx(
12963
- Form$2.Field,
12964
- {
12965
- control: form.control,
12966
- name: "postal_code",
12967
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12968
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12969
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12970
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12971
- ] })
12972
- }
12973
- ),
12974
- /* @__PURE__ */ jsx(
12975
- Form$2.Field,
12976
- {
12977
- control: form.control,
12978
- name: "city",
12979
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12980
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12981
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12982
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12983
- ] })
12984
- }
12985
- )
12986
- ] }),
12987
- /* @__PURE__ */ jsx(
12988
- Form$2.Field,
12989
- {
12990
- control: form.control,
12991
- name: "province",
12992
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12993
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12994
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12995
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12996
- ] })
12997
- }
12998
- ),
12999
- /* @__PURE__ */ jsx(
13000
- Form$2.Field,
13001
- {
13002
- control: form.control,
13003
- name: "phone",
13004
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13005
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13006
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13007
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13008
- ] })
13009
- }
13010
- )
13011
- ] }) }),
13012
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13013
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13014
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13015
- ] }) })
13016
- ]
13017
- }
13018
- ) });
13019
- };
13020
- const schema$1 = addressSchema;
13021
- const CustomItems = () => {
13022
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13023
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13024
- /* @__PURE__ */ jsx(CustomItemsForm, {})
13025
- ] });
13026
- };
13027
- const CustomItemsForm = () => {
13028
- const form = useForm({
13029
- resolver: zodResolver(schema)
13030
- });
13031
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13033
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13036
- ] }) })
13037
- ] }) });
13038
- };
13039
13039
  const schema = objectType({
13040
- email: stringType().email()
13040
+ customer_id: stringType().min(1)
13041
13041
  });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
@@ -13059,10 +13059,18 @@ const routeModule = {
13059
13059
  handle,
13060
13060
  loader,
13061
13061
  children: [
13062
+ {
13063
+ Component: CustomItems,
13064
+ path: "/draft-orders/:id/custom-items"
13065
+ },
13062
13066
  {
13063
13067
  Component: Email,
13064
13068
  path: "/draft-orders/:id/email"
13065
13069
  },
13070
+ {
13071
+ Component: BillingAddress,
13072
+ path: "/draft-orders/:id/billing-address"
13073
+ },
13066
13074
  {
13067
13075
  Component: Items,
13068
13076
  path: "/draft-orders/:id/items"
@@ -13079,25 +13087,17 @@ const routeModule = {
13079
13087
  Component: SalesChannel,
13080
13088
  path: "/draft-orders/:id/sales-channel"
13081
13089
  },
13082
- {
13083
- Component: Shipping,
13084
- path: "/draft-orders/:id/shipping"
13085
- },
13086
13090
  {
13087
13091
  Component: ShippingAddress,
13088
13092
  path: "/draft-orders/:id/shipping-address"
13089
13093
  },
13090
13094
  {
13091
- Component: TransferOwnership,
13092
- path: "/draft-orders/:id/transfer-ownership"
13093
- },
13094
- {
13095
- Component: BillingAddress,
13096
- path: "/draft-orders/:id/billing-address"
13095
+ Component: Shipping,
13096
+ path: "/draft-orders/:id/shipping"
13097
13097
  },
13098
13098
  {
13099
- Component: CustomItems,
13100
- path: "/draft-orders/:id/custom-items"
13099
+ Component: TransferOwnership,
13100
+ path: "/draft-orders/:id/transfer-ownership"
13101
13101
  }
13102
13102
  ]
13103
13103
  }