@medusajs/draft-order 2.11.2-preview-20251026120206 → 2.11.2-snapshot-20251026124930

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,196 +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
9574
  const Email = () => {
9765
9575
  const { id } = reactRouterDom.useParams();
9766
9576
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9783,7 +9593,7 @@ const EmailForm = ({ order }) => {
9783
9593
  defaultValues: {
9784
9594
  email: order.email ?? ""
9785
9595
  },
9786
- resolver: zod.zodResolver(schema$4)
9596
+ resolver: zod.zodResolver(schema$5)
9787
9597
  });
9788
9598
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9789
9599
  const { handleSuccess } = useRouteModal();
@@ -9826,7 +9636,7 @@ const EmailForm = ({ order }) => {
9826
9636
  }
9827
9637
  ) });
9828
9638
  };
9829
- const schema$4 = objectType({
9639
+ const schema$5 = objectType({
9830
9640
  email: stringType().email()
9831
9641
  });
9832
9642
  const NumberInput = React.forwardRef(
@@ -11430,6 +11240,27 @@ function getPromotionIds(items, shippingMethods) {
11430
11240
  }
11431
11241
  return Array.from(promotionIds);
11432
11242
  }
11243
+ const CustomItems = () => {
11244
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11245
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
11246
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
11247
+ ] });
11248
+ };
11249
+ const CustomItemsForm = () => {
11250
+ const form = reactHookForm.useForm({
11251
+ resolver: zod.zodResolver(schema$4)
11252
+ });
11253
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11254
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
11255
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11256
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11257
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
11258
+ ] }) })
11259
+ ] }) });
11260
+ };
11261
+ const schema$4 = objectType({
11262
+ email: stringType().email()
11263
+ });
11433
11264
  const SalesChannel = () => {
11434
11265
  const { id } = reactRouterDom.useParams();
11435
11266
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -12343,244 +12174,41 @@ const CustomAmountField = ({
12343
12174
  }
12344
12175
  );
12345
12176
  };
12346
- const ShippingAddress = () => {
12177
+ const TransferOwnership = () => {
12347
12178
  const { id } = reactRouterDom.useParams();
12348
- const { order, isPending, isError, error } = useOrder(id, {
12349
- fields: "+shipping_address"
12179
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12180
+ fields: "id,customer_id,customer.*"
12350
12181
  });
12351
12182
  if (isError) {
12352
12183
  throw error;
12353
12184
  }
12354
- const isReady = !isPending && !!order;
12185
+ const isReady = !isPending && !!draft_order;
12355
12186
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12356
12187
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12357
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12358
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12188
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12189
+ /* @__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" }) })
12359
12190
  ] }),
12360
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12191
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12361
12192
  ] });
12362
12193
  };
12363
- const ShippingAddressForm = ({ order }) => {
12364
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12194
+ const TransferOwnershipForm = ({ order }) => {
12195
+ var _a, _b;
12365
12196
  const form = reactHookForm.useForm({
12366
12197
  defaultValues: {
12367
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12368
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12369
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12370
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12371
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12372
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12373
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12374
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12375
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12376
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12198
+ customer_id: order.customer_id || ""
12377
12199
  },
12378
12200
  resolver: zod.zodResolver(schema$2)
12379
12201
  });
12380
12202
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12381
12203
  const { handleSuccess } = useRouteModal();
12204
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12205
+ const currentCustomer = order.customer ? {
12206
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12207
+ value: order.customer.id
12208
+ } : null;
12382
12209
  const onSubmit = form.handleSubmit(async (data) => {
12383
12210
  await mutateAsync(
12384
- {
12385
- shipping_address: {
12386
- first_name: data.first_name,
12387
- last_name: data.last_name,
12388
- company: data.company,
12389
- address_1: data.address_1,
12390
- address_2: data.address_2,
12391
- city: data.city,
12392
- province: data.province,
12393
- country_code: data.country_code,
12394
- postal_code: data.postal_code,
12395
- phone: data.phone
12396
- }
12397
- },
12398
- {
12399
- onSuccess: () => {
12400
- handleSuccess();
12401
- },
12402
- onError: (error) => {
12403
- ui.toast.error(error.message);
12404
- }
12405
- }
12406
- );
12407
- });
12408
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12409
- KeyboundForm,
12410
- {
12411
- className: "flex flex-1 flex-col overflow-hidden",
12412
- onSubmit,
12413
- children: [
12414
- /* @__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: [
12415
- /* @__PURE__ */ jsxRuntime.jsx(
12416
- Form$2.Field,
12417
- {
12418
- control: form.control,
12419
- name: "country_code",
12420
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12421
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12422
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12423
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12424
- ] })
12425
- }
12426
- ),
12427
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12428
- /* @__PURE__ */ jsxRuntime.jsx(
12429
- Form$2.Field,
12430
- {
12431
- control: form.control,
12432
- name: "first_name",
12433
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12434
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12435
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12436
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12437
- ] })
12438
- }
12439
- ),
12440
- /* @__PURE__ */ jsxRuntime.jsx(
12441
- Form$2.Field,
12442
- {
12443
- control: form.control,
12444
- name: "last_name",
12445
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12446
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12447
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12448
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12449
- ] })
12450
- }
12451
- )
12452
- ] }),
12453
- /* @__PURE__ */ jsxRuntime.jsx(
12454
- Form$2.Field,
12455
- {
12456
- control: form.control,
12457
- name: "company",
12458
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12459
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12460
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12461
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12462
- ] })
12463
- }
12464
- ),
12465
- /* @__PURE__ */ jsxRuntime.jsx(
12466
- Form$2.Field,
12467
- {
12468
- control: form.control,
12469
- name: "address_1",
12470
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12471
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12472
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12473
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12474
- ] })
12475
- }
12476
- ),
12477
- /* @__PURE__ */ jsxRuntime.jsx(
12478
- Form$2.Field,
12479
- {
12480
- control: form.control,
12481
- name: "address_2",
12482
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12483
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12484
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12485
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12486
- ] })
12487
- }
12488
- ),
12489
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12490
- /* @__PURE__ */ jsxRuntime.jsx(
12491
- Form$2.Field,
12492
- {
12493
- control: form.control,
12494
- name: "postal_code",
12495
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12496
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12497
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12498
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12499
- ] })
12500
- }
12501
- ),
12502
- /* @__PURE__ */ jsxRuntime.jsx(
12503
- Form$2.Field,
12504
- {
12505
- control: form.control,
12506
- name: "city",
12507
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12508
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12509
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12510
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12511
- ] })
12512
- }
12513
- )
12514
- ] }),
12515
- /* @__PURE__ */ jsxRuntime.jsx(
12516
- Form$2.Field,
12517
- {
12518
- control: form.control,
12519
- name: "province",
12520
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12521
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12522
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12523
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12524
- ] })
12525
- }
12526
- ),
12527
- /* @__PURE__ */ jsxRuntime.jsx(
12528
- Form$2.Field,
12529
- {
12530
- control: form.control,
12531
- name: "phone",
12532
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12533
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12534
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12535
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12536
- ] })
12537
- }
12538
- )
12539
- ] }) }),
12540
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12541
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12542
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12543
- ] }) })
12544
- ]
12545
- }
12546
- ) });
12547
- };
12548
- const schema$2 = addressSchema;
12549
- const TransferOwnership = () => {
12550
- const { id } = reactRouterDom.useParams();
12551
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12552
- fields: "id,customer_id,customer.*"
12553
- });
12554
- if (isError) {
12555
- throw error;
12556
- }
12557
- const isReady = !isPending && !!draft_order;
12558
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12559
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12560
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12561
- /* @__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" }) })
12562
- ] }),
12563
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12564
- ] });
12565
- };
12566
- const TransferOwnershipForm = ({ order }) => {
12567
- var _a, _b;
12568
- const form = reactHookForm.useForm({
12569
- defaultValues: {
12570
- customer_id: order.customer_id || ""
12571
- },
12572
- resolver: zod.zodResolver(schema$1)
12573
- });
12574
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12575
- const { handleSuccess } = useRouteModal();
12576
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12577
- const currentCustomer = order.customer ? {
12578
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12579
- value: order.customer.id
12580
- } : null;
12581
- const onSubmit = form.handleSubmit(async (data) => {
12582
- await mutateAsync(
12583
- { customer_id: data.customer_id },
12211
+ { customer_id: data.customer_id },
12584
12212
  {
12585
12213
  onSuccess: () => {
12586
12214
  ui.toast.success("Customer updated");
@@ -13019,54 +12647,422 @@ const Illustration = () => {
13019
12647
  }
13020
12648
  );
13021
12649
  };
13022
- const schema$1 = objectType({
12650
+ const schema$2 = objectType({
13023
12651
  customer_id: stringType().min(1)
13024
12652
  });
13025
- const CustomItems = () => {
12653
+ const ShippingAddress = () => {
12654
+ const { id } = reactRouterDom.useParams();
12655
+ const { order, isPending, isError, error } = useOrder(id, {
12656
+ fields: "+shipping_address"
12657
+ });
12658
+ if (isError) {
12659
+ throw error;
12660
+ }
12661
+ const isReady = !isPending && !!order;
13026
12662
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13028
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12663
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12664
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12665
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12666
+ ] }),
12667
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
13029
12668
  ] });
13030
12669
  };
13031
- const CustomItemsForm = () => {
12670
+ const ShippingAddressForm = ({ order }) => {
12671
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
13032
12672
  const form = reactHookForm.useForm({
13033
- resolver: zod.zodResolver(schema)
13034
- });
13035
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13036
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
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", children: "Save" })
13040
- ] }) })
13041
- ] }) });
13042
- };
13043
- const schema = objectType({
13044
- email: stringType().email()
13045
- });
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
- ]
12673
+ defaultValues: {
12674
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12675
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12676
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12677
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12678
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12679
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12680
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12681
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12682
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12683
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
13059
12684
  },
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"
12685
+ resolver: zod.zodResolver(schema$1)
12686
+ });
12687
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12688
+ const { handleSuccess } = useRouteModal();
12689
+ const onSubmit = form.handleSubmit(async (data) => {
12690
+ await mutateAsync(
12691
+ {
12692
+ shipping_address: {
12693
+ first_name: data.first_name,
12694
+ last_name: data.last_name,
12695
+ company: data.company,
12696
+ address_1: data.address_1,
12697
+ address_2: data.address_2,
12698
+ city: data.city,
12699
+ province: data.province,
12700
+ country_code: data.country_code,
12701
+ postal_code: data.postal_code,
12702
+ phone: data.phone
12703
+ }
12704
+ },
12705
+ {
12706
+ onSuccess: () => {
12707
+ handleSuccess();
12708
+ },
12709
+ onError: (error) => {
12710
+ ui.toast.error(error.message);
12711
+ }
12712
+ }
12713
+ );
12714
+ });
12715
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12716
+ KeyboundForm,
12717
+ {
12718
+ className: "flex flex-1 flex-col overflow-hidden",
12719
+ onSubmit,
12720
+ children: [
12721
+ /* @__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: [
12722
+ /* @__PURE__ */ jsxRuntime.jsx(
12723
+ Form$2.Field,
12724
+ {
12725
+ control: form.control,
12726
+ name: "country_code",
12727
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12728
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12729
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12730
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12731
+ ] })
12732
+ }
12733
+ ),
12734
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12735
+ /* @__PURE__ */ jsxRuntime.jsx(
12736
+ Form$2.Field,
12737
+ {
12738
+ control: form.control,
12739
+ name: "first_name",
12740
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12741
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12742
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12743
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12744
+ ] })
12745
+ }
12746
+ ),
12747
+ /* @__PURE__ */ jsxRuntime.jsx(
12748
+ Form$2.Field,
12749
+ {
12750
+ control: form.control,
12751
+ name: "last_name",
12752
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12753
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12754
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12755
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12756
+ ] })
12757
+ }
12758
+ )
12759
+ ] }),
12760
+ /* @__PURE__ */ jsxRuntime.jsx(
12761
+ Form$2.Field,
12762
+ {
12763
+ control: form.control,
12764
+ name: "company",
12765
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12766
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12767
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12768
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12769
+ ] })
12770
+ }
12771
+ ),
12772
+ /* @__PURE__ */ jsxRuntime.jsx(
12773
+ Form$2.Field,
12774
+ {
12775
+ control: form.control,
12776
+ name: "address_1",
12777
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12778
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12779
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12780
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12781
+ ] })
12782
+ }
12783
+ ),
12784
+ /* @__PURE__ */ jsxRuntime.jsx(
12785
+ Form$2.Field,
12786
+ {
12787
+ control: form.control,
12788
+ name: "address_2",
12789
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12790
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12791
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12792
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12793
+ ] })
12794
+ }
12795
+ ),
12796
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12797
+ /* @__PURE__ */ jsxRuntime.jsx(
12798
+ Form$2.Field,
12799
+ {
12800
+ control: form.control,
12801
+ name: "postal_code",
12802
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12803
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12804
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12805
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12806
+ ] })
12807
+ }
12808
+ ),
12809
+ /* @__PURE__ */ jsxRuntime.jsx(
12810
+ Form$2.Field,
12811
+ {
12812
+ control: form.control,
12813
+ name: "city",
12814
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12815
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12816
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12817
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12818
+ ] })
12819
+ }
12820
+ )
12821
+ ] }),
12822
+ /* @__PURE__ */ jsxRuntime.jsx(
12823
+ Form$2.Field,
12824
+ {
12825
+ control: form.control,
12826
+ name: "province",
12827
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12828
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12829
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12830
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12831
+ ] })
12832
+ }
12833
+ ),
12834
+ /* @__PURE__ */ jsxRuntime.jsx(
12835
+ Form$2.Field,
12836
+ {
12837
+ control: form.control,
12838
+ name: "phone",
12839
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12840
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12841
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12842
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12843
+ ] })
12844
+ }
12845
+ )
12846
+ ] }) }),
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", isLoading: isPending, children: "Save" })
12850
+ ] }) })
12851
+ ]
12852
+ }
12853
+ ) });
12854
+ };
12855
+ const schema$1 = addressSchema;
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();
13069
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: [
13070
13066
  {
13071
13067
  Component: Email,
13072
13068
  path: "/draft-orders/:id/email"
@@ -13083,6 +13079,10 @@ const routeModule = {
13083
13079
  Component: Promotions,
13084
13080
  path: "/draft-orders/:id/promotions"
13085
13081
  },
13082
+ {
13083
+ Component: CustomItems,
13084
+ path: "/draft-orders/:id/custom-items"
13085
+ },
13086
13086
  {
13087
13087
  Component: SalesChannel,
13088
13088
  path: "/draft-orders/:id/sales-channel"
@@ -13091,17 +13091,17 @@ const routeModule = {
13091
13091
  Component: Shipping,
13092
13092
  path: "/draft-orders/:id/shipping"
13093
13093
  },
13094
- {
13095
- Component: ShippingAddress,
13096
- path: "/draft-orders/:id/shipping-address"
13097
- },
13098
13094
  {
13099
13095
  Component: TransferOwnership,
13100
13096
  path: "/draft-orders/:id/transfer-ownership"
13101
13097
  },
13102
13098
  {
13103
- Component: CustomItems,
13104
- path: "/draft-orders/:id/custom-items"
13099
+ Component: ShippingAddress,
13100
+ path: "/draft-orders/:id/shipping-address"
13101
+ },
13102
+ {
13103
+ Component: BillingAddress,
13104
+ path: "/draft-orders/:id/billing-address"
13105
13105
  }
13106
13106
  ]
13107
13107
  }