@medusajs/draft-order 2.11.0-preview-20251019090151 → 2.11.0-preview-20251019150150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9571,217 +9571,6 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
- const BillingAddress = () => {
9575
- const { id } = reactRouterDom.useParams();
9576
- const { order, isPending, isError, error } = useOrder(id, {
9577
- fields: "+billing_address"
9578
- });
9579
- if (isError) {
9580
- throw error;
9581
- }
9582
- const isReady = !isPending && !!order;
9583
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9584
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9585
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9587
- ] }),
9588
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9589
- ] });
9590
- };
9591
- const BillingAddressForm = ({ order }) => {
9592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9593
- const form = reactHookForm.useForm({
9594
- defaultValues: {
9595
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9596
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9597
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9598
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9599
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9600
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9601
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9602
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9603
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
- },
9606
- resolver: zod.zodResolver(schema$5)
9607
- });
9608
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
- const { handleSuccess } = useRouteModal();
9610
- const onSubmit = form.handleSubmit(async (data) => {
9611
- await mutateAsync(
9612
- { billing_address: data },
9613
- {
9614
- onSuccess: () => {
9615
- handleSuccess();
9616
- },
9617
- onError: (error) => {
9618
- ui.toast.error(error.message);
9619
- }
9620
- }
9621
- );
9622
- });
9623
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9624
- KeyboundForm,
9625
- {
9626
- className: "flex flex-1 flex-col overflow-hidden",
9627
- onSubmit,
9628
- children: [
9629
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9630
- /* @__PURE__ */ jsxRuntime.jsx(
9631
- Form$2.Field,
9632
- {
9633
- control: form.control,
9634
- name: "country_code",
9635
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9636
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9637
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9639
- ] })
9640
- }
9641
- ),
9642
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9643
- /* @__PURE__ */ jsxRuntime.jsx(
9644
- Form$2.Field,
9645
- {
9646
- control: form.control,
9647
- name: "first_name",
9648
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9652
- ] })
9653
- }
9654
- ),
9655
- /* @__PURE__ */ jsxRuntime.jsx(
9656
- Form$2.Field,
9657
- {
9658
- control: form.control,
9659
- name: "last_name",
9660
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9661
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9662
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9664
- ] })
9665
- }
9666
- )
9667
- ] }),
9668
- /* @__PURE__ */ jsxRuntime.jsx(
9669
- Form$2.Field,
9670
- {
9671
- control: form.control,
9672
- name: "company",
9673
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9674
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9677
- ] })
9678
- }
9679
- ),
9680
- /* @__PURE__ */ jsxRuntime.jsx(
9681
- Form$2.Field,
9682
- {
9683
- control: form.control,
9684
- name: "address_1",
9685
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9686
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9689
- ] })
9690
- }
9691
- ),
9692
- /* @__PURE__ */ jsxRuntime.jsx(
9693
- Form$2.Field,
9694
- {
9695
- control: form.control,
9696
- name: "address_2",
9697
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9698
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9701
- ] })
9702
- }
9703
- ),
9704
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
- /* @__PURE__ */ jsxRuntime.jsx(
9706
- Form$2.Field,
9707
- {
9708
- control: form.control,
9709
- name: "postal_code",
9710
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9711
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9714
- ] })
9715
- }
9716
- ),
9717
- /* @__PURE__ */ jsxRuntime.jsx(
9718
- Form$2.Field,
9719
- {
9720
- control: form.control,
9721
- name: "city",
9722
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9723
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9724
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9726
- ] })
9727
- }
9728
- )
9729
- ] }),
9730
- /* @__PURE__ */ jsxRuntime.jsx(
9731
- Form$2.Field,
9732
- {
9733
- control: form.control,
9734
- name: "province",
9735
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9736
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9739
- ] })
9740
- }
9741
- ),
9742
- /* @__PURE__ */ jsxRuntime.jsx(
9743
- Form$2.Field,
9744
- {
9745
- control: form.control,
9746
- name: "phone",
9747
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9748
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9749
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9751
- ] })
9752
- }
9753
- )
9754
- ] }) }),
9755
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9756
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9757
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9758
- ] }) })
9759
- ]
9760
- }
9761
- ) });
9762
- };
9763
- const schema$5 = addressSchema;
9764
- const CustomItems = () => {
9765
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9766
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9767
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9768
- ] });
9769
- };
9770
- const CustomItemsForm = () => {
9771
- const form = reactHookForm.useForm({
9772
- resolver: zod.zodResolver(schema$4)
9773
- });
9774
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9775
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9776
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9778
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9779
- ] }) })
9780
- ] }) });
9781
- };
9782
- const schema$4 = objectType({
9783
- email: stringType().email()
9784
- });
9785
9574
  const Email = () => {
9786
9575
  const { id } = reactRouterDom.useParams();
9787
9576
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9804,7 +9593,7 @@ const EmailForm = ({ order }) => {
9804
9593
  defaultValues: {
9805
9594
  email: order.email ?? ""
9806
9595
  },
9807
- resolver: zod.zodResolver(schema$3)
9596
+ resolver: zod.zodResolver(schema$5)
9808
9597
  });
9809
9598
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9810
9599
  const { handleSuccess } = useRouteModal();
@@ -9847,7 +9636,7 @@ const EmailForm = ({ order }) => {
9847
9636
  }
9848
9637
  ) });
9849
9638
  };
9850
- const schema$3 = objectType({
9639
+ const schema$5 = objectType({
9851
9640
  email: stringType().email()
9852
9641
  });
9853
9642
  const NumberInput = React.forwardRef(
@@ -11479,7 +11268,7 @@ const SalesChannelForm = ({ order }) => {
11479
11268
  defaultValues: {
11480
11269
  sales_channel_id: order.sales_channel_id || ""
11481
11270
  },
11482
- resolver: zod.zodResolver(schema$2)
11271
+ resolver: zod.zodResolver(schema$4)
11483
11272
  });
11484
11273
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
11274
  const { handleSuccess } = useRouteModal();
@@ -11554,7 +11343,7 @@ const SalesChannelField = ({ control, order }) => {
11554
11343
  }
11555
11344
  );
11556
11345
  };
11557
- const schema$2 = objectType({
11346
+ const schema$4 = objectType({
11558
11347
  sales_channel_id: stringType().min(1)
11559
11348
  });
11560
11349
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12364,244 +12153,41 @@ const CustomAmountField = ({
12364
12153
  }
12365
12154
  );
12366
12155
  };
12367
- const ShippingAddress = () => {
12156
+ const TransferOwnership = () => {
12368
12157
  const { id } = reactRouterDom.useParams();
12369
- const { order, isPending, isError, error } = useOrder(id, {
12370
- fields: "+shipping_address"
12158
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12159
+ fields: "id,customer_id,customer.*"
12371
12160
  });
12372
12161
  if (isError) {
12373
12162
  throw error;
12374
12163
  }
12375
- const isReady = !isPending && !!order;
12164
+ const isReady = !isPending && !!draft_order;
12376
12165
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12377
12166
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12378
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12379
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12167
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12168
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12380
12169
  ] }),
12381
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12170
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12382
12171
  ] });
12383
12172
  };
12384
- const ShippingAddressForm = ({ order }) => {
12385
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12173
+ const TransferOwnershipForm = ({ order }) => {
12174
+ var _a, _b;
12386
12175
  const form = reactHookForm.useForm({
12387
12176
  defaultValues: {
12388
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12389
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12390
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12391
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12392
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12393
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12394
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12395
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12396
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12397
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12177
+ customer_id: order.customer_id || ""
12398
12178
  },
12399
- resolver: zod.zodResolver(schema$1)
12179
+ resolver: zod.zodResolver(schema$3)
12400
12180
  });
12401
12181
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12402
12182
  const { handleSuccess } = useRouteModal();
12183
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12184
+ const currentCustomer = order.customer ? {
12185
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12186
+ value: order.customer.id
12187
+ } : null;
12403
12188
  const onSubmit = form.handleSubmit(async (data) => {
12404
12189
  await mutateAsync(
12405
- {
12406
- shipping_address: {
12407
- first_name: data.first_name,
12408
- last_name: data.last_name,
12409
- company: data.company,
12410
- address_1: data.address_1,
12411
- address_2: data.address_2,
12412
- city: data.city,
12413
- province: data.province,
12414
- country_code: data.country_code,
12415
- postal_code: data.postal_code,
12416
- phone: data.phone
12417
- }
12418
- },
12419
- {
12420
- onSuccess: () => {
12421
- handleSuccess();
12422
- },
12423
- onError: (error) => {
12424
- ui.toast.error(error.message);
12425
- }
12426
- }
12427
- );
12428
- });
12429
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12430
- KeyboundForm,
12431
- {
12432
- className: "flex flex-1 flex-col overflow-hidden",
12433
- onSubmit,
12434
- children: [
12435
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12436
- /* @__PURE__ */ jsxRuntime.jsx(
12437
- Form$2.Field,
12438
- {
12439
- control: form.control,
12440
- name: "country_code",
12441
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12442
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12443
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12444
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12445
- ] })
12446
- }
12447
- ),
12448
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12449
- /* @__PURE__ */ jsxRuntime.jsx(
12450
- Form$2.Field,
12451
- {
12452
- control: form.control,
12453
- name: "first_name",
12454
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12455
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12456
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12457
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12458
- ] })
12459
- }
12460
- ),
12461
- /* @__PURE__ */ jsxRuntime.jsx(
12462
- Form$2.Field,
12463
- {
12464
- control: form.control,
12465
- name: "last_name",
12466
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12467
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12468
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12469
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12470
- ] })
12471
- }
12472
- )
12473
- ] }),
12474
- /* @__PURE__ */ jsxRuntime.jsx(
12475
- Form$2.Field,
12476
- {
12477
- control: form.control,
12478
- name: "company",
12479
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12480
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12481
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12482
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12483
- ] })
12484
- }
12485
- ),
12486
- /* @__PURE__ */ jsxRuntime.jsx(
12487
- Form$2.Field,
12488
- {
12489
- control: form.control,
12490
- name: "address_1",
12491
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12492
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12493
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12494
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12495
- ] })
12496
- }
12497
- ),
12498
- /* @__PURE__ */ jsxRuntime.jsx(
12499
- Form$2.Field,
12500
- {
12501
- control: form.control,
12502
- name: "address_2",
12503
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12504
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12505
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12506
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12507
- ] })
12508
- }
12509
- ),
12510
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12511
- /* @__PURE__ */ jsxRuntime.jsx(
12512
- Form$2.Field,
12513
- {
12514
- control: form.control,
12515
- name: "postal_code",
12516
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12517
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12518
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12519
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12520
- ] })
12521
- }
12522
- ),
12523
- /* @__PURE__ */ jsxRuntime.jsx(
12524
- Form$2.Field,
12525
- {
12526
- control: form.control,
12527
- name: "city",
12528
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12529
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12530
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12531
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12532
- ] })
12533
- }
12534
- )
12535
- ] }),
12536
- /* @__PURE__ */ jsxRuntime.jsx(
12537
- Form$2.Field,
12538
- {
12539
- control: form.control,
12540
- name: "province",
12541
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12542
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12543
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12544
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12545
- ] })
12546
- }
12547
- ),
12548
- /* @__PURE__ */ jsxRuntime.jsx(
12549
- Form$2.Field,
12550
- {
12551
- control: form.control,
12552
- name: "phone",
12553
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12554
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12555
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12556
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12557
- ] })
12558
- }
12559
- )
12560
- ] }) }),
12561
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12562
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12563
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12564
- ] }) })
12565
- ]
12566
- }
12567
- ) });
12568
- };
12569
- const schema$1 = addressSchema;
12570
- const TransferOwnership = () => {
12571
- const { id } = reactRouterDom.useParams();
12572
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12573
- fields: "id,customer_id,customer.*"
12574
- });
12575
- if (isError) {
12576
- throw error;
12577
- }
12578
- const isReady = !isPending && !!draft_order;
12579
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12580
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12581
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12582
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12583
- ] }),
12584
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12585
- ] });
12586
- };
12587
- const TransferOwnershipForm = ({ order }) => {
12588
- var _a, _b;
12589
- const form = reactHookForm.useForm({
12590
- defaultValues: {
12591
- customer_id: order.customer_id || ""
12592
- },
12593
- resolver: zod.zodResolver(schema)
12594
- });
12595
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12596
- const { handleSuccess } = useRouteModal();
12597
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12598
- const currentCustomer = order.customer ? {
12599
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12600
- value: order.customer.id
12601
- } : null;
12602
- const onSubmit = form.handleSubmit(async (data) => {
12603
- await mutateAsync(
12604
- { customer_id: data.customer_id },
12190
+ { customer_id: data.customer_id },
12605
12191
  {
12606
12192
  onSuccess: () => {
12607
12193
  ui.toast.success("Customer updated");
@@ -13040,38 +12626,444 @@ const Illustration = () => {
13040
12626
  }
13041
12627
  );
13042
12628
  };
13043
- const schema = objectType({
12629
+ const schema$3 = objectType({
13044
12630
  customer_id: stringType().min(1)
13045
12631
  });
13046
- const widgetModule = { widgets: [] };
13047
- const routeModule = {
13048
- routes: [
13049
- {
13050
- Component: List,
13051
- path: "/draft-orders",
13052
- handle: handle$1,
13053
- children: [
13054
- {
13055
- Component: Create,
13056
- path: "/draft-orders/create"
13057
- }
13058
- ]
12632
+ const ShippingAddress = () => {
12633
+ const { id } = reactRouterDom.useParams();
12634
+ const { order, isPending, isError, error } = useOrder(id, {
12635
+ fields: "+shipping_address"
12636
+ });
12637
+ if (isError) {
12638
+ throw error;
12639
+ }
12640
+ const isReady = !isPending && !!order;
12641
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12642
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12643
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12644
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12645
+ ] }),
12646
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12647
+ ] });
12648
+ };
12649
+ const ShippingAddressForm = ({ order }) => {
12650
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12651
+ const form = reactHookForm.useForm({
12652
+ defaultValues: {
12653
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12654
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12655
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12656
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12657
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12658
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12659
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12660
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12661
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12662
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
13059
12663
  },
13060
- {
13061
- Component: ID,
13062
- path: "/draft-orders/:id",
13063
- handle,
13064
- loader,
13065
- children: [
13066
- {
13067
- Component: BillingAddress,
13068
- path: "/draft-orders/:id/billing-address"
13069
- },
13070
- {
13071
- Component: CustomItems,
13072
- path: "/draft-orders/:id/custom-items"
13073
- },
13074
- {
12664
+ resolver: zod.zodResolver(schema$2)
12665
+ });
12666
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12667
+ const { handleSuccess } = useRouteModal();
12668
+ const onSubmit = form.handleSubmit(async (data) => {
12669
+ await mutateAsync(
12670
+ {
12671
+ shipping_address: {
12672
+ first_name: data.first_name,
12673
+ last_name: data.last_name,
12674
+ company: data.company,
12675
+ address_1: data.address_1,
12676
+ address_2: data.address_2,
12677
+ city: data.city,
12678
+ province: data.province,
12679
+ country_code: data.country_code,
12680
+ postal_code: data.postal_code,
12681
+ phone: data.phone
12682
+ }
12683
+ },
12684
+ {
12685
+ onSuccess: () => {
12686
+ handleSuccess();
12687
+ },
12688
+ onError: (error) => {
12689
+ ui.toast.error(error.message);
12690
+ }
12691
+ }
12692
+ );
12693
+ });
12694
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12695
+ KeyboundForm,
12696
+ {
12697
+ className: "flex flex-1 flex-col overflow-hidden",
12698
+ onSubmit,
12699
+ children: [
12700
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12701
+ /* @__PURE__ */ jsxRuntime.jsx(
12702
+ Form$2.Field,
12703
+ {
12704
+ control: form.control,
12705
+ name: "country_code",
12706
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12707
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12708
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12709
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12710
+ ] })
12711
+ }
12712
+ ),
12713
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12714
+ /* @__PURE__ */ jsxRuntime.jsx(
12715
+ Form$2.Field,
12716
+ {
12717
+ control: form.control,
12718
+ name: "first_name",
12719
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12720
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12721
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12722
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12723
+ ] })
12724
+ }
12725
+ ),
12726
+ /* @__PURE__ */ jsxRuntime.jsx(
12727
+ Form$2.Field,
12728
+ {
12729
+ control: form.control,
12730
+ name: "last_name",
12731
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12732
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12733
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12734
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12735
+ ] })
12736
+ }
12737
+ )
12738
+ ] }),
12739
+ /* @__PURE__ */ jsxRuntime.jsx(
12740
+ Form$2.Field,
12741
+ {
12742
+ control: form.control,
12743
+ name: "company",
12744
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12745
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12746
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12747
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12748
+ ] })
12749
+ }
12750
+ ),
12751
+ /* @__PURE__ */ jsxRuntime.jsx(
12752
+ Form$2.Field,
12753
+ {
12754
+ control: form.control,
12755
+ name: "address_1",
12756
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12757
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12758
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12759
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12760
+ ] })
12761
+ }
12762
+ ),
12763
+ /* @__PURE__ */ jsxRuntime.jsx(
12764
+ Form$2.Field,
12765
+ {
12766
+ control: form.control,
12767
+ name: "address_2",
12768
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12769
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12770
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12771
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12772
+ ] })
12773
+ }
12774
+ ),
12775
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12776
+ /* @__PURE__ */ jsxRuntime.jsx(
12777
+ Form$2.Field,
12778
+ {
12779
+ control: form.control,
12780
+ name: "postal_code",
12781
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12782
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12783
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12784
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12785
+ ] })
12786
+ }
12787
+ ),
12788
+ /* @__PURE__ */ jsxRuntime.jsx(
12789
+ Form$2.Field,
12790
+ {
12791
+ control: form.control,
12792
+ name: "city",
12793
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12794
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12795
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12796
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12797
+ ] })
12798
+ }
12799
+ )
12800
+ ] }),
12801
+ /* @__PURE__ */ jsxRuntime.jsx(
12802
+ Form$2.Field,
12803
+ {
12804
+ control: form.control,
12805
+ name: "province",
12806
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12807
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12808
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12809
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12810
+ ] })
12811
+ }
12812
+ ),
12813
+ /* @__PURE__ */ jsxRuntime.jsx(
12814
+ Form$2.Field,
12815
+ {
12816
+ control: form.control,
12817
+ name: "phone",
12818
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12819
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12820
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12821
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12822
+ ] })
12823
+ }
12824
+ )
12825
+ ] }) }),
12826
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12827
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12828
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12829
+ ] }) })
12830
+ ]
12831
+ }
12832
+ ) });
12833
+ };
12834
+ const schema$2 = addressSchema;
12835
+ const CustomItems = () => {
12836
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12837
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
12838
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12839
+ ] });
12840
+ };
12841
+ const CustomItemsForm = () => {
12842
+ const form = reactHookForm.useForm({
12843
+ resolver: zod.zodResolver(schema$1)
12844
+ });
12845
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
12847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12848
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12849
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
12850
+ ] }) })
12851
+ ] }) });
12852
+ };
12853
+ const schema$1 = objectType({
12854
+ email: stringType().email()
12855
+ });
12856
+ const BillingAddress = () => {
12857
+ const { id } = reactRouterDom.useParams();
12858
+ const { order, isPending, isError, error } = useOrder(id, {
12859
+ fields: "+billing_address"
12860
+ });
12861
+ if (isError) {
12862
+ throw error;
12863
+ }
12864
+ const isReady = !isPending && !!order;
12865
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12866
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12867
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12868
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12869
+ ] }),
12870
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12871
+ ] });
12872
+ };
12873
+ const BillingAddressForm = ({ order }) => {
12874
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12875
+ const form = reactHookForm.useForm({
12876
+ defaultValues: {
12877
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12878
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12879
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12880
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12881
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12882
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12883
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12884
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12885
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12886
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12887
+ },
12888
+ resolver: zod.zodResolver(schema)
12889
+ });
12890
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12891
+ const { handleSuccess } = useRouteModal();
12892
+ const onSubmit = form.handleSubmit(async (data) => {
12893
+ await mutateAsync(
12894
+ { billing_address: data },
12895
+ {
12896
+ onSuccess: () => {
12897
+ handleSuccess();
12898
+ },
12899
+ onError: (error) => {
12900
+ ui.toast.error(error.message);
12901
+ }
12902
+ }
12903
+ );
12904
+ });
12905
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12906
+ KeyboundForm,
12907
+ {
12908
+ className: "flex flex-1 flex-col overflow-hidden",
12909
+ onSubmit,
12910
+ children: [
12911
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12912
+ /* @__PURE__ */ jsxRuntime.jsx(
12913
+ Form$2.Field,
12914
+ {
12915
+ control: form.control,
12916
+ name: "country_code",
12917
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12918
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12919
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12920
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12921
+ ] })
12922
+ }
12923
+ ),
12924
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12925
+ /* @__PURE__ */ jsxRuntime.jsx(
12926
+ Form$2.Field,
12927
+ {
12928
+ control: form.control,
12929
+ name: "first_name",
12930
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12931
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12932
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12933
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12934
+ ] })
12935
+ }
12936
+ ),
12937
+ /* @__PURE__ */ jsxRuntime.jsx(
12938
+ Form$2.Field,
12939
+ {
12940
+ control: form.control,
12941
+ name: "last_name",
12942
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12943
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12944
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12946
+ ] })
12947
+ }
12948
+ )
12949
+ ] }),
12950
+ /* @__PURE__ */ jsxRuntime.jsx(
12951
+ Form$2.Field,
12952
+ {
12953
+ control: form.control,
12954
+ name: "company",
12955
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12956
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12957
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12958
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12959
+ ] })
12960
+ }
12961
+ ),
12962
+ /* @__PURE__ */ jsxRuntime.jsx(
12963
+ Form$2.Field,
12964
+ {
12965
+ control: form.control,
12966
+ name: "address_1",
12967
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12968
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12969
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12970
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12971
+ ] })
12972
+ }
12973
+ ),
12974
+ /* @__PURE__ */ jsxRuntime.jsx(
12975
+ Form$2.Field,
12976
+ {
12977
+ control: form.control,
12978
+ name: "address_2",
12979
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12980
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12981
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12982
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12983
+ ] })
12984
+ }
12985
+ ),
12986
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12987
+ /* @__PURE__ */ jsxRuntime.jsx(
12988
+ Form$2.Field,
12989
+ {
12990
+ control: form.control,
12991
+ name: "postal_code",
12992
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12993
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12994
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12995
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12996
+ ] })
12997
+ }
12998
+ ),
12999
+ /* @__PURE__ */ jsxRuntime.jsx(
13000
+ Form$2.Field,
13001
+ {
13002
+ control: form.control,
13003
+ name: "city",
13004
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13005
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13006
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13007
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13008
+ ] })
13009
+ }
13010
+ )
13011
+ ] }),
13012
+ /* @__PURE__ */ jsxRuntime.jsx(
13013
+ Form$2.Field,
13014
+ {
13015
+ control: form.control,
13016
+ name: "province",
13017
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13018
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13019
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13020
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13021
+ ] })
13022
+ }
13023
+ ),
13024
+ /* @__PURE__ */ jsxRuntime.jsx(
13025
+ Form$2.Field,
13026
+ {
13027
+ control: form.control,
13028
+ name: "phone",
13029
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13030
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13031
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13032
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13033
+ ] })
13034
+ }
13035
+ )
13036
+ ] }) }),
13037
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13040
+ ] }) })
13041
+ ]
13042
+ }
13043
+ ) });
13044
+ };
13045
+ const schema = addressSchema;
13046
+ const widgetModule = { widgets: [] };
13047
+ const routeModule = {
13048
+ routes: [
13049
+ {
13050
+ Component: List,
13051
+ path: "/draft-orders",
13052
+ handle: handle$1,
13053
+ children: [
13054
+ {
13055
+ Component: Create,
13056
+ path: "/draft-orders/create"
13057
+ }
13058
+ ]
13059
+ },
13060
+ {
13061
+ Component: ID,
13062
+ path: "/draft-orders/:id",
13063
+ handle,
13064
+ loader,
13065
+ children: [
13066
+ {
13075
13067
  Component: Email,
13076
13068
  path: "/draft-orders/:id/email"
13077
13069
  },
@@ -13095,13 +13087,21 @@ const routeModule = {
13095
13087
  Component: Shipping,
13096
13088
  path: "/draft-orders/:id/shipping"
13097
13089
  },
13090
+ {
13091
+ Component: TransferOwnership,
13092
+ path: "/draft-orders/:id/transfer-ownership"
13093
+ },
13098
13094
  {
13099
13095
  Component: ShippingAddress,
13100
13096
  path: "/draft-orders/:id/shipping-address"
13101
13097
  },
13102
13098
  {
13103
- Component: TransferOwnership,
13104
- path: "/draft-orders/:id/transfer-ownership"
13099
+ Component: CustomItems,
13100
+ path: "/draft-orders/:id/custom-items"
13101
+ },
13102
+ {
13103
+ Component: BillingAddress,
13104
+ path: "/draft-orders/:id/billing-address"
13105
13105
  }
13106
13106
  ]
13107
13107
  }