@medusajs/draft-order 2.11.3-preview-20251102000316 → 2.11.3-preview-20251102032220

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.
@@ -9776,74 +9776,6 @@ const CustomItemsForm = () => {
9776
9776
  const schema$4 = objectType({
9777
9777
  email: stringType().email()
9778
9778
  });
9779
- const Email = () => {
9780
- const { id } = useParams();
9781
- const { order, isPending, isError, error } = useOrder(id, {
9782
- fields: "+email"
9783
- });
9784
- if (isError) {
9785
- throw error;
9786
- }
9787
- const isReady = !isPending && !!order;
9788
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9789
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9790
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9791
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9792
- ] }),
9793
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9794
- ] });
9795
- };
9796
- const EmailForm = ({ order }) => {
9797
- const form = useForm({
9798
- defaultValues: {
9799
- email: order.email ?? ""
9800
- },
9801
- resolver: zodResolver(schema$3)
9802
- });
9803
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
- const { handleSuccess } = useRouteModal();
9805
- const onSubmit = form.handleSubmit(async (data) => {
9806
- await mutateAsync(
9807
- { email: data.email },
9808
- {
9809
- onSuccess: () => {
9810
- handleSuccess();
9811
- },
9812
- onError: (error) => {
9813
- toast.error(error.message);
9814
- }
9815
- }
9816
- );
9817
- });
9818
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9819
- KeyboundForm,
9820
- {
9821
- className: "flex flex-1 flex-col overflow-hidden",
9822
- onSubmit,
9823
- children: [
9824
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9825
- Form$2.Field,
9826
- {
9827
- control: form.control,
9828
- name: "email",
9829
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9830
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9831
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9832
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9833
- ] })
9834
- }
9835
- ) }),
9836
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9837
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9838
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9839
- ] }) })
9840
- ]
9841
- }
9842
- ) });
9843
- };
9844
- const schema$3 = objectType({
9845
- email: stringType().email()
9846
- });
9847
9779
  const NumberInput = forwardRef(
9848
9780
  ({
9849
9781
  value,
@@ -10818,6 +10750,74 @@ const customItemSchema = objectType({
10818
10750
  quantity: numberType(),
10819
10751
  unit_price: unionType([numberType(), stringType()])
10820
10752
  });
10753
+ const Email = () => {
10754
+ const { id } = useParams();
10755
+ const { order, isPending, isError, error } = useOrder(id, {
10756
+ fields: "+email"
10757
+ });
10758
+ if (isError) {
10759
+ throw error;
10760
+ }
10761
+ const isReady = !isPending && !!order;
10762
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10763
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10764
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
10765
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10766
+ ] }),
10767
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
10768
+ ] });
10769
+ };
10770
+ const EmailForm = ({ order }) => {
10771
+ const form = useForm({
10772
+ defaultValues: {
10773
+ email: order.email ?? ""
10774
+ },
10775
+ resolver: zodResolver(schema$3)
10776
+ });
10777
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10778
+ const { handleSuccess } = useRouteModal();
10779
+ const onSubmit = form.handleSubmit(async (data) => {
10780
+ await mutateAsync(
10781
+ { email: data.email },
10782
+ {
10783
+ onSuccess: () => {
10784
+ handleSuccess();
10785
+ },
10786
+ onError: (error) => {
10787
+ toast.error(error.message);
10788
+ }
10789
+ }
10790
+ );
10791
+ });
10792
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10793
+ KeyboundForm,
10794
+ {
10795
+ className: "flex flex-1 flex-col overflow-hidden",
10796
+ onSubmit,
10797
+ children: [
10798
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
10799
+ Form$2.Field,
10800
+ {
10801
+ control: form.control,
10802
+ name: "email",
10803
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10804
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
10805
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10806
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10807
+ ] })
10808
+ }
10809
+ ) }),
10810
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10811
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10812
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10813
+ ] }) })
10814
+ ]
10815
+ }
10816
+ ) });
10817
+ };
10818
+ const schema$3 = objectType({
10819
+ email: stringType().email()
10820
+ });
10821
10821
  const InlineTip = forwardRef(
10822
10822
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10823
10823
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11445,112 +11445,6 @@ 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
- });
11554
11448
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11555
11449
  const Shipping = () => {
11556
11450
  var _a;
@@ -12358,11 +12252,320 @@ const CustomAmountField = ({
12358
12252
  }
12359
12253
  );
12360
12254
  };
12361
- const TransferOwnership = () => {
12255
+ const SalesChannel = () => {
12362
12256
  const { id } = useParams();
12363
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12364
- fields: "id,customer_id,customer.*"
12365
- });
12257
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12258
+ id,
12259
+ {
12260
+ fields: "+sales_channel_id"
12261
+ },
12262
+ {
12263
+ enabled: !!id
12264
+ }
12265
+ );
12266
+ if (isError) {
12267
+ throw error;
12268
+ }
12269
+ const ISrEADY = !!draft_order && !isPending;
12270
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12271
+ /* @__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" }) })
12274
+ ] }),
12275
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12276
+ ] });
12277
+ };
12278
+ const SalesChannelForm = ({ order }) => {
12279
+ const form = useForm({
12280
+ defaultValues: {
12281
+ sales_channel_id: order.sales_channel_id || ""
12282
+ },
12283
+ resolver: zodResolver(schema$2)
12284
+ });
12285
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12286
+ const { handleSuccess } = useRouteModal();
12287
+ const onSubmit = form.handleSubmit(async (data) => {
12288
+ await mutateAsync(
12289
+ {
12290
+ sales_channel_id: data.sales_channel_id
12291
+ },
12292
+ {
12293
+ onSuccess: () => {
12294
+ toast.success("Sales channel updated");
12295
+ handleSuccess();
12296
+ },
12297
+ onError: (error) => {
12298
+ toast.error(error.message);
12299
+ }
12300
+ }
12301
+ );
12302
+ });
12303
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12304
+ KeyboundForm,
12305
+ {
12306
+ className: "flex flex-1 flex-col overflow-hidden",
12307
+ onSubmit,
12308
+ 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,
12342
+ {
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
12350
+ }
12351
+ ) }),
12352
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12353
+ ] });
12354
+ }
12355
+ }
12356
+ );
12357
+ };
12358
+ const schema$2 = objectType({
12359
+ sales_channel_id: stringType().min(1)
12360
+ });
12361
+ const ShippingAddress = () => {
12362
+ const { id } = useParams();
12363
+ const { order, isPending, isError, error } = useOrder(id, {
12364
+ fields: "+shipping_address"
12365
+ });
12366
+ if (isError) {
12367
+ throw error;
12368
+ }
12369
+ const isReady = !isPending && !!order;
12370
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12371
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
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" }) })
12374
+ ] }),
12375
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12376
+ ] });
12377
+ };
12378
+ const ShippingAddressForm = ({ order }) => {
12379
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12380
+ const form = useForm({
12381
+ defaultValues: {
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) ?? ""
12392
+ },
12393
+ resolver: zodResolver(schema$1)
12394
+ });
12395
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
+ const { handleSuccess } = useRouteModal();
12397
+ const onSubmit = form.handleSubmit(async (data) => {
12398
+ await mutateAsync(
12399
+ {
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
+ }
12412
+ },
12413
+ {
12414
+ onSuccess: () => {
12415
+ handleSuccess();
12416
+ },
12417
+ onError: (error) => {
12418
+ toast.error(error.message);
12419
+ }
12420
+ }
12421
+ );
12422
+ });
12423
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12424
+ KeyboundForm,
12425
+ {
12426
+ className: "flex flex-1 flex-col overflow-hidden",
12427
+ onSubmit,
12428
+ children: [
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,
12432
+ {
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
+ ] })
12440
+ }
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
+ ) });
12562
+ };
12563
+ const schema$1 = addressSchema;
12564
+ const TransferOwnership = () => {
12565
+ const { id } = useParams();
12566
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12567
+ fields: "id,customer_id,customer.*"
12568
+ });
12366
12569
  if (isError) {
12367
12570
  throw error;
12368
12571
  }
@@ -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: [
@@ -13065,14 +13065,14 @@ const routeModule = {
13065
13065
  Component: CustomItems,
13066
13066
  path: "/draft-orders/:id/custom-items"
13067
13067
  },
13068
- {
13069
- Component: Email,
13070
- path: "/draft-orders/:id/email"
13071
- },
13072
13068
  {
13073
13069
  Component: Items,
13074
13070
  path: "/draft-orders/:id/items"
13075
13071
  },
13072
+ {
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13075
+ },
13076
13076
  {
13077
13077
  Component: Metadata,
13078
13078
  path: "/draft-orders/:id/metadata"
@@ -13081,21 +13081,21 @@ const routeModule = {
13081
13081
  Component: Promotions,
13082
13082
  path: "/draft-orders/:id/promotions"
13083
13083
  },
13084
- {
13085
- Component: SalesChannel,
13086
- path: "/draft-orders/:id/sales-channel"
13087
- },
13088
13084
  {
13089
13085
  Component: Shipping,
13090
13086
  path: "/draft-orders/:id/shipping"
13091
13087
  },
13092
13088
  {
13093
- Component: TransferOwnership,
13094
- path: "/draft-orders/:id/transfer-ownership"
13089
+ Component: SalesChannel,
13090
+ path: "/draft-orders/:id/sales-channel"
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
  }