@medusajs/draft-order 2.11.3-preview-20251031210152 → 2.11.3-preview-20251101032014

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