@medusajs/draft-order 2.10.4-preview-20251004090150 → 2.10.4-preview-20251004150159

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.
@@ -9573,10 +9573,31 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
- const BillingAddress = () => {
9576
+ const CustomItems = () => {
9577
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9579
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9580
+ ] });
9581
+ };
9582
+ const CustomItemsForm = () => {
9583
+ const form = reactHookForm.useForm({
9584
+ resolver: zod.zodResolver(schema$5)
9585
+ });
9586
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9589
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9590
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9591
+ ] }) })
9592
+ ] }) });
9593
+ };
9594
+ const schema$5 = objectType({
9595
+ email: stringType().email()
9596
+ });
9597
+ const Email = () => {
9577
9598
  const { id } = reactRouterDom.useParams();
9578
9599
  const { order, isPending, isError, error } = useOrder(id, {
9579
- fields: "+billing_address"
9600
+ fields: "+email"
9580
9601
  });
9581
9602
  if (isError) {
9582
9603
  throw error;
@@ -9584,34 +9605,24 @@ const BillingAddress = () => {
9584
9605
  const isReady = !isPending && !!order;
9585
9606
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9586
9607
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9587
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9588
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9608
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9609
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9589
9610
  ] }),
9590
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9611
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9591
9612
  ] });
9592
9613
  };
9593
- const BillingAddressForm = ({ order }) => {
9594
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9614
+ const EmailForm = ({ order }) => {
9595
9615
  const form = reactHookForm.useForm({
9596
9616
  defaultValues: {
9597
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9598
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9599
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9600
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9601
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9602
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9603
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9604
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9605
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9606
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9617
+ email: order.email ?? ""
9607
9618
  },
9608
- resolver: zod.zodResolver(schema$5)
9619
+ resolver: zod.zodResolver(schema$4)
9609
9620
  });
9610
9621
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9611
9622
  const { handleSuccess } = useRouteModal();
9612
9623
  const onSubmit = form.handleSubmit(async (data) => {
9613
9624
  await mutateAsync(
9614
- { billing_address: data },
9625
+ { email: data.email },
9615
9626
  {
9616
9627
  onSuccess: () => {
9617
9628
  handleSuccess();
@@ -9628,132 +9639,18 @@ const BillingAddressForm = ({ order }) => {
9628
9639
  className: "flex flex-1 flex-col overflow-hidden",
9629
9640
  onSubmit,
9630
9641
  children: [
9631
- /* @__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: [
9632
- /* @__PURE__ */ jsxRuntime.jsx(
9633
- Form$2.Field,
9634
- {
9635
- control: form.control,
9636
- name: "country_code",
9637
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9639
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9640
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
- ] })
9642
- }
9643
- ),
9644
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9645
- /* @__PURE__ */ jsxRuntime.jsx(
9646
- Form$2.Field,
9647
- {
9648
- control: form.control,
9649
- name: "first_name",
9650
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9652
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9653
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9654
- ] })
9655
- }
9656
- ),
9657
- /* @__PURE__ */ jsxRuntime.jsx(
9658
- Form$2.Field,
9659
- {
9660
- control: form.control,
9661
- name: "last_name",
9662
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9664
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9665
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9666
- ] })
9667
- }
9668
- )
9669
- ] }),
9670
- /* @__PURE__ */ jsxRuntime.jsx(
9671
- Form$2.Field,
9672
- {
9673
- control: form.control,
9674
- name: "company",
9675
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9677
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9678
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9679
- ] })
9680
- }
9681
- ),
9682
- /* @__PURE__ */ jsxRuntime.jsx(
9683
- Form$2.Field,
9684
- {
9685
- control: form.control,
9686
- name: "address_1",
9687
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9689
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9690
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9691
- ] })
9692
- }
9693
- ),
9694
- /* @__PURE__ */ jsxRuntime.jsx(
9695
- Form$2.Field,
9696
- {
9697
- control: form.control,
9698
- name: "address_2",
9699
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9701
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9702
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9703
- ] })
9704
- }
9705
- ),
9706
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9707
- /* @__PURE__ */ jsxRuntime.jsx(
9708
- Form$2.Field,
9709
- {
9710
- control: form.control,
9711
- name: "postal_code",
9712
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9714
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9715
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9716
- ] })
9717
- }
9718
- ),
9719
- /* @__PURE__ */ jsxRuntime.jsx(
9720
- Form$2.Field,
9721
- {
9722
- control: form.control,
9723
- name: "city",
9724
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9726
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9727
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
- ] })
9729
- }
9730
- )
9731
- ] }),
9732
- /* @__PURE__ */ jsxRuntime.jsx(
9733
- Form$2.Field,
9734
- {
9735
- control: form.control,
9736
- name: "province",
9737
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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: "phone",
9749
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
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
- ] }) }),
9642
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9643
+ Form$2.Field,
9644
+ {
9645
+ control: form.control,
9646
+ name: "email",
9647
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9648
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9649
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9651
+ ] })
9652
+ }
9653
+ ) }),
9757
9654
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9758
9655
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9759
9656
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -9762,7 +9659,9 @@ const BillingAddressForm = ({ order }) => {
9762
9659
  }
9763
9660
  ) });
9764
9661
  };
9765
- const schema$5 = addressSchema;
9662
+ const schema$4 = objectType({
9663
+ email: stringType().email()
9664
+ });
9766
9665
  const NumberInput = React.forwardRef(
9767
9666
  ({
9768
9667
  value,
@@ -11364,27 +11263,6 @@ function getPromotionIds(items, shippingMethods) {
11364
11263
  }
11365
11264
  return Array.from(promotionIds);
11366
11265
  }
11367
- const CustomItems = () => {
11368
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11369
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
11370
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
11371
- ] });
11372
- };
11373
- const CustomItemsForm = () => {
11374
- const form = reactHookForm.useForm({
11375
- resolver: zod.zodResolver(schema$4)
11376
- });
11377
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11378
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
11379
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11380
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11381
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
11382
- ] }) })
11383
- ] }) });
11384
- };
11385
- const schema$4 = objectType({
11386
- email: stringType().email()
11387
- });
11388
11266
  const SalesChannel = () => {
11389
11267
  const { id } = reactRouterDom.useParams();
11390
11268
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -12298,53 +12176,256 @@ const CustomAmountField = ({
12298
12176
  }
12299
12177
  );
12300
12178
  };
12301
- const TransferOwnership = () => {
12179
+ const ShippingAddress = () => {
12302
12180
  const { id } = reactRouterDom.useParams();
12303
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12304
- fields: "id,customer_id,customer.*"
12181
+ const { order, isPending, isError, error } = useOrder(id, {
12182
+ fields: "+shipping_address"
12305
12183
  });
12306
12184
  if (isError) {
12307
12185
  throw error;
12308
12186
  }
12309
- const isReady = !isPending && !!draft_order;
12187
+ const isReady = !isPending && !!order;
12310
12188
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12311
12189
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12312
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12313
- /* @__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" }) })
12190
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12191
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12314
12192
  ] }),
12315
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12193
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12316
12194
  ] });
12317
12195
  };
12318
- const TransferOwnershipForm = ({ order }) => {
12319
- var _a, _b;
12196
+ const ShippingAddressForm = ({ order }) => {
12197
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12320
12198
  const form = reactHookForm.useForm({
12321
12199
  defaultValues: {
12322
- customer_id: order.customer_id || ""
12200
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12201
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12202
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12203
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12204
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12205
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12206
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12207
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12208
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12209
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12323
12210
  },
12324
12211
  resolver: zod.zodResolver(schema$2)
12325
12212
  });
12326
12213
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12327
12214
  const { handleSuccess } = useRouteModal();
12328
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12329
- const currentCustomer = order.customer ? {
12330
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12331
- value: order.customer.id
12332
- } : null;
12333
12215
  const onSubmit = form.handleSubmit(async (data) => {
12334
12216
  await mutateAsync(
12335
- { customer_id: data.customer_id },
12336
12217
  {
12337
- onSuccess: () => {
12338
- ui.toast.success("Customer updated");
12339
- handleSuccess();
12340
- },
12341
- onError: (error) => {
12342
- ui.toast.error(error.message);
12343
- }
12344
- }
12345
- );
12346
- });
12347
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12218
+ shipping_address: {
12219
+ first_name: data.first_name,
12220
+ last_name: data.last_name,
12221
+ company: data.company,
12222
+ address_1: data.address_1,
12223
+ address_2: data.address_2,
12224
+ city: data.city,
12225
+ province: data.province,
12226
+ country_code: data.country_code,
12227
+ postal_code: data.postal_code,
12228
+ phone: data.phone
12229
+ }
12230
+ },
12231
+ {
12232
+ onSuccess: () => {
12233
+ handleSuccess();
12234
+ },
12235
+ onError: (error) => {
12236
+ ui.toast.error(error.message);
12237
+ }
12238
+ }
12239
+ );
12240
+ });
12241
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12242
+ KeyboundForm,
12243
+ {
12244
+ className: "flex flex-1 flex-col overflow-hidden",
12245
+ onSubmit,
12246
+ children: [
12247
+ /* @__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: [
12248
+ /* @__PURE__ */ jsxRuntime.jsx(
12249
+ Form$2.Field,
12250
+ {
12251
+ control: form.control,
12252
+ name: "country_code",
12253
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12254
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12255
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12256
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12257
+ ] })
12258
+ }
12259
+ ),
12260
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12261
+ /* @__PURE__ */ jsxRuntime.jsx(
12262
+ Form$2.Field,
12263
+ {
12264
+ control: form.control,
12265
+ name: "first_name",
12266
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12267
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12268
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12269
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12270
+ ] })
12271
+ }
12272
+ ),
12273
+ /* @__PURE__ */ jsxRuntime.jsx(
12274
+ Form$2.Field,
12275
+ {
12276
+ control: form.control,
12277
+ name: "last_name",
12278
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12279
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12280
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12281
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12282
+ ] })
12283
+ }
12284
+ )
12285
+ ] }),
12286
+ /* @__PURE__ */ jsxRuntime.jsx(
12287
+ Form$2.Field,
12288
+ {
12289
+ control: form.control,
12290
+ name: "company",
12291
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12292
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12293
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12294
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12295
+ ] })
12296
+ }
12297
+ ),
12298
+ /* @__PURE__ */ jsxRuntime.jsx(
12299
+ Form$2.Field,
12300
+ {
12301
+ control: form.control,
12302
+ name: "address_1",
12303
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12304
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12305
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12306
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12307
+ ] })
12308
+ }
12309
+ ),
12310
+ /* @__PURE__ */ jsxRuntime.jsx(
12311
+ Form$2.Field,
12312
+ {
12313
+ control: form.control,
12314
+ name: "address_2",
12315
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12316
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12317
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12318
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12319
+ ] })
12320
+ }
12321
+ ),
12322
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12323
+ /* @__PURE__ */ jsxRuntime.jsx(
12324
+ Form$2.Field,
12325
+ {
12326
+ control: form.control,
12327
+ name: "postal_code",
12328
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12329
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12330
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12331
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12332
+ ] })
12333
+ }
12334
+ ),
12335
+ /* @__PURE__ */ jsxRuntime.jsx(
12336
+ Form$2.Field,
12337
+ {
12338
+ control: form.control,
12339
+ name: "city",
12340
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12341
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12342
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12343
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12344
+ ] })
12345
+ }
12346
+ )
12347
+ ] }),
12348
+ /* @__PURE__ */ jsxRuntime.jsx(
12349
+ Form$2.Field,
12350
+ {
12351
+ control: form.control,
12352
+ name: "province",
12353
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12354
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12355
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12356
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12357
+ ] })
12358
+ }
12359
+ ),
12360
+ /* @__PURE__ */ jsxRuntime.jsx(
12361
+ Form$2.Field,
12362
+ {
12363
+ control: form.control,
12364
+ name: "phone",
12365
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12366
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12367
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12368
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12369
+ ] })
12370
+ }
12371
+ )
12372
+ ] }) }),
12373
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12374
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12375
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12376
+ ] }) })
12377
+ ]
12378
+ }
12379
+ ) });
12380
+ };
12381
+ const schema$2 = addressSchema;
12382
+ const TransferOwnership = () => {
12383
+ const { id } = reactRouterDom.useParams();
12384
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12385
+ fields: "id,customer_id,customer.*"
12386
+ });
12387
+ if (isError) {
12388
+ throw error;
12389
+ }
12390
+ const isReady = !isPending && !!draft_order;
12391
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12392
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12393
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12394
+ /* @__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" }) })
12395
+ ] }),
12396
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12397
+ ] });
12398
+ };
12399
+ const TransferOwnershipForm = ({ order }) => {
12400
+ var _a, _b;
12401
+ const form = reactHookForm.useForm({
12402
+ defaultValues: {
12403
+ customer_id: order.customer_id || ""
12404
+ },
12405
+ resolver: zod.zodResolver(schema$1)
12406
+ });
12407
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12408
+ const { handleSuccess } = useRouteModal();
12409
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12410
+ const currentCustomer = order.customer ? {
12411
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12412
+ value: order.customer.id
12413
+ } : null;
12414
+ const onSubmit = form.handleSubmit(async (data) => {
12415
+ await mutateAsync(
12416
+ { customer_id: data.customer_id },
12417
+ {
12418
+ onSuccess: () => {
12419
+ ui.toast.success("Customer updated");
12420
+ handleSuccess();
12421
+ },
12422
+ onError: (error) => {
12423
+ ui.toast.error(error.message);
12424
+ }
12425
+ }
12426
+ );
12427
+ });
12428
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12348
12429
  KeyboundForm,
12349
12430
  {
12350
12431
  className: "flex flex-1 flex-col overflow-hidden",
@@ -12771,13 +12852,13 @@ const Illustration = () => {
12771
12852
  }
12772
12853
  );
12773
12854
  };
12774
- const schema$2 = objectType({
12855
+ const schema$1 = objectType({
12775
12856
  customer_id: stringType().min(1)
12776
12857
  });
12777
- const ShippingAddress = () => {
12858
+ const BillingAddress = () => {
12778
12859
  const { id } = reactRouterDom.useParams();
12779
12860
  const { order, isPending, isError, error } = useOrder(id, {
12780
- fields: "+shipping_address"
12861
+ fields: "+billing_address"
12781
12862
  });
12782
12863
  if (isError) {
12783
12864
  throw error;
@@ -12785,47 +12866,34 @@ const ShippingAddress = () => {
12785
12866
  const isReady = !isPending && !!order;
12786
12867
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12787
12868
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12788
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12789
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
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" }) })
12790
12871
  ] }),
12791
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12872
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12792
12873
  ] });
12793
12874
  };
12794
- const ShippingAddressForm = ({ order }) => {
12875
+ const BillingAddressForm = ({ order }) => {
12795
12876
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12796
12877
  const form = reactHookForm.useForm({
12797
12878
  defaultValues: {
12798
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12799
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12800
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12801
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12802
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12803
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12804
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12805
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12806
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12807
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
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) ?? ""
12808
12889
  },
12809
- resolver: zod.zodResolver(schema$1)
12890
+ resolver: zod.zodResolver(schema)
12810
12891
  });
12811
12892
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12812
12893
  const { handleSuccess } = useRouteModal();
12813
12894
  const onSubmit = form.handleSubmit(async (data) => {
12814
12895
  await mutateAsync(
12815
- {
12816
- shipping_address: {
12817
- first_name: data.first_name,
12818
- last_name: data.last_name,
12819
- company: data.company,
12820
- address_1: data.address_1,
12821
- address_2: data.address_2,
12822
- city: data.city,
12823
- province: data.province,
12824
- country_code: data.country_code,
12825
- postal_code: data.postal_code,
12826
- phone: data.phone
12827
- }
12828
- },
12896
+ { billing_address: data },
12829
12897
  {
12830
12898
  onSuccess: () => {
12831
12899
  handleSuccess();
@@ -12976,75 +13044,7 @@ const ShippingAddressForm = ({ order }) => {
12976
13044
  }
12977
13045
  ) });
12978
13046
  };
12979
- const schema$1 = addressSchema;
12980
- const Email = () => {
12981
- const { id } = reactRouterDom.useParams();
12982
- const { order, isPending, isError, error } = useOrder(id, {
12983
- fields: "+email"
12984
- });
12985
- if (isError) {
12986
- throw error;
12987
- }
12988
- const isReady = !isPending && !!order;
12989
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12990
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12991
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
12992
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12993
- ] }),
12994
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
12995
- ] });
12996
- };
12997
- const EmailForm = ({ order }) => {
12998
- const form = reactHookForm.useForm({
12999
- defaultValues: {
13000
- email: order.email ?? ""
13001
- },
13002
- resolver: zod.zodResolver(schema)
13003
- });
13004
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13005
- const { handleSuccess } = useRouteModal();
13006
- const onSubmit = form.handleSubmit(async (data) => {
13007
- await mutateAsync(
13008
- { email: data.email },
13009
- {
13010
- onSuccess: () => {
13011
- handleSuccess();
13012
- },
13013
- onError: (error) => {
13014
- ui.toast.error(error.message);
13015
- }
13016
- }
13017
- );
13018
- });
13019
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
13020
- KeyboundForm,
13021
- {
13022
- className: "flex flex-1 flex-col overflow-hidden",
13023
- onSubmit,
13024
- children: [
13025
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
13026
- Form$2.Field,
13027
- {
13028
- control: form.control,
13029
- name: "email",
13030
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
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 = objectType({
13046
- email: stringType().email()
13047
- });
13047
+ const schema = addressSchema;
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13066,8 +13066,12 @@ const routeModule = {
13066
13066
  loader,
13067
13067
  children: [
13068
13068
  {
13069
- Component: BillingAddress,
13070
- path: "/draft-orders/:id/billing-address"
13069
+ Component: CustomItems,
13070
+ path: "/draft-orders/:id/custom-items"
13071
+ },
13072
+ {
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13071
13075
  },
13072
13076
  {
13073
13077
  Component: Items,
@@ -13081,10 +13085,6 @@ const routeModule = {
13081
13085
  Component: Promotions,
13082
13086
  path: "/draft-orders/:id/promotions"
13083
13087
  },
13084
- {
13085
- Component: CustomItems,
13086
- path: "/draft-orders/:id/custom-items"
13087
- },
13088
13088
  {
13089
13089
  Component: SalesChannel,
13090
13090
  path: "/draft-orders/:id/sales-channel"
@@ -13093,17 +13093,17 @@ const routeModule = {
13093
13093
  Component: Shipping,
13094
13094
  path: "/draft-orders/:id/shipping"
13095
13095
  },
13096
- {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13099
- },
13100
13096
  {
13101
13097
  Component: ShippingAddress,
13102
13098
  path: "/draft-orders/:id/shipping-address"
13103
13099
  },
13104
13100
  {
13105
- Component: Email,
13106
- path: "/draft-orders/:id/email"
13101
+ Component: TransferOwnership,
13102
+ path: "/draft-orders/:id/transfer-ownership"
13103
+ },
13104
+ {
13105
+ Component: BillingAddress,
13106
+ path: "/draft-orders/:id/billing-address"
13107
13107
  }
13108
13108
  ]
13109
13109
  }