@medusajs/draft-order 2.11.0-snapshot-20251017130454 → 2.11.0-snapshot-20251017164419

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.
@@ -9757,27 +9757,6 @@ const BillingAddressForm = ({ order }) => {
9757
9757
  ) });
9758
9758
  };
9759
9759
  const schema$5 = addressSchema;
9760
- const CustomItems = () => {
9761
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9762
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9763
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9764
- ] });
9765
- };
9766
- const CustomItemsForm = () => {
9767
- const form = useForm({
9768
- resolver: zodResolver(schema$4)
9769
- });
9770
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9772
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9773
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9774
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9775
- ] }) })
9776
- ] }) });
9777
- };
9778
- const schema$4 = objectType({
9779
- email: stringType().email()
9780
- });
9781
9760
  const Email = () => {
9782
9761
  const { id } = useParams();
9783
9762
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9800,7 +9779,7 @@ const EmailForm = ({ order }) => {
9800
9779
  defaultValues: {
9801
9780
  email: order.email ?? ""
9802
9781
  },
9803
- resolver: zodResolver(schema$3)
9782
+ resolver: zodResolver(schema$4)
9804
9783
  });
9805
9784
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
9785
  const { handleSuccess } = useRouteModal();
@@ -9843,7 +9822,7 @@ const EmailForm = ({ order }) => {
9843
9822
  }
9844
9823
  ) });
9845
9824
  };
9846
- const schema$3 = objectType({
9825
+ const schema$4 = objectType({
9847
9826
  email: stringType().email()
9848
9827
  });
9849
9828
  const NumberInput = forwardRef(
@@ -11447,112 +11426,6 @@ function getPromotionIds(items, shippingMethods) {
11447
11426
  }
11448
11427
  return Array.from(promotionIds);
11449
11428
  }
11450
- const SalesChannel = () => {
11451
- const { id } = useParams();
11452
- const { draft_order, isPending, isError, error } = useDraftOrder(
11453
- id,
11454
- {
11455
- fields: "+sales_channel_id"
11456
- },
11457
- {
11458
- enabled: !!id
11459
- }
11460
- );
11461
- if (isError) {
11462
- throw error;
11463
- }
11464
- const ISrEADY = !!draft_order && !isPending;
11465
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11466
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11467
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11468
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11469
- ] }),
11470
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11471
- ] });
11472
- };
11473
- const SalesChannelForm = ({ order }) => {
11474
- const form = useForm({
11475
- defaultValues: {
11476
- sales_channel_id: order.sales_channel_id || ""
11477
- },
11478
- resolver: zodResolver(schema$2)
11479
- });
11480
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11481
- const { handleSuccess } = useRouteModal();
11482
- const onSubmit = form.handleSubmit(async (data) => {
11483
- await mutateAsync(
11484
- {
11485
- sales_channel_id: data.sales_channel_id
11486
- },
11487
- {
11488
- onSuccess: () => {
11489
- toast.success("Sales channel updated");
11490
- handleSuccess();
11491
- },
11492
- onError: (error) => {
11493
- toast.error(error.message);
11494
- }
11495
- }
11496
- );
11497
- });
11498
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11499
- KeyboundForm,
11500
- {
11501
- className: "flex flex-1 flex-col overflow-hidden",
11502
- onSubmit,
11503
- children: [
11504
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11505
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11506
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11507
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11508
- ] }) })
11509
- ]
11510
- }
11511
- ) });
11512
- };
11513
- const SalesChannelField = ({ control, order }) => {
11514
- const salesChannels = useComboboxData({
11515
- queryFn: async (params) => {
11516
- return await sdk.admin.salesChannel.list(params);
11517
- },
11518
- queryKey: ["sales-channels"],
11519
- getOptions: (data) => {
11520
- return data.sales_channels.map((salesChannel) => ({
11521
- label: salesChannel.name,
11522
- value: salesChannel.id
11523
- }));
11524
- },
11525
- defaultValue: order.sales_channel_id || void 0
11526
- });
11527
- return /* @__PURE__ */ jsx(
11528
- Form$2.Field,
11529
- {
11530
- control,
11531
- name: "sales_channel_id",
11532
- render: ({ field }) => {
11533
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11534
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11535
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11536
- Combobox,
11537
- {
11538
- options: salesChannels.options,
11539
- fetchNextPage: salesChannels.fetchNextPage,
11540
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11541
- searchValue: salesChannels.searchValue,
11542
- onSearchValueChange: salesChannels.onSearchValueChange,
11543
- placeholder: "Select sales channel",
11544
- ...field
11545
- }
11546
- ) }),
11547
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11548
- ] });
11549
- }
11550
- }
11551
- );
11552
- };
11553
- const schema$2 = objectType({
11554
- sales_channel_id: stringType().min(1)
11555
- });
11556
11429
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11557
11430
  const Shipping = () => {
11558
11431
  var _a;
@@ -12360,60 +12233,46 @@ const CustomAmountField = ({
12360
12233
  }
12361
12234
  );
12362
12235
  };
12363
- const ShippingAddress = () => {
12236
+ const SalesChannel = () => {
12364
12237
  const { id } = useParams();
12365
- const { order, isPending, isError, error } = useOrder(id, {
12366
- fields: "+shipping_address"
12367
- });
12238
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12239
+ id,
12240
+ {
12241
+ fields: "+sales_channel_id"
12242
+ },
12243
+ {
12244
+ enabled: !!id
12245
+ }
12246
+ );
12368
12247
  if (isError) {
12369
12248
  throw error;
12370
12249
  }
12371
- const isReady = !isPending && !!order;
12250
+ const ISrEADY = !!draft_order && !isPending;
12372
12251
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12373
12252
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12374
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12375
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12253
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12254
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12376
12255
  ] }),
12377
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12256
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12378
12257
  ] });
12379
12258
  };
12380
- const ShippingAddressForm = ({ order }) => {
12381
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12259
+ const SalesChannelForm = ({ order }) => {
12382
12260
  const form = useForm({
12383
12261
  defaultValues: {
12384
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12385
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12386
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12387
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12388
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12389
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12390
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12391
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12392
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12393
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12262
+ sales_channel_id: order.sales_channel_id || ""
12394
12263
  },
12395
- resolver: zodResolver(schema$1)
12264
+ resolver: zodResolver(schema$3)
12396
12265
  });
12397
12266
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12398
12267
  const { handleSuccess } = useRouteModal();
12399
12268
  const onSubmit = form.handleSubmit(async (data) => {
12400
12269
  await mutateAsync(
12401
12270
  {
12402
- shipping_address: {
12403
- first_name: data.first_name,
12404
- last_name: data.last_name,
12405
- company: data.company,
12406
- address_1: data.address_1,
12407
- address_2: data.address_2,
12408
- city: data.city,
12409
- province: data.province,
12410
- country_code: data.country_code,
12411
- postal_code: data.postal_code,
12412
- phone: data.phone
12413
- }
12271
+ sales_channel_id: data.sales_channel_id
12414
12272
  },
12415
12273
  {
12416
12274
  onSuccess: () => {
12275
+ toast.success("Sales channel updated");
12417
12276
  handleSuccess();
12418
12277
  },
12419
12278
  onError: (error) => {
@@ -12428,141 +12287,58 @@ const ShippingAddressForm = ({ order }) => {
12428
12287
  className: "flex flex-1 flex-col overflow-hidden",
12429
12288
  onSubmit,
12430
12289
  children: [
12431
- /* @__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: [
12432
- /* @__PURE__ */ jsx(
12433
- Form$2.Field,
12290
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12291
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12292
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12293
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12294
+ ] }) })
12295
+ ]
12296
+ }
12297
+ ) });
12298
+ };
12299
+ const SalesChannelField = ({ control, order }) => {
12300
+ const salesChannels = useComboboxData({
12301
+ queryFn: async (params) => {
12302
+ return await sdk.admin.salesChannel.list(params);
12303
+ },
12304
+ queryKey: ["sales-channels"],
12305
+ getOptions: (data) => {
12306
+ return data.sales_channels.map((salesChannel) => ({
12307
+ label: salesChannel.name,
12308
+ value: salesChannel.id
12309
+ }));
12310
+ },
12311
+ defaultValue: order.sales_channel_id || void 0
12312
+ });
12313
+ return /* @__PURE__ */ jsx(
12314
+ Form$2.Field,
12315
+ {
12316
+ control,
12317
+ name: "sales_channel_id",
12318
+ render: ({ field }) => {
12319
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12320
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12321
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12322
+ Combobox,
12434
12323
  {
12435
- control: form.control,
12436
- name: "country_code",
12437
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12438
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12439
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12440
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12441
- ] })
12324
+ options: salesChannels.options,
12325
+ fetchNextPage: salesChannels.fetchNextPage,
12326
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12327
+ searchValue: salesChannels.searchValue,
12328
+ onSearchValueChange: salesChannels.onSearchValueChange,
12329
+ placeholder: "Select sales channel",
12330
+ ...field
12442
12331
  }
12443
- ),
12444
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12445
- /* @__PURE__ */ jsx(
12446
- Form$2.Field,
12447
- {
12448
- control: form.control,
12449
- name: "first_name",
12450
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12451
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12452
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12453
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12454
- ] })
12455
- }
12456
- ),
12457
- /* @__PURE__ */ jsx(
12458
- Form$2.Field,
12459
- {
12460
- control: form.control,
12461
- name: "last_name",
12462
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12463
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12464
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12465
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12466
- ] })
12467
- }
12468
- )
12469
- ] }),
12470
- /* @__PURE__ */ jsx(
12471
- Form$2.Field,
12472
- {
12473
- control: form.control,
12474
- name: "company",
12475
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12476
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12477
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12478
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12479
- ] })
12480
- }
12481
- ),
12482
- /* @__PURE__ */ jsx(
12483
- Form$2.Field,
12484
- {
12485
- control: form.control,
12486
- name: "address_1",
12487
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12488
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12489
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12490
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12491
- ] })
12492
- }
12493
- ),
12494
- /* @__PURE__ */ jsx(
12495
- Form$2.Field,
12496
- {
12497
- control: form.control,
12498
- name: "address_2",
12499
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12500
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12501
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12502
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12503
- ] })
12504
- }
12505
- ),
12506
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12507
- /* @__PURE__ */ jsx(
12508
- Form$2.Field,
12509
- {
12510
- control: form.control,
12511
- name: "postal_code",
12512
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12513
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12514
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12515
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12516
- ] })
12517
- }
12518
- ),
12519
- /* @__PURE__ */ jsx(
12520
- Form$2.Field,
12521
- {
12522
- control: form.control,
12523
- name: "city",
12524
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12525
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12526
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12527
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12528
- ] })
12529
- }
12530
- )
12531
- ] }),
12532
- /* @__PURE__ */ jsx(
12533
- Form$2.Field,
12534
- {
12535
- control: form.control,
12536
- name: "province",
12537
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12538
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12539
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12540
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12541
- ] })
12542
- }
12543
- ),
12544
- /* @__PURE__ */ jsx(
12545
- Form$2.Field,
12546
- {
12547
- control: form.control,
12548
- name: "phone",
12549
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12550
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12551
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12552
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12553
- ] })
12554
- }
12555
- )
12556
- ] }) }),
12557
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12558
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12559
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12560
- ] }) })
12561
- ]
12332
+ ) }),
12333
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12334
+ ] });
12335
+ }
12562
12336
  }
12563
- ) });
12337
+ );
12564
12338
  };
12565
- const schema$1 = addressSchema;
12339
+ const schema$3 = objectType({
12340
+ sales_channel_id: stringType().min(1)
12341
+ });
12566
12342
  const TransferOwnership = () => {
12567
12343
  const { id } = useParams();
12568
12344
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12586,7 +12362,7 @@ const TransferOwnershipForm = ({ order }) => {
12586
12362
  defaultValues: {
12587
12363
  customer_id: order.customer_id || ""
12588
12364
  },
12589
- resolver: zodResolver(schema)
12365
+ resolver: zodResolver(schema$2)
12590
12366
  });
12591
12367
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12592
12368
  const { handleSuccess } = useRouteModal();
@@ -13036,9 +12812,233 @@ const Illustration = () => {
13036
12812
  }
13037
12813
  );
13038
12814
  };
13039
- const schema = objectType({
12815
+ const schema$2 = objectType({
13040
12816
  customer_id: stringType().min(1)
13041
12817
  });
12818
+ const ShippingAddress = () => {
12819
+ const { id } = useParams();
12820
+ const { order, isPending, isError, error } = useOrder(id, {
12821
+ fields: "+shipping_address"
12822
+ });
12823
+ if (isError) {
12824
+ throw error;
12825
+ }
12826
+ const isReady = !isPending && !!order;
12827
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12828
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12829
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12830
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12831
+ ] }),
12832
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12833
+ ] });
12834
+ };
12835
+ const ShippingAddressForm = ({ order }) => {
12836
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12837
+ const form = useForm({
12838
+ defaultValues: {
12839
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12840
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12841
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12842
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12843
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12844
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12845
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12846
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12847
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12848
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12849
+ },
12850
+ resolver: zodResolver(schema$1)
12851
+ });
12852
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12853
+ const { handleSuccess } = useRouteModal();
12854
+ const onSubmit = form.handleSubmit(async (data) => {
12855
+ await mutateAsync(
12856
+ {
12857
+ shipping_address: {
12858
+ first_name: data.first_name,
12859
+ last_name: data.last_name,
12860
+ company: data.company,
12861
+ address_1: data.address_1,
12862
+ address_2: data.address_2,
12863
+ city: data.city,
12864
+ province: data.province,
12865
+ country_code: data.country_code,
12866
+ postal_code: data.postal_code,
12867
+ phone: data.phone
12868
+ }
12869
+ },
12870
+ {
12871
+ onSuccess: () => {
12872
+ handleSuccess();
12873
+ },
12874
+ onError: (error) => {
12875
+ toast.error(error.message);
12876
+ }
12877
+ }
12878
+ );
12879
+ });
12880
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12881
+ KeyboundForm,
12882
+ {
12883
+ className: "flex flex-1 flex-col overflow-hidden",
12884
+ onSubmit,
12885
+ children: [
12886
+ /* @__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: [
12887
+ /* @__PURE__ */ jsx(
12888
+ Form$2.Field,
12889
+ {
12890
+ control: form.control,
12891
+ name: "country_code",
12892
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12893
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12894
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12895
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12896
+ ] })
12897
+ }
12898
+ ),
12899
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12900
+ /* @__PURE__ */ jsx(
12901
+ Form$2.Field,
12902
+ {
12903
+ control: form.control,
12904
+ name: "first_name",
12905
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12906
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12907
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12908
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12909
+ ] })
12910
+ }
12911
+ ),
12912
+ /* @__PURE__ */ jsx(
12913
+ Form$2.Field,
12914
+ {
12915
+ control: form.control,
12916
+ name: "last_name",
12917
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12918
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12919
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12920
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12921
+ ] })
12922
+ }
12923
+ )
12924
+ ] }),
12925
+ /* @__PURE__ */ jsx(
12926
+ Form$2.Field,
12927
+ {
12928
+ control: form.control,
12929
+ name: "company",
12930
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12931
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12932
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12933
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12934
+ ] })
12935
+ }
12936
+ ),
12937
+ /* @__PURE__ */ jsx(
12938
+ Form$2.Field,
12939
+ {
12940
+ control: form.control,
12941
+ name: "address_1",
12942
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12943
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12944
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12945
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12946
+ ] })
12947
+ }
12948
+ ),
12949
+ /* @__PURE__ */ jsx(
12950
+ Form$2.Field,
12951
+ {
12952
+ control: form.control,
12953
+ name: "address_2",
12954
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12955
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12956
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12957
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12958
+ ] })
12959
+ }
12960
+ ),
12961
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12962
+ /* @__PURE__ */ jsx(
12963
+ Form$2.Field,
12964
+ {
12965
+ control: form.control,
12966
+ name: "postal_code",
12967
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12968
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12969
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12970
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12971
+ ] })
12972
+ }
12973
+ ),
12974
+ /* @__PURE__ */ jsx(
12975
+ Form$2.Field,
12976
+ {
12977
+ control: form.control,
12978
+ name: "city",
12979
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12980
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12981
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12982
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12983
+ ] })
12984
+ }
12985
+ )
12986
+ ] }),
12987
+ /* @__PURE__ */ jsx(
12988
+ Form$2.Field,
12989
+ {
12990
+ control: form.control,
12991
+ name: "province",
12992
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12993
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12994
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12995
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12996
+ ] })
12997
+ }
12998
+ ),
12999
+ /* @__PURE__ */ jsx(
13000
+ Form$2.Field,
13001
+ {
13002
+ control: form.control,
13003
+ name: "phone",
13004
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13005
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13006
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13007
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13008
+ ] })
13009
+ }
13010
+ )
13011
+ ] }) }),
13012
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13013
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13014
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13015
+ ] }) })
13016
+ ]
13017
+ }
13018
+ ) });
13019
+ };
13020
+ const schema$1 = addressSchema;
13021
+ const CustomItems = () => {
13022
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13023
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13024
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
13025
+ ] });
13026
+ };
13027
+ const CustomItemsForm = () => {
13028
+ const form = useForm({
13029
+ resolver: zodResolver(schema)
13030
+ });
13031
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13033
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13036
+ ] }) })
13037
+ ] }) });
13038
+ };
13039
+ const schema = objectType({
13040
+ email: stringType().email()
13041
+ });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13063,10 +13063,6 @@ const routeModule = {
13063
13063
  Component: BillingAddress,
13064
13064
  path: "/draft-orders/:id/billing-address"
13065
13065
  },
13066
- {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13069
- },
13070
13066
  {
13071
13067
  Component: Email,
13072
13068
  path: "/draft-orders/:id/email"
@@ -13083,21 +13079,25 @@ const routeModule = {
13083
13079
  Component: Promotions,
13084
13080
  path: "/draft-orders/:id/promotions"
13085
13081
  },
13082
+ {
13083
+ Component: Shipping,
13084
+ path: "/draft-orders/:id/shipping"
13085
+ },
13086
13086
  {
13087
13087
  Component: SalesChannel,
13088
13088
  path: "/draft-orders/:id/sales-channel"
13089
13089
  },
13090
13090
  {
13091
- Component: Shipping,
13092
- path: "/draft-orders/:id/shipping"
13091
+ Component: TransferOwnership,
13092
+ path: "/draft-orders/:id/transfer-ownership"
13093
13093
  },
13094
13094
  {
13095
13095
  Component: ShippingAddress,
13096
13096
  path: "/draft-orders/:id/shipping-address"
13097
13097
  },
13098
13098
  {
13099
- Component: TransferOwnership,
13100
- path: "/draft-orders/:id/transfer-ownership"
13099
+ Component: CustomItems,
13100
+ path: "/draft-orders/:id/custom-items"
13101
13101
  }
13102
13102
  ]
13103
13103
  }