@medusajs/draft-order 2.11.0-preview-20251019060156 → 2.11.0-preview-20251019120202

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.
@@ -7823,12 +7823,10 @@ const CustomerField$1 = ({ control, setValue }) => {
7823
7823
  (option) => option.value === value
7824
7824
  )) == null ? void 0 : _a.label;
7825
7825
  const customerEmail = ((_b = label == null ? void 0 : label.match(/\((.*@.*)\)$/)) == null ? void 0 : _b[1]) || label;
7826
- if (!email && customerEmail) {
7827
- setValue("email", customerEmail, {
7828
- shouldDirty: true,
7829
- shouldTouch: true
7830
- });
7831
- }
7826
+ setValue("email", customerEmail || "", {
7827
+ shouldDirty: true,
7828
+ shouldTouch: true
7829
+ });
7832
7830
  },
7833
7831
  [email, setValue, customers.options]
7834
7832
  );
@@ -9662,6 +9660,196 @@ const EmailForm = ({ order }) => {
9662
9660
  const schema$4 = objectType({
9663
9661
  email: stringType().email()
9664
9662
  });
9663
+ const BillingAddress = () => {
9664
+ const { id } = reactRouterDom.useParams();
9665
+ const { order, isPending, isError, error } = useOrder(id, {
9666
+ fields: "+billing_address"
9667
+ });
9668
+ if (isError) {
9669
+ throw error;
9670
+ }
9671
+ const isReady = !isPending && !!order;
9672
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9673
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9674
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9675
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9676
+ ] }),
9677
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9678
+ ] });
9679
+ };
9680
+ const BillingAddressForm = ({ order }) => {
9681
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9682
+ const form = reactHookForm.useForm({
9683
+ defaultValues: {
9684
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9685
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9686
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9687
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9688
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9689
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9690
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9691
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9692
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9693
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9694
+ },
9695
+ resolver: zod.zodResolver(schema$3)
9696
+ });
9697
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9698
+ const { handleSuccess } = useRouteModal();
9699
+ const onSubmit = form.handleSubmit(async (data) => {
9700
+ await mutateAsync(
9701
+ { billing_address: data },
9702
+ {
9703
+ onSuccess: () => {
9704
+ handleSuccess();
9705
+ },
9706
+ onError: (error) => {
9707
+ ui.toast.error(error.message);
9708
+ }
9709
+ }
9710
+ );
9711
+ });
9712
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9713
+ KeyboundForm,
9714
+ {
9715
+ className: "flex flex-1 flex-col overflow-hidden",
9716
+ onSubmit,
9717
+ children: [
9718
+ /* @__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: [
9719
+ /* @__PURE__ */ jsxRuntime.jsx(
9720
+ Form$2.Field,
9721
+ {
9722
+ control: form.control,
9723
+ name: "country_code",
9724
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
+ ] })
9729
+ }
9730
+ ),
9731
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9732
+ /* @__PURE__ */ jsxRuntime.jsx(
9733
+ Form$2.Field,
9734
+ {
9735
+ control: form.control,
9736
+ name: "first_name",
9737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9741
+ ] })
9742
+ }
9743
+ ),
9744
+ /* @__PURE__ */ jsxRuntime.jsx(
9745
+ Form$2.Field,
9746
+ {
9747
+ control: form.control,
9748
+ name: "last_name",
9749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9753
+ ] })
9754
+ }
9755
+ )
9756
+ ] }),
9757
+ /* @__PURE__ */ jsxRuntime.jsx(
9758
+ Form$2.Field,
9759
+ {
9760
+ control: form.control,
9761
+ name: "company",
9762
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9763
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9764
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9765
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9766
+ ] })
9767
+ }
9768
+ ),
9769
+ /* @__PURE__ */ jsxRuntime.jsx(
9770
+ Form$2.Field,
9771
+ {
9772
+ control: form.control,
9773
+ name: "address_1",
9774
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9775
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9776
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9777
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9778
+ ] })
9779
+ }
9780
+ ),
9781
+ /* @__PURE__ */ jsxRuntime.jsx(
9782
+ Form$2.Field,
9783
+ {
9784
+ control: form.control,
9785
+ name: "address_2",
9786
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9787
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9788
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9789
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9790
+ ] })
9791
+ }
9792
+ ),
9793
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9794
+ /* @__PURE__ */ jsxRuntime.jsx(
9795
+ Form$2.Field,
9796
+ {
9797
+ control: form.control,
9798
+ name: "postal_code",
9799
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9800
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9801
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9802
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9803
+ ] })
9804
+ }
9805
+ ),
9806
+ /* @__PURE__ */ jsxRuntime.jsx(
9807
+ Form$2.Field,
9808
+ {
9809
+ control: form.control,
9810
+ name: "city",
9811
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9812
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9813
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9814
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9815
+ ] })
9816
+ }
9817
+ )
9818
+ ] }),
9819
+ /* @__PURE__ */ jsxRuntime.jsx(
9820
+ Form$2.Field,
9821
+ {
9822
+ control: form.control,
9823
+ name: "province",
9824
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9825
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9826
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9827
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9828
+ ] })
9829
+ }
9830
+ ),
9831
+ /* @__PURE__ */ jsxRuntime.jsx(
9832
+ Form$2.Field,
9833
+ {
9834
+ control: form.control,
9835
+ name: "phone",
9836
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9837
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9838
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9839
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9840
+ ] })
9841
+ }
9842
+ )
9843
+ ] }) }),
9844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9845
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9847
+ ] }) })
9848
+ ]
9849
+ }
9850
+ ) });
9851
+ };
9852
+ const schema$3 = addressSchema;
9665
9853
  const NumberInput = React.forwardRef(
9666
9854
  ({
9667
9855
  value,
@@ -11291,7 +11479,7 @@ const SalesChannelForm = ({ order }) => {
11291
11479
  defaultValues: {
11292
11480
  sales_channel_id: order.sales_channel_id || ""
11293
11481
  },
11294
- resolver: zod.zodResolver(schema$3)
11482
+ resolver: zod.zodResolver(schema$2)
11295
11483
  });
11296
11484
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11297
11485
  const { handleSuccess } = useRouteModal();
@@ -11366,7 +11554,7 @@ const SalesChannelField = ({ control, order }) => {
11366
11554
  }
11367
11555
  );
11368
11556
  };
11369
- const schema$3 = objectType({
11557
+ const schema$2 = objectType({
11370
11558
  sales_channel_id: stringType().min(1)
11371
11559
  });
11372
11560
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12176,44 +12364,60 @@ const CustomAmountField = ({
12176
12364
  }
12177
12365
  );
12178
12366
  };
12179
- const TransferOwnership = () => {
12367
+ const ShippingAddress = () => {
12180
12368
  const { id } = reactRouterDom.useParams();
12181
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12182
- fields: "id,customer_id,customer.*"
12369
+ const { order, isPending, isError, error } = useOrder(id, {
12370
+ fields: "+shipping_address"
12183
12371
  });
12184
12372
  if (isError) {
12185
12373
  throw error;
12186
12374
  }
12187
- const isReady = !isPending && !!draft_order;
12375
+ const isReady = !isPending && !!order;
12188
12376
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12189
12377
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12190
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12191
- /* @__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" }) })
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" }) })
12192
12380
  ] }),
12193
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12381
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12194
12382
  ] });
12195
12383
  };
12196
- const TransferOwnershipForm = ({ order }) => {
12197
- var _a, _b;
12384
+ const ShippingAddressForm = ({ order }) => {
12385
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12198
12386
  const form = reactHookForm.useForm({
12199
12387
  defaultValues: {
12200
- customer_id: order.customer_id || ""
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) ?? ""
12201
12398
  },
12202
- resolver: zod.zodResolver(schema$2)
12399
+ resolver: zod.zodResolver(schema$1)
12203
12400
  });
12204
12401
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12205
12402
  const { handleSuccess } = useRouteModal();
12206
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12207
- const currentCustomer = order.customer ? {
12208
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12209
- value: order.customer.id
12210
- } : null;
12211
12403
  const onSubmit = form.handleSubmit(async (data) => {
12212
12404
  await mutateAsync(
12213
- { customer_id: data.customer_id },
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
+ },
12214
12419
  {
12215
12420
  onSuccess: () => {
12216
- ui.toast.success("Customer updated");
12217
12421
  handleSuccess();
12218
12422
  },
12219
12423
  onError: (error) => {
@@ -12228,15 +12432,202 @@ const TransferOwnershipForm = ({ order }) => {
12228
12432
  className: "flex flex-1 flex-col overflow-hidden",
12229
12433
  onSubmit,
12230
12434
  children: [
12231
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12232
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12233
- currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12234
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12235
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12236
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12237
- ] }),
12238
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12239
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
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 },
12605
+ {
12606
+ onSuccess: () => {
12607
+ ui.toast.success("Customer updated");
12608
+ handleSuccess();
12609
+ },
12610
+ onError: (error) => {
12611
+ ui.toast.error(error.message);
12612
+ }
12613
+ }
12614
+ );
12615
+ });
12616
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12617
+ KeyboundForm,
12618
+ {
12619
+ className: "flex flex-1 flex-col overflow-hidden",
12620
+ onSubmit,
12621
+ children: [
12622
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12623
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12624
+ currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12625
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12626
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12627
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12628
+ ] }),
12629
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12630
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12240
12631
  /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12241
12632
  ] })
12242
12633
  ] }),
@@ -12649,415 +13040,22 @@ const Illustration = () => {
12649
13040
  }
12650
13041
  );
12651
13042
  };
12652
- const schema$2 = objectType({
13043
+ const schema = objectType({
12653
13044
  customer_id: stringType().min(1)
12654
13045
  });
12655
- const ShippingAddress = () => {
12656
- const { id } = reactRouterDom.useParams();
12657
- const { order, isPending, isError, error } = useOrder(id, {
12658
- fields: "+shipping_address"
12659
- });
12660
- if (isError) {
12661
- throw error;
12662
- }
12663
- const isReady = !isPending && !!order;
12664
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12665
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12666
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12667
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12668
- ] }),
12669
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12670
- ] });
12671
- };
12672
- const ShippingAddressForm = ({ order }) => {
12673
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12674
- const form = reactHookForm.useForm({
12675
- defaultValues: {
12676
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12677
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12678
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12679
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12680
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12681
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12682
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12683
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12684
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12685
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12686
- },
12687
- resolver: zod.zodResolver(schema$1)
12688
- });
12689
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12690
- const { handleSuccess } = useRouteModal();
12691
- const onSubmit = form.handleSubmit(async (data) => {
12692
- await mutateAsync(
12693
- {
12694
- shipping_address: {
12695
- first_name: data.first_name,
12696
- last_name: data.last_name,
12697
- company: data.company,
12698
- address_1: data.address_1,
12699
- address_2: data.address_2,
12700
- city: data.city,
12701
- province: data.province,
12702
- country_code: data.country_code,
12703
- postal_code: data.postal_code,
12704
- phone: data.phone
12705
- }
12706
- },
12707
- {
12708
- onSuccess: () => {
12709
- handleSuccess();
12710
- },
12711
- onError: (error) => {
12712
- ui.toast.error(error.message);
12713
- }
12714
- }
12715
- );
12716
- });
12717
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12718
- KeyboundForm,
12719
- {
12720
- className: "flex flex-1 flex-col overflow-hidden",
12721
- onSubmit,
12722
- children: [
12723
- /* @__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: [
12724
- /* @__PURE__ */ jsxRuntime.jsx(
12725
- Form$2.Field,
12726
- {
12727
- control: form.control,
12728
- name: "country_code",
12729
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12730
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12731
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12732
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12733
- ] })
12734
- }
12735
- ),
12736
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12737
- /* @__PURE__ */ jsxRuntime.jsx(
12738
- Form$2.Field,
12739
- {
12740
- control: form.control,
12741
- name: "first_name",
12742
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12743
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12744
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12745
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12746
- ] })
12747
- }
12748
- ),
12749
- /* @__PURE__ */ jsxRuntime.jsx(
12750
- Form$2.Field,
12751
- {
12752
- control: form.control,
12753
- name: "last_name",
12754
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12755
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12756
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12757
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12758
- ] })
12759
- }
12760
- )
12761
- ] }),
12762
- /* @__PURE__ */ jsxRuntime.jsx(
12763
- Form$2.Field,
12764
- {
12765
- control: form.control,
12766
- name: "company",
12767
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12768
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12769
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12770
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12771
- ] })
12772
- }
12773
- ),
12774
- /* @__PURE__ */ jsxRuntime.jsx(
12775
- Form$2.Field,
12776
- {
12777
- control: form.control,
12778
- name: "address_1",
12779
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12780
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12781
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12782
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12783
- ] })
12784
- }
12785
- ),
12786
- /* @__PURE__ */ jsxRuntime.jsx(
12787
- Form$2.Field,
12788
- {
12789
- control: form.control,
12790
- name: "address_2",
12791
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12792
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12793
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12794
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12795
- ] })
12796
- }
12797
- ),
12798
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12799
- /* @__PURE__ */ jsxRuntime.jsx(
12800
- Form$2.Field,
12801
- {
12802
- control: form.control,
12803
- name: "postal_code",
12804
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12805
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12806
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12807
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12808
- ] })
12809
- }
12810
- ),
12811
- /* @__PURE__ */ jsxRuntime.jsx(
12812
- Form$2.Field,
12813
- {
12814
- control: form.control,
12815
- name: "city",
12816
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12817
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12818
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12819
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12820
- ] })
12821
- }
12822
- )
12823
- ] }),
12824
- /* @__PURE__ */ jsxRuntime.jsx(
12825
- Form$2.Field,
12826
- {
12827
- control: form.control,
12828
- name: "province",
12829
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12830
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12831
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12832
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12833
- ] })
12834
- }
12835
- ),
12836
- /* @__PURE__ */ jsxRuntime.jsx(
12837
- Form$2.Field,
12838
- {
12839
- control: form.control,
12840
- name: "phone",
12841
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12842
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12843
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12844
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12845
- ] })
12846
- }
12847
- )
12848
- ] }) }),
12849
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12850
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12851
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12852
- ] }) })
12853
- ]
12854
- }
12855
- ) });
12856
- };
12857
- const schema$1 = addressSchema;
12858
- const BillingAddress = () => {
12859
- const { id } = reactRouterDom.useParams();
12860
- const { order, isPending, isError, error } = useOrder(id, {
12861
- fields: "+billing_address"
12862
- });
12863
- if (isError) {
12864
- throw error;
12865
- }
12866
- const isReady = !isPending && !!order;
12867
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12868
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12869
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12870
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12871
- ] }),
12872
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12873
- ] });
12874
- };
12875
- const BillingAddressForm = ({ order }) => {
12876
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12877
- const form = reactHookForm.useForm({
12878
- defaultValues: {
12879
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12880
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12881
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12882
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12883
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12884
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12885
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12886
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12887
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12888
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12889
- },
12890
- resolver: zod.zodResolver(schema)
12891
- });
12892
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12893
- const { handleSuccess } = useRouteModal();
12894
- const onSubmit = form.handleSubmit(async (data) => {
12895
- await mutateAsync(
12896
- { billing_address: data },
12897
- {
12898
- onSuccess: () => {
12899
- handleSuccess();
12900
- },
12901
- onError: (error) => {
12902
- ui.toast.error(error.message);
12903
- }
12904
- }
12905
- );
12906
- });
12907
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12908
- KeyboundForm,
12909
- {
12910
- className: "flex flex-1 flex-col overflow-hidden",
12911
- onSubmit,
12912
- children: [
12913
- /* @__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: [
12914
- /* @__PURE__ */ jsxRuntime.jsx(
12915
- Form$2.Field,
12916
- {
12917
- control: form.control,
12918
- name: "country_code",
12919
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12922
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
- ] })
12924
- }
12925
- ),
12926
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12927
- /* @__PURE__ */ jsxRuntime.jsx(
12928
- Form$2.Field,
12929
- {
12930
- control: form.control,
12931
- name: "first_name",
12932
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12934
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12935
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12936
- ] })
12937
- }
12938
- ),
12939
- /* @__PURE__ */ jsxRuntime.jsx(
12940
- Form$2.Field,
12941
- {
12942
- control: form.control,
12943
- name: "last_name",
12944
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12948
- ] })
12949
- }
12950
- )
12951
- ] }),
12952
- /* @__PURE__ */ jsxRuntime.jsx(
12953
- Form$2.Field,
12954
- {
12955
- control: form.control,
12956
- name: "company",
12957
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12959
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12960
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12961
- ] })
12962
- }
12963
- ),
12964
- /* @__PURE__ */ jsxRuntime.jsx(
12965
- Form$2.Field,
12966
- {
12967
- control: form.control,
12968
- name: "address_1",
12969
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12972
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12973
- ] })
12974
- }
12975
- ),
12976
- /* @__PURE__ */ jsxRuntime.jsx(
12977
- Form$2.Field,
12978
- {
12979
- control: form.control,
12980
- name: "address_2",
12981
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12985
- ] })
12986
- }
12987
- ),
12988
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12989
- /* @__PURE__ */ jsxRuntime.jsx(
12990
- Form$2.Field,
12991
- {
12992
- control: form.control,
12993
- name: "postal_code",
12994
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12997
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12998
- ] })
12999
- }
13000
- ),
13001
- /* @__PURE__ */ jsxRuntime.jsx(
13002
- Form$2.Field,
13003
- {
13004
- control: form.control,
13005
- name: "city",
13006
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13009
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13010
- ] })
13011
- }
13012
- )
13013
- ] }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(
13015
- Form$2.Field,
13016
- {
13017
- control: form.control,
13018
- name: "province",
13019
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13020
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13021
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13022
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13023
- ] })
13024
- }
13025
- ),
13026
- /* @__PURE__ */ jsxRuntime.jsx(
13027
- Form$2.Field,
13028
- {
13029
- control: form.control,
13030
- name: "phone",
13031
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13034
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13035
- ] })
13036
- }
13037
- )
13038
- ] }) }),
13039
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13040
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13041
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13042
- ] }) })
13043
- ]
13044
- }
13045
- ) });
13046
- };
13047
- const schema = addressSchema;
13048
- const widgetModule = { widgets: [] };
13049
- const routeModule = {
13050
- routes: [
13051
- {
13052
- Component: List,
13053
- path: "/draft-orders",
13054
- handle: handle$1,
13055
- children: [
13056
- {
13057
- Component: Create,
13058
- path: "/draft-orders/create"
13059
- }
13060
- ]
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
+ ]
13061
13059
  },
13062
13060
  {
13063
13061
  Component: ID,
@@ -13073,6 +13071,10 @@ const routeModule = {
13073
13071
  Component: Email,
13074
13072
  path: "/draft-orders/:id/email"
13075
13073
  },
13074
+ {
13075
+ Component: BillingAddress,
13076
+ path: "/draft-orders/:id/billing-address"
13077
+ },
13076
13078
  {
13077
13079
  Component: Items,
13078
13080
  path: "/draft-orders/:id/items"
@@ -13093,17 +13095,13 @@ const routeModule = {
13093
13095
  Component: Shipping,
13094
13096
  path: "/draft-orders/:id/shipping"
13095
13097
  },
13096
- {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13099
- },
13100
13098
  {
13101
13099
  Component: ShippingAddress,
13102
13100
  path: "/draft-orders/:id/shipping-address"
13103
13101
  },
13104
13102
  {
13105
- Component: BillingAddress,
13106
- path: "/draft-orders/:id/billing-address"
13103
+ Component: TransferOwnership,
13104
+ path: "/draft-orders/:id/transfer-ownership"
13107
13105
  }
13108
13106
  ]
13109
13107
  }