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