@medusajs/draft-order 2.10.2-preview-20250912000322 → 2.10.2-preview-20250912060156

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.
@@ -9778,74 +9778,6 @@ const CustomItemsForm = () => {
9778
9778
  const schema$4 = objectType({
9779
9779
  email: stringType().email()
9780
9780
  });
9781
- const Email = () => {
9782
- const { id } = useParams();
9783
- const { order, isPending, isError, error } = useOrder(id, {
9784
- fields: "+email"
9785
- });
9786
- if (isError) {
9787
- throw error;
9788
- }
9789
- const isReady = !isPending && !!order;
9790
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9791
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9792
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9793
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9794
- ] }),
9795
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9796
- ] });
9797
- };
9798
- const EmailForm = ({ order }) => {
9799
- const form = useForm({
9800
- defaultValues: {
9801
- email: order.email ?? ""
9802
- },
9803
- resolver: zodResolver(schema$3)
9804
- });
9805
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
- const { handleSuccess } = useRouteModal();
9807
- const onSubmit = form.handleSubmit(async (data) => {
9808
- await mutateAsync(
9809
- { email: data.email },
9810
- {
9811
- onSuccess: () => {
9812
- handleSuccess();
9813
- },
9814
- onError: (error) => {
9815
- toast.error(error.message);
9816
- }
9817
- }
9818
- );
9819
- });
9820
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9821
- KeyboundForm,
9822
- {
9823
- className: "flex flex-1 flex-col overflow-hidden",
9824
- onSubmit,
9825
- children: [
9826
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9827
- Form$2.Field,
9828
- {
9829
- control: form.control,
9830
- name: "email",
9831
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9832
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9833
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9834
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9835
- ] })
9836
- }
9837
- ) }),
9838
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9839
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9840
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9841
- ] }) })
9842
- ]
9843
- }
9844
- ) });
9845
- };
9846
- const schema$3 = objectType({
9847
- email: stringType().email()
9848
- });
9849
9781
  const NumberInput = forwardRef(
9850
9782
  ({
9851
9783
  value,
@@ -11447,60 +11379,46 @@ function getPromotionIds(items, shippingMethods) {
11447
11379
  }
11448
11380
  return Array.from(promotionIds);
11449
11381
  }
11450
- const ShippingAddress = () => {
11382
+ const SalesChannel = () => {
11451
11383
  const { id } = useParams();
11452
- const { order, isPending, isError, error } = useOrder(id, {
11453
- fields: "+shipping_address"
11454
- });
11384
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11385
+ id,
11386
+ {
11387
+ fields: "+sales_channel_id"
11388
+ },
11389
+ {
11390
+ enabled: !!id
11391
+ }
11392
+ );
11455
11393
  if (isError) {
11456
11394
  throw error;
11457
11395
  }
11458
- const isReady = !isPending && !!order;
11396
+ const ISrEADY = !!draft_order && !isPending;
11459
11397
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11460
11398
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11461
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11462
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11399
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11400
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11463
11401
  ] }),
11464
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11402
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11465
11403
  ] });
11466
11404
  };
11467
- const ShippingAddressForm = ({ order }) => {
11468
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11405
+ const SalesChannelForm = ({ order }) => {
11469
11406
  const form = useForm({
11470
11407
  defaultValues: {
11471
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11472
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11473
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11474
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11475
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11476
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11477
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11478
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11479
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11480
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11408
+ sales_channel_id: order.sales_channel_id || ""
11481
11409
  },
11482
- resolver: zodResolver(schema$2)
11410
+ resolver: zodResolver(schema$3)
11483
11411
  });
11484
11412
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
11413
  const { handleSuccess } = useRouteModal();
11486
11414
  const onSubmit = form.handleSubmit(async (data) => {
11487
11415
  await mutateAsync(
11488
11416
  {
11489
- shipping_address: {
11490
- first_name: data.first_name,
11491
- last_name: data.last_name,
11492
- company: data.company,
11493
- address_1: data.address_1,
11494
- address_2: data.address_2,
11495
- city: data.city,
11496
- province: data.province,
11497
- country_code: data.country_code,
11498
- postal_code: data.postal_code,
11499
- phone: data.phone
11500
- }
11417
+ sales_channel_id: data.sales_channel_id
11501
11418
  },
11502
11419
  {
11503
11420
  onSuccess: () => {
11421
+ toast.success("Sales channel updated");
11504
11422
  handleSuccess();
11505
11423
  },
11506
11424
  onError: (error) => {
@@ -11515,132 +11433,7 @@ const ShippingAddressForm = ({ order }) => {
11515
11433
  className: "flex flex-1 flex-col overflow-hidden",
11516
11434
  onSubmit,
11517
11435
  children: [
11518
- /* @__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: [
11519
- /* @__PURE__ */ jsx(
11520
- Form$2.Field,
11521
- {
11522
- control: form.control,
11523
- name: "country_code",
11524
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11525
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11526
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11527
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11528
- ] })
11529
- }
11530
- ),
11531
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11532
- /* @__PURE__ */ jsx(
11533
- Form$2.Field,
11534
- {
11535
- control: form.control,
11536
- name: "first_name",
11537
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11538
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11539
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11540
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11541
- ] })
11542
- }
11543
- ),
11544
- /* @__PURE__ */ jsx(
11545
- Form$2.Field,
11546
- {
11547
- control: form.control,
11548
- name: "last_name",
11549
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11550
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11551
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11552
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11553
- ] })
11554
- }
11555
- )
11556
- ] }),
11557
- /* @__PURE__ */ jsx(
11558
- Form$2.Field,
11559
- {
11560
- control: form.control,
11561
- name: "company",
11562
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11563
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11564
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11565
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11566
- ] })
11567
- }
11568
- ),
11569
- /* @__PURE__ */ jsx(
11570
- Form$2.Field,
11571
- {
11572
- control: form.control,
11573
- name: "address_1",
11574
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11575
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11576
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11577
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11578
- ] })
11579
- }
11580
- ),
11581
- /* @__PURE__ */ jsx(
11582
- Form$2.Field,
11583
- {
11584
- control: form.control,
11585
- name: "address_2",
11586
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11587
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11588
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11589
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11590
- ] })
11591
- }
11592
- ),
11593
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11594
- /* @__PURE__ */ jsx(
11595
- Form$2.Field,
11596
- {
11597
- control: form.control,
11598
- name: "postal_code",
11599
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11600
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11601
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11602
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11603
- ] })
11604
- }
11605
- ),
11606
- /* @__PURE__ */ jsx(
11607
- Form$2.Field,
11608
- {
11609
- control: form.control,
11610
- name: "city",
11611
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11612
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11613
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11614
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11615
- ] })
11616
- }
11617
- )
11618
- ] }),
11619
- /* @__PURE__ */ jsx(
11620
- Form$2.Field,
11621
- {
11622
- control: form.control,
11623
- name: "province",
11624
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11625
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11626
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11627
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11628
- ] })
11629
- }
11630
- ),
11631
- /* @__PURE__ */ jsx(
11632
- Form$2.Field,
11633
- {
11634
- control: form.control,
11635
- name: "phone",
11636
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11637
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11638
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11639
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11640
- ] })
11641
- }
11642
- )
11643
- ] }) }),
11436
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11644
11437
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11645
11438
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11646
11439
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -11649,15 +11442,57 @@ const ShippingAddressForm = ({ order }) => {
11649
11442
  }
11650
11443
  ) });
11651
11444
  };
11652
- const schema$2 = addressSchema;
11653
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11654
- const Shipping = () => {
11655
- var _a;
11656
- const { id } = useParams();
11657
- const { order, isPending, isError, error } = useOrder(id, {
11658
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11659
- });
11660
- const {
11445
+ const SalesChannelField = ({ control, order }) => {
11446
+ const salesChannels = useComboboxData({
11447
+ queryFn: async (params) => {
11448
+ return await sdk.admin.salesChannel.list(params);
11449
+ },
11450
+ queryKey: ["sales-channels"],
11451
+ getOptions: (data) => {
11452
+ return data.sales_channels.map((salesChannel) => ({
11453
+ label: salesChannel.name,
11454
+ value: salesChannel.id
11455
+ }));
11456
+ },
11457
+ defaultValue: order.sales_channel_id || void 0
11458
+ });
11459
+ return /* @__PURE__ */ jsx(
11460
+ Form$2.Field,
11461
+ {
11462
+ control,
11463
+ name: "sales_channel_id",
11464
+ render: ({ field }) => {
11465
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11466
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11467
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11468
+ Combobox,
11469
+ {
11470
+ options: salesChannels.options,
11471
+ fetchNextPage: salesChannels.fetchNextPage,
11472
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11473
+ searchValue: salesChannels.searchValue,
11474
+ onSearchValueChange: salesChannels.onSearchValueChange,
11475
+ placeholder: "Select sales channel",
11476
+ ...field
11477
+ }
11478
+ ) }),
11479
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11480
+ ] });
11481
+ }
11482
+ }
11483
+ );
11484
+ };
11485
+ const schema$3 = objectType({
11486
+ sales_channel_id: stringType().min(1)
11487
+ });
11488
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11489
+ const Shipping = () => {
11490
+ var _a;
11491
+ const { id } = useParams();
11492
+ const { order, isPending, isError, error } = useOrder(id, {
11493
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11494
+ });
11495
+ const {
11661
11496
  order: preview,
11662
11497
  isPending: isPreviewPending,
11663
11498
  isError: isPreviewError,
@@ -12457,6 +12292,209 @@ const CustomAmountField = ({
12457
12292
  }
12458
12293
  );
12459
12294
  };
12295
+ const ShippingAddress = () => {
12296
+ const { id } = useParams();
12297
+ const { order, isPending, isError, error } = useOrder(id, {
12298
+ fields: "+shipping_address"
12299
+ });
12300
+ if (isError) {
12301
+ throw error;
12302
+ }
12303
+ const isReady = !isPending && !!order;
12304
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12305
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12306
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12307
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12308
+ ] }),
12309
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12310
+ ] });
12311
+ };
12312
+ const ShippingAddressForm = ({ order }) => {
12313
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12314
+ const form = useForm({
12315
+ defaultValues: {
12316
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12317
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12318
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12319
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12320
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12321
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12322
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12323
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12324
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12325
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12326
+ },
12327
+ resolver: zodResolver(schema$2)
12328
+ });
12329
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12330
+ const { handleSuccess } = useRouteModal();
12331
+ const onSubmit = form.handleSubmit(async (data) => {
12332
+ await mutateAsync(
12333
+ {
12334
+ shipping_address: {
12335
+ first_name: data.first_name,
12336
+ last_name: data.last_name,
12337
+ company: data.company,
12338
+ address_1: data.address_1,
12339
+ address_2: data.address_2,
12340
+ city: data.city,
12341
+ province: data.province,
12342
+ country_code: data.country_code,
12343
+ postal_code: data.postal_code,
12344
+ phone: data.phone
12345
+ }
12346
+ },
12347
+ {
12348
+ onSuccess: () => {
12349
+ handleSuccess();
12350
+ },
12351
+ onError: (error) => {
12352
+ toast.error(error.message);
12353
+ }
12354
+ }
12355
+ );
12356
+ });
12357
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12358
+ KeyboundForm,
12359
+ {
12360
+ className: "flex flex-1 flex-col overflow-hidden",
12361
+ onSubmit,
12362
+ children: [
12363
+ /* @__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: [
12364
+ /* @__PURE__ */ jsx(
12365
+ Form$2.Field,
12366
+ {
12367
+ control: form.control,
12368
+ name: "country_code",
12369
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12370
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12371
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12372
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12373
+ ] })
12374
+ }
12375
+ ),
12376
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12377
+ /* @__PURE__ */ jsx(
12378
+ Form$2.Field,
12379
+ {
12380
+ control: form.control,
12381
+ name: "first_name",
12382
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12383
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12384
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12385
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12386
+ ] })
12387
+ }
12388
+ ),
12389
+ /* @__PURE__ */ jsx(
12390
+ Form$2.Field,
12391
+ {
12392
+ control: form.control,
12393
+ name: "last_name",
12394
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12395
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12396
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12397
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12398
+ ] })
12399
+ }
12400
+ )
12401
+ ] }),
12402
+ /* @__PURE__ */ jsx(
12403
+ Form$2.Field,
12404
+ {
12405
+ control: form.control,
12406
+ name: "company",
12407
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12408
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12409
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12410
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12411
+ ] })
12412
+ }
12413
+ ),
12414
+ /* @__PURE__ */ jsx(
12415
+ Form$2.Field,
12416
+ {
12417
+ control: form.control,
12418
+ name: "address_1",
12419
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12420
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12421
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12422
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12423
+ ] })
12424
+ }
12425
+ ),
12426
+ /* @__PURE__ */ jsx(
12427
+ Form$2.Field,
12428
+ {
12429
+ control: form.control,
12430
+ name: "address_2",
12431
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12432
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12433
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12434
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12435
+ ] })
12436
+ }
12437
+ ),
12438
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12439
+ /* @__PURE__ */ jsx(
12440
+ Form$2.Field,
12441
+ {
12442
+ control: form.control,
12443
+ name: "postal_code",
12444
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12445
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12446
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12447
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12448
+ ] })
12449
+ }
12450
+ ),
12451
+ /* @__PURE__ */ jsx(
12452
+ Form$2.Field,
12453
+ {
12454
+ control: form.control,
12455
+ name: "city",
12456
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12457
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12458
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12459
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12460
+ ] })
12461
+ }
12462
+ )
12463
+ ] }),
12464
+ /* @__PURE__ */ jsx(
12465
+ Form$2.Field,
12466
+ {
12467
+ control: form.control,
12468
+ name: "province",
12469
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12470
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12471
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12472
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12473
+ ] })
12474
+ }
12475
+ ),
12476
+ /* @__PURE__ */ jsx(
12477
+ Form$2.Field,
12478
+ {
12479
+ control: form.control,
12480
+ name: "phone",
12481
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12482
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12483
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12484
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12485
+ ] })
12486
+ }
12487
+ )
12488
+ ] }) }),
12489
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12490
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12491
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12492
+ ] }) })
12493
+ ]
12494
+ }
12495
+ ) });
12496
+ };
12497
+ const schema$2 = addressSchema;
12460
12498
  const TransferOwnership = () => {
12461
12499
  const { id } = useParams();
12462
12500
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12933,33 +12971,27 @@ const Illustration = () => {
12933
12971
  const schema$1 = objectType({
12934
12972
  customer_id: stringType().min(1)
12935
12973
  });
12936
- const SalesChannel = () => {
12974
+ const Email = () => {
12937
12975
  const { id } = useParams();
12938
- const { draft_order, isPending, isError, error } = useDraftOrder(
12939
- id,
12940
- {
12941
- fields: "+sales_channel_id"
12942
- },
12943
- {
12944
- enabled: !!id
12945
- }
12946
- );
12976
+ const { order, isPending, isError, error } = useOrder(id, {
12977
+ fields: "+email"
12978
+ });
12947
12979
  if (isError) {
12948
12980
  throw error;
12949
12981
  }
12950
- const ISrEADY = !!draft_order && !isPending;
12982
+ const isReady = !isPending && !!order;
12951
12983
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12952
12984
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12953
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12954
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
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" }) })
12955
12987
  ] }),
12956
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12988
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
12957
12989
  ] });
12958
12990
  };
12959
- const SalesChannelForm = ({ order }) => {
12991
+ const EmailForm = ({ order }) => {
12960
12992
  const form = useForm({
12961
12993
  defaultValues: {
12962
- sales_channel_id: order.sales_channel_id || ""
12994
+ email: order.email ?? ""
12963
12995
  },
12964
12996
  resolver: zodResolver(schema)
12965
12997
  });
@@ -12967,12 +12999,9 @@ const SalesChannelForm = ({ order }) => {
12967
12999
  const { handleSuccess } = useRouteModal();
12968
13000
  const onSubmit = form.handleSubmit(async (data) => {
12969
13001
  await mutateAsync(
12970
- {
12971
- sales_channel_id: data.sales_channel_id
12972
- },
13002
+ { email: data.email },
12973
13003
  {
12974
13004
  onSuccess: () => {
12975
- toast.success("Sales channel updated");
12976
13005
  handleSuccess();
12977
13006
  },
12978
13007
  onError: (error) => {
@@ -12987,7 +13016,18 @@ const SalesChannelForm = ({ order }) => {
12987
13016
  className: "flex flex-1 flex-col overflow-hidden",
12988
13017
  onSubmit,
12989
13018
  children: [
12990
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
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
+ ) }),
12991
13031
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12992
13032
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12993
13033
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -12996,48 +13036,8 @@ const SalesChannelForm = ({ order }) => {
12996
13036
  }
12997
13037
  ) });
12998
13038
  };
12999
- const SalesChannelField = ({ control, order }) => {
13000
- const salesChannels = useComboboxData({
13001
- queryFn: async (params) => {
13002
- return await sdk.admin.salesChannel.list(params);
13003
- },
13004
- queryKey: ["sales-channels"],
13005
- getOptions: (data) => {
13006
- return data.sales_channels.map((salesChannel) => ({
13007
- label: salesChannel.name,
13008
- value: salesChannel.id
13009
- }));
13010
- },
13011
- defaultValue: order.sales_channel_id || void 0
13012
- });
13013
- return /* @__PURE__ */ jsx(
13014
- Form$2.Field,
13015
- {
13016
- control,
13017
- name: "sales_channel_id",
13018
- render: ({ field }) => {
13019
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13020
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13021
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13022
- Combobox,
13023
- {
13024
- options: salesChannels.options,
13025
- fetchNextPage: salesChannels.fetchNextPage,
13026
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13027
- searchValue: salesChannels.searchValue,
13028
- onSearchValueChange: salesChannels.onSearchValueChange,
13029
- placeholder: "Select sales channel",
13030
- ...field
13031
- }
13032
- ) }),
13033
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13034
- ] });
13035
- }
13036
- }
13037
- );
13038
- };
13039
13039
  const schema = objectType({
13040
- sales_channel_id: stringType().min(1)
13040
+ email: stringType().email()
13041
13041
  });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
@@ -13067,10 +13067,6 @@ const routeModule = {
13067
13067
  Component: CustomItems,
13068
13068
  path: "/draft-orders/:id/custom-items"
13069
13069
  },
13070
- {
13071
- Component: Email,
13072
- path: "/draft-orders/:id/email"
13073
- },
13074
13070
  {
13075
13071
  Component: Items,
13076
13072
  path: "/draft-orders/:id/items"
@@ -13084,20 +13080,24 @@ const routeModule = {
13084
13080
  path: "/draft-orders/:id/promotions"
13085
13081
  },
13086
13082
  {
13087
- Component: ShippingAddress,
13088
- path: "/draft-orders/:id/shipping-address"
13083
+ Component: SalesChannel,
13084
+ path: "/draft-orders/:id/sales-channel"
13089
13085
  },
13090
13086
  {
13091
13087
  Component: Shipping,
13092
13088
  path: "/draft-orders/:id/shipping"
13093
13089
  },
13090
+ {
13091
+ Component: ShippingAddress,
13092
+ path: "/draft-orders/:id/shipping-address"
13093
+ },
13094
13094
  {
13095
13095
  Component: TransferOwnership,
13096
13096
  path: "/draft-orders/:id/transfer-ownership"
13097
13097
  },
13098
13098
  {
13099
- Component: SalesChannel,
13100
- path: "/draft-orders/:id/sales-channel"
13099
+ Component: Email,
13100
+ path: "/draft-orders/:id/email"
13101
13101
  }
13102
13102
  ]
13103
13103
  }