@medusajs/draft-order 2.12.2-preview-20251206150134 → 2.12.2-preview-20251206180127

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.
@@ -11551,813 +11551,209 @@ const SalesChannelField = ({ control, order }) => {
11551
11551
  const schema$2 = objectType({
11552
11552
  sales_channel_id: stringType().min(1)
11553
11553
  });
11554
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11555
- const Shipping = () => {
11556
- var _a;
11554
+ const ShippingAddress = () => {
11557
11555
  const { id } = useParams();
11558
11556
  const { order, isPending, isError, error } = useOrder(id, {
11559
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11557
+ fields: "+shipping_address"
11560
11558
  });
11561
- const {
11562
- order: preview,
11563
- isPending: isPreviewPending,
11564
- isError: isPreviewError,
11565
- error: previewError
11566
- } = useOrderPreview(id);
11567
- useInitiateOrderEdit({ preview });
11568
- const { onCancel } = useCancelOrderEdit({ preview });
11569
11559
  if (isError) {
11570
11560
  throw error;
11571
11561
  }
11572
- if (isPreviewError) {
11573
- throw previewError;
11574
- }
11575
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11576
- const isReady = preview && !isPreviewPending && order && !isPending;
11577
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11578
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11579
- /* @__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: [
11580
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11581
- /* @__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." }) })
11582
- ] }) }) }),
11583
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11584
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11585
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11586
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11587
- ] }) });
11562
+ const isReady = !isPending && !!order;
11563
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11564
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11565
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11566
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11567
+ ] }),
11568
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11569
+ ] });
11588
11570
  };
11589
- const ShippingForm = ({ preview, order }) => {
11590
- var _a;
11591
- const { setIsOpen } = useStackedModal();
11592
- const [isSubmitting, setIsSubmitting] = useState(false);
11593
- const [data, setData] = useState(null);
11594
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11595
- const { shipping_options } = useShippingOptions(
11596
- {
11597
- id: appliedShippingOptionIds,
11598
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11571
+ const ShippingAddressForm = ({ order }) => {
11572
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11573
+ const form = useForm({
11574
+ defaultValues: {
11575
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11576
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11577
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11578
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11579
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11580
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11581
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11582
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11583
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11584
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11599
11585
  },
11600
- {
11601
- enabled: appliedShippingOptionIds.length > 0
11602
- }
11603
- );
11604
- const uniqueShippingProfiles = useMemo(() => {
11605
- const profiles = /* @__PURE__ */ new Map();
11606
- getUniqueShippingProfiles(order.items).forEach((profile) => {
11607
- profiles.set(profile.id, profile);
11608
- });
11609
- shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11610
- profiles.set(option.shipping_profile_id, option.shipping_profile);
11611
- });
11612
- return Array.from(profiles.values());
11613
- }, [order.items, shipping_options]);
11586
+ resolver: zodResolver(schema$1)
11587
+ });
11588
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11614
11589
  const { handleSuccess } = useRouteModal();
11615
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11616
- const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
11617
- const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
11618
- const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
11619
- const onSubmit = async () => {
11620
- setIsSubmitting(true);
11621
- let requestSucceeded = false;
11622
- await requestOrderEdit(void 0, {
11623
- onError: (e) => {
11624
- toast.error(`Failed to request order edit: ${e.message}`);
11625
- },
11626
- onSuccess: () => {
11627
- requestSucceeded = true;
11628
- }
11629
- });
11630
- if (!requestSucceeded) {
11631
- setIsSubmitting(false);
11632
- return;
11633
- }
11634
- await confirmOrderEdit(void 0, {
11635
- onError: (e) => {
11636
- toast.error(`Failed to confirm order edit: ${e.message}`);
11637
- },
11638
- onSuccess: () => {
11639
- handleSuccess();
11590
+ const onSubmit = form.handleSubmit(async (data) => {
11591
+ await mutateAsync(
11592
+ {
11593
+ shipping_address: {
11594
+ first_name: data.first_name,
11595
+ last_name: data.last_name,
11596
+ company: data.company,
11597
+ address_1: data.address_1,
11598
+ address_2: data.address_2,
11599
+ city: data.city,
11600
+ province: data.province,
11601
+ country_code: data.country_code,
11602
+ postal_code: data.postal_code,
11603
+ phone: data.phone
11604
+ }
11640
11605
  },
11641
- onSettled: () => {
11642
- setIsSubmitting(false);
11643
- }
11644
- });
11645
- };
11646
- const onKeydown = useCallback(
11647
- (e) => {
11648
- if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
11649
- if (data || isSubmitting) {
11650
- return;
11606
+ {
11607
+ onSuccess: () => {
11608
+ handleSuccess();
11609
+ },
11610
+ onError: (error) => {
11611
+ toast.error(error.message);
11651
11612
  }
11652
- onSubmit();
11653
11613
  }
11654
- },
11655
- [data, isSubmitting, onSubmit]
11656
- );
11657
- useEffect(() => {
11658
- document.addEventListener("keydown", onKeydown);
11659
- return () => {
11660
- document.removeEventListener("keydown", onKeydown);
11661
- };
11662
- }, [onKeydown]);
11663
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
11664
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11665
- /* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
11666
- /* @__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: [
11667
- /* @__PURE__ */ jsxs("div", { children: [
11668
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11669
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
11670
- ] }),
11671
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11672
- /* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
11673
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
11614
+ );
11615
+ });
11616
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11617
+ KeyboundForm,
11618
+ {
11619
+ className: "flex flex-1 flex-col overflow-hidden",
11620
+ onSubmit,
11621
+ children: [
11622
+ /* @__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: [
11623
+ /* @__PURE__ */ jsx(
11624
+ Form$2.Field,
11625
+ {
11626
+ control: form.control,
11627
+ name: "country_code",
11628
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11629
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11630
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11631
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11632
+ ] })
11633
+ }
11634
+ ),
11635
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11674
11636
  /* @__PURE__ */ jsx(
11675
- Text,
11637
+ Form$2.Field,
11676
11638
  {
11677
- size: "xsmall",
11678
- weight: "plus",
11679
- className: "text-ui-fg-muted",
11680
- children: "Shipping profile"
11639
+ control: form.control,
11640
+ name: "first_name",
11641
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11642
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11643
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11644
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11645
+ ] })
11681
11646
  }
11682
11647
  ),
11683
11648
  /* @__PURE__ */ jsx(
11684
- Text,
11649
+ Form$2.Field,
11685
11650
  {
11686
- size: "xsmall",
11687
- weight: "plus",
11688
- className: "text-ui-fg-muted",
11689
- children: "Action"
11651
+ control: form.control,
11652
+ name: "last_name",
11653
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11654
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11655
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11656
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11657
+ ] })
11690
11658
  }
11691
11659
  )
11692
11660
  ] }),
11693
- /* @__PURE__ */ jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
11694
- var _a2, _b, _c, _d, _e, _f, _g;
11695
- const items = getItemsWithShippingProfile(
11696
- profile.id,
11697
- order.items
11698
- );
11699
- const hasItems = items.length > 0;
11700
- const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
11701
- (option) => option.shipping_profile_id === profile.id
11702
- );
11703
- const shippingMethod = preview.shipping_methods.find(
11704
- (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
11705
- );
11706
- const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
11707
- (action) => action.action === "SHIPPING_ADD"
11708
- );
11709
- return /* @__PURE__ */ jsxs(
11710
- Accordion.Item,
11711
- {
11712
- value: profile.id,
11713
- className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
11714
- children: [
11715
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
11716
- /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
11717
- /* @__PURE__ */ jsx(Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
11718
- IconButton,
11719
- {
11720
- size: "2xsmall",
11721
- variant: "transparent",
11722
- className: "group/trigger",
11723
- disabled: !hasItems,
11724
- children: /* @__PURE__ */ jsx(TriangleRightMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-90" })
11725
- }
11726
- ) }),
11727
- !shippingOption ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
11728
- /* @__PURE__ */ jsx("div", { className: "shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component-hover flex size-6 items-center justify-center rounded", children: /* @__PURE__ */ jsx(Shopping, { className: "text-ui-fg-subtle" }) }) }),
11729
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
11730
- /* @__PURE__ */ jsx(
11731
- Text,
11732
- {
11733
- size: "small",
11734
- weight: "plus",
11735
- leading: "compact",
11736
- children: profile.name
11737
- }
11738
- ),
11739
- /* @__PURE__ */ jsxs(
11740
- Text,
11741
- {
11742
- size: "small",
11743
- leading: "compact",
11744
- className: "text-ui-fg-subtle",
11745
- children: [
11746
- items.length,
11747
- " ",
11748
- pluralize(items.length, "items", "item")
11749
- ]
11750
- }
11751
- )
11752
- ] })
11753
- ] }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-1 items-center gap-[5px] overflow-hidden max-sm:flex-col max-sm:items-start", children: [
11754
- /* @__PURE__ */ jsx(
11755
- Tooltip,
11756
- {
11757
- content: /* @__PURE__ */ jsx("ul", { children: items.map((item) => {
11758
- var _a3, _b2, _c2;
11759
- return /* @__PURE__ */ jsx(
11760
- "li",
11761
- {
11762
- children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
11763
- },
11764
- item.id
11765
- );
11766
- }) }),
11767
- children: /* @__PURE__ */ jsxs(
11768
- Badge,
11769
- {
11770
- className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
11771
- size: "xsmall",
11772
- children: [
11773
- /* @__PURE__ */ jsx(Shopping, { className: "shrink-0" }),
11774
- /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
11775
- items.reduce(
11776
- (acc, item) => acc + item.quantity,
11777
- 0
11778
- ),
11779
- "x",
11780
- " ",
11781
- pluralize(items.length, "items", "item")
11782
- ] })
11783
- ]
11784
- }
11785
- )
11786
- }
11787
- ),
11788
- /* @__PURE__ */ jsx(
11789
- Tooltip,
11790
- {
11791
- content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
11792
- children: /* @__PURE__ */ jsxs(
11793
- Badge,
11794
- {
11795
- className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
11796
- size: "xsmall",
11797
- children: [
11798
- /* @__PURE__ */ jsx(Buildings, { className: "shrink-0" }),
11799
- /* @__PURE__ */ jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
11800
- ]
11801
- }
11802
- )
11803
- }
11804
- ),
11805
- /* @__PURE__ */ jsx(Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxs(
11806
- Badge,
11807
- {
11808
- className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
11809
- size: "xsmall",
11810
- children: [
11811
- /* @__PURE__ */ jsx(TruckFast, { className: "shrink-0" }),
11812
- /* @__PURE__ */ jsx("span", { className: "truncate", children: shippingOption.name })
11813
- ]
11814
- }
11815
- ) })
11816
- ] })
11817
- ] }),
11818
- shippingOption ? /* @__PURE__ */ jsx(
11819
- ActionMenu,
11820
- {
11821
- groups: [
11822
- {
11823
- actions: [
11824
- hasItems ? {
11825
- label: "Edit shipping option",
11826
- icon: /* @__PURE__ */ jsx(Channels, {}),
11827
- onClick: () => {
11828
- setIsOpen(
11829
- STACKED_FOCUS_MODAL_ID,
11830
- true
11831
- );
11832
- setData({
11833
- shippingProfileId: profile.id,
11834
- shippingOption,
11835
- shippingMethod
11836
- });
11837
- }
11838
- } : void 0,
11839
- {
11840
- label: "Remove shipping option",
11841
- icon: /* @__PURE__ */ jsx(Trash, {}),
11842
- onClick: () => {
11843
- if (shippingMethod) {
11844
- if (addShippingMethodAction) {
11845
- removeActionShippingMethod(
11846
- addShippingMethodAction.id
11847
- );
11848
- } else {
11849
- removeShippingMethod(
11850
- shippingMethod.id
11851
- );
11852
- }
11853
- }
11854
- }
11855
- }
11856
- ].filter(Boolean)
11857
- }
11858
- ]
11859
- }
11860
- ) : /* @__PURE__ */ jsx(
11861
- StackedModalTrigger,
11862
- {
11863
- shippingProfileId: profile.id,
11864
- shippingOption,
11865
- shippingMethod,
11866
- setData,
11867
- children: "Add shipping option"
11868
- }
11869
- )
11870
- ] }),
11871
- /* @__PURE__ */ jsxs(Accordion.Content, { children: [
11872
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11873
- items.map((item, idx) => {
11874
- var _a3, _b2, _c2, _d2, _e2;
11875
- return /* @__PURE__ */ jsxs("div", { children: [
11876
- /* @__PURE__ */ jsxs(
11877
- "div",
11878
- {
11879
- className: "flex items-center gap-x-3 px-3",
11880
- children: [
11881
- /* @__PURE__ */ jsx("div", { className: "flex h-[56px] w-5 flex-col items-center justify-center", children: /* @__PURE__ */ jsx(
11882
- Divider,
11883
- {
11884
- variant: "dashed",
11885
- orientation: "vertical"
11886
- }
11887
- ) }),
11888
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3 py-2", children: [
11889
- /* @__PURE__ */ jsx("div", { className: "flex size-7 items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxs(
11890
- Text,
11891
- {
11892
- size: "small",
11893
- leading: "compact",
11894
- className: "text-ui-fg-subtle",
11895
- children: [
11896
- item.quantity,
11897
- "x"
11898
- ]
11899
- }
11900
- ) }),
11901
- /* @__PURE__ */ jsx(Thumbnail, { thumbnail: item.thumbnail }),
11902
- /* @__PURE__ */ jsxs("div", { children: [
11903
- /* @__PURE__ */ jsxs(
11904
- Text,
11905
- {
11906
- size: "small",
11907
- leading: "compact",
11908
- weight: "plus",
11909
- children: [
11910
- (_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
11911
- " (",
11912
- (_c2 = item.variant) == null ? void 0 : _c2.title,
11913
- ")"
11914
- ]
11915
- }
11916
- ),
11917
- /* @__PURE__ */ jsx(
11918
- Text,
11919
- {
11920
- size: "small",
11921
- leading: "compact",
11922
- className: "text-ui-fg-subtle",
11923
- children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
11924
- }
11925
- )
11926
- ] })
11927
- ] })
11928
- ]
11929
- },
11930
- item.id
11931
- ),
11932
- idx !== items.length - 1 && /* @__PURE__ */ jsx(Divider, { variant: "dashed" })
11933
- ] }, item.id);
11934
- })
11935
- ] })
11936
- ]
11937
- },
11938
- profile.id
11939
- );
11940
- }) })
11941
- ] }) })
11942
- ] }) }),
11943
- /* @__PURE__ */ jsx(
11944
- StackedFocusModal,
11945
- {
11946
- id: STACKED_FOCUS_MODAL_ID,
11947
- onOpenChangeCallback: (open) => {
11948
- if (!open) {
11949
- setData(null);
11950
- }
11951
- return open;
11952
- },
11953
- children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
11954
- }
11955
- )
11956
- ] }),
11957
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
11958
- /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11959
- /* @__PURE__ */ jsx(
11960
- Button,
11961
- {
11962
- size: "small",
11963
- type: "button",
11964
- isLoading: isSubmitting,
11965
- onClick: onSubmit,
11966
- children: "Save"
11967
- }
11968
- )
11969
- ] }) })
11970
- ] });
11971
- };
11972
- const StackedModalTrigger = ({
11973
- shippingProfileId,
11974
- shippingOption,
11975
- shippingMethod,
11976
- setData,
11977
- children
11978
- }) => {
11979
- const { setIsOpen, getIsOpen } = useStackedModal();
11980
- const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
11981
- const onToggle = () => {
11982
- if (isOpen) {
11983
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11984
- setData(null);
11985
- } else {
11986
- setIsOpen(STACKED_FOCUS_MODAL_ID, true);
11987
- setData({
11988
- shippingProfileId,
11989
- shippingOption,
11990
- shippingMethod
11991
- });
11992
- }
11993
- };
11994
- return /* @__PURE__ */ jsx(
11995
- Button,
11996
- {
11997
- size: "small",
11998
- variant: "secondary",
11999
- onClick: onToggle,
12000
- className: "text-ui-fg-primary shrink-0",
12001
- children
12002
- }
12003
- );
12004
- };
12005
- const ShippingProfileForm = ({
12006
- data,
12007
- order,
12008
- preview
12009
- }) => {
12010
- var _a, _b, _c, _d, _e, _f;
12011
- const { setIsOpen } = useStackedModal();
12012
- const form = useForm({
12013
- resolver: zodResolver(shippingMethodSchema),
12014
- defaultValues: {
12015
- location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
12016
- shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12017
- custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12018
- }
12019
- });
12020
- const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12021
- const {
12022
- mutateAsync: updateShippingMethod,
12023
- isPending: isUpdatingShippingMethod
12024
- } = useDraftOrderUpdateShippingMethod(order.id);
12025
- const onSubmit = form.handleSubmit(async (values) => {
12026
- if (isEqual(values, form.formState.defaultValues)) {
12027
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12028
- return;
12029
- }
12030
- if (data.shippingMethod) {
12031
- await updateShippingMethod(
12032
- {
12033
- method_id: data.shippingMethod.id,
12034
- shipping_option_id: values.shipping_option_id,
12035
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12036
- },
12037
- {
12038
- onError: (e) => {
12039
- toast.error(e.message);
12040
- },
12041
- onSuccess: () => {
12042
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12043
- }
12044
- }
12045
- );
12046
- return;
12047
- }
12048
- await addShippingMethod(
12049
- {
12050
- shipping_option_id: values.shipping_option_id,
12051
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12052
- },
12053
- {
12054
- onError: (e) => {
12055
- toast.error(e.message);
12056
- },
12057
- onSuccess: () => {
12058
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12059
- }
12060
- }
12061
- );
12062
- });
12063
- return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
12064
- KeyboundForm,
12065
- {
12066
- className: "flex h-full flex-col overflow-hidden",
12067
- onSubmit,
12068
- children: [
12069
- /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
12070
- /* @__PURE__ */ jsx(StackedFocusModal.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: [
12071
- /* @__PURE__ */ jsxs("div", { children: [
12072
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12073
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
12074
- ] }),
12075
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12076
11661
  /* @__PURE__ */ jsx(
12077
- LocationField,
11662
+ Form$2.Field,
12078
11663
  {
12079
11664
  control: form.control,
12080
- setValue: form.setValue
11665
+ name: "company",
11666
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11667
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11668
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11669
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11670
+ ] })
12081
11671
  }
12082
11672
  ),
12083
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12084
11673
  /* @__PURE__ */ jsx(
12085
- ShippingOptionField,
11674
+ Form$2.Field,
12086
11675
  {
12087
- shippingProfileId: data.shippingProfileId,
12088
- preview,
12089
- control: form.control
11676
+ control: form.control,
11677
+ name: "address_1",
11678
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11679
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11680
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11681
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11682
+ ] })
12090
11683
  }
12091
11684
  ),
12092
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12093
11685
  /* @__PURE__ */ jsx(
12094
- CustomAmountField,
11686
+ Form$2.Field,
12095
11687
  {
12096
11688
  control: form.control,
12097
- currencyCode: order.currency_code
11689
+ name: "address_2",
11690
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11691
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11692
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11693
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11694
+ ] })
12098
11695
  }
12099
11696
  ),
12100
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12101
- /* @__PURE__ */ jsx(
12102
- ItemsPreview,
12103
- {
12104
- order,
12105
- shippingProfileId: data.shippingProfileId
12106
- }
12107
- )
12108
- ] }) }) }),
12109
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12110
- /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12111
- /* @__PURE__ */ jsx(
12112
- Button,
12113
- {
12114
- size: "small",
12115
- type: "submit",
12116
- isLoading: isPending || isUpdatingShippingMethod,
12117
- children: data.shippingMethod ? "Update" : "Add"
12118
- }
12119
- )
12120
- ] }) })
12121
- ]
12122
- }
12123
- ) }) });
12124
- };
12125
- const shippingMethodSchema = objectType({
12126
- location_id: stringType(),
12127
- shipping_option_id: stringType(),
12128
- custom_amount: unionType([numberType(), stringType()]).optional()
12129
- });
12130
- const ItemsPreview = ({ order, shippingProfileId }) => {
12131
- const matches = order.items.filter(
12132
- (item) => {
12133
- var _a, _b, _c;
12134
- return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12135
- }
12136
- );
12137
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
12138
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12139
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12140
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12141
- ] }) }),
12142
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12143
- /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
12144
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
12145
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
12146
- ] }),
12147
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
12148
- "div",
12149
- {
12150
- className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
12151
- children: [
12152
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12153
- /* @__PURE__ */ jsx(
12154
- Thumbnail,
12155
- {
12156
- thumbnail: item.thumbnail,
12157
- alt: item.product_title ?? void 0
12158
- }
12159
- ),
12160
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12161
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
12162
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12163
- /* @__PURE__ */ jsxs(
12164
- Text,
12165
- {
12166
- size: "small",
12167
- leading: "compact",
12168
- className: "text-ui-fg-subtle",
12169
- children: [
12170
- "(",
12171
- item.variant_title,
12172
- ")"
12173
- ]
12174
- }
12175
- )
12176
- ] }),
12177
- /* @__PURE__ */ jsx(
12178
- Text,
12179
- {
12180
- size: "small",
12181
- leading: "compact",
12182
- className: "text-ui-fg-subtle",
12183
- children: item.variant_sku
12184
- }
12185
- )
12186
- ] })
12187
- ] }),
12188
- /* @__PURE__ */ jsxs(
12189
- Text,
11697
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11698
+ /* @__PURE__ */ jsx(
11699
+ Form$2.Field,
12190
11700
  {
12191
- size: "small",
12192
- leading: "compact",
12193
- className: "text-ui-fg-subtle",
12194
- children: [
12195
- item.quantity,
12196
- "x"
12197
- ]
11701
+ control: form.control,
11702
+ name: "postal_code",
11703
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11704
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11705
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11706
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11707
+ ] })
12198
11708
  }
12199
- )
12200
- ]
12201
- },
12202
- item.id
12203
- )) : /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
12204
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12205
- /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12206
- 'No items found for "',
12207
- query,
12208
- '".'
12209
- ] })
12210
- ] }) })
12211
- ] })
12212
- ] });
12213
- };
12214
- const LocationField = ({ control, setValue }) => {
12215
- const locations = useComboboxData({
12216
- queryKey: ["locations"],
12217
- queryFn: async (params) => {
12218
- return await sdk.admin.stockLocation.list(params);
12219
- },
12220
- getOptions: (data) => {
12221
- return data.stock_locations.map((location) => ({
12222
- label: location.name,
12223
- value: location.id
12224
- }));
12225
- }
12226
- });
12227
- return /* @__PURE__ */ jsx(
12228
- Form$2.Field,
12229
- {
12230
- control,
12231
- name: "location_id",
12232
- render: ({ field: { onChange, ...field } }) => {
12233
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12234
- /* @__PURE__ */ jsxs("div", { children: [
12235
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12236
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12237
- ] }),
12238
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12239
- Combobox,
12240
- {
12241
- options: locations.options,
12242
- fetchNextPage: locations.fetchNextPage,
12243
- isFetchingNextPage: locations.isFetchingNextPage,
12244
- searchValue: locations.searchValue,
12245
- onSearchValueChange: locations.onSearchValueChange,
12246
- placeholder: "Select location",
12247
- onChange: (value) => {
12248
- setValue("shipping_option_id", "", {
12249
- shouldDirty: true,
12250
- shouldTouch: true
12251
- });
12252
- onChange(value);
12253
- },
12254
- ...field
12255
- }
12256
- ) })
12257
- ] }) });
12258
- }
12259
- }
12260
- );
12261
- };
12262
- const ShippingOptionField = ({
12263
- shippingProfileId,
12264
- preview,
12265
- control
12266
- }) => {
12267
- var _a;
12268
- const locationId = useWatch({ control, name: "location_id" });
12269
- const shippingOptions = useComboboxData({
12270
- queryKey: ["shipping_options", locationId, shippingProfileId],
12271
- queryFn: async (params) => {
12272
- return await sdk.admin.shippingOption.list({
12273
- ...params,
12274
- stock_location_id: locationId,
12275
- shipping_profile_id: shippingProfileId
12276
- });
12277
- },
12278
- getOptions: (data) => {
12279
- return data.shipping_options.map((option) => {
12280
- var _a2;
12281
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12282
- (r) => r.attribute === "is_return" && r.value === "true"
12283
- )) {
12284
- return void 0;
12285
- }
12286
- return {
12287
- label: option.name,
12288
- value: option.id
12289
- };
12290
- }).filter(Boolean);
12291
- },
12292
- enabled: !!locationId && !!shippingProfileId,
12293
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12294
- });
12295
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12296
- return /* @__PURE__ */ jsx(
12297
- Form$2.Field,
12298
- {
12299
- control,
12300
- name: "shipping_option_id",
12301
- render: ({ field }) => {
12302
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12303
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12304
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12305
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
11709
+ ),
11710
+ /* @__PURE__ */ jsx(
11711
+ Form$2.Field,
11712
+ {
11713
+ control: form.control,
11714
+ name: "city",
11715
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11716
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11717
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11718
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11719
+ ] })
11720
+ }
11721
+ )
12306
11722
  ] }),
12307
11723
  /* @__PURE__ */ jsx(
12308
- ConditionalTooltip,
11724
+ Form$2.Field,
12309
11725
  {
12310
- content: tooltipContent,
12311
- showTooltip: !locationId || !shippingProfileId,
12312
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12313
- Combobox,
12314
- {
12315
- options: shippingOptions.options,
12316
- fetchNextPage: shippingOptions.fetchNextPage,
12317
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12318
- searchValue: shippingOptions.searchValue,
12319
- onSearchValueChange: shippingOptions.onSearchValueChange,
12320
- placeholder: "Select shipping option",
12321
- ...field,
12322
- disabled: !locationId || !shippingProfileId
12323
- }
12324
- ) }) })
11726
+ control: form.control,
11727
+ name: "province",
11728
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11729
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11730
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11731
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11732
+ ] })
12325
11733
  }
12326
- )
12327
- ] }) });
12328
- }
12329
- }
12330
- );
12331
- };
12332
- const CustomAmountField = ({
12333
- control,
12334
- currencyCode
12335
- }) => {
12336
- return /* @__PURE__ */ jsx(
12337
- Form$2.Field,
12338
- {
12339
- control,
12340
- name: "custom_amount",
12341
- render: ({ field: { onChange, ...field } }) => {
12342
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12343
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12344
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12345
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12346
- ] }),
12347
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12348
- CurrencyInput,
11734
+ ),
11735
+ /* @__PURE__ */ jsx(
11736
+ Form$2.Field,
12349
11737
  {
12350
- ...field,
12351
- onValueChange: (value) => onChange(value),
12352
- symbol: getNativeSymbol(currencyCode),
12353
- code: currencyCode
11738
+ control: form.control,
11739
+ name: "phone",
11740
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11741
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11742
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11743
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11744
+ ] })
12354
11745
  }
12355
- ) })
12356
- ] });
12357
- }
11746
+ )
11747
+ ] }) }),
11748
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11749
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11750
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11751
+ ] }) })
11752
+ ]
12358
11753
  }
12359
- );
11754
+ ) });
12360
11755
  };
11756
+ const schema$1 = addressSchema;
12361
11757
  const TransferOwnership = () => {
12362
11758
  const { id } = useParams();
12363
11759
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12381,7 +11777,7 @@ const TransferOwnershipForm = ({ order }) => {
12381
11777
  defaultValues: {
12382
11778
  customer_id: order.customer_id || ""
12383
11779
  },
12384
- resolver: zodResolver(schema$1)
11780
+ resolver: zodResolver(schema)
12385
11781
  });
12386
11782
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12387
11783
  const { handleSuccess } = useRouteModal();
@@ -12825,218 +12221,822 @@ const Illustration = () => {
12825
12221
  fill: "white",
12826
12222
  transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12827
12223
  }
12828
- ) })
12829
- ] })
12830
- ]
12831
- }
12832
- );
12833
- };
12834
- const schema$1 = objectType({
12835
- customer_id: stringType().min(1)
12836
- });
12837
- const ShippingAddress = () => {
12838
- const { id } = useParams();
12839
- const { order, isPending, isError, error } = useOrder(id, {
12840
- fields: "+shipping_address"
12841
- });
12842
- if (isError) {
12843
- throw error;
12844
- }
12845
- const isReady = !isPending && !!order;
12846
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12847
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12848
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12849
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12224
+ ) })
12225
+ ] })
12226
+ ]
12227
+ }
12228
+ );
12229
+ };
12230
+ const schema = objectType({
12231
+ customer_id: stringType().min(1)
12232
+ });
12233
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
12234
+ const Shipping = () => {
12235
+ var _a;
12236
+ const { id } = useParams();
12237
+ const { order, isPending, isError, error } = useOrder(id, {
12238
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
12239
+ });
12240
+ const {
12241
+ order: preview,
12242
+ isPending: isPreviewPending,
12243
+ isError: isPreviewError,
12244
+ error: previewError
12245
+ } = useOrderPreview(id);
12246
+ useInitiateOrderEdit({ preview });
12247
+ const { onCancel } = useCancelOrderEdit({ preview });
12248
+ if (isError) {
12249
+ throw error;
12250
+ }
12251
+ if (isPreviewError) {
12252
+ throw previewError;
12253
+ }
12254
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
12255
+ const isReady = preview && !isPreviewPending && order && !isPending;
12256
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
12257
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
12258
+ /* @__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: [
12259
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12260
+ /* @__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." }) })
12261
+ ] }) }) }),
12262
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
12263
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
12264
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
12265
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
12266
+ ] }) });
12267
+ };
12268
+ const ShippingForm = ({ preview, order }) => {
12269
+ var _a;
12270
+ const { setIsOpen } = useStackedModal();
12271
+ const [isSubmitting, setIsSubmitting] = useState(false);
12272
+ const [data, setData] = useState(null);
12273
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
12274
+ const { shipping_options } = useShippingOptions(
12275
+ {
12276
+ id: appliedShippingOptionIds,
12277
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
12278
+ },
12279
+ {
12280
+ enabled: appliedShippingOptionIds.length > 0
12281
+ }
12282
+ );
12283
+ const uniqueShippingProfiles = useMemo(() => {
12284
+ const profiles = /* @__PURE__ */ new Map();
12285
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
12286
+ profiles.set(profile.id, profile);
12287
+ });
12288
+ shipping_options == null ? void 0 : shipping_options.forEach((option) => {
12289
+ profiles.set(option.shipping_profile_id, option.shipping_profile);
12290
+ });
12291
+ return Array.from(profiles.values());
12292
+ }, [order.items, shipping_options]);
12293
+ const { handleSuccess } = useRouteModal();
12294
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
12295
+ const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
12296
+ const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
12297
+ const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
12298
+ const onSubmit = async () => {
12299
+ setIsSubmitting(true);
12300
+ let requestSucceeded = false;
12301
+ await requestOrderEdit(void 0, {
12302
+ onError: (e) => {
12303
+ toast.error(`Failed to request order edit: ${e.message}`);
12304
+ },
12305
+ onSuccess: () => {
12306
+ requestSucceeded = true;
12307
+ }
12308
+ });
12309
+ if (!requestSucceeded) {
12310
+ setIsSubmitting(false);
12311
+ return;
12312
+ }
12313
+ await confirmOrderEdit(void 0, {
12314
+ onError: (e) => {
12315
+ toast.error(`Failed to confirm order edit: ${e.message}`);
12316
+ },
12317
+ onSuccess: () => {
12318
+ handleSuccess();
12319
+ },
12320
+ onSettled: () => {
12321
+ setIsSubmitting(false);
12322
+ }
12323
+ });
12324
+ };
12325
+ const onKeydown = useCallback(
12326
+ (e) => {
12327
+ if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
12328
+ if (data || isSubmitting) {
12329
+ return;
12330
+ }
12331
+ onSubmit();
12332
+ }
12333
+ },
12334
+ [data, isSubmitting, onSubmit]
12335
+ );
12336
+ useEffect(() => {
12337
+ document.addEventListener("keydown", onKeydown);
12338
+ return () => {
12339
+ document.removeEventListener("keydown", onKeydown);
12340
+ };
12341
+ }, [onKeydown]);
12342
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
12343
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
12344
+ /* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
12345
+ /* @__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: [
12346
+ /* @__PURE__ */ jsxs("div", { children: [
12347
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12348
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
12349
+ ] }),
12350
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12351
+ /* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12352
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
12353
+ /* @__PURE__ */ jsx(
12354
+ Text,
12355
+ {
12356
+ size: "xsmall",
12357
+ weight: "plus",
12358
+ className: "text-ui-fg-muted",
12359
+ children: "Shipping profile"
12360
+ }
12361
+ ),
12362
+ /* @__PURE__ */ jsx(
12363
+ Text,
12364
+ {
12365
+ size: "xsmall",
12366
+ weight: "plus",
12367
+ className: "text-ui-fg-muted",
12368
+ children: "Action"
12369
+ }
12370
+ )
12371
+ ] }),
12372
+ /* @__PURE__ */ jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
12373
+ var _a2, _b, _c, _d, _e, _f, _g;
12374
+ const items = getItemsWithShippingProfile(
12375
+ profile.id,
12376
+ order.items
12377
+ );
12378
+ const hasItems = items.length > 0;
12379
+ const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
12380
+ (option) => option.shipping_profile_id === profile.id
12381
+ );
12382
+ const shippingMethod = preview.shipping_methods.find(
12383
+ (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
12384
+ );
12385
+ const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
12386
+ (action) => action.action === "SHIPPING_ADD"
12387
+ );
12388
+ return /* @__PURE__ */ jsxs(
12389
+ Accordion.Item,
12390
+ {
12391
+ value: profile.id,
12392
+ className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
12393
+ children: [
12394
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
12395
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
12396
+ /* @__PURE__ */ jsx(Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
12397
+ IconButton,
12398
+ {
12399
+ size: "2xsmall",
12400
+ variant: "transparent",
12401
+ className: "group/trigger",
12402
+ disabled: !hasItems,
12403
+ children: /* @__PURE__ */ jsx(TriangleRightMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-90" })
12404
+ }
12405
+ ) }),
12406
+ !shippingOption ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12407
+ /* @__PURE__ */ jsx("div", { className: "shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component-hover flex size-6 items-center justify-center rounded", children: /* @__PURE__ */ jsx(Shopping, { className: "text-ui-fg-subtle" }) }) }),
12408
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
12409
+ /* @__PURE__ */ jsx(
12410
+ Text,
12411
+ {
12412
+ size: "small",
12413
+ weight: "plus",
12414
+ leading: "compact",
12415
+ children: profile.name
12416
+ }
12417
+ ),
12418
+ /* @__PURE__ */ jsxs(
12419
+ Text,
12420
+ {
12421
+ size: "small",
12422
+ leading: "compact",
12423
+ className: "text-ui-fg-subtle",
12424
+ children: [
12425
+ items.length,
12426
+ " ",
12427
+ pluralize(items.length, "items", "item")
12428
+ ]
12429
+ }
12430
+ )
12431
+ ] })
12432
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-1 items-center gap-[5px] overflow-hidden max-sm:flex-col max-sm:items-start", children: [
12433
+ /* @__PURE__ */ jsx(
12434
+ Tooltip,
12435
+ {
12436
+ content: /* @__PURE__ */ jsx("ul", { children: items.map((item) => {
12437
+ var _a3, _b2, _c2;
12438
+ return /* @__PURE__ */ jsx(
12439
+ "li",
12440
+ {
12441
+ children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
12442
+ },
12443
+ item.id
12444
+ );
12445
+ }) }),
12446
+ children: /* @__PURE__ */ jsxs(
12447
+ Badge,
12448
+ {
12449
+ className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
12450
+ size: "xsmall",
12451
+ children: [
12452
+ /* @__PURE__ */ jsx(Shopping, { className: "shrink-0" }),
12453
+ /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
12454
+ items.reduce(
12455
+ (acc, item) => acc + item.quantity,
12456
+ 0
12457
+ ),
12458
+ "x",
12459
+ " ",
12460
+ pluralize(items.length, "items", "item")
12461
+ ] })
12462
+ ]
12463
+ }
12464
+ )
12465
+ }
12466
+ ),
12467
+ /* @__PURE__ */ jsx(
12468
+ Tooltip,
12469
+ {
12470
+ content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
12471
+ children: /* @__PURE__ */ jsxs(
12472
+ Badge,
12473
+ {
12474
+ className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
12475
+ size: "xsmall",
12476
+ children: [
12477
+ /* @__PURE__ */ jsx(Buildings, { className: "shrink-0" }),
12478
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
12479
+ ]
12480
+ }
12481
+ )
12482
+ }
12483
+ ),
12484
+ /* @__PURE__ */ jsx(Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxs(
12485
+ Badge,
12486
+ {
12487
+ className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
12488
+ size: "xsmall",
12489
+ children: [
12490
+ /* @__PURE__ */ jsx(TruckFast, { className: "shrink-0" }),
12491
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: shippingOption.name })
12492
+ ]
12493
+ }
12494
+ ) })
12495
+ ] })
12496
+ ] }),
12497
+ shippingOption ? /* @__PURE__ */ jsx(
12498
+ ActionMenu,
12499
+ {
12500
+ groups: [
12501
+ {
12502
+ actions: [
12503
+ hasItems ? {
12504
+ label: "Edit shipping option",
12505
+ icon: /* @__PURE__ */ jsx(Channels, {}),
12506
+ onClick: () => {
12507
+ setIsOpen(
12508
+ STACKED_FOCUS_MODAL_ID,
12509
+ true
12510
+ );
12511
+ setData({
12512
+ shippingProfileId: profile.id,
12513
+ shippingOption,
12514
+ shippingMethod
12515
+ });
12516
+ }
12517
+ } : void 0,
12518
+ {
12519
+ label: "Remove shipping option",
12520
+ icon: /* @__PURE__ */ jsx(Trash, {}),
12521
+ onClick: () => {
12522
+ if (shippingMethod) {
12523
+ if (addShippingMethodAction) {
12524
+ removeActionShippingMethod(
12525
+ addShippingMethodAction.id
12526
+ );
12527
+ } else {
12528
+ removeShippingMethod(
12529
+ shippingMethod.id
12530
+ );
12531
+ }
12532
+ }
12533
+ }
12534
+ }
12535
+ ].filter(Boolean)
12536
+ }
12537
+ ]
12538
+ }
12539
+ ) : /* @__PURE__ */ jsx(
12540
+ StackedModalTrigger,
12541
+ {
12542
+ shippingProfileId: profile.id,
12543
+ shippingOption,
12544
+ shippingMethod,
12545
+ setData,
12546
+ children: "Add shipping option"
12547
+ }
12548
+ )
12549
+ ] }),
12550
+ /* @__PURE__ */ jsxs(Accordion.Content, { children: [
12551
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12552
+ items.map((item, idx) => {
12553
+ var _a3, _b2, _c2, _d2, _e2;
12554
+ return /* @__PURE__ */ jsxs("div", { children: [
12555
+ /* @__PURE__ */ jsxs(
12556
+ "div",
12557
+ {
12558
+ className: "flex items-center gap-x-3 px-3",
12559
+ children: [
12560
+ /* @__PURE__ */ jsx("div", { className: "flex h-[56px] w-5 flex-col items-center justify-center", children: /* @__PURE__ */ jsx(
12561
+ Divider,
12562
+ {
12563
+ variant: "dashed",
12564
+ orientation: "vertical"
12565
+ }
12566
+ ) }),
12567
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3 py-2", children: [
12568
+ /* @__PURE__ */ jsx("div", { className: "flex size-7 items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxs(
12569
+ Text,
12570
+ {
12571
+ size: "small",
12572
+ leading: "compact",
12573
+ className: "text-ui-fg-subtle",
12574
+ children: [
12575
+ item.quantity,
12576
+ "x"
12577
+ ]
12578
+ }
12579
+ ) }),
12580
+ /* @__PURE__ */ jsx(Thumbnail, { thumbnail: item.thumbnail }),
12581
+ /* @__PURE__ */ jsxs("div", { children: [
12582
+ /* @__PURE__ */ jsxs(
12583
+ Text,
12584
+ {
12585
+ size: "small",
12586
+ leading: "compact",
12587
+ weight: "plus",
12588
+ children: [
12589
+ (_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
12590
+ " (",
12591
+ (_c2 = item.variant) == null ? void 0 : _c2.title,
12592
+ ")"
12593
+ ]
12594
+ }
12595
+ ),
12596
+ /* @__PURE__ */ jsx(
12597
+ Text,
12598
+ {
12599
+ size: "small",
12600
+ leading: "compact",
12601
+ className: "text-ui-fg-subtle",
12602
+ children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
12603
+ }
12604
+ )
12605
+ ] })
12606
+ ] })
12607
+ ]
12608
+ },
12609
+ item.id
12610
+ ),
12611
+ idx !== items.length - 1 && /* @__PURE__ */ jsx(Divider, { variant: "dashed" })
12612
+ ] }, item.id);
12613
+ })
12614
+ ] })
12615
+ ]
12616
+ },
12617
+ profile.id
12618
+ );
12619
+ }) })
12620
+ ] }) })
12621
+ ] }) }),
12622
+ /* @__PURE__ */ jsx(
12623
+ StackedFocusModal,
12624
+ {
12625
+ id: STACKED_FOCUS_MODAL_ID,
12626
+ onOpenChangeCallback: (open) => {
12627
+ if (!open) {
12628
+ setData(null);
12629
+ }
12630
+ return open;
12631
+ },
12632
+ children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
12633
+ }
12634
+ )
12850
12635
  ] }),
12851
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12636
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12637
+ /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12638
+ /* @__PURE__ */ jsx(
12639
+ Button,
12640
+ {
12641
+ size: "small",
12642
+ type: "button",
12643
+ isLoading: isSubmitting,
12644
+ onClick: onSubmit,
12645
+ children: "Save"
12646
+ }
12647
+ )
12648
+ ] }) })
12852
12649
  ] });
12853
12650
  };
12854
- const ShippingAddressForm = ({ order }) => {
12855
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12651
+ const StackedModalTrigger = ({
12652
+ shippingProfileId,
12653
+ shippingOption,
12654
+ shippingMethod,
12655
+ setData,
12656
+ children
12657
+ }) => {
12658
+ const { setIsOpen, getIsOpen } = useStackedModal();
12659
+ const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
12660
+ const onToggle = () => {
12661
+ if (isOpen) {
12662
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12663
+ setData(null);
12664
+ } else {
12665
+ setIsOpen(STACKED_FOCUS_MODAL_ID, true);
12666
+ setData({
12667
+ shippingProfileId,
12668
+ shippingOption,
12669
+ shippingMethod
12670
+ });
12671
+ }
12672
+ };
12673
+ return /* @__PURE__ */ jsx(
12674
+ Button,
12675
+ {
12676
+ size: "small",
12677
+ variant: "secondary",
12678
+ onClick: onToggle,
12679
+ className: "text-ui-fg-primary shrink-0",
12680
+ children
12681
+ }
12682
+ );
12683
+ };
12684
+ const ShippingProfileForm = ({
12685
+ data,
12686
+ order,
12687
+ preview
12688
+ }) => {
12689
+ var _a, _b, _c, _d, _e, _f;
12690
+ const { setIsOpen } = useStackedModal();
12856
12691
  const form = useForm({
12692
+ resolver: zodResolver(shippingMethodSchema),
12857
12693
  defaultValues: {
12858
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12859
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12860
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12861
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12862
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12863
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12864
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12865
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12866
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12867
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12868
- },
12869
- resolver: zodResolver(schema)
12694
+ location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
12695
+ shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12696
+ custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12697
+ }
12870
12698
  });
12871
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12872
- const { handleSuccess } = useRouteModal();
12873
- const onSubmit = form.handleSubmit(async (data) => {
12874
- await mutateAsync(
12875
- {
12876
- shipping_address: {
12877
- first_name: data.first_name,
12878
- last_name: data.last_name,
12879
- company: data.company,
12880
- address_1: data.address_1,
12881
- address_2: data.address_2,
12882
- city: data.city,
12883
- province: data.province,
12884
- country_code: data.country_code,
12885
- postal_code: data.postal_code,
12886
- phone: data.phone
12699
+ const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12700
+ const {
12701
+ mutateAsync: updateShippingMethod,
12702
+ isPending: isUpdatingShippingMethod
12703
+ } = useDraftOrderUpdateShippingMethod(order.id);
12704
+ const onSubmit = form.handleSubmit(async (values) => {
12705
+ if (isEqual(values, form.formState.defaultValues)) {
12706
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12707
+ return;
12708
+ }
12709
+ if (data.shippingMethod) {
12710
+ await updateShippingMethod(
12711
+ {
12712
+ method_id: data.shippingMethod.id,
12713
+ shipping_option_id: values.shipping_option_id,
12714
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12715
+ },
12716
+ {
12717
+ onError: (e) => {
12718
+ toast.error(e.message);
12719
+ },
12720
+ onSuccess: () => {
12721
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12722
+ }
12887
12723
  }
12724
+ );
12725
+ return;
12726
+ }
12727
+ await addShippingMethod(
12728
+ {
12729
+ shipping_option_id: values.shipping_option_id,
12730
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12888
12731
  },
12889
12732
  {
12890
- onSuccess: () => {
12891
- handleSuccess();
12733
+ onError: (e) => {
12734
+ toast.error(e.message);
12892
12735
  },
12893
- onError: (error) => {
12894
- toast.error(error.message);
12736
+ onSuccess: () => {
12737
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12895
12738
  }
12896
12739
  }
12897
12740
  );
12898
12741
  });
12899
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12742
+ return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
12900
12743
  KeyboundForm,
12901
12744
  {
12902
- className: "flex flex-1 flex-col overflow-hidden",
12745
+ className: "flex h-full flex-col overflow-hidden",
12903
12746
  onSubmit,
12904
12747
  children: [
12905
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
12748
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
12749
+ /* @__PURE__ */ jsx(StackedFocusModal.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: [
12750
+ /* @__PURE__ */ jsxs("div", { children: [
12751
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12752
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
12753
+ ] }),
12754
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12906
12755
  /* @__PURE__ */ jsx(
12907
- Form$2.Field,
12756
+ LocationField,
12908
12757
  {
12909
12758
  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
- ] })
12759
+ setValue: form.setValue
12916
12760
  }
12917
12761
  ),
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
- ] }),
12762
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12944
12763
  /* @__PURE__ */ jsx(
12945
- Form$2.Field,
12764
+ ShippingOptionField,
12946
12765
  {
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
- ] })
12766
+ shippingProfileId: data.shippingProfileId,
12767
+ preview,
12768
+ control: form.control
12954
12769
  }
12955
12770
  ),
12771
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12956
12772
  /* @__PURE__ */ jsx(
12957
- Form$2.Field,
12773
+ CustomAmountField,
12958
12774
  {
12959
12775
  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
- ] })
12776
+ currencyCode: order.currency_code
12966
12777
  }
12967
12778
  ),
12779
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12968
12780
  /* @__PURE__ */ jsx(
12969
- Form$2.Field,
12781
+ ItemsPreview,
12970
12782
  {
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, {})
12783
+ order,
12784
+ shippingProfileId: data.shippingProfileId
12785
+ }
12786
+ )
12787
+ ] }) }) }),
12788
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12789
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12790
+ /* @__PURE__ */ jsx(
12791
+ Button,
12792
+ {
12793
+ size: "small",
12794
+ type: "submit",
12795
+ isLoading: isPending || isUpdatingShippingMethod,
12796
+ children: data.shippingMethod ? "Update" : "Add"
12797
+ }
12798
+ )
12799
+ ] }) })
12800
+ ]
12801
+ }
12802
+ ) }) });
12803
+ };
12804
+ const shippingMethodSchema = objectType({
12805
+ location_id: stringType(),
12806
+ shipping_option_id: stringType(),
12807
+ custom_amount: unionType([numberType(), stringType()]).optional()
12808
+ });
12809
+ const ItemsPreview = ({ order, shippingProfileId }) => {
12810
+ const matches = order.items.filter(
12811
+ (item) => {
12812
+ var _a, _b, _c;
12813
+ return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12814
+ }
12815
+ );
12816
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
12817
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12818
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12819
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12820
+ ] }) }),
12821
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12822
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
12823
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
12824
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
12825
+ ] }),
12826
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
12827
+ "div",
12828
+ {
12829
+ className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
12830
+ children: [
12831
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12832
+ /* @__PURE__ */ jsx(
12833
+ Thumbnail,
12834
+ {
12835
+ thumbnail: item.thumbnail,
12836
+ alt: item.product_title ?? void 0
12837
+ }
12838
+ ),
12839
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12840
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
12841
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12842
+ /* @__PURE__ */ jsxs(
12843
+ Text,
12844
+ {
12845
+ size: "small",
12846
+ leading: "compact",
12847
+ className: "text-ui-fg-subtle",
12848
+ children: [
12849
+ "(",
12850
+ item.variant_title,
12851
+ ")"
12852
+ ]
12853
+ }
12854
+ )
12855
+ ] }),
12856
+ /* @__PURE__ */ jsx(
12857
+ Text,
12858
+ {
12859
+ size: "small",
12860
+ leading: "compact",
12861
+ className: "text-ui-fg-subtle",
12862
+ children: item.variant_sku
12863
+ }
12864
+ )
12977
12865
  ] })
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,
12866
+ ] }),
12867
+ /* @__PURE__ */ jsxs(
12868
+ Text,
12995
12869
  {
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
- ] })
12870
+ size: "small",
12871
+ leading: "compact",
12872
+ className: "text-ui-fg-subtle",
12873
+ children: [
12874
+ item.quantity,
12875
+ "x"
12876
+ ]
13003
12877
  }
13004
12878
  )
12879
+ ]
12880
+ },
12881
+ item.id
12882
+ )) : /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
12883
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12884
+ /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12885
+ 'No items found for "',
12886
+ query,
12887
+ '".'
12888
+ ] })
12889
+ ] }) })
12890
+ ] })
12891
+ ] });
12892
+ };
12893
+ const LocationField = ({ control, setValue }) => {
12894
+ const locations = useComboboxData({
12895
+ queryKey: ["locations"],
12896
+ queryFn: async (params) => {
12897
+ return await sdk.admin.stockLocation.list(params);
12898
+ },
12899
+ getOptions: (data) => {
12900
+ return data.stock_locations.map((location) => ({
12901
+ label: location.name,
12902
+ value: location.id
12903
+ }));
12904
+ }
12905
+ });
12906
+ return /* @__PURE__ */ jsx(
12907
+ Form$2.Field,
12908
+ {
12909
+ control,
12910
+ name: "location_id",
12911
+ render: ({ field: { onChange, ...field } }) => {
12912
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12913
+ /* @__PURE__ */ jsxs("div", { children: [
12914
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12915
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
13005
12916
  ] }),
13006
- /* @__PURE__ */ jsx(
13007
- Form$2.Field,
12917
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12918
+ Combobox,
13008
12919
  {
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
- ] })
12920
+ options: locations.options,
12921
+ fetchNextPage: locations.fetchNextPage,
12922
+ isFetchingNextPage: locations.isFetchingNextPage,
12923
+ searchValue: locations.searchValue,
12924
+ onSearchValueChange: locations.onSearchValueChange,
12925
+ placeholder: "Select location",
12926
+ onChange: (value) => {
12927
+ setValue("shipping_option_id", "", {
12928
+ shouldDirty: true,
12929
+ shouldTouch: true
12930
+ });
12931
+ onChange(value);
12932
+ },
12933
+ ...field
13016
12934
  }
13017
- ),
12935
+ ) })
12936
+ ] }) });
12937
+ }
12938
+ }
12939
+ );
12940
+ };
12941
+ const ShippingOptionField = ({
12942
+ shippingProfileId,
12943
+ preview,
12944
+ control
12945
+ }) => {
12946
+ var _a;
12947
+ const locationId = useWatch({ control, name: "location_id" });
12948
+ const shippingOptions = useComboboxData({
12949
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12950
+ queryFn: async (params) => {
12951
+ return await sdk.admin.shippingOption.list({
12952
+ ...params,
12953
+ stock_location_id: locationId,
12954
+ shipping_profile_id: shippingProfileId
12955
+ });
12956
+ },
12957
+ getOptions: (data) => {
12958
+ return data.shipping_options.map((option) => {
12959
+ var _a2;
12960
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12961
+ (r) => r.attribute === "is_return" && r.value === "true"
12962
+ )) {
12963
+ return void 0;
12964
+ }
12965
+ return {
12966
+ label: option.name,
12967
+ value: option.id
12968
+ };
12969
+ }).filter(Boolean);
12970
+ },
12971
+ enabled: !!locationId && !!shippingProfileId,
12972
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12973
+ });
12974
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12975
+ return /* @__PURE__ */ jsx(
12976
+ Form$2.Field,
12977
+ {
12978
+ control,
12979
+ name: "shipping_option_id",
12980
+ render: ({ field }) => {
12981
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12982
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12983
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12984
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12985
+ ] }),
13018
12986
  /* @__PURE__ */ jsx(
13019
- Form$2.Field,
12987
+ ConditionalTooltip,
13020
12988
  {
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
- ] })
12989
+ content: tooltipContent,
12990
+ showTooltip: !locationId || !shippingProfileId,
12991
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12992
+ Combobox,
12993
+ {
12994
+ options: shippingOptions.options,
12995
+ fetchNextPage: shippingOptions.fetchNextPage,
12996
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12997
+ searchValue: shippingOptions.searchValue,
12998
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12999
+ placeholder: "Select shipping option",
13000
+ ...field,
13001
+ disabled: !locationId || !shippingProfileId
13002
+ }
13003
+ ) }) })
13028
13004
  }
13029
13005
  )
13030
- ] }) }),
13031
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13034
- ] }) })
13035
- ]
13006
+ ] }) });
13007
+ }
13036
13008
  }
13037
- ) });
13009
+ );
13010
+ };
13011
+ const CustomAmountField = ({
13012
+ control,
13013
+ currencyCode
13014
+ }) => {
13015
+ return /* @__PURE__ */ jsx(
13016
+ Form$2.Field,
13017
+ {
13018
+ control,
13019
+ name: "custom_amount",
13020
+ render: ({ field: { onChange, ...field } }) => {
13021
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
13022
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
13023
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
13024
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
13025
+ ] }),
13026
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13027
+ CurrencyInput,
13028
+ {
13029
+ ...field,
13030
+ onValueChange: (value) => onChange(value),
13031
+ symbol: getNativeSymbol(currencyCode),
13032
+ code: currencyCode
13033
+ }
13034
+ ) })
13035
+ ] });
13036
+ }
13037
+ }
13038
+ );
13038
13039
  };
13039
- const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13086,16 +13086,16 @@ const routeModule = {
13086
13086
  path: "/draft-orders/:id/sales-channel"
13087
13087
  },
13088
13088
  {
13089
- Component: Shipping,
13090
- path: "/draft-orders/:id/shipping"
13089
+ Component: ShippingAddress,
13090
+ path: "/draft-orders/:id/shipping-address"
13091
13091
  },
13092
13092
  {
13093
13093
  Component: TransferOwnership,
13094
13094
  path: "/draft-orders/:id/transfer-ownership"
13095
13095
  },
13096
13096
  {
13097
- Component: ShippingAddress,
13098
- path: "/draft-orders/:id/shipping-address"
13097
+ Component: Shipping,
13098
+ path: "/draft-orders/:id/shipping"
13099
13099
  }
13100
13100
  ]
13101
13101
  }