@medusajs/draft-order 2.10.4-preview-20250930150158 → 2.10.4-preview-20250930210154

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.
@@ -9573,6 +9573,27 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
+ const CustomItems = () => {
9577
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9579
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9580
+ ] });
9581
+ };
9582
+ const CustomItemsForm = () => {
9583
+ const form = reactHookForm.useForm({
9584
+ resolver: zod.zodResolver(schema$5)
9585
+ });
9586
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9589
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9590
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9591
+ ] }) })
9592
+ ] }) });
9593
+ };
9594
+ const schema$5 = objectType({
9595
+ email: stringType().email()
9596
+ });
9576
9597
  const Email = () => {
9577
9598
  const { id } = reactRouterDom.useParams();
9578
9599
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9595,7 +9616,7 @@ const EmailForm = ({ order }) => {
9595
9616
  defaultValues: {
9596
9617
  email: order.email ?? ""
9597
9618
  },
9598
- resolver: zod.zodResolver(schema$5)
9619
+ resolver: zod.zodResolver(schema$4)
9599
9620
  });
9600
9621
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9601
9622
  const { handleSuccess } = useRouteModal();
@@ -9638,7 +9659,7 @@ const EmailForm = ({ order }) => {
9638
9659
  }
9639
9660
  ) });
9640
9661
  };
9641
- const schema$5 = objectType({
9662
+ const schema$4 = objectType({
9642
9663
  email: stringType().email()
9643
9664
  });
9644
9665
  const NumberInput = React.forwardRef(
@@ -11270,7 +11291,7 @@ const SalesChannelForm = ({ order }) => {
11270
11291
  defaultValues: {
11271
11292
  sales_channel_id: order.sales_channel_id || ""
11272
11293
  },
11273
- resolver: zod.zodResolver(schema$4)
11294
+ resolver: zod.zodResolver(schema$3)
11274
11295
  });
11275
11296
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11276
11297
  const { handleSuccess } = useRouteModal();
@@ -11345,9 +11366,212 @@ const SalesChannelField = ({ control, order }) => {
11345
11366
  }
11346
11367
  );
11347
11368
  };
11348
- const schema$4 = objectType({
11369
+ const schema$3 = objectType({
11349
11370
  sales_channel_id: stringType().min(1)
11350
11371
  });
11372
+ const ShippingAddress = () => {
11373
+ const { id } = reactRouterDom.useParams();
11374
+ const { order, isPending, isError, error } = useOrder(id, {
11375
+ fields: "+shipping_address"
11376
+ });
11377
+ if (isError) {
11378
+ throw error;
11379
+ }
11380
+ const isReady = !isPending && !!order;
11381
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11382
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11383
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11384
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11385
+ ] }),
11386
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11387
+ ] });
11388
+ };
11389
+ const ShippingAddressForm = ({ order }) => {
11390
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11391
+ const form = reactHookForm.useForm({
11392
+ defaultValues: {
11393
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11394
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11395
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11396
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11397
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11398
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11399
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11400
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11401
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11402
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11403
+ },
11404
+ resolver: zod.zodResolver(schema$2)
11405
+ });
11406
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11407
+ const { handleSuccess } = useRouteModal();
11408
+ const onSubmit = form.handleSubmit(async (data) => {
11409
+ await mutateAsync(
11410
+ {
11411
+ shipping_address: {
11412
+ first_name: data.first_name,
11413
+ last_name: data.last_name,
11414
+ company: data.company,
11415
+ address_1: data.address_1,
11416
+ address_2: data.address_2,
11417
+ city: data.city,
11418
+ province: data.province,
11419
+ country_code: data.country_code,
11420
+ postal_code: data.postal_code,
11421
+ phone: data.phone
11422
+ }
11423
+ },
11424
+ {
11425
+ onSuccess: () => {
11426
+ handleSuccess();
11427
+ },
11428
+ onError: (error) => {
11429
+ ui.toast.error(error.message);
11430
+ }
11431
+ }
11432
+ );
11433
+ });
11434
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11435
+ KeyboundForm,
11436
+ {
11437
+ className: "flex flex-1 flex-col overflow-hidden",
11438
+ onSubmit,
11439
+ children: [
11440
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
11441
+ /* @__PURE__ */ jsxRuntime.jsx(
11442
+ Form$2.Field,
11443
+ {
11444
+ control: form.control,
11445
+ name: "country_code",
11446
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11447
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11448
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11449
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11450
+ ] })
11451
+ }
11452
+ ),
11453
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11454
+ /* @__PURE__ */ jsxRuntime.jsx(
11455
+ Form$2.Field,
11456
+ {
11457
+ control: form.control,
11458
+ name: "first_name",
11459
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11460
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11461
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11462
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11463
+ ] })
11464
+ }
11465
+ ),
11466
+ /* @__PURE__ */ jsxRuntime.jsx(
11467
+ Form$2.Field,
11468
+ {
11469
+ control: form.control,
11470
+ name: "last_name",
11471
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11472
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11473
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11474
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11475
+ ] })
11476
+ }
11477
+ )
11478
+ ] }),
11479
+ /* @__PURE__ */ jsxRuntime.jsx(
11480
+ Form$2.Field,
11481
+ {
11482
+ control: form.control,
11483
+ name: "company",
11484
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11485
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11486
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11487
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11488
+ ] })
11489
+ }
11490
+ ),
11491
+ /* @__PURE__ */ jsxRuntime.jsx(
11492
+ Form$2.Field,
11493
+ {
11494
+ control: form.control,
11495
+ name: "address_1",
11496
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11497
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11498
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11499
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11500
+ ] })
11501
+ }
11502
+ ),
11503
+ /* @__PURE__ */ jsxRuntime.jsx(
11504
+ Form$2.Field,
11505
+ {
11506
+ control: form.control,
11507
+ name: "address_2",
11508
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11509
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11510
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11511
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11512
+ ] })
11513
+ }
11514
+ ),
11515
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11516
+ /* @__PURE__ */ jsxRuntime.jsx(
11517
+ Form$2.Field,
11518
+ {
11519
+ control: form.control,
11520
+ name: "postal_code",
11521
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11522
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11523
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11524
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11525
+ ] })
11526
+ }
11527
+ ),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Form$2.Field,
11530
+ {
11531
+ control: form.control,
11532
+ name: "city",
11533
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11534
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11535
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11536
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11537
+ ] })
11538
+ }
11539
+ )
11540
+ ] }),
11541
+ /* @__PURE__ */ jsxRuntime.jsx(
11542
+ Form$2.Field,
11543
+ {
11544
+ control: form.control,
11545
+ name: "province",
11546
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11547
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11548
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11549
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11550
+ ] })
11551
+ }
11552
+ ),
11553
+ /* @__PURE__ */ jsxRuntime.jsx(
11554
+ Form$2.Field,
11555
+ {
11556
+ control: form.control,
11557
+ name: "phone",
11558
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11559
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11560
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11561
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11562
+ ] })
11563
+ }
11564
+ )
11565
+ ] }) }),
11566
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11567
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11568
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11569
+ ] }) })
11570
+ ]
11571
+ }
11572
+ ) });
11573
+ };
11574
+ const schema$2 = addressSchema;
11351
11575
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11352
11576
  const Shipping = () => {
11353
11577
  var _a;
@@ -12155,209 +12379,6 @@ const CustomAmountField = ({
12155
12379
  }
12156
12380
  );
12157
12381
  };
12158
- const ShippingAddress = () => {
12159
- const { id } = reactRouterDom.useParams();
12160
- const { order, isPending, isError, error } = useOrder(id, {
12161
- fields: "+shipping_address"
12162
- });
12163
- if (isError) {
12164
- throw error;
12165
- }
12166
- const isReady = !isPending && !!order;
12167
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12168
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12169
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12170
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12171
- ] }),
12172
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12173
- ] });
12174
- };
12175
- const ShippingAddressForm = ({ order }) => {
12176
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12177
- const form = reactHookForm.useForm({
12178
- defaultValues: {
12179
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12180
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12181
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12182
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12183
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12184
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12185
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12186
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12187
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12188
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12189
- },
12190
- resolver: zod.zodResolver(schema$3)
12191
- });
12192
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12193
- const { handleSuccess } = useRouteModal();
12194
- const onSubmit = form.handleSubmit(async (data) => {
12195
- await mutateAsync(
12196
- {
12197
- shipping_address: {
12198
- first_name: data.first_name,
12199
- last_name: data.last_name,
12200
- company: data.company,
12201
- address_1: data.address_1,
12202
- address_2: data.address_2,
12203
- city: data.city,
12204
- province: data.province,
12205
- country_code: data.country_code,
12206
- postal_code: data.postal_code,
12207
- phone: data.phone
12208
- }
12209
- },
12210
- {
12211
- onSuccess: () => {
12212
- handleSuccess();
12213
- },
12214
- onError: (error) => {
12215
- ui.toast.error(error.message);
12216
- }
12217
- }
12218
- );
12219
- });
12220
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12221
- KeyboundForm,
12222
- {
12223
- className: "flex flex-1 flex-col overflow-hidden",
12224
- onSubmit,
12225
- children: [
12226
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12227
- /* @__PURE__ */ jsxRuntime.jsx(
12228
- Form$2.Field,
12229
- {
12230
- control: form.control,
12231
- name: "country_code",
12232
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12233
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12234
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12235
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12236
- ] })
12237
- }
12238
- ),
12239
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12240
- /* @__PURE__ */ jsxRuntime.jsx(
12241
- Form$2.Field,
12242
- {
12243
- control: form.control,
12244
- name: "first_name",
12245
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12246
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12247
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12248
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12249
- ] })
12250
- }
12251
- ),
12252
- /* @__PURE__ */ jsxRuntime.jsx(
12253
- Form$2.Field,
12254
- {
12255
- control: form.control,
12256
- name: "last_name",
12257
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12258
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12259
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12260
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12261
- ] })
12262
- }
12263
- )
12264
- ] }),
12265
- /* @__PURE__ */ jsxRuntime.jsx(
12266
- Form$2.Field,
12267
- {
12268
- control: form.control,
12269
- name: "company",
12270
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12271
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12272
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12273
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12274
- ] })
12275
- }
12276
- ),
12277
- /* @__PURE__ */ jsxRuntime.jsx(
12278
- Form$2.Field,
12279
- {
12280
- control: form.control,
12281
- name: "address_1",
12282
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12283
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12284
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12285
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12286
- ] })
12287
- }
12288
- ),
12289
- /* @__PURE__ */ jsxRuntime.jsx(
12290
- Form$2.Field,
12291
- {
12292
- control: form.control,
12293
- name: "address_2",
12294
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12295
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12296
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12297
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12298
- ] })
12299
- }
12300
- ),
12301
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12302
- /* @__PURE__ */ jsxRuntime.jsx(
12303
- Form$2.Field,
12304
- {
12305
- control: form.control,
12306
- name: "postal_code",
12307
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12308
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12309
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12310
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12311
- ] })
12312
- }
12313
- ),
12314
- /* @__PURE__ */ jsxRuntime.jsx(
12315
- Form$2.Field,
12316
- {
12317
- control: form.control,
12318
- name: "city",
12319
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12320
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12321
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12322
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12323
- ] })
12324
- }
12325
- )
12326
- ] }),
12327
- /* @__PURE__ */ jsxRuntime.jsx(
12328
- Form$2.Field,
12329
- {
12330
- control: form.control,
12331
- name: "province",
12332
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12333
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12334
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12335
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12336
- ] })
12337
- }
12338
- ),
12339
- /* @__PURE__ */ jsxRuntime.jsx(
12340
- Form$2.Field,
12341
- {
12342
- control: form.control,
12343
- name: "phone",
12344
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12345
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12346
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12347
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12348
- ] })
12349
- }
12350
- )
12351
- ] }) }),
12352
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12353
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12354
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12355
- ] }) })
12356
- ]
12357
- }
12358
- ) });
12359
- };
12360
- const schema$3 = addressSchema;
12361
12382
  const TransferOwnership = () => {
12362
12383
  const { id } = reactRouterDom.useParams();
12363
12384
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12381,7 +12402,7 @@ const TransferOwnershipForm = ({ order }) => {
12381
12402
  defaultValues: {
12382
12403
  customer_id: order.customer_id || ""
12383
12404
  },
12384
- resolver: zod.zodResolver(schema$2)
12405
+ resolver: zod.zodResolver(schema$1)
12385
12406
  });
12386
12407
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12387
12408
  const { handleSuccess } = useRouteModal();
@@ -12831,29 +12852,8 @@ const Illustration = () => {
12831
12852
  }
12832
12853
  );
12833
12854
  };
12834
- const schema$2 = objectType({
12835
- customer_id: stringType().min(1)
12836
- });
12837
- const CustomItems = () => {
12838
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12839
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
12840
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12841
- ] });
12842
- };
12843
- const CustomItemsForm = () => {
12844
- const form = reactHookForm.useForm({
12845
- resolver: zod.zodResolver(schema$1)
12846
- });
12847
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12848
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
12849
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12850
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12851
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
12852
- ] }) })
12853
- ] }) });
12854
- };
12855
12855
  const schema$1 = objectType({
12856
- email: stringType().email()
12856
+ customer_id: stringType().min(1)
12857
12857
  });
12858
12858
  const BillingAddress = () => {
12859
12859
  const { id } = reactRouterDom.useParams();
@@ -13065,6 +13065,10 @@ const routeModule = {
13065
13065
  handle,
13066
13066
  loader,
13067
13067
  children: [
13068
+ {
13069
+ Component: CustomItems,
13070
+ path: "/draft-orders/:id/custom-items"
13071
+ },
13068
13072
  {
13069
13073
  Component: Email,
13070
13074
  path: "/draft-orders/:id/email"
@@ -13085,21 +13089,17 @@ const routeModule = {
13085
13089
  Component: SalesChannel,
13086
13090
  path: "/draft-orders/:id/sales-channel"
13087
13091
  },
13088
- {
13089
- Component: Shipping,
13090
- path: "/draft-orders/:id/shipping"
13091
- },
13092
13092
  {
13093
13093
  Component: ShippingAddress,
13094
13094
  path: "/draft-orders/:id/shipping-address"
13095
13095
  },
13096
13096
  {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13097
+ Component: Shipping,
13098
+ path: "/draft-orders/:id/shipping"
13099
13099
  },
13100
13100
  {
13101
- Component: CustomItems,
13102
- path: "/draft-orders/:id/custom-items"
13101
+ Component: TransferOwnership,
13102
+ path: "/draft-orders/:id/transfer-ownership"
13103
13103
  },
13104
13104
  {
13105
13105
  Component: BillingAddress,
@@ -9567,6 +9567,27 @@ const ID = () => {
9567
9567
  /* @__PURE__ */ jsx(Outlet, {})
9568
9568
  ] });
9569
9569
  };
9570
+ const CustomItems = () => {
9571
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9572
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9573
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9574
+ ] });
9575
+ };
9576
+ const CustomItemsForm = () => {
9577
+ const form = useForm({
9578
+ resolver: zodResolver(schema$5)
9579
+ });
9580
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9581
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9582
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9583
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9584
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9585
+ ] }) })
9586
+ ] }) });
9587
+ };
9588
+ const schema$5 = objectType({
9589
+ email: stringType().email()
9590
+ });
9570
9591
  const Email = () => {
9571
9592
  const { id } = useParams();
9572
9593
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9589,7 +9610,7 @@ const EmailForm = ({ order }) => {
9589
9610
  defaultValues: {
9590
9611
  email: order.email ?? ""
9591
9612
  },
9592
- resolver: zodResolver(schema$5)
9613
+ resolver: zodResolver(schema$4)
9593
9614
  });
9594
9615
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9595
9616
  const { handleSuccess } = useRouteModal();
@@ -9632,7 +9653,7 @@ const EmailForm = ({ order }) => {
9632
9653
  }
9633
9654
  ) });
9634
9655
  };
9635
- const schema$5 = objectType({
9656
+ const schema$4 = objectType({
9636
9657
  email: stringType().email()
9637
9658
  });
9638
9659
  const NumberInput = forwardRef(
@@ -11264,7 +11285,7 @@ const SalesChannelForm = ({ order }) => {
11264
11285
  defaultValues: {
11265
11286
  sales_channel_id: order.sales_channel_id || ""
11266
11287
  },
11267
- resolver: zodResolver(schema$4)
11288
+ resolver: zodResolver(schema$3)
11268
11289
  });
11269
11290
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11270
11291
  const { handleSuccess } = useRouteModal();
@@ -11339,9 +11360,212 @@ const SalesChannelField = ({ control, order }) => {
11339
11360
  }
11340
11361
  );
11341
11362
  };
11342
- const schema$4 = objectType({
11363
+ const schema$3 = objectType({
11343
11364
  sales_channel_id: stringType().min(1)
11344
11365
  });
11366
+ const ShippingAddress = () => {
11367
+ const { id } = useParams();
11368
+ const { order, isPending, isError, error } = useOrder(id, {
11369
+ fields: "+shipping_address"
11370
+ });
11371
+ if (isError) {
11372
+ throw error;
11373
+ }
11374
+ const isReady = !isPending && !!order;
11375
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11376
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11377
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11378
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11379
+ ] }),
11380
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11381
+ ] });
11382
+ };
11383
+ const ShippingAddressForm = ({ order }) => {
11384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11385
+ const form = useForm({
11386
+ defaultValues: {
11387
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11388
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11389
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11390
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11391
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11392
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11393
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11394
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11395
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11396
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11397
+ },
11398
+ resolver: zodResolver(schema$2)
11399
+ });
11400
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11401
+ const { handleSuccess } = useRouteModal();
11402
+ const onSubmit = form.handleSubmit(async (data) => {
11403
+ await mutateAsync(
11404
+ {
11405
+ shipping_address: {
11406
+ first_name: data.first_name,
11407
+ last_name: data.last_name,
11408
+ company: data.company,
11409
+ address_1: data.address_1,
11410
+ address_2: data.address_2,
11411
+ city: data.city,
11412
+ province: data.province,
11413
+ country_code: data.country_code,
11414
+ postal_code: data.postal_code,
11415
+ phone: data.phone
11416
+ }
11417
+ },
11418
+ {
11419
+ onSuccess: () => {
11420
+ handleSuccess();
11421
+ },
11422
+ onError: (error) => {
11423
+ toast.error(error.message);
11424
+ }
11425
+ }
11426
+ );
11427
+ });
11428
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11429
+ KeyboundForm,
11430
+ {
11431
+ className: "flex flex-1 flex-col overflow-hidden",
11432
+ onSubmit,
11433
+ children: [
11434
+ /* @__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: [
11435
+ /* @__PURE__ */ jsx(
11436
+ Form$2.Field,
11437
+ {
11438
+ control: form.control,
11439
+ name: "country_code",
11440
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11441
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11442
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11443
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11444
+ ] })
11445
+ }
11446
+ ),
11447
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11448
+ /* @__PURE__ */ jsx(
11449
+ Form$2.Field,
11450
+ {
11451
+ control: form.control,
11452
+ name: "first_name",
11453
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11454
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11455
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11456
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11457
+ ] })
11458
+ }
11459
+ ),
11460
+ /* @__PURE__ */ jsx(
11461
+ Form$2.Field,
11462
+ {
11463
+ control: form.control,
11464
+ name: "last_name",
11465
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11466
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11467
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11468
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11469
+ ] })
11470
+ }
11471
+ )
11472
+ ] }),
11473
+ /* @__PURE__ */ jsx(
11474
+ Form$2.Field,
11475
+ {
11476
+ control: form.control,
11477
+ name: "company",
11478
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11479
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11480
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11481
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11482
+ ] })
11483
+ }
11484
+ ),
11485
+ /* @__PURE__ */ jsx(
11486
+ Form$2.Field,
11487
+ {
11488
+ control: form.control,
11489
+ name: "address_1",
11490
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11491
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11492
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11493
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11494
+ ] })
11495
+ }
11496
+ ),
11497
+ /* @__PURE__ */ jsx(
11498
+ Form$2.Field,
11499
+ {
11500
+ control: form.control,
11501
+ name: "address_2",
11502
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11503
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11504
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11505
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11506
+ ] })
11507
+ }
11508
+ ),
11509
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11510
+ /* @__PURE__ */ jsx(
11511
+ Form$2.Field,
11512
+ {
11513
+ control: form.control,
11514
+ name: "postal_code",
11515
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11516
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11517
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11518
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11519
+ ] })
11520
+ }
11521
+ ),
11522
+ /* @__PURE__ */ jsx(
11523
+ Form$2.Field,
11524
+ {
11525
+ control: form.control,
11526
+ name: "city",
11527
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11528
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11529
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11530
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11531
+ ] })
11532
+ }
11533
+ )
11534
+ ] }),
11535
+ /* @__PURE__ */ jsx(
11536
+ Form$2.Field,
11537
+ {
11538
+ control: form.control,
11539
+ name: "province",
11540
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11541
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11542
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11543
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11544
+ ] })
11545
+ }
11546
+ ),
11547
+ /* @__PURE__ */ jsx(
11548
+ Form$2.Field,
11549
+ {
11550
+ control: form.control,
11551
+ name: "phone",
11552
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11553
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11554
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11555
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11556
+ ] })
11557
+ }
11558
+ )
11559
+ ] }) }),
11560
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11561
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11562
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11563
+ ] }) })
11564
+ ]
11565
+ }
11566
+ ) });
11567
+ };
11568
+ const schema$2 = addressSchema;
11345
11569
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11346
11570
  const Shipping = () => {
11347
11571
  var _a;
@@ -12149,209 +12373,6 @@ const CustomAmountField = ({
12149
12373
  }
12150
12374
  );
12151
12375
  };
12152
- const ShippingAddress = () => {
12153
- const { id } = useParams();
12154
- const { order, isPending, isError, error } = useOrder(id, {
12155
- fields: "+shipping_address"
12156
- });
12157
- if (isError) {
12158
- throw error;
12159
- }
12160
- const isReady = !isPending && !!order;
12161
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12162
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12163
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12164
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12165
- ] }),
12166
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12167
- ] });
12168
- };
12169
- const ShippingAddressForm = ({ order }) => {
12170
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12171
- const form = useForm({
12172
- defaultValues: {
12173
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12174
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12175
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12176
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12177
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12178
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12179
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12180
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12181
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12182
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12183
- },
12184
- resolver: zodResolver(schema$3)
12185
- });
12186
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12187
- const { handleSuccess } = useRouteModal();
12188
- const onSubmit = form.handleSubmit(async (data) => {
12189
- await mutateAsync(
12190
- {
12191
- shipping_address: {
12192
- first_name: data.first_name,
12193
- last_name: data.last_name,
12194
- company: data.company,
12195
- address_1: data.address_1,
12196
- address_2: data.address_2,
12197
- city: data.city,
12198
- province: data.province,
12199
- country_code: data.country_code,
12200
- postal_code: data.postal_code,
12201
- phone: data.phone
12202
- }
12203
- },
12204
- {
12205
- onSuccess: () => {
12206
- handleSuccess();
12207
- },
12208
- onError: (error) => {
12209
- toast.error(error.message);
12210
- }
12211
- }
12212
- );
12213
- });
12214
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12215
- KeyboundForm,
12216
- {
12217
- className: "flex flex-1 flex-col overflow-hidden",
12218
- onSubmit,
12219
- children: [
12220
- /* @__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: [
12221
- /* @__PURE__ */ jsx(
12222
- Form$2.Field,
12223
- {
12224
- control: form.control,
12225
- name: "country_code",
12226
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12227
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12228
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12229
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12230
- ] })
12231
- }
12232
- ),
12233
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12234
- /* @__PURE__ */ jsx(
12235
- Form$2.Field,
12236
- {
12237
- control: form.control,
12238
- name: "first_name",
12239
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12240
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12241
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12242
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12243
- ] })
12244
- }
12245
- ),
12246
- /* @__PURE__ */ jsx(
12247
- Form$2.Field,
12248
- {
12249
- control: form.control,
12250
- name: "last_name",
12251
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12252
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12253
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12254
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12255
- ] })
12256
- }
12257
- )
12258
- ] }),
12259
- /* @__PURE__ */ jsx(
12260
- Form$2.Field,
12261
- {
12262
- control: form.control,
12263
- name: "company",
12264
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12265
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12266
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12267
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12268
- ] })
12269
- }
12270
- ),
12271
- /* @__PURE__ */ jsx(
12272
- Form$2.Field,
12273
- {
12274
- control: form.control,
12275
- name: "address_1",
12276
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12277
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12278
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12279
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12280
- ] })
12281
- }
12282
- ),
12283
- /* @__PURE__ */ jsx(
12284
- Form$2.Field,
12285
- {
12286
- control: form.control,
12287
- name: "address_2",
12288
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12289
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12290
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12291
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12292
- ] })
12293
- }
12294
- ),
12295
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12296
- /* @__PURE__ */ jsx(
12297
- Form$2.Field,
12298
- {
12299
- control: form.control,
12300
- name: "postal_code",
12301
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12302
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12303
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12304
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12305
- ] })
12306
- }
12307
- ),
12308
- /* @__PURE__ */ jsx(
12309
- Form$2.Field,
12310
- {
12311
- control: form.control,
12312
- name: "city",
12313
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12314
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12315
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12316
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12317
- ] })
12318
- }
12319
- )
12320
- ] }),
12321
- /* @__PURE__ */ jsx(
12322
- Form$2.Field,
12323
- {
12324
- control: form.control,
12325
- name: "province",
12326
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12327
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12328
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12329
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12330
- ] })
12331
- }
12332
- ),
12333
- /* @__PURE__ */ jsx(
12334
- Form$2.Field,
12335
- {
12336
- control: form.control,
12337
- name: "phone",
12338
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12339
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12340
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12341
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12342
- ] })
12343
- }
12344
- )
12345
- ] }) }),
12346
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12347
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12348
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12349
- ] }) })
12350
- ]
12351
- }
12352
- ) });
12353
- };
12354
- const schema$3 = addressSchema;
12355
12376
  const TransferOwnership = () => {
12356
12377
  const { id } = useParams();
12357
12378
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12375,7 +12396,7 @@ const TransferOwnershipForm = ({ order }) => {
12375
12396
  defaultValues: {
12376
12397
  customer_id: order.customer_id || ""
12377
12398
  },
12378
- resolver: zodResolver(schema$2)
12399
+ resolver: zodResolver(schema$1)
12379
12400
  });
12380
12401
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12381
12402
  const { handleSuccess } = useRouteModal();
@@ -12825,29 +12846,8 @@ const Illustration = () => {
12825
12846
  }
12826
12847
  );
12827
12848
  };
12828
- const schema$2 = objectType({
12829
- customer_id: stringType().min(1)
12830
- });
12831
- const CustomItems = () => {
12832
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12833
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
12834
- /* @__PURE__ */ jsx(CustomItemsForm, {})
12835
- ] });
12836
- };
12837
- const CustomItemsForm = () => {
12838
- const form = useForm({
12839
- resolver: zodResolver(schema$1)
12840
- });
12841
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12842
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
12843
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12844
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12845
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
12846
- ] }) })
12847
- ] }) });
12848
- };
12849
12849
  const schema$1 = objectType({
12850
- email: stringType().email()
12850
+ customer_id: stringType().min(1)
12851
12851
  });
12852
12852
  const BillingAddress = () => {
12853
12853
  const { id } = useParams();
@@ -13059,6 +13059,10 @@ const routeModule = {
13059
13059
  handle,
13060
13060
  loader,
13061
13061
  children: [
13062
+ {
13063
+ Component: CustomItems,
13064
+ path: "/draft-orders/:id/custom-items"
13065
+ },
13062
13066
  {
13063
13067
  Component: Email,
13064
13068
  path: "/draft-orders/:id/email"
@@ -13079,21 +13083,17 @@ const routeModule = {
13079
13083
  Component: SalesChannel,
13080
13084
  path: "/draft-orders/:id/sales-channel"
13081
13085
  },
13082
- {
13083
- Component: Shipping,
13084
- path: "/draft-orders/:id/shipping"
13085
- },
13086
13086
  {
13087
13087
  Component: ShippingAddress,
13088
13088
  path: "/draft-orders/:id/shipping-address"
13089
13089
  },
13090
13090
  {
13091
- Component: TransferOwnership,
13092
- path: "/draft-orders/:id/transfer-ownership"
13091
+ Component: Shipping,
13092
+ path: "/draft-orders/:id/shipping"
13093
13093
  },
13094
13094
  {
13095
- Component: CustomItems,
13096
- path: "/draft-orders/:id/custom-items"
13095
+ Component: TransferOwnership,
13096
+ path: "/draft-orders/:id/transfer-ownership"
13097
13097
  },
13098
13098
  {
13099
13099
  Component: BillingAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.4-preview-20250930150158",
3
+ "version": "2.10.4-preview-20250930210154",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.10.4-preview-20250930150158",
39
+ "@medusajs/js-sdk": "2.10.4-preview-20250930210154",
40
40
  "@tanstack/react-query": "5.64.2",
41
41
  "@uiw/react-json-view": "^2.0.0-alpha.17",
42
42
  "date-fns": "^3.6.0",
@@ -45,14 +45,14 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.4-preview-20250930150158",
49
- "@medusajs/cli": "2.10.4-preview-20250930150158",
50
- "@medusajs/framework": "2.10.4-preview-20250930150158",
51
- "@medusajs/icons": "2.10.4-preview-20250930150158",
52
- "@medusajs/test-utils": "2.10.4-preview-20250930150158",
53
- "@medusajs/types": "2.10.4-preview-20250930150158",
54
- "@medusajs/ui": "4.0.24-preview-20250930150158",
55
- "@medusajs/ui-preset": "2.10.4-preview-20250930150158",
48
+ "@medusajs/admin-sdk": "2.10.4-preview-20250930210154",
49
+ "@medusajs/cli": "2.10.4-preview-20250930210154",
50
+ "@medusajs/framework": "2.10.4-preview-20250930210154",
51
+ "@medusajs/icons": "2.10.4-preview-20250930210154",
52
+ "@medusajs/test-utils": "2.10.4-preview-20250930210154",
53
+ "@medusajs/types": "2.10.4-preview-20250930210154",
54
+ "@medusajs/ui": "4.0.24-preview-20250930210154",
55
+ "@medusajs/ui-preset": "2.10.4-preview-20250930210154",
56
56
  "@swc/core": "1.5.7",
57
57
  "@types/lodash": "^4.17.15",
58
58
  "@types/node": "^20.0.0",
@@ -69,12 +69,12 @@
69
69
  "yalc": "^1.0.0-pre.53"
70
70
  },
71
71
  "peerDependencies": {
72
- "@medusajs/admin-sdk": "2.10.4-preview-20250930150158",
73
- "@medusajs/cli": "2.10.4-preview-20250930150158",
74
- "@medusajs/framework": "2.10.4-preview-20250930150158",
75
- "@medusajs/icons": "2.10.4-preview-20250930150158",
76
- "@medusajs/test-utils": "2.10.4-preview-20250930150158",
77
- "@medusajs/ui": "4.0.24-preview-20250930150158",
72
+ "@medusajs/admin-sdk": "2.10.4-preview-20250930210154",
73
+ "@medusajs/cli": "2.10.4-preview-20250930210154",
74
+ "@medusajs/framework": "2.10.4-preview-20250930210154",
75
+ "@medusajs/icons": "2.10.4-preview-20250930210154",
76
+ "@medusajs/test-utils": "2.10.4-preview-20250930210154",
77
+ "@medusajs/ui": "4.0.24-preview-20250930210154",
78
78
  "lodash": "^4.17.21",
79
79
  "react-router-dom": "6.20.1"
80
80
  },