@medusajs/draft-order 2.10.4-snapshot-20251008074348 → 2.10.4-snapshot-20251008113737

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.
@@ -9567,196 +9567,27 @@ const ID = () => {
9567
9567
  /* @__PURE__ */ jsx(Outlet, {})
9568
9568
  ] });
9569
9569
  };
9570
- const BillingAddress = () => {
9571
- const { id } = useParams();
9572
- const { order, isPending, isError, error } = useOrder(id, {
9573
- fields: "+billing_address"
9574
- });
9575
- if (isError) {
9576
- throw error;
9577
- }
9578
- const isReady = !isPending && !!order;
9570
+ const CustomItems = () => {
9579
9571
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9580
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9581
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9582
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9583
- ] }),
9584
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9572
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9573
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9585
9574
  ] });
9586
9575
  };
9587
- const BillingAddressForm = ({ order }) => {
9588
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9576
+ const CustomItemsForm = () => {
9589
9577
  const form = useForm({
9590
- defaultValues: {
9591
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9592
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9593
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9594
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9595
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9596
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9597
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9598
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9599
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9600
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9601
- },
9602
9578
  resolver: zodResolver(schema$5)
9603
9579
  });
9604
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9605
- const { handleSuccess } = useRouteModal();
9606
- const onSubmit = form.handleSubmit(async (data) => {
9607
- await mutateAsync(
9608
- { billing_address: data },
9609
- {
9610
- onSuccess: () => {
9611
- handleSuccess();
9612
- },
9613
- onError: (error) => {
9614
- toast.error(error.message);
9615
- }
9616
- }
9617
- );
9618
- });
9619
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9620
- KeyboundForm,
9621
- {
9622
- className: "flex flex-1 flex-col overflow-hidden",
9623
- onSubmit,
9624
- children: [
9625
- /* @__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: [
9626
- /* @__PURE__ */ jsx(
9627
- Form$2.Field,
9628
- {
9629
- control: form.control,
9630
- name: "country_code",
9631
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9632
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9633
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9634
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9635
- ] })
9636
- }
9637
- ),
9638
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9639
- /* @__PURE__ */ jsx(
9640
- Form$2.Field,
9641
- {
9642
- control: form.control,
9643
- name: "first_name",
9644
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9645
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9646
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9647
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9648
- ] })
9649
- }
9650
- ),
9651
- /* @__PURE__ */ jsx(
9652
- Form$2.Field,
9653
- {
9654
- control: form.control,
9655
- name: "last_name",
9656
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9657
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9658
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9659
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9660
- ] })
9661
- }
9662
- )
9663
- ] }),
9664
- /* @__PURE__ */ jsx(
9665
- Form$2.Field,
9666
- {
9667
- control: form.control,
9668
- name: "company",
9669
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9670
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9671
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9672
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9673
- ] })
9674
- }
9675
- ),
9676
- /* @__PURE__ */ jsx(
9677
- Form$2.Field,
9678
- {
9679
- control: form.control,
9680
- name: "address_1",
9681
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9682
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9683
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9684
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9685
- ] })
9686
- }
9687
- ),
9688
- /* @__PURE__ */ jsx(
9689
- Form$2.Field,
9690
- {
9691
- control: form.control,
9692
- name: "address_2",
9693
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9694
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9695
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9696
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9697
- ] })
9698
- }
9699
- ),
9700
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9701
- /* @__PURE__ */ jsx(
9702
- Form$2.Field,
9703
- {
9704
- control: form.control,
9705
- name: "postal_code",
9706
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9707
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9708
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9709
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9710
- ] })
9711
- }
9712
- ),
9713
- /* @__PURE__ */ jsx(
9714
- Form$2.Field,
9715
- {
9716
- control: form.control,
9717
- name: "city",
9718
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9719
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9720
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9721
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9722
- ] })
9723
- }
9724
- )
9725
- ] }),
9726
- /* @__PURE__ */ jsx(
9727
- Form$2.Field,
9728
- {
9729
- control: form.control,
9730
- name: "province",
9731
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9732
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9733
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9734
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9735
- ] })
9736
- }
9737
- ),
9738
- /* @__PURE__ */ jsx(
9739
- Form$2.Field,
9740
- {
9741
- control: form.control,
9742
- name: "phone",
9743
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9744
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9745
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9746
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9747
- ] })
9748
- }
9749
- )
9750
- ] }) }),
9751
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9752
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9753
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9754
- ] }) })
9755
- ]
9756
- }
9757
- ) });
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
+ ] }) });
9758
9587
  };
9759
- const schema$5 = addressSchema;
9588
+ const schema$5 = objectType({
9589
+ email: stringType().email()
9590
+ });
9760
9591
  const Email = () => {
9761
9592
  const { id } = useParams();
9762
9593
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11532,64 +11363,267 @@ const SalesChannelField = ({ control, order }) => {
11532
11363
  const schema$3 = objectType({
11533
11364
  sales_channel_id: stringType().min(1)
11534
11365
  });
11535
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11536
- const Shipping = () => {
11537
- var _a;
11366
+ const ShippingAddress = () => {
11538
11367
  const { id } = useParams();
11539
11368
  const { order, isPending, isError, error } = useOrder(id, {
11540
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11369
+ fields: "+shipping_address"
11541
11370
  });
11542
- const {
11543
- order: preview,
11544
- isPending: isPreviewPending,
11545
- isError: isPreviewError,
11546
- error: previewError
11547
- } = useOrderPreview(id);
11548
- useInitiateOrderEdit({ preview });
11549
- const { onCancel } = useCancelOrderEdit({ preview });
11550
11371
  if (isError) {
11551
11372
  throw error;
11552
11373
  }
11553
- if (isPreviewError) {
11554
- throw previewError;
11555
- }
11556
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11557
- const isReady = preview && !isPreviewPending && order && !isPending;
11558
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11559
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11560
- /* @__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 py-16 px-6", children: [
11561
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11562
- /* @__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." }) })
11563
- ] }) }) }),
11564
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11565
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11566
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11567
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11568
- ] }) });
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
+ ] });
11569
11382
  };
11570
- const ShippingForm = ({ preview, order }) => {
11571
- var _a;
11572
- const { setIsOpen } = useStackedModal();
11573
- const [isSubmitting, setIsSubmitting] = useState(false);
11574
- const [data, setData] = useState(null);
11575
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11576
- const { shipping_options } = useShippingOptions(
11577
- {
11578
- id: appliedShippingOptionIds,
11579
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11580
- },
11581
- {
11582
- enabled: appliedShippingOptionIds.length > 0
11583
- }
11584
- );
11585
- const uniqueShippingProfiles = useMemo(() => {
11586
- const profiles = /* @__PURE__ */ new Map();
11587
- getUniqueShippingProfiles(order.items).forEach((profile) => {
11588
- profiles.set(profile.id, profile);
11589
- });
11590
- shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11591
- profiles.set(option.shipping_profile_id, option.shipping_profile);
11592
- });
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;
11569
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11570
+ const Shipping = () => {
11571
+ var _a;
11572
+ const { id } = useParams();
11573
+ const { order, isPending, isError, error } = useOrder(id, {
11574
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11575
+ });
11576
+ const {
11577
+ order: preview,
11578
+ isPending: isPreviewPending,
11579
+ isError: isPreviewError,
11580
+ error: previewError
11581
+ } = useOrderPreview(id);
11582
+ useInitiateOrderEdit({ preview });
11583
+ const { onCancel } = useCancelOrderEdit({ preview });
11584
+ if (isError) {
11585
+ throw error;
11586
+ }
11587
+ if (isPreviewError) {
11588
+ throw previewError;
11589
+ }
11590
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11591
+ const isReady = preview && !isPreviewPending && order && !isPending;
11592
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11593
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11594
+ /* @__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 py-16 px-6", children: [
11595
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11596
+ /* @__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." }) })
11597
+ ] }) }) }),
11598
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11599
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11600
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11601
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11602
+ ] }) });
11603
+ };
11604
+ const ShippingForm = ({ preview, order }) => {
11605
+ var _a;
11606
+ const { setIsOpen } = useStackedModal();
11607
+ const [isSubmitting, setIsSubmitting] = useState(false);
11608
+ const [data, setData] = useState(null);
11609
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11610
+ const { shipping_options } = useShippingOptions(
11611
+ {
11612
+ id: appliedShippingOptionIds,
11613
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11614
+ },
11615
+ {
11616
+ enabled: appliedShippingOptionIds.length > 0
11617
+ }
11618
+ );
11619
+ const uniqueShippingProfiles = useMemo(() => {
11620
+ const profiles = /* @__PURE__ */ new Map();
11621
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
11622
+ profiles.set(profile.id, profile);
11623
+ });
11624
+ shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11625
+ profiles.set(option.shipping_profile_id, option.shipping_profile);
11626
+ });
11593
11627
  return Array.from(profiles.values());
11594
11628
  }, [order.items, shipping_options]);
11595
11629
  const { handleSuccess } = useRouteModal();
@@ -12339,222 +12373,19 @@ const CustomAmountField = ({
12339
12373
  }
12340
12374
  );
12341
12375
  };
12342
- const ShippingAddress = () => {
12376
+ const TransferOwnership = () => {
12343
12377
  const { id } = useParams();
12344
- const { order, isPending, isError, error } = useOrder(id, {
12345
- fields: "+shipping_address"
12378
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12379
+ fields: "id,customer_id,customer.*"
12346
12380
  });
12347
12381
  if (isError) {
12348
12382
  throw error;
12349
12383
  }
12350
- const isReady = !isPending && !!order;
12384
+ const isReady = !isPending && !!draft_order;
12351
12385
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12352
12386
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12353
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12354
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12355
- ] }),
12356
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12357
- ] });
12358
- };
12359
- const ShippingAddressForm = ({ order }) => {
12360
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12361
- const form = useForm({
12362
- defaultValues: {
12363
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12364
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12365
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12366
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12367
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12368
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12369
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12370
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12371
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12372
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12373
- },
12374
- resolver: zodResolver(schema$2)
12375
- });
12376
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12377
- const { handleSuccess } = useRouteModal();
12378
- const onSubmit = form.handleSubmit(async (data) => {
12379
- await mutateAsync(
12380
- {
12381
- shipping_address: {
12382
- first_name: data.first_name,
12383
- last_name: data.last_name,
12384
- company: data.company,
12385
- address_1: data.address_1,
12386
- address_2: data.address_2,
12387
- city: data.city,
12388
- province: data.province,
12389
- country_code: data.country_code,
12390
- postal_code: data.postal_code,
12391
- phone: data.phone
12392
- }
12393
- },
12394
- {
12395
- onSuccess: () => {
12396
- handleSuccess();
12397
- },
12398
- onError: (error) => {
12399
- toast.error(error.message);
12400
- }
12401
- }
12402
- );
12403
- });
12404
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12405
- KeyboundForm,
12406
- {
12407
- className: "flex flex-1 flex-col overflow-hidden",
12408
- onSubmit,
12409
- children: [
12410
- /* @__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: [
12411
- /* @__PURE__ */ jsx(
12412
- Form$2.Field,
12413
- {
12414
- control: form.control,
12415
- name: "country_code",
12416
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12417
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12418
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12419
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12420
- ] })
12421
- }
12422
- ),
12423
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12424
- /* @__PURE__ */ jsx(
12425
- Form$2.Field,
12426
- {
12427
- control: form.control,
12428
- name: "first_name",
12429
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12430
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
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: "last_name",
12441
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12442
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12443
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12444
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12445
- ] })
12446
- }
12447
- )
12448
- ] }),
12449
- /* @__PURE__ */ jsx(
12450
- Form$2.Field,
12451
- {
12452
- control: form.control,
12453
- name: "company",
12454
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12455
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12456
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12457
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12458
- ] })
12459
- }
12460
- ),
12461
- /* @__PURE__ */ jsx(
12462
- Form$2.Field,
12463
- {
12464
- control: form.control,
12465
- name: "address_1",
12466
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12467
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12468
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12469
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12470
- ] })
12471
- }
12472
- ),
12473
- /* @__PURE__ */ jsx(
12474
- Form$2.Field,
12475
- {
12476
- control: form.control,
12477
- name: "address_2",
12478
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12479
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12480
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12481
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12482
- ] })
12483
- }
12484
- ),
12485
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12486
- /* @__PURE__ */ jsx(
12487
- Form$2.Field,
12488
- {
12489
- control: form.control,
12490
- name: "postal_code",
12491
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12492
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12493
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12494
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12495
- ] })
12496
- }
12497
- ),
12498
- /* @__PURE__ */ jsx(
12499
- Form$2.Field,
12500
- {
12501
- control: form.control,
12502
- name: "city",
12503
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12504
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12505
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12506
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12507
- ] })
12508
- }
12509
- )
12510
- ] }),
12511
- /* @__PURE__ */ jsx(
12512
- Form$2.Field,
12513
- {
12514
- control: form.control,
12515
- name: "province",
12516
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12517
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12518
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12519
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12520
- ] })
12521
- }
12522
- ),
12523
- /* @__PURE__ */ jsx(
12524
- Form$2.Field,
12525
- {
12526
- control: form.control,
12527
- name: "phone",
12528
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12529
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12530
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12531
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12532
- ] })
12533
- }
12534
- )
12535
- ] }) }),
12536
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12537
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12538
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12539
- ] }) })
12540
- ]
12541
- }
12542
- ) });
12543
- };
12544
- const schema$2 = addressSchema;
12545
- const TransferOwnership = () => {
12546
- const { id } = useParams();
12547
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12548
- fields: "id,customer_id,customer.*"
12549
- });
12550
- if (isError) {
12551
- throw error;
12552
- }
12553
- const isReady = !isPending && !!draft_order;
12554
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12555
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12556
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12557
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12387
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12388
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12558
12389
  ] }),
12559
12390
  isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12560
12391
  ] });
@@ -13018,27 +12849,196 @@ const Illustration = () => {
13018
12849
  const schema$1 = objectType({
13019
12850
  customer_id: stringType().min(1)
13020
12851
  });
13021
- const CustomItems = () => {
12852
+ const BillingAddress = () => {
12853
+ const { id } = useParams();
12854
+ const { order, isPending, isError, error } = useOrder(id, {
12855
+ fields: "+billing_address"
12856
+ });
12857
+ if (isError) {
12858
+ throw error;
12859
+ }
12860
+ const isReady = !isPending && !!order;
13022
12861
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13023
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13024
- /* @__PURE__ */ jsx(CustomItemsForm, {})
12862
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12863
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12864
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12865
+ ] }),
12866
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
13025
12867
  ] });
13026
12868
  };
13027
- const CustomItemsForm = () => {
12869
+ const BillingAddressForm = ({ order }) => {
12870
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
13028
12871
  const form = useForm({
12872
+ defaultValues: {
12873
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12874
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12875
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12876
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12877
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12878
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12879
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12880
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12881
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12882
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12883
+ },
13029
12884
  resolver: zodResolver(schema)
13030
12885
  });
13031
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13033
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13036
- ] }) })
13037
- ] }) });
12886
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12887
+ const { handleSuccess } = useRouteModal();
12888
+ const onSubmit = form.handleSubmit(async (data) => {
12889
+ await mutateAsync(
12890
+ { billing_address: data },
12891
+ {
12892
+ onSuccess: () => {
12893
+ handleSuccess();
12894
+ },
12895
+ onError: (error) => {
12896
+ toast.error(error.message);
12897
+ }
12898
+ }
12899
+ );
12900
+ });
12901
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12902
+ KeyboundForm,
12903
+ {
12904
+ className: "flex flex-1 flex-col overflow-hidden",
12905
+ onSubmit,
12906
+ children: [
12907
+ /* @__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: [
12908
+ /* @__PURE__ */ jsx(
12909
+ Form$2.Field,
12910
+ {
12911
+ control: form.control,
12912
+ name: "country_code",
12913
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12914
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12915
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12916
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12917
+ ] })
12918
+ }
12919
+ ),
12920
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12921
+ /* @__PURE__ */ jsx(
12922
+ Form$2.Field,
12923
+ {
12924
+ control: form.control,
12925
+ name: "first_name",
12926
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12927
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12928
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12929
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12930
+ ] })
12931
+ }
12932
+ ),
12933
+ /* @__PURE__ */ jsx(
12934
+ Form$2.Field,
12935
+ {
12936
+ control: form.control,
12937
+ name: "last_name",
12938
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12939
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12940
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12941
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12942
+ ] })
12943
+ }
12944
+ )
12945
+ ] }),
12946
+ /* @__PURE__ */ jsx(
12947
+ Form$2.Field,
12948
+ {
12949
+ control: form.control,
12950
+ name: "company",
12951
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12952
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12953
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12954
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12955
+ ] })
12956
+ }
12957
+ ),
12958
+ /* @__PURE__ */ jsx(
12959
+ Form$2.Field,
12960
+ {
12961
+ control: form.control,
12962
+ name: "address_1",
12963
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12964
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12965
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12966
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12967
+ ] })
12968
+ }
12969
+ ),
12970
+ /* @__PURE__ */ jsx(
12971
+ Form$2.Field,
12972
+ {
12973
+ control: form.control,
12974
+ name: "address_2",
12975
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12976
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12977
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12978
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12979
+ ] })
12980
+ }
12981
+ ),
12982
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12983
+ /* @__PURE__ */ jsx(
12984
+ Form$2.Field,
12985
+ {
12986
+ control: form.control,
12987
+ name: "postal_code",
12988
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12989
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12990
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12991
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12992
+ ] })
12993
+ }
12994
+ ),
12995
+ /* @__PURE__ */ jsx(
12996
+ Form$2.Field,
12997
+ {
12998
+ control: form.control,
12999
+ name: "city",
13000
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13001
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13002
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13003
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13004
+ ] })
13005
+ }
13006
+ )
13007
+ ] }),
13008
+ /* @__PURE__ */ jsx(
13009
+ Form$2.Field,
13010
+ {
13011
+ control: form.control,
13012
+ name: "province",
13013
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13014
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13015
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13016
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13017
+ ] })
13018
+ }
13019
+ ),
13020
+ /* @__PURE__ */ jsx(
13021
+ Form$2.Field,
13022
+ {
13023
+ control: form.control,
13024
+ name: "phone",
13025
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13026
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13027
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13028
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13029
+ ] })
13030
+ }
13031
+ )
13032
+ ] }) }),
13033
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13036
+ ] }) })
13037
+ ]
13038
+ }
13039
+ ) });
13038
13040
  };
13039
- const schema = objectType({
13040
- email: stringType().email()
13041
- });
13041
+ const schema = addressSchema;
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13060,8 +13060,8 @@ const routeModule = {
13060
13060
  loader,
13061
13061
  children: [
13062
13062
  {
13063
- Component: BillingAddress,
13064
- path: "/draft-orders/:id/billing-address"
13063
+ Component: CustomItems,
13064
+ path: "/draft-orders/:id/custom-items"
13065
13065
  },
13066
13066
  {
13067
13067
  Component: Email,
@@ -13083,21 +13083,21 @@ const routeModule = {
13083
13083
  Component: SalesChannel,
13084
13084
  path: "/draft-orders/:id/sales-channel"
13085
13085
  },
13086
- {
13087
- Component: Shipping,
13088
- path: "/draft-orders/:id/shipping"
13089
- },
13090
13086
  {
13091
13087
  Component: ShippingAddress,
13092
13088
  path: "/draft-orders/:id/shipping-address"
13093
13089
  },
13090
+ {
13091
+ Component: Shipping,
13092
+ path: "/draft-orders/:id/shipping"
13093
+ },
13094
13094
  {
13095
13095
  Component: TransferOwnership,
13096
13096
  path: "/draft-orders/:id/transfer-ownership"
13097
13097
  },
13098
13098
  {
13099
- Component: CustomItems,
13100
- path: "/draft-orders/:id/custom-items"
13099
+ Component: BillingAddress,
13100
+ path: "/draft-orders/:id/billing-address"
13101
13101
  }
13102
13102
  ]
13103
13103
  }