@medusajs/draft-order 2.12.2-preview-20251204000309 → 2.12.2-preview-20251204032622

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,6 +9565,196 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
+ const BillingAddress = () => {
9569
+ const { id } = useParams();
9570
+ const { order, isPending, isError, error } = useOrder(id, {
9571
+ fields: "+billing_address"
9572
+ });
9573
+ if (isError) {
9574
+ throw error;
9575
+ }
9576
+ const isReady = !isPending && !!order;
9577
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9579
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9580
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9581
+ ] }),
9582
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9583
+ ] });
9584
+ };
9585
+ const BillingAddressForm = ({ order }) => {
9586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9587
+ const form = useForm({
9588
+ defaultValues: {
9589
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9590
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9591
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9592
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9593
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9594
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9595
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9596
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9597
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9599
+ },
9600
+ resolver: zodResolver(schema$5)
9601
+ });
9602
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9603
+ const { handleSuccess } = useRouteModal();
9604
+ const onSubmit = form.handleSubmit(async (data) => {
9605
+ await mutateAsync(
9606
+ { billing_address: data },
9607
+ {
9608
+ onSuccess: () => {
9609
+ handleSuccess();
9610
+ },
9611
+ onError: (error) => {
9612
+ toast.error(error.message);
9613
+ }
9614
+ }
9615
+ );
9616
+ });
9617
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9618
+ KeyboundForm,
9619
+ {
9620
+ className: "flex flex-1 flex-col overflow-hidden",
9621
+ onSubmit,
9622
+ children: [
9623
+ /* @__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: [
9624
+ /* @__PURE__ */ jsx(
9625
+ Form$2.Field,
9626
+ {
9627
+ control: form.control,
9628
+ name: "country_code",
9629
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9630
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9631
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9632
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9633
+ ] })
9634
+ }
9635
+ ),
9636
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9637
+ /* @__PURE__ */ jsx(
9638
+ Form$2.Field,
9639
+ {
9640
+ control: form.control,
9641
+ name: "first_name",
9642
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9643
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9644
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9645
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9646
+ ] })
9647
+ }
9648
+ ),
9649
+ /* @__PURE__ */ jsx(
9650
+ Form$2.Field,
9651
+ {
9652
+ control: form.control,
9653
+ name: "last_name",
9654
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9655
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9656
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9657
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9658
+ ] })
9659
+ }
9660
+ )
9661
+ ] }),
9662
+ /* @__PURE__ */ jsx(
9663
+ Form$2.Field,
9664
+ {
9665
+ control: form.control,
9666
+ name: "company",
9667
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9668
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9669
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9670
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9671
+ ] })
9672
+ }
9673
+ ),
9674
+ /* @__PURE__ */ jsx(
9675
+ Form$2.Field,
9676
+ {
9677
+ control: form.control,
9678
+ name: "address_1",
9679
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9680
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9681
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9682
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9683
+ ] })
9684
+ }
9685
+ ),
9686
+ /* @__PURE__ */ jsx(
9687
+ Form$2.Field,
9688
+ {
9689
+ control: form.control,
9690
+ name: "address_2",
9691
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9692
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9693
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9694
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9695
+ ] })
9696
+ }
9697
+ ),
9698
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9699
+ /* @__PURE__ */ jsx(
9700
+ Form$2.Field,
9701
+ {
9702
+ control: form.control,
9703
+ name: "postal_code",
9704
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9705
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9706
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9707
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9708
+ ] })
9709
+ }
9710
+ ),
9711
+ /* @__PURE__ */ jsx(
9712
+ Form$2.Field,
9713
+ {
9714
+ control: form.control,
9715
+ name: "city",
9716
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9717
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9718
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9719
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9720
+ ] })
9721
+ }
9722
+ )
9723
+ ] }),
9724
+ /* @__PURE__ */ jsx(
9725
+ Form$2.Field,
9726
+ {
9727
+ control: form.control,
9728
+ name: "province",
9729
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9730
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9731
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9732
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9733
+ ] })
9734
+ }
9735
+ ),
9736
+ /* @__PURE__ */ jsx(
9737
+ Form$2.Field,
9738
+ {
9739
+ control: form.control,
9740
+ name: "phone",
9741
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9742
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9743
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9744
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9745
+ ] })
9746
+ }
9747
+ )
9748
+ ] }) }),
9749
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9750
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9751
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9752
+ ] }) })
9753
+ ]
9754
+ }
9755
+ ) });
9756
+ };
9757
+ const schema$5 = addressSchema;
9568
9758
  const CustomItems = () => {
9569
9759
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9570
9760
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -9573,7 +9763,7 @@ const CustomItems = () => {
9573
9763
  };
9574
9764
  const CustomItemsForm = () => {
9575
9765
  const form = useForm({
9576
- resolver: zodResolver(schema$5)
9766
+ resolver: zodResolver(schema$4)
9577
9767
  });
9578
9768
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9579
9769
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -9583,7 +9773,7 @@ const CustomItemsForm = () => {
9583
9773
  ] }) })
9584
9774
  ] }) });
9585
9775
  };
9586
- const schema$5 = objectType({
9776
+ const schema$4 = objectType({
9587
9777
  email: stringType().email()
9588
9778
  });
9589
9779
  const Email = () => {
@@ -9608,7 +9798,7 @@ const EmailForm = ({ order }) => {
9608
9798
  defaultValues: {
9609
9799
  email: order.email ?? ""
9610
9800
  },
9611
- resolver: zodResolver(schema$4)
9801
+ resolver: zodResolver(schema$3)
9612
9802
  });
9613
9803
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9614
9804
  const { handleSuccess } = useRouteModal();
@@ -9651,7 +9841,7 @@ const EmailForm = ({ order }) => {
9651
9841
  }
9652
9842
  ) });
9653
9843
  };
9654
- const schema$4 = objectType({
9844
+ const schema$3 = objectType({
9655
9845
  email: stringType().email()
9656
9846
  });
9657
9847
  const NumberInput = forwardRef(
@@ -11255,230 +11445,40 @@ function getPromotionIds(items, shippingMethods) {
11255
11445
  }
11256
11446
  return Array.from(promotionIds);
11257
11447
  }
11258
- const BillingAddress = () => {
11448
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11449
+ const Shipping = () => {
11450
+ var _a;
11259
11451
  const { id } = useParams();
11260
11452
  const { order, isPending, isError, error } = useOrder(id, {
11261
- fields: "+billing_address"
11453
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11262
11454
  });
11455
+ const {
11456
+ order: preview,
11457
+ isPending: isPreviewPending,
11458
+ isError: isPreviewError,
11459
+ error: previewError
11460
+ } = useOrderPreview(id);
11461
+ useInitiateOrderEdit({ preview });
11462
+ const { onCancel } = useCancelOrderEdit({ preview });
11263
11463
  if (isError) {
11264
11464
  throw error;
11265
11465
  }
11266
- const isReady = !isPending && !!order;
11267
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11268
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11269
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
11270
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11271
- ] }),
11272
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
11273
- ] });
11274
- };
11275
- const BillingAddressForm = ({ order }) => {
11276
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11277
- const form = useForm({
11278
- defaultValues: {
11279
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
11280
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11281
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11282
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11283
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11284
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11285
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11286
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11287
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11288
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11289
- },
11290
- resolver: zodResolver(schema$3)
11291
- });
11292
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11293
- const { handleSuccess } = useRouteModal();
11294
- const onSubmit = form.handleSubmit(async (data) => {
11295
- await mutateAsync(
11296
- { billing_address: data },
11297
- {
11298
- onSuccess: () => {
11299
- handleSuccess();
11300
- },
11301
- onError: (error) => {
11302
- toast.error(error.message);
11303
- }
11304
- }
11305
- );
11306
- });
11307
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11308
- KeyboundForm,
11309
- {
11310
- className: "flex flex-1 flex-col overflow-hidden",
11311
- onSubmit,
11312
- children: [
11313
- /* @__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: [
11314
- /* @__PURE__ */ jsx(
11315
- Form$2.Field,
11316
- {
11317
- control: form.control,
11318
- name: "country_code",
11319
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11320
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11321
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11322
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11323
- ] })
11324
- }
11325
- ),
11326
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11327
- /* @__PURE__ */ jsx(
11328
- Form$2.Field,
11329
- {
11330
- control: form.control,
11331
- name: "first_name",
11332
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11333
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11334
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11335
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11336
- ] })
11337
- }
11338
- ),
11339
- /* @__PURE__ */ jsx(
11340
- Form$2.Field,
11341
- {
11342
- control: form.control,
11343
- name: "last_name",
11344
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11345
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11346
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11347
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11348
- ] })
11349
- }
11350
- )
11351
- ] }),
11352
- /* @__PURE__ */ jsx(
11353
- Form$2.Field,
11354
- {
11355
- control: form.control,
11356
- name: "company",
11357
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11358
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11359
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11360
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11361
- ] })
11362
- }
11363
- ),
11364
- /* @__PURE__ */ jsx(
11365
- Form$2.Field,
11366
- {
11367
- control: form.control,
11368
- name: "address_1",
11369
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11370
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11371
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11372
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11373
- ] })
11374
- }
11375
- ),
11376
- /* @__PURE__ */ jsx(
11377
- Form$2.Field,
11378
- {
11379
- control: form.control,
11380
- name: "address_2",
11381
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11382
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11383
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11384
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11385
- ] })
11386
- }
11387
- ),
11388
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11389
- /* @__PURE__ */ jsx(
11390
- Form$2.Field,
11391
- {
11392
- control: form.control,
11393
- name: "postal_code",
11394
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11395
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11396
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11397
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11398
- ] })
11399
- }
11400
- ),
11401
- /* @__PURE__ */ jsx(
11402
- Form$2.Field,
11403
- {
11404
- control: form.control,
11405
- name: "city",
11406
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11407
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11408
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11409
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11410
- ] })
11411
- }
11412
- )
11413
- ] }),
11414
- /* @__PURE__ */ jsx(
11415
- Form$2.Field,
11416
- {
11417
- control: form.control,
11418
- name: "province",
11419
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11420
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11421
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11422
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11423
- ] })
11424
- }
11425
- ),
11426
- /* @__PURE__ */ jsx(
11427
- Form$2.Field,
11428
- {
11429
- control: form.control,
11430
- name: "phone",
11431
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11432
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11433
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11434
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11435
- ] })
11436
- }
11437
- )
11438
- ] }) }),
11439
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11440
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11441
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11442
- ] }) })
11443
- ]
11444
- }
11445
- ) });
11446
- };
11447
- const schema$3 = addressSchema;
11448
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11449
- const Shipping = () => {
11450
- var _a;
11451
- const { id } = useParams();
11452
- const { order, isPending, isError, error } = useOrder(id, {
11453
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11454
- });
11455
- const {
11456
- order: preview,
11457
- isPending: isPreviewPending,
11458
- isError: isPreviewError,
11459
- error: previewError
11460
- } = useOrderPreview(id);
11461
- useInitiateOrderEdit({ preview });
11462
- const { onCancel } = useCancelOrderEdit({ preview });
11463
- if (isError) {
11464
- throw error;
11465
- }
11466
- if (isPreviewError) {
11467
- throw previewError;
11468
- }
11469
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11470
- const isReady = preview && !isPreviewPending && order && !isPending;
11471
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11472
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11473
- /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
11474
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11475
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11476
- ] }) }) }),
11477
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11478
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11479
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11480
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11481
- ] }) });
11466
+ if (isPreviewError) {
11467
+ throw previewError;
11468
+ }
11469
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11470
+ const isReady = preview && !isPreviewPending && order && !isPending;
11471
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11472
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11473
+ /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
11474
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11475
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11476
+ ] }) }) }),
11477
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11478
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11479
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11480
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11481
+ ] }) });
11482
11482
  };
11483
11483
  const ShippingForm = ({ preview, order }) => {
11484
11484
  var _a;
@@ -12252,37 +12252,33 @@ const CustomAmountField = ({
12252
12252
  }
12253
12253
  );
12254
12254
  };
12255
- const ShippingAddress = () => {
12255
+ const SalesChannel = () => {
12256
12256
  const { id } = useParams();
12257
- const { order, isPending, isError, error } = useOrder(id, {
12258
- fields: "+shipping_address"
12259
- });
12257
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12258
+ id,
12259
+ {
12260
+ fields: "+sales_channel_id"
12261
+ },
12262
+ {
12263
+ enabled: !!id
12264
+ }
12265
+ );
12260
12266
  if (isError) {
12261
12267
  throw error;
12262
12268
  }
12263
- const isReady = !isPending && !!order;
12269
+ const ISrEADY = !!draft_order && !isPending;
12264
12270
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12265
12271
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12266
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12267
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
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" }) })
12268
12274
  ] }),
12269
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12275
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12270
12276
  ] });
12271
12277
  };
12272
- const ShippingAddressForm = ({ order }) => {
12273
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12278
+ const SalesChannelForm = ({ order }) => {
12274
12279
  const form = useForm({
12275
12280
  defaultValues: {
12276
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12277
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12278
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12279
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12280
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12281
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12282
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12283
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12284
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12285
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12281
+ sales_channel_id: order.sales_channel_id || ""
12286
12282
  },
12287
12283
  resolver: zodResolver(schema$2)
12288
12284
  });
@@ -12291,21 +12287,11 @@ const ShippingAddressForm = ({ order }) => {
12291
12287
  const onSubmit = form.handleSubmit(async (data) => {
12292
12288
  await mutateAsync(
12293
12289
  {
12294
- shipping_address: {
12295
- first_name: data.first_name,
12296
- last_name: data.last_name,
12297
- company: data.company,
12298
- address_1: data.address_1,
12299
- address_2: data.address_2,
12300
- city: data.city,
12301
- province: data.province,
12302
- country_code: data.country_code,
12303
- postal_code: data.postal_code,
12304
- phone: data.phone
12305
- }
12290
+ sales_channel_id: data.sales_channel_id
12306
12291
  },
12307
12292
  {
12308
12293
  onSuccess: () => {
12294
+ toast.success("Sales channel updated");
12309
12295
  handleSuccess();
12310
12296
  },
12311
12297
  onError: (error) => {
@@ -12320,132 +12306,7 @@ const ShippingAddressForm = ({ order }) => {
12320
12306
  className: "flex flex-1 flex-col overflow-hidden",
12321
12307
  onSubmit,
12322
12308
  children: [
12323
- /* @__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: [
12324
- /* @__PURE__ */ jsx(
12325
- Form$2.Field,
12326
- {
12327
- control: form.control,
12328
- name: "country_code",
12329
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12330
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12331
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12332
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12333
- ] })
12334
- }
12335
- ),
12336
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12337
- /* @__PURE__ */ jsx(
12338
- Form$2.Field,
12339
- {
12340
- control: form.control,
12341
- name: "first_name",
12342
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12343
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12344
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12345
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12346
- ] })
12347
- }
12348
- ),
12349
- /* @__PURE__ */ jsx(
12350
- Form$2.Field,
12351
- {
12352
- control: form.control,
12353
- name: "last_name",
12354
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12355
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12356
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12357
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12358
- ] })
12359
- }
12360
- )
12361
- ] }),
12362
- /* @__PURE__ */ jsx(
12363
- Form$2.Field,
12364
- {
12365
- control: form.control,
12366
- name: "company",
12367
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12368
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12369
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12370
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12371
- ] })
12372
- }
12373
- ),
12374
- /* @__PURE__ */ jsx(
12375
- Form$2.Field,
12376
- {
12377
- control: form.control,
12378
- name: "address_1",
12379
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12380
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12381
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12382
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12383
- ] })
12384
- }
12385
- ),
12386
- /* @__PURE__ */ jsx(
12387
- Form$2.Field,
12388
- {
12389
- control: form.control,
12390
- name: "address_2",
12391
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12392
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12393
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12394
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12395
- ] })
12396
- }
12397
- ),
12398
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12399
- /* @__PURE__ */ jsx(
12400
- Form$2.Field,
12401
- {
12402
- control: form.control,
12403
- name: "postal_code",
12404
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12405
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12406
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12407
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12408
- ] })
12409
- }
12410
- ),
12411
- /* @__PURE__ */ jsx(
12412
- Form$2.Field,
12413
- {
12414
- control: form.control,
12415
- name: "city",
12416
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12417
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12418
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12419
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12420
- ] })
12421
- }
12422
- )
12423
- ] }),
12424
- /* @__PURE__ */ jsx(
12425
- Form$2.Field,
12426
- {
12427
- control: form.control,
12428
- name: "province",
12429
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12430
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12431
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12432
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12433
- ] })
12434
- }
12435
- ),
12436
- /* @__PURE__ */ jsx(
12437
- Form$2.Field,
12438
- {
12439
- control: form.control,
12440
- name: "phone",
12441
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12442
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12443
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12444
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12445
- ] })
12446
- }
12447
- )
12448
- ] }) }),
12309
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12449
12310
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12450
12311
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12451
12312
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -12454,7 +12315,49 @@ const ShippingAddressForm = ({ order }) => {
12454
12315
  }
12455
12316
  ) });
12456
12317
  };
12457
- const schema$2 = addressSchema;
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
+ });
12458
12361
  const TransferOwnership = () => {
12459
12362
  const { id } = useParams();
12460
12363
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12931,33 +12834,37 @@ const Illustration = () => {
12931
12834
  const schema$1 = objectType({
12932
12835
  customer_id: stringType().min(1)
12933
12836
  });
12934
- const SalesChannel = () => {
12837
+ const ShippingAddress = () => {
12935
12838
  const { id } = useParams();
12936
- const { draft_order, isPending, isError, error } = useDraftOrder(
12937
- id,
12938
- {
12939
- fields: "+sales_channel_id"
12940
- },
12941
- {
12942
- enabled: !!id
12943
- }
12944
- );
12839
+ const { order, isPending, isError, error } = useOrder(id, {
12840
+ fields: "+shipping_address"
12841
+ });
12945
12842
  if (isError) {
12946
12843
  throw error;
12947
12844
  }
12948
- const ISrEADY = !!draft_order && !isPending;
12845
+ const isReady = !isPending && !!order;
12949
12846
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12950
12847
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12951
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12952
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
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" }) })
12953
12850
  ] }),
12954
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12851
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12955
12852
  ] });
12956
12853
  };
12957
- const SalesChannelForm = ({ order }) => {
12854
+ const ShippingAddressForm = ({ order }) => {
12855
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12958
12856
  const form = useForm({
12959
12857
  defaultValues: {
12960
- sales_channel_id: order.sales_channel_id || ""
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) ?? ""
12961
12868
  },
12962
12869
  resolver: zodResolver(schema)
12963
12870
  });
@@ -12966,11 +12873,21 @@ const SalesChannelForm = ({ order }) => {
12966
12873
  const onSubmit = form.handleSubmit(async (data) => {
12967
12874
  await mutateAsync(
12968
12875
  {
12969
- sales_channel_id: data.sales_channel_id
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
+ }
12970
12888
  },
12971
12889
  {
12972
12890
  onSuccess: () => {
12973
- toast.success("Sales channel updated");
12974
12891
  handleSuccess();
12975
12892
  },
12976
12893
  onError: (error) => {
@@ -12985,7 +12902,132 @@ const SalesChannelForm = ({ order }) => {
12985
12902
  className: "flex flex-1 flex-col overflow-hidden",
12986
12903
  onSubmit,
12987
12904
  children: [
12988
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
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
+ ] }) }),
12989
13031
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12990
13032
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12991
13033
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -12994,49 +13036,7 @@ const SalesChannelForm = ({ order }) => {
12994
13036
  }
12995
13037
  ) });
12996
13038
  };
12997
- const SalesChannelField = ({ control, order }) => {
12998
- const salesChannels = useComboboxData({
12999
- queryFn: async (params) => {
13000
- return await sdk.admin.salesChannel.list(params);
13001
- },
13002
- queryKey: ["sales-channels"],
13003
- getOptions: (data) => {
13004
- return data.sales_channels.map((salesChannel) => ({
13005
- label: salesChannel.name,
13006
- value: salesChannel.id
13007
- }));
13008
- },
13009
- defaultValue: order.sales_channel_id || void 0
13010
- });
13011
- return /* @__PURE__ */ jsx(
13012
- Form$2.Field,
13013
- {
13014
- control,
13015
- name: "sales_channel_id",
13016
- render: ({ field }) => {
13017
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13018
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13019
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13020
- Combobox,
13021
- {
13022
- options: salesChannels.options,
13023
- fetchNextPage: salesChannels.fetchNextPage,
13024
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13025
- searchValue: salesChannels.searchValue,
13026
- onSearchValueChange: salesChannels.onSearchValueChange,
13027
- placeholder: "Select sales channel",
13028
- ...field
13029
- }
13030
- ) }),
13031
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13032
- ] });
13033
- }
13034
- }
13035
- );
13036
- };
13037
- const schema = objectType({
13038
- sales_channel_id: stringType().min(1)
13039
- });
13039
+ const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,6 +13057,10 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
+ {
13061
+ Component: BillingAddress,
13062
+ path: "/draft-orders/:id/billing-address"
13063
+ },
13060
13064
  {
13061
13065
  Component: CustomItems,
13062
13066
  path: "/draft-orders/:id/custom-items"
@@ -13077,25 +13081,21 @@ const routeModule = {
13077
13081
  Component: Promotions,
13078
13082
  path: "/draft-orders/:id/promotions"
13079
13083
  },
13080
- {
13081
- Component: BillingAddress,
13082
- path: "/draft-orders/:id/billing-address"
13083
- },
13084
13084
  {
13085
13085
  Component: Shipping,
13086
13086
  path: "/draft-orders/:id/shipping"
13087
13087
  },
13088
13088
  {
13089
- Component: ShippingAddress,
13090
- path: "/draft-orders/:id/shipping-address"
13089
+ Component: SalesChannel,
13090
+ path: "/draft-orders/:id/sales-channel"
13091
13091
  },
13092
13092
  {
13093
13093
  Component: TransferOwnership,
13094
13094
  path: "/draft-orders/:id/transfer-ownership"
13095
13095
  },
13096
13096
  {
13097
- Component: SalesChannel,
13098
- path: "/draft-orders/:id/sales-channel"
13097
+ Component: ShippingAddress,
13098
+ path: "/draft-orders/:id/shipping-address"
13099
13099
  }
13100
13100
  ]
13101
13101
  }