@medusajs/draft-order 2.11.0-preview-20251018150154 → 2.11.0-preview-20251018180153

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.
@@ -9778,74 +9778,6 @@ const CustomItemsForm = () => {
9778
9778
  const schema$4 = objectType({
9779
9779
  email: stringType().email()
9780
9780
  });
9781
- const Email = () => {
9782
- const { id } = useParams();
9783
- const { order, isPending, isError, error } = useOrder(id, {
9784
- fields: "+email"
9785
- });
9786
- if (isError) {
9787
- throw error;
9788
- }
9789
- const isReady = !isPending && !!order;
9790
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9791
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9792
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9793
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9794
- ] }),
9795
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9796
- ] });
9797
- };
9798
- const EmailForm = ({ order }) => {
9799
- const form = useForm({
9800
- defaultValues: {
9801
- email: order.email ?? ""
9802
- },
9803
- resolver: zodResolver(schema$3)
9804
- });
9805
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
- const { handleSuccess } = useRouteModal();
9807
- const onSubmit = form.handleSubmit(async (data) => {
9808
- await mutateAsync(
9809
- { email: data.email },
9810
- {
9811
- onSuccess: () => {
9812
- handleSuccess();
9813
- },
9814
- onError: (error) => {
9815
- toast.error(error.message);
9816
- }
9817
- }
9818
- );
9819
- });
9820
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9821
- KeyboundForm,
9822
- {
9823
- className: "flex flex-1 flex-col overflow-hidden",
9824
- onSubmit,
9825
- children: [
9826
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9827
- Form$2.Field,
9828
- {
9829
- control: form.control,
9830
- name: "email",
9831
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9832
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9833
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9834
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9835
- ] })
9836
- }
9837
- ) }),
9838
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9839
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9840
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9841
- ] }) })
9842
- ]
9843
- }
9844
- ) });
9845
- };
9846
- const schema$3 = objectType({
9847
- email: stringType().email()
9848
- });
9849
9781
  const NumberInput = forwardRef(
9850
9782
  ({
9851
9783
  value,
@@ -11475,7 +11407,7 @@ const SalesChannelForm = ({ order }) => {
11475
11407
  defaultValues: {
11476
11408
  sales_channel_id: order.sales_channel_id || ""
11477
11409
  },
11478
- resolver: zodResolver(schema$2)
11410
+ resolver: zodResolver(schema$3)
11479
11411
  });
11480
11412
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11481
11413
  const { handleSuccess } = useRouteModal();
@@ -11550,7 +11482,7 @@ const SalesChannelField = ({ control, order }) => {
11550
11482
  }
11551
11483
  );
11552
11484
  };
11553
- const schema$2 = objectType({
11485
+ const schema$3 = objectType({
11554
11486
  sales_channel_id: stringType().min(1)
11555
11487
  });
11556
11488
  const ShippingAddress = () => {
@@ -11585,7 +11517,7 @@ const ShippingAddressForm = ({ order }) => {
11585
11517
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11586
11518
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11587
11519
  },
11588
- resolver: zodResolver(schema$1)
11520
+ resolver: zodResolver(schema$2)
11589
11521
  });
11590
11522
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11591
11523
  const { handleSuccess } = useRouteModal();
@@ -11755,531 +11687,55 @@ const ShippingAddressForm = ({ order }) => {
11755
11687
  }
11756
11688
  ) });
11757
11689
  };
11758
- const schema$1 = addressSchema;
11759
- const TransferOwnership = () => {
11690
+ const schema$2 = addressSchema;
11691
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11692
+ const Shipping = () => {
11693
+ var _a;
11760
11694
  const { id } = useParams();
11761
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
11762
- fields: "id,customer_id,customer.*"
11695
+ const { order, isPending, isError, error } = useOrder(id, {
11696
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11763
11697
  });
11698
+ const {
11699
+ order: preview,
11700
+ isPending: isPreviewPending,
11701
+ isError: isPreviewError,
11702
+ error: previewError
11703
+ } = useOrderPreview(id);
11704
+ useInitiateOrderEdit({ preview });
11705
+ const { onCancel } = useCancelOrderEdit({ preview });
11764
11706
  if (isError) {
11765
11707
  throw error;
11766
11708
  }
11767
- const isReady = !isPending && !!draft_order;
11768
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11769
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11770
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
11771
- /* @__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" }) })
11772
- ] }),
11773
- isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
11774
- ] });
11709
+ if (isPreviewError) {
11710
+ throw previewError;
11711
+ }
11712
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11713
+ const isReady = preview && !isPreviewPending && order && !isPending;
11714
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11715
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11716
+ /* @__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: [
11717
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11718
+ /* @__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." }) })
11719
+ ] }) }) }),
11720
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11721
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11722
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11723
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11724
+ ] }) });
11775
11725
  };
11776
- const TransferOwnershipForm = ({ order }) => {
11777
- var _a, _b;
11778
- const form = useForm({
11779
- defaultValues: {
11780
- customer_id: order.customer_id || ""
11781
- },
11782
- resolver: zodResolver(schema)
11783
- });
11784
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11785
- const { handleSuccess } = useRouteModal();
11786
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
11787
- const currentCustomer = order.customer ? {
11788
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
11789
- value: order.customer.id
11790
- } : null;
11791
- const onSubmit = form.handleSubmit(async (data) => {
11792
- await mutateAsync(
11793
- { customer_id: data.customer_id },
11794
- {
11795
- onSuccess: () => {
11796
- toast.success("Customer updated");
11797
- handleSuccess();
11798
- },
11799
- onError: (error) => {
11800
- toast.error(error.message);
11801
- }
11802
- }
11803
- );
11804
- });
11805
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11806
- KeyboundForm,
11726
+ const ShippingForm = ({ preview, order }) => {
11727
+ var _a;
11728
+ const { setIsOpen } = useStackedModal();
11729
+ const [isSubmitting, setIsSubmitting] = useState(false);
11730
+ const [data, setData] = useState(null);
11731
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11732
+ const { shipping_options } = useShippingOptions(
11807
11733
  {
11808
- className: "flex flex-1 flex-col overflow-hidden",
11809
- onSubmit,
11810
- children: [
11811
- /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
11812
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
11813
- currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
11814
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11815
- /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
11816
- /* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
11817
- ] }),
11818
- /* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
11819
- /* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
11820
- /* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
11821
- ] })
11822
- ] }),
11823
- /* @__PURE__ */ jsx(
11824
- CustomerField,
11825
- {
11826
- control: form.control,
11827
- currentCustomerId: order.customer_id
11828
- }
11829
- )
11830
- ] }),
11831
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11832
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
11833
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11834
- ] }) })
11835
- ]
11836
- }
11837
- ) });
11838
- };
11839
- const CustomerField = ({ control, currentCustomerId }) => {
11840
- const customers = useComboboxData({
11841
- queryFn: async (params) => {
11842
- return await sdk.admin.customer.list({
11843
- ...params,
11844
- id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
11845
- });
11734
+ id: appliedShippingOptionIds,
11735
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11846
11736
  },
11847
- queryKey: ["customers"],
11848
- getOptions: (data) => {
11849
- return data.customers.map((customer) => {
11850
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
11851
- return {
11852
- label: name ? `${name} (${customer.email})` : customer.email,
11853
- value: customer.id
11854
- };
11855
- });
11856
- }
11857
- });
11858
- return /* @__PURE__ */ jsx(
11859
- Form$2.Field,
11860
11737
  {
11861
- name: "customer_id",
11862
- control,
11863
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
11864
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11865
- /* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
11866
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
11867
- ] }),
11868
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11869
- Combobox,
11870
- {
11871
- options: customers.options,
11872
- fetchNextPage: customers.fetchNextPage,
11873
- isFetchingNextPage: customers.isFetchingNextPage,
11874
- searchValue: customers.searchValue,
11875
- onSearchValueChange: customers.onSearchValueChange,
11876
- placeholder: "Select customer",
11877
- ...field
11878
- }
11879
- ) }),
11880
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11881
- ] })
11882
- }
11883
- );
11884
- };
11885
- const Illustration = () => {
11886
- return /* @__PURE__ */ jsxs(
11887
- "svg",
11888
- {
11889
- width: "280",
11890
- height: "180",
11891
- viewBox: "0 0 280 180",
11892
- fill: "none",
11893
- xmlns: "http://www.w3.org/2000/svg",
11894
- children: [
11895
- /* @__PURE__ */ jsx(
11896
- "rect",
11897
- {
11898
- x: "0.00428286",
11899
- y: "-0.742904",
11900
- width: "33.5",
11901
- height: "65.5",
11902
- rx: "6.75",
11903
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
11904
- fill: "#D4D4D8",
11905
- stroke: "#52525B",
11906
- strokeWidth: "1.5"
11907
- }
11908
- ),
11909
- /* @__PURE__ */ jsx(
11910
- "rect",
11911
- {
11912
- x: "0.00428286",
11913
- y: "-0.742904",
11914
- width: "33.5",
11915
- height: "65.5",
11916
- rx: "6.75",
11917
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
11918
- fill: "white",
11919
- stroke: "#52525B",
11920
- strokeWidth: "1.5"
11921
- }
11922
- ),
11923
- /* @__PURE__ */ jsx(
11924
- "path",
11925
- {
11926
- d: "M180.579 107.142L179.126 107.959",
11927
- stroke: "#52525B",
11928
- strokeWidth: "1.5",
11929
- strokeLinecap: "round",
11930
- strokeLinejoin: "round"
11931
- }
11932
- ),
11933
- /* @__PURE__ */ jsx(
11934
- "path",
11935
- {
11936
- opacity: "0.88",
11937
- d: "M182.305 109.546L180.257 109.534",
11938
- stroke: "#52525B",
11939
- strokeWidth: "1.5",
11940
- strokeLinecap: "round",
11941
- strokeLinejoin: "round"
11942
- }
11943
- ),
11944
- /* @__PURE__ */ jsx(
11945
- "path",
11946
- {
11947
- opacity: "0.75",
11948
- d: "M180.551 111.93L179.108 111.096",
11949
- stroke: "#52525B",
11950
- strokeWidth: "1.5",
11951
- strokeLinecap: "round",
11952
- strokeLinejoin: "round"
11953
- }
11954
- ),
11955
- /* @__PURE__ */ jsx(
11956
- "path",
11957
- {
11958
- opacity: "0.63",
11959
- d: "M176.347 112.897L176.354 111.73",
11960
- stroke: "#52525B",
11961
- strokeWidth: "1.5",
11962
- strokeLinecap: "round",
11963
- strokeLinejoin: "round"
11964
- }
11965
- ),
11966
- /* @__PURE__ */ jsx(
11967
- "path",
11968
- {
11969
- opacity: "0.5",
11970
- d: "M172.153 111.881L173.606 111.064",
11971
- stroke: "#52525B",
11972
- strokeWidth: "1.5",
11973
- strokeLinecap: "round",
11974
- strokeLinejoin: "round"
11975
- }
11976
- ),
11977
- /* @__PURE__ */ jsx(
11978
- "path",
11979
- {
11980
- opacity: "0.38",
11981
- d: "M170.428 109.478L172.476 109.489",
11982
- stroke: "#52525B",
11983
- strokeWidth: "1.5",
11984
- strokeLinecap: "round",
11985
- strokeLinejoin: "round"
11986
- }
11987
- ),
11988
- /* @__PURE__ */ jsx(
11989
- "path",
11990
- {
11991
- opacity: "0.25",
11992
- d: "M172.181 107.094L173.624 107.928",
11993
- stroke: "#52525B",
11994
- strokeWidth: "1.5",
11995
- strokeLinecap: "round",
11996
- strokeLinejoin: "round"
11997
- }
11998
- ),
11999
- /* @__PURE__ */ jsx(
12000
- "path",
12001
- {
12002
- opacity: "0.13",
12003
- d: "M176.386 106.126L176.379 107.294",
12004
- stroke: "#52525B",
12005
- strokeWidth: "1.5",
12006
- strokeLinecap: "round",
12007
- strokeLinejoin: "round"
12008
- }
12009
- ),
12010
- /* @__PURE__ */ jsx(
12011
- "rect",
12012
- {
12013
- width: "12",
12014
- height: "3",
12015
- rx: "1.5",
12016
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12017
- fill: "#D4D4D8"
12018
- }
12019
- ),
12020
- /* @__PURE__ */ jsx(
12021
- "rect",
12022
- {
12023
- x: "0.00428286",
12024
- y: "-0.742904",
12025
- width: "33.5",
12026
- height: "65.5",
12027
- rx: "6.75",
12028
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12029
- fill: "#D4D4D8",
12030
- stroke: "#52525B",
12031
- strokeWidth: "1.5"
12032
- }
12033
- ),
12034
- /* @__PURE__ */ jsx(
12035
- "rect",
12036
- {
12037
- x: "0.00428286",
12038
- y: "-0.742904",
12039
- width: "33.5",
12040
- height: "65.5",
12041
- rx: "6.75",
12042
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12043
- fill: "white",
12044
- stroke: "#52525B",
12045
- strokeWidth: "1.5"
12046
- }
12047
- ),
12048
- /* @__PURE__ */ jsx(
12049
- "rect",
12050
- {
12051
- width: "12",
12052
- height: "3",
12053
- rx: "1.5",
12054
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12055
- fill: "#D4D4D8"
12056
- }
12057
- ),
12058
- /* @__PURE__ */ jsx(
12059
- "rect",
12060
- {
12061
- width: "17",
12062
- height: "3",
12063
- rx: "1.5",
12064
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12065
- fill: "#D4D4D8"
12066
- }
12067
- ),
12068
- /* @__PURE__ */ jsx(
12069
- "rect",
12070
- {
12071
- width: "12",
12072
- height: "3",
12073
- rx: "1.5",
12074
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12075
- fill: "#D4D4D8"
12076
- }
12077
- ),
12078
- /* @__PURE__ */ jsx(
12079
- "path",
12080
- {
12081
- d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
12082
- fill: "#A1A1AA"
12083
- }
12084
- ),
12085
- /* @__PURE__ */ jsx(
12086
- "rect",
12087
- {
12088
- width: "17",
12089
- height: "3",
12090
- rx: "1.5",
12091
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12092
- fill: "#A1A1AA"
12093
- }
12094
- ),
12095
- /* @__PURE__ */ jsx(
12096
- "rect",
12097
- {
12098
- width: "12",
12099
- height: "3",
12100
- rx: "1.5",
12101
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12102
- fill: "#A1A1AA"
12103
- }
12104
- ),
12105
- /* @__PURE__ */ jsx(
12106
- "path",
12107
- {
12108
- d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
12109
- fill: "#52525B"
12110
- }
12111
- ),
12112
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
12113
- "path",
12114
- {
12115
- d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12116
- stroke: "#A1A1AA",
12117
- strokeWidth: "1.5",
12118
- strokeLinecap: "round",
12119
- strokeLinejoin: "round"
12120
- }
12121
- ) }),
12122
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
12123
- "path",
12124
- {
12125
- d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12126
- stroke: "#A1A1AA",
12127
- strokeWidth: "1.5",
12128
- strokeLinecap: "round",
12129
- strokeLinejoin: "round"
12130
- }
12131
- ) }),
12132
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
12133
- "path",
12134
- {
12135
- d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12136
- stroke: "#A1A1AA",
12137
- strokeWidth: "1.5",
12138
- strokeLinecap: "round",
12139
- strokeLinejoin: "round"
12140
- }
12141
- ) }),
12142
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
12143
- "path",
12144
- {
12145
- d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12146
- stroke: "#A1A1AA",
12147
- strokeWidth: "1.5",
12148
- strokeLinecap: "round",
12149
- strokeLinejoin: "round"
12150
- }
12151
- ) }),
12152
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
12153
- "path",
12154
- {
12155
- d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12156
- stroke: "#A1A1AA",
12157
- strokeWidth: "1.5",
12158
- strokeLinecap: "round",
12159
- strokeLinejoin: "round"
12160
- }
12161
- ) }),
12162
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
12163
- "path",
12164
- {
12165
- d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12166
- stroke: "#A1A1AA",
12167
- strokeWidth: "1.5",
12168
- strokeLinecap: "round",
12169
- strokeLinejoin: "round"
12170
- }
12171
- ) }),
12172
- /* @__PURE__ */ jsxs("defs", { children: [
12173
- /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12174
- "rect",
12175
- {
12176
- width: "12",
12177
- height: "12",
12178
- fill: "white",
12179
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12180
- }
12181
- ) }),
12182
- /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12183
- "rect",
12184
- {
12185
- width: "12",
12186
- height: "12",
12187
- fill: "white",
12188
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12189
- }
12190
- ) }),
12191
- /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12192
- "rect",
12193
- {
12194
- width: "12",
12195
- height: "12",
12196
- fill: "white",
12197
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12198
- }
12199
- ) }),
12200
- /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
12201
- "rect",
12202
- {
12203
- width: "12",
12204
- height: "12",
12205
- fill: "white",
12206
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12207
- }
12208
- ) }),
12209
- /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
12210
- "rect",
12211
- {
12212
- width: "12",
12213
- height: "12",
12214
- fill: "white",
12215
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12216
- }
12217
- ) }),
12218
- /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
12219
- "rect",
12220
- {
12221
- width: "12",
12222
- height: "12",
12223
- fill: "white",
12224
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12225
- }
12226
- ) })
12227
- ] })
12228
- ]
12229
- }
12230
- );
12231
- };
12232
- const schema = objectType({
12233
- customer_id: stringType().min(1)
12234
- });
12235
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
12236
- const Shipping = () => {
12237
- var _a;
12238
- const { id } = useParams();
12239
- const { order, isPending, isError, error } = useOrder(id, {
12240
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
12241
- });
12242
- const {
12243
- order: preview,
12244
- isPending: isPreviewPending,
12245
- isError: isPreviewError,
12246
- error: previewError
12247
- } = useOrderPreview(id);
12248
- useInitiateOrderEdit({ preview });
12249
- const { onCancel } = useCancelOrderEdit({ preview });
12250
- if (isError) {
12251
- throw error;
12252
- }
12253
- if (isPreviewError) {
12254
- throw previewError;
12255
- }
12256
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
12257
- const isReady = preview && !isPreviewPending && order && !isPending;
12258
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
12259
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
12260
- /* @__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: [
12261
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12262
- /* @__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." }) })
12263
- ] }) }) }),
12264
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
12265
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
12266
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
12267
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
12268
- ] }) });
12269
- };
12270
- const ShippingForm = ({ preview, order }) => {
12271
- var _a;
12272
- const { setIsOpen } = useStackedModal();
12273
- const [isSubmitting, setIsSubmitting] = useState(false);
12274
- const [data, setData] = useState(null);
12275
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
12276
- const { shipping_options } = useShippingOptions(
12277
- {
12278
- id: appliedShippingOptionIds,
12279
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
12280
- },
12281
- {
12282
- enabled: appliedShippingOptionIds.length > 0
11738
+ enabled: appliedShippingOptionIds.length > 0
12283
11739
  }
12284
11740
  );
12285
11741
  const uniqueShippingProfiles = useMemo(() => {
@@ -12620,425 +12076,969 @@ const ShippingForm = ({ preview, order }) => {
12620
12076
  );
12621
12077
  }) })
12622
12078
  ] }) })
12623
- ] }) }),
12624
- /* @__PURE__ */ jsx(
12625
- StackedFocusModal,
12079
+ ] }) }),
12080
+ /* @__PURE__ */ jsx(
12081
+ StackedFocusModal,
12082
+ {
12083
+ id: STACKED_FOCUS_MODAL_ID,
12084
+ onOpenChangeCallback: (open) => {
12085
+ if (!open) {
12086
+ setData(null);
12087
+ }
12088
+ return open;
12089
+ },
12090
+ children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
12091
+ }
12092
+ )
12093
+ ] }),
12094
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12095
+ /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12096
+ /* @__PURE__ */ jsx(
12097
+ Button,
12098
+ {
12099
+ size: "small",
12100
+ type: "button",
12101
+ isLoading: isSubmitting,
12102
+ onClick: onSubmit,
12103
+ children: "Save"
12104
+ }
12105
+ )
12106
+ ] }) })
12107
+ ] });
12108
+ };
12109
+ const StackedModalTrigger = ({
12110
+ shippingProfileId,
12111
+ shippingOption,
12112
+ shippingMethod,
12113
+ setData,
12114
+ children
12115
+ }) => {
12116
+ const { setIsOpen, getIsOpen } = useStackedModal();
12117
+ const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
12118
+ const onToggle = () => {
12119
+ if (isOpen) {
12120
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12121
+ setData(null);
12122
+ } else {
12123
+ setIsOpen(STACKED_FOCUS_MODAL_ID, true);
12124
+ setData({
12125
+ shippingProfileId,
12126
+ shippingOption,
12127
+ shippingMethod
12128
+ });
12129
+ }
12130
+ };
12131
+ return /* @__PURE__ */ jsx(
12132
+ Button,
12133
+ {
12134
+ size: "small",
12135
+ variant: "secondary",
12136
+ onClick: onToggle,
12137
+ className: "text-ui-fg-primary shrink-0",
12138
+ children
12139
+ }
12140
+ );
12141
+ };
12142
+ const ShippingProfileForm = ({
12143
+ data,
12144
+ order,
12145
+ preview
12146
+ }) => {
12147
+ var _a, _b, _c, _d, _e, _f;
12148
+ const { setIsOpen } = useStackedModal();
12149
+ const form = useForm({
12150
+ resolver: zodResolver(shippingMethodSchema),
12151
+ defaultValues: {
12152
+ 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,
12153
+ shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12154
+ custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12155
+ }
12156
+ });
12157
+ const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12158
+ const {
12159
+ mutateAsync: updateShippingMethod,
12160
+ isPending: isUpdatingShippingMethod
12161
+ } = useDraftOrderUpdateShippingMethod(order.id);
12162
+ const onSubmit = form.handleSubmit(async (values) => {
12163
+ if (isEqual(values, form.formState.defaultValues)) {
12164
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12165
+ return;
12166
+ }
12167
+ if (data.shippingMethod) {
12168
+ await updateShippingMethod(
12169
+ {
12170
+ method_id: data.shippingMethod.id,
12171
+ shipping_option_id: values.shipping_option_id,
12172
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12173
+ },
12174
+ {
12175
+ onError: (e) => {
12176
+ toast.error(e.message);
12177
+ },
12178
+ onSuccess: () => {
12179
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12180
+ }
12181
+ }
12182
+ );
12183
+ return;
12184
+ }
12185
+ await addShippingMethod(
12186
+ {
12187
+ shipping_option_id: values.shipping_option_id,
12188
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12189
+ },
12190
+ {
12191
+ onError: (e) => {
12192
+ toast.error(e.message);
12193
+ },
12194
+ onSuccess: () => {
12195
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12196
+ }
12197
+ }
12198
+ );
12199
+ });
12200
+ return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
12201
+ KeyboundForm,
12202
+ {
12203
+ className: "flex h-full flex-col overflow-hidden",
12204
+ onSubmit,
12205
+ children: [
12206
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
12207
+ /* @__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 py-16 px-6", children: [
12208
+ /* @__PURE__ */ jsxs("div", { children: [
12209
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12210
+ /* @__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." }) })
12211
+ ] }),
12212
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12213
+ /* @__PURE__ */ jsx(
12214
+ LocationField,
12215
+ {
12216
+ control: form.control,
12217
+ setValue: form.setValue
12218
+ }
12219
+ ),
12220
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12221
+ /* @__PURE__ */ jsx(
12222
+ ShippingOptionField,
12223
+ {
12224
+ shippingProfileId: data.shippingProfileId,
12225
+ preview,
12226
+ control: form.control
12227
+ }
12228
+ ),
12229
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12230
+ /* @__PURE__ */ jsx(
12231
+ CustomAmountField,
12232
+ {
12233
+ control: form.control,
12234
+ currencyCode: order.currency_code
12235
+ }
12236
+ ),
12237
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12238
+ /* @__PURE__ */ jsx(
12239
+ ItemsPreview,
12240
+ {
12241
+ order,
12242
+ shippingProfileId: data.shippingProfileId
12243
+ }
12244
+ )
12245
+ ] }) }) }),
12246
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12247
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12248
+ /* @__PURE__ */ jsx(
12249
+ Button,
12250
+ {
12251
+ size: "small",
12252
+ type: "submit",
12253
+ isLoading: isPending || isUpdatingShippingMethod,
12254
+ children: data.shippingMethod ? "Update" : "Add"
12255
+ }
12256
+ )
12257
+ ] }) })
12258
+ ]
12259
+ }
12260
+ ) }) });
12261
+ };
12262
+ const shippingMethodSchema = objectType({
12263
+ location_id: stringType(),
12264
+ shipping_option_id: stringType(),
12265
+ custom_amount: unionType([numberType(), stringType()]).optional()
12266
+ });
12267
+ const ItemsPreview = ({ order, shippingProfileId }) => {
12268
+ const matches = order.items.filter(
12269
+ (item) => {
12270
+ var _a, _b, _c;
12271
+ return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12272
+ }
12273
+ );
12274
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
12275
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12276
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12277
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12278
+ ] }) }),
12279
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12280
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
12281
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
12282
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
12283
+ ] }),
12284
+ /* @__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(
12285
+ "div",
12626
12286
  {
12627
- id: STACKED_FOCUS_MODAL_ID,
12628
- onOpenChangeCallback: (open) => {
12629
- if (!open) {
12630
- setData(null);
12287
+ className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
12288
+ children: [
12289
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12290
+ /* @__PURE__ */ jsx(
12291
+ Thumbnail,
12292
+ {
12293
+ thumbnail: item.thumbnail,
12294
+ alt: item.product_title ?? void 0
12295
+ }
12296
+ ),
12297
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12298
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
12299
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12300
+ /* @__PURE__ */ jsxs(
12301
+ Text,
12302
+ {
12303
+ size: "small",
12304
+ leading: "compact",
12305
+ className: "text-ui-fg-subtle",
12306
+ children: [
12307
+ "(",
12308
+ item.variant_title,
12309
+ ")"
12310
+ ]
12311
+ }
12312
+ )
12313
+ ] }),
12314
+ /* @__PURE__ */ jsx(
12315
+ Text,
12316
+ {
12317
+ size: "small",
12318
+ leading: "compact",
12319
+ className: "text-ui-fg-subtle",
12320
+ children: item.variant_sku
12321
+ }
12322
+ )
12323
+ ] })
12324
+ ] }),
12325
+ /* @__PURE__ */ jsxs(
12326
+ Text,
12327
+ {
12328
+ size: "small",
12329
+ leading: "compact",
12330
+ className: "text-ui-fg-subtle",
12331
+ children: [
12332
+ item.quantity,
12333
+ "x"
12334
+ ]
12335
+ }
12336
+ )
12337
+ ]
12338
+ },
12339
+ item.id
12340
+ )) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
12341
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12342
+ /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12343
+ 'No items found for "',
12344
+ query,
12345
+ '".'
12346
+ ] })
12347
+ ] }) })
12348
+ ] })
12349
+ ] });
12350
+ };
12351
+ const LocationField = ({ control, setValue }) => {
12352
+ const locations = useComboboxData({
12353
+ queryKey: ["locations"],
12354
+ queryFn: async (params) => {
12355
+ return await sdk.admin.stockLocation.list(params);
12356
+ },
12357
+ getOptions: (data) => {
12358
+ return data.stock_locations.map((location) => ({
12359
+ label: location.name,
12360
+ value: location.id
12361
+ }));
12362
+ }
12363
+ });
12364
+ return /* @__PURE__ */ jsx(
12365
+ Form$2.Field,
12366
+ {
12367
+ control,
12368
+ name: "location_id",
12369
+ render: ({ field: { onChange, ...field } }) => {
12370
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12371
+ /* @__PURE__ */ jsxs("div", { children: [
12372
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12373
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12374
+ ] }),
12375
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12376
+ Combobox,
12377
+ {
12378
+ options: locations.options,
12379
+ fetchNextPage: locations.fetchNextPage,
12380
+ isFetchingNextPage: locations.isFetchingNextPage,
12381
+ searchValue: locations.searchValue,
12382
+ onSearchValueChange: locations.onSearchValueChange,
12383
+ placeholder: "Select location",
12384
+ onChange: (value) => {
12385
+ setValue("shipping_option_id", "", {
12386
+ shouldDirty: true,
12387
+ shouldTouch: true
12388
+ });
12389
+ onChange(value);
12390
+ },
12391
+ ...field
12631
12392
  }
12632
- return open;
12633
- },
12634
- children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
12393
+ ) })
12394
+ ] }) });
12395
+ }
12396
+ }
12397
+ );
12398
+ };
12399
+ const ShippingOptionField = ({
12400
+ shippingProfileId,
12401
+ preview,
12402
+ control
12403
+ }) => {
12404
+ var _a;
12405
+ const locationId = useWatch({ control, name: "location_id" });
12406
+ const shippingOptions = useComboboxData({
12407
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12408
+ queryFn: async (params) => {
12409
+ return await sdk.admin.shippingOption.list({
12410
+ ...params,
12411
+ stock_location_id: locationId,
12412
+ shipping_profile_id: shippingProfileId
12413
+ });
12414
+ },
12415
+ getOptions: (data) => {
12416
+ return data.shipping_options.map((option) => {
12417
+ var _a2;
12418
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12419
+ (r) => r.attribute === "is_return" && r.value === "true"
12420
+ )) {
12421
+ return void 0;
12635
12422
  }
12636
- )
12423
+ return {
12424
+ label: option.name,
12425
+ value: option.id
12426
+ };
12427
+ }).filter(Boolean);
12428
+ },
12429
+ enabled: !!locationId && !!shippingProfileId,
12430
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12431
+ });
12432
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12433
+ return /* @__PURE__ */ jsx(
12434
+ Form$2.Field,
12435
+ {
12436
+ control,
12437
+ name: "shipping_option_id",
12438
+ render: ({ field }) => {
12439
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12440
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12441
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12442
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12443
+ ] }),
12444
+ /* @__PURE__ */ jsx(
12445
+ ConditionalTooltip,
12446
+ {
12447
+ content: tooltipContent,
12448
+ showTooltip: !locationId || !shippingProfileId,
12449
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12450
+ Combobox,
12451
+ {
12452
+ options: shippingOptions.options,
12453
+ fetchNextPage: shippingOptions.fetchNextPage,
12454
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12455
+ searchValue: shippingOptions.searchValue,
12456
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12457
+ placeholder: "Select shipping option",
12458
+ ...field,
12459
+ disabled: !locationId || !shippingProfileId
12460
+ }
12461
+ ) }) })
12462
+ }
12463
+ )
12464
+ ] }) });
12465
+ }
12466
+ }
12467
+ );
12468
+ };
12469
+ const CustomAmountField = ({
12470
+ control,
12471
+ currencyCode
12472
+ }) => {
12473
+ return /* @__PURE__ */ jsx(
12474
+ Form$2.Field,
12475
+ {
12476
+ control,
12477
+ name: "custom_amount",
12478
+ render: ({ field: { onChange, ...field } }) => {
12479
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12480
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12481
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12482
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12483
+ ] }),
12484
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12485
+ CurrencyInput,
12486
+ {
12487
+ ...field,
12488
+ onValueChange: (value) => onChange(value),
12489
+ symbol: getNativeSymbol(currencyCode),
12490
+ code: currencyCode
12491
+ }
12492
+ ) })
12493
+ ] });
12494
+ }
12495
+ }
12496
+ );
12497
+ };
12498
+ const TransferOwnership = () => {
12499
+ const { id } = useParams();
12500
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12501
+ fields: "id,customer_id,customer.*"
12502
+ });
12503
+ if (isError) {
12504
+ throw error;
12505
+ }
12506
+ const isReady = !isPending && !!draft_order;
12507
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12508
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12509
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12510
+ /* @__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" }) })
12637
12511
  ] }),
12638
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12639
- /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12640
- /* @__PURE__ */ jsx(
12641
- Button,
12642
- {
12643
- size: "small",
12644
- type: "button",
12645
- isLoading: isSubmitting,
12646
- onClick: onSubmit,
12647
- children: "Save"
12648
- }
12649
- )
12650
- ] }) })
12512
+ isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12651
12513
  ] });
12652
12514
  };
12653
- const StackedModalTrigger = ({
12654
- shippingProfileId,
12655
- shippingOption,
12656
- shippingMethod,
12657
- setData,
12658
- children
12659
- }) => {
12660
- const { setIsOpen, getIsOpen } = useStackedModal();
12661
- const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
12662
- const onToggle = () => {
12663
- if (isOpen) {
12664
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12665
- setData(null);
12666
- } else {
12667
- setIsOpen(STACKED_FOCUS_MODAL_ID, true);
12668
- setData({
12669
- shippingProfileId,
12670
- shippingOption,
12671
- shippingMethod
12515
+ const TransferOwnershipForm = ({ order }) => {
12516
+ var _a, _b;
12517
+ const form = useForm({
12518
+ defaultValues: {
12519
+ customer_id: order.customer_id || ""
12520
+ },
12521
+ resolver: zodResolver(schema$1)
12522
+ });
12523
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12524
+ const { handleSuccess } = useRouteModal();
12525
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12526
+ const currentCustomer = order.customer ? {
12527
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12528
+ value: order.customer.id
12529
+ } : null;
12530
+ const onSubmit = form.handleSubmit(async (data) => {
12531
+ await mutateAsync(
12532
+ { customer_id: data.customer_id },
12533
+ {
12534
+ onSuccess: () => {
12535
+ toast.success("Customer updated");
12536
+ handleSuccess();
12537
+ },
12538
+ onError: (error) => {
12539
+ toast.error(error.message);
12540
+ }
12541
+ }
12542
+ );
12543
+ });
12544
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12545
+ KeyboundForm,
12546
+ {
12547
+ className: "flex flex-1 flex-col overflow-hidden",
12548
+ onSubmit,
12549
+ children: [
12550
+ /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12551
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
12552
+ currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
12553
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12554
+ /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12555
+ /* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
12556
+ ] }),
12557
+ /* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
12558
+ /* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
12559
+ /* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12560
+ ] })
12561
+ ] }),
12562
+ /* @__PURE__ */ jsx(
12563
+ CustomerField,
12564
+ {
12565
+ control: form.control,
12566
+ currentCustomerId: order.customer_id
12567
+ }
12568
+ )
12569
+ ] }),
12570
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12571
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12572
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12573
+ ] }) })
12574
+ ]
12575
+ }
12576
+ ) });
12577
+ };
12578
+ const CustomerField = ({ control, currentCustomerId }) => {
12579
+ const customers = useComboboxData({
12580
+ queryFn: async (params) => {
12581
+ return await sdk.admin.customer.list({
12582
+ ...params,
12583
+ id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12584
+ });
12585
+ },
12586
+ queryKey: ["customers"],
12587
+ getOptions: (data) => {
12588
+ return data.customers.map((customer) => {
12589
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12590
+ return {
12591
+ label: name ? `${name} (${customer.email})` : customer.email,
12592
+ value: customer.id
12593
+ };
12672
12594
  });
12673
12595
  }
12674
- };
12596
+ });
12675
12597
  return /* @__PURE__ */ jsx(
12676
- Button,
12598
+ Form$2.Field,
12677
12599
  {
12678
- size: "small",
12679
- variant: "secondary",
12680
- onClick: onToggle,
12681
- className: "text-ui-fg-primary shrink-0",
12682
- children
12600
+ name: "customer_id",
12601
+ control,
12602
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
12603
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12604
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
12605
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
12606
+ ] }),
12607
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12608
+ Combobox,
12609
+ {
12610
+ options: customers.options,
12611
+ fetchNextPage: customers.fetchNextPage,
12612
+ isFetchingNextPage: customers.isFetchingNextPage,
12613
+ searchValue: customers.searchValue,
12614
+ onSearchValueChange: customers.onSearchValueChange,
12615
+ placeholder: "Select customer",
12616
+ ...field
12617
+ }
12618
+ ) }),
12619
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12620
+ ] })
12683
12621
  }
12684
12622
  );
12685
12623
  };
12686
- const ShippingProfileForm = ({
12687
- data,
12688
- order,
12689
- preview
12690
- }) => {
12691
- var _a, _b, _c, _d, _e, _f;
12692
- const { setIsOpen } = useStackedModal();
12693
- const form = useForm({
12694
- resolver: zodResolver(shippingMethodSchema),
12695
- defaultValues: {
12696
- 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,
12697
- shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12698
- custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12699
- }
12700
- });
12701
- const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12702
- const {
12703
- mutateAsync: updateShippingMethod,
12704
- isPending: isUpdatingShippingMethod
12705
- } = useDraftOrderUpdateShippingMethod(order.id);
12706
- const onSubmit = form.handleSubmit(async (values) => {
12707
- if (isEqual(values, form.formState.defaultValues)) {
12708
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12709
- return;
12710
- }
12711
- if (data.shippingMethod) {
12712
- await updateShippingMethod(
12713
- {
12714
- method_id: data.shippingMethod.id,
12715
- shipping_option_id: values.shipping_option_id,
12716
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12717
- },
12718
- {
12719
- onError: (e) => {
12720
- toast.error(e.message);
12721
- },
12722
- onSuccess: () => {
12723
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12624
+ const Illustration = () => {
12625
+ return /* @__PURE__ */ jsxs(
12626
+ "svg",
12627
+ {
12628
+ width: "280",
12629
+ height: "180",
12630
+ viewBox: "0 0 280 180",
12631
+ fill: "none",
12632
+ xmlns: "http://www.w3.org/2000/svg",
12633
+ children: [
12634
+ /* @__PURE__ */ jsx(
12635
+ "rect",
12636
+ {
12637
+ x: "0.00428286",
12638
+ y: "-0.742904",
12639
+ width: "33.5",
12640
+ height: "65.5",
12641
+ rx: "6.75",
12642
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
12643
+ fill: "#D4D4D8",
12644
+ stroke: "#52525B",
12645
+ strokeWidth: "1.5"
12646
+ }
12647
+ ),
12648
+ /* @__PURE__ */ jsx(
12649
+ "rect",
12650
+ {
12651
+ x: "0.00428286",
12652
+ y: "-0.742904",
12653
+ width: "33.5",
12654
+ height: "65.5",
12655
+ rx: "6.75",
12656
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
12657
+ fill: "white",
12658
+ stroke: "#52525B",
12659
+ strokeWidth: "1.5"
12660
+ }
12661
+ ),
12662
+ /* @__PURE__ */ jsx(
12663
+ "path",
12664
+ {
12665
+ d: "M180.579 107.142L179.126 107.959",
12666
+ stroke: "#52525B",
12667
+ strokeWidth: "1.5",
12668
+ strokeLinecap: "round",
12669
+ strokeLinejoin: "round"
12670
+ }
12671
+ ),
12672
+ /* @__PURE__ */ jsx(
12673
+ "path",
12674
+ {
12675
+ opacity: "0.88",
12676
+ d: "M182.305 109.546L180.257 109.534",
12677
+ stroke: "#52525B",
12678
+ strokeWidth: "1.5",
12679
+ strokeLinecap: "round",
12680
+ strokeLinejoin: "round"
12681
+ }
12682
+ ),
12683
+ /* @__PURE__ */ jsx(
12684
+ "path",
12685
+ {
12686
+ opacity: "0.75",
12687
+ d: "M180.551 111.93L179.108 111.096",
12688
+ stroke: "#52525B",
12689
+ strokeWidth: "1.5",
12690
+ strokeLinecap: "round",
12691
+ strokeLinejoin: "round"
12692
+ }
12693
+ ),
12694
+ /* @__PURE__ */ jsx(
12695
+ "path",
12696
+ {
12697
+ opacity: "0.63",
12698
+ d: "M176.347 112.897L176.354 111.73",
12699
+ stroke: "#52525B",
12700
+ strokeWidth: "1.5",
12701
+ strokeLinecap: "round",
12702
+ strokeLinejoin: "round"
12703
+ }
12704
+ ),
12705
+ /* @__PURE__ */ jsx(
12706
+ "path",
12707
+ {
12708
+ opacity: "0.5",
12709
+ d: "M172.153 111.881L173.606 111.064",
12710
+ stroke: "#52525B",
12711
+ strokeWidth: "1.5",
12712
+ strokeLinecap: "round",
12713
+ strokeLinejoin: "round"
12714
+ }
12715
+ ),
12716
+ /* @__PURE__ */ jsx(
12717
+ "path",
12718
+ {
12719
+ opacity: "0.38",
12720
+ d: "M170.428 109.478L172.476 109.489",
12721
+ stroke: "#52525B",
12722
+ strokeWidth: "1.5",
12723
+ strokeLinecap: "round",
12724
+ strokeLinejoin: "round"
12725
+ }
12726
+ ),
12727
+ /* @__PURE__ */ jsx(
12728
+ "path",
12729
+ {
12730
+ opacity: "0.25",
12731
+ d: "M172.181 107.094L173.624 107.928",
12732
+ stroke: "#52525B",
12733
+ strokeWidth: "1.5",
12734
+ strokeLinecap: "round",
12735
+ strokeLinejoin: "round"
12736
+ }
12737
+ ),
12738
+ /* @__PURE__ */ jsx(
12739
+ "path",
12740
+ {
12741
+ opacity: "0.13",
12742
+ d: "M176.386 106.126L176.379 107.294",
12743
+ stroke: "#52525B",
12744
+ strokeWidth: "1.5",
12745
+ strokeLinecap: "round",
12746
+ strokeLinejoin: "round"
12747
+ }
12748
+ ),
12749
+ /* @__PURE__ */ jsx(
12750
+ "rect",
12751
+ {
12752
+ width: "12",
12753
+ height: "3",
12754
+ rx: "1.5",
12755
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12756
+ fill: "#D4D4D8"
12757
+ }
12758
+ ),
12759
+ /* @__PURE__ */ jsx(
12760
+ "rect",
12761
+ {
12762
+ x: "0.00428286",
12763
+ y: "-0.742904",
12764
+ width: "33.5",
12765
+ height: "65.5",
12766
+ rx: "6.75",
12767
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12768
+ fill: "#D4D4D8",
12769
+ stroke: "#52525B",
12770
+ strokeWidth: "1.5"
12771
+ }
12772
+ ),
12773
+ /* @__PURE__ */ jsx(
12774
+ "rect",
12775
+ {
12776
+ x: "0.00428286",
12777
+ y: "-0.742904",
12778
+ width: "33.5",
12779
+ height: "65.5",
12780
+ rx: "6.75",
12781
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12782
+ fill: "white",
12783
+ stroke: "#52525B",
12784
+ strokeWidth: "1.5"
12785
+ }
12786
+ ),
12787
+ /* @__PURE__ */ jsx(
12788
+ "rect",
12789
+ {
12790
+ width: "12",
12791
+ height: "3",
12792
+ rx: "1.5",
12793
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12794
+ fill: "#D4D4D8"
12795
+ }
12796
+ ),
12797
+ /* @__PURE__ */ jsx(
12798
+ "rect",
12799
+ {
12800
+ width: "17",
12801
+ height: "3",
12802
+ rx: "1.5",
12803
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12804
+ fill: "#D4D4D8"
12805
+ }
12806
+ ),
12807
+ /* @__PURE__ */ jsx(
12808
+ "rect",
12809
+ {
12810
+ width: "12",
12811
+ height: "3",
12812
+ rx: "1.5",
12813
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12814
+ fill: "#D4D4D8"
12815
+ }
12816
+ ),
12817
+ /* @__PURE__ */ jsx(
12818
+ "path",
12819
+ {
12820
+ d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
12821
+ fill: "#A1A1AA"
12822
+ }
12823
+ ),
12824
+ /* @__PURE__ */ jsx(
12825
+ "rect",
12826
+ {
12827
+ width: "17",
12828
+ height: "3",
12829
+ rx: "1.5",
12830
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12831
+ fill: "#A1A1AA"
12832
+ }
12833
+ ),
12834
+ /* @__PURE__ */ jsx(
12835
+ "rect",
12836
+ {
12837
+ width: "12",
12838
+ height: "3",
12839
+ rx: "1.5",
12840
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12841
+ fill: "#A1A1AA"
12724
12842
  }
12725
- }
12726
- );
12727
- return;
12728
- }
12729
- await addShippingMethod(
12730
- {
12731
- shipping_option_id: values.shipping_option_id,
12732
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12733
- },
12734
- {
12735
- onError: (e) => {
12736
- toast.error(e.message);
12737
- },
12738
- onSuccess: () => {
12739
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12740
- }
12741
- }
12742
- );
12743
- });
12744
- return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
12745
- KeyboundForm,
12746
- {
12747
- className: "flex h-full flex-col overflow-hidden",
12748
- onSubmit,
12749
- children: [
12750
- /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
12751
- /* @__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 py-16 px-6", children: [
12752
- /* @__PURE__ */ jsxs("div", { children: [
12753
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12754
- /* @__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." }) })
12755
- ] }),
12756
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12757
- /* @__PURE__ */ jsx(
12758
- LocationField,
12759
- {
12760
- control: form.control,
12761
- setValue: form.setValue
12762
- }
12763
- ),
12764
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12765
- /* @__PURE__ */ jsx(
12766
- ShippingOptionField,
12767
- {
12768
- shippingProfileId: data.shippingProfileId,
12769
- preview,
12770
- control: form.control
12771
- }
12772
- ),
12773
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12774
- /* @__PURE__ */ jsx(
12775
- CustomAmountField,
12776
- {
12777
- control: form.control,
12778
- currencyCode: order.currency_code
12779
- }
12780
- ),
12781
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12782
- /* @__PURE__ */ jsx(
12783
- ItemsPreview,
12784
- {
12785
- order,
12786
- shippingProfileId: data.shippingProfileId
12787
- }
12788
- )
12789
- ] }) }) }),
12790
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12791
- /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12792
- /* @__PURE__ */ jsx(
12793
- Button,
12794
- {
12795
- size: "small",
12796
- type: "submit",
12797
- isLoading: isPending || isUpdatingShippingMethod,
12798
- children: data.shippingMethod ? "Update" : "Add"
12799
- }
12800
- )
12801
- ] }) })
12802
- ]
12803
- }
12804
- ) }) });
12805
- };
12806
- const shippingMethodSchema = objectType({
12807
- location_id: stringType(),
12808
- shipping_option_id: stringType(),
12809
- custom_amount: unionType([numberType(), stringType()]).optional()
12810
- });
12811
- const ItemsPreview = ({ order, shippingProfileId }) => {
12812
- const matches = order.items.filter(
12813
- (item) => {
12814
- var _a, _b, _c;
12815
- return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12816
- }
12817
- );
12818
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
12819
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12820
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12821
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12822
- ] }) }),
12823
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12824
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
12825
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
12826
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
12827
- ] }),
12828
- /* @__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(
12829
- "div",
12830
- {
12831
- className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
12832
- children: [
12833
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12834
- /* @__PURE__ */ jsx(
12835
- Thumbnail,
12836
- {
12837
- thumbnail: item.thumbnail,
12838
- alt: item.product_title ?? void 0
12839
- }
12840
- ),
12841
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12842
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
12843
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12844
- /* @__PURE__ */ jsxs(
12845
- Text,
12846
- {
12847
- size: "small",
12848
- leading: "compact",
12849
- className: "text-ui-fg-subtle",
12850
- children: [
12851
- "(",
12852
- item.variant_title,
12853
- ")"
12854
- ]
12855
- }
12856
- )
12857
- ] }),
12858
- /* @__PURE__ */ jsx(
12859
- Text,
12860
- {
12861
- size: "small",
12862
- leading: "compact",
12863
- className: "text-ui-fg-subtle",
12864
- children: item.variant_sku
12865
- }
12866
- )
12867
- ] })
12868
- ] }),
12869
- /* @__PURE__ */ jsxs(
12870
- Text,
12871
- {
12872
- size: "small",
12873
- leading: "compact",
12874
- className: "text-ui-fg-subtle",
12875
- children: [
12876
- item.quantity,
12877
- "x"
12878
- ]
12879
- }
12880
- )
12881
- ]
12882
- },
12883
- item.id
12884
- )) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
12885
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12886
- /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12887
- 'No items found for "',
12888
- query,
12889
- '".'
12890
- ] })
12891
- ] }) })
12892
- ] })
12893
- ] });
12894
- };
12895
- const LocationField = ({ control, setValue }) => {
12896
- const locations = useComboboxData({
12897
- queryKey: ["locations"],
12898
- queryFn: async (params) => {
12899
- return await sdk.admin.stockLocation.list(params);
12900
- },
12901
- getOptions: (data) => {
12902
- return data.stock_locations.map((location) => ({
12903
- label: location.name,
12904
- value: location.id
12905
- }));
12906
- }
12907
- });
12908
- return /* @__PURE__ */ jsx(
12909
- Form$2.Field,
12910
- {
12911
- control,
12912
- name: "location_id",
12913
- render: ({ field: { onChange, ...field } }) => {
12914
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12915
- /* @__PURE__ */ jsxs("div", { children: [
12916
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12917
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12918
- ] }),
12919
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12920
- Combobox,
12843
+ ),
12844
+ /* @__PURE__ */ jsx(
12845
+ "path",
12846
+ {
12847
+ d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
12848
+ fill: "#52525B"
12849
+ }
12850
+ ),
12851
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
12852
+ "path",
12853
+ {
12854
+ d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12855
+ stroke: "#A1A1AA",
12856
+ strokeWidth: "1.5",
12857
+ strokeLinecap: "round",
12858
+ strokeLinejoin: "round"
12859
+ }
12860
+ ) }),
12861
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
12862
+ "path",
12863
+ {
12864
+ d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12865
+ stroke: "#A1A1AA",
12866
+ strokeWidth: "1.5",
12867
+ strokeLinecap: "round",
12868
+ strokeLinejoin: "round"
12869
+ }
12870
+ ) }),
12871
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
12872
+ "path",
12873
+ {
12874
+ d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12875
+ stroke: "#A1A1AA",
12876
+ strokeWidth: "1.5",
12877
+ strokeLinecap: "round",
12878
+ strokeLinejoin: "round"
12879
+ }
12880
+ ) }),
12881
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
12882
+ "path",
12883
+ {
12884
+ d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12885
+ stroke: "#A1A1AA",
12886
+ strokeWidth: "1.5",
12887
+ strokeLinecap: "round",
12888
+ strokeLinejoin: "round"
12889
+ }
12890
+ ) }),
12891
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
12892
+ "path",
12893
+ {
12894
+ d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12895
+ stroke: "#A1A1AA",
12896
+ strokeWidth: "1.5",
12897
+ strokeLinecap: "round",
12898
+ strokeLinejoin: "round"
12899
+ }
12900
+ ) }),
12901
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
12902
+ "path",
12903
+ {
12904
+ d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12905
+ stroke: "#A1A1AA",
12906
+ strokeWidth: "1.5",
12907
+ strokeLinecap: "round",
12908
+ strokeLinejoin: "round"
12909
+ }
12910
+ ) }),
12911
+ /* @__PURE__ */ jsxs("defs", { children: [
12912
+ /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12913
+ "rect",
12921
12914
  {
12922
- options: locations.options,
12923
- fetchNextPage: locations.fetchNextPage,
12924
- isFetchingNextPage: locations.isFetchingNextPage,
12925
- searchValue: locations.searchValue,
12926
- onSearchValueChange: locations.onSearchValueChange,
12927
- placeholder: "Select location",
12928
- onChange: (value) => {
12929
- setValue("shipping_option_id", "", {
12930
- shouldDirty: true,
12931
- shouldTouch: true
12932
- });
12933
- onChange(value);
12934
- },
12935
- ...field
12915
+ width: "12",
12916
+ height: "12",
12917
+ fill: "white",
12918
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12919
+ }
12920
+ ) }),
12921
+ /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12922
+ "rect",
12923
+ {
12924
+ width: "12",
12925
+ height: "12",
12926
+ fill: "white",
12927
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12928
+ }
12929
+ ) }),
12930
+ /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12931
+ "rect",
12932
+ {
12933
+ width: "12",
12934
+ height: "12",
12935
+ fill: "white",
12936
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12937
+ }
12938
+ ) }),
12939
+ /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
12940
+ "rect",
12941
+ {
12942
+ width: "12",
12943
+ height: "12",
12944
+ fill: "white",
12945
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12946
+ }
12947
+ ) }),
12948
+ /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
12949
+ "rect",
12950
+ {
12951
+ width: "12",
12952
+ height: "12",
12953
+ fill: "white",
12954
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12955
+ }
12956
+ ) }),
12957
+ /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
12958
+ "rect",
12959
+ {
12960
+ width: "12",
12961
+ height: "12",
12962
+ fill: "white",
12963
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12936
12964
  }
12937
12965
  ) })
12938
- ] }) });
12939
- }
12966
+ ] })
12967
+ ]
12940
12968
  }
12941
12969
  );
12942
12970
  };
12943
- const ShippingOptionField = ({
12944
- shippingProfileId,
12945
- preview,
12946
- control
12947
- }) => {
12948
- var _a;
12949
- const locationId = useWatch({ control, name: "location_id" });
12950
- const shippingOptions = useComboboxData({
12951
- queryKey: ["shipping_options", locationId, shippingProfileId],
12952
- queryFn: async (params) => {
12953
- return await sdk.admin.shippingOption.list({
12954
- ...params,
12955
- stock_location_id: locationId,
12956
- shipping_profile_id: shippingProfileId
12957
- });
12958
- },
12959
- getOptions: (data) => {
12960
- return data.shipping_options.map((option) => {
12961
- var _a2;
12962
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12963
- (r) => r.attribute === "is_return" && r.value === "true"
12964
- )) {
12965
- return void 0;
12966
- }
12967
- return {
12968
- label: option.name,
12969
- value: option.id
12970
- };
12971
- }).filter(Boolean);
12971
+ const schema$1 = objectType({
12972
+ customer_id: stringType().min(1)
12973
+ });
12974
+ const Email = () => {
12975
+ const { id } = useParams();
12976
+ const { order, isPending, isError, error } = useOrder(id, {
12977
+ fields: "+email"
12978
+ });
12979
+ if (isError) {
12980
+ throw error;
12981
+ }
12982
+ const isReady = !isPending && !!order;
12983
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12984
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12985
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
12986
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12987
+ ] }),
12988
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
12989
+ ] });
12990
+ };
12991
+ const EmailForm = ({ order }) => {
12992
+ const form = useForm({
12993
+ defaultValues: {
12994
+ email: order.email ?? ""
12972
12995
  },
12973
- enabled: !!locationId && !!shippingProfileId,
12974
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12996
+ resolver: zodResolver(schema)
12975
12997
  });
12976
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12977
- return /* @__PURE__ */ jsx(
12978
- Form$2.Field,
12979
- {
12980
- control,
12981
- name: "shipping_option_id",
12982
- render: ({ field }) => {
12983
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12984
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12985
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12986
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12987
- ] }),
12988
- /* @__PURE__ */ jsx(
12989
- ConditionalTooltip,
12990
- {
12991
- content: tooltipContent,
12992
- showTooltip: !locationId || !shippingProfileId,
12993
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12994
- Combobox,
12995
- {
12996
- options: shippingOptions.options,
12997
- fetchNextPage: shippingOptions.fetchNextPage,
12998
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12999
- searchValue: shippingOptions.searchValue,
13000
- onSearchValueChange: shippingOptions.onSearchValueChange,
13001
- placeholder: "Select shipping option",
13002
- ...field,
13003
- disabled: !locationId || !shippingProfileId
13004
- }
13005
- ) }) })
13006
- }
13007
- )
13008
- ] }) });
12998
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12999
+ const { handleSuccess } = useRouteModal();
13000
+ const onSubmit = form.handleSubmit(async (data) => {
13001
+ await mutateAsync(
13002
+ { email: data.email },
13003
+ {
13004
+ onSuccess: () => {
13005
+ handleSuccess();
13006
+ },
13007
+ onError: (error) => {
13008
+ toast.error(error.message);
13009
+ }
13009
13010
  }
13010
- }
13011
- );
13012
- };
13013
- const CustomAmountField = ({
13014
- control,
13015
- currencyCode
13016
- }) => {
13017
- return /* @__PURE__ */ jsx(
13018
- Form$2.Field,
13011
+ );
13012
+ });
13013
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
13014
+ KeyboundForm,
13019
13015
  {
13020
- control,
13021
- name: "custom_amount",
13022
- render: ({ field: { onChange, ...field } }) => {
13023
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
13024
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
13025
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
13026
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
13027
- ] }),
13028
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13029
- CurrencyInput,
13030
- {
13031
- ...field,
13032
- onValueChange: (value) => onChange(value),
13033
- symbol: getNativeSymbol(currencyCode),
13034
- code: currencyCode
13035
- }
13036
- ) })
13037
- ] });
13038
- }
13016
+ className: "flex flex-1 flex-col overflow-hidden",
13017
+ onSubmit,
13018
+ children: [
13019
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
13020
+ Form$2.Field,
13021
+ {
13022
+ control: form.control,
13023
+ name: "email",
13024
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13025
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
13026
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13027
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13028
+ ] })
13029
+ }
13030
+ ) }),
13031
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13034
+ ] }) })
13035
+ ]
13039
13036
  }
13040
- );
13037
+ ) });
13041
13038
  };
13039
+ const schema = objectType({
13040
+ email: stringType().email()
13041
+ });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13067,10 +13067,6 @@ const routeModule = {
13067
13067
  Component: CustomItems,
13068
13068
  path: "/draft-orders/:id/custom-items"
13069
13069
  },
13070
- {
13071
- Component: Email,
13072
- path: "/draft-orders/:id/email"
13073
- },
13074
13070
  {
13075
13071
  Component: Items,
13076
13072
  path: "/draft-orders/:id/items"
@@ -13091,13 +13087,17 @@ const routeModule = {
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: Shipping,
13100
- path: "/draft-orders/:id/shipping"
13099
+ Component: Email,
13100
+ path: "/draft-orders/:id/email"
13101
13101
  }
13102
13102
  ]
13103
13103
  }