@medusajs/draft-order 2.10.2-preview-20250910090158 → 2.10.2-preview-20250910113759

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.
@@ -9763,6 +9763,27 @@ const BillingAddressForm = ({ order }) => {
9763
9763
  ) });
9764
9764
  };
9765
9765
  const schema$5 = addressSchema;
9766
+ const CustomItems = () => {
9767
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9768
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9769
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9770
+ ] });
9771
+ };
9772
+ const CustomItemsForm = () => {
9773
+ const form = reactHookForm.useForm({
9774
+ resolver: zod.zodResolver(schema$4)
9775
+ });
9776
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9779
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9780
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9781
+ ] }) })
9782
+ ] }) });
9783
+ };
9784
+ const schema$4 = objectType({
9785
+ email: stringType().email()
9786
+ });
9766
9787
  const Email = () => {
9767
9788
  const { id } = reactRouterDom.useParams();
9768
9789
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9785,7 +9806,7 @@ const EmailForm = ({ order }) => {
9785
9806
  defaultValues: {
9786
9807
  email: order.email ?? ""
9787
9808
  },
9788
- resolver: zod.zodResolver(schema$4)
9809
+ resolver: zod.zodResolver(schema$3)
9789
9810
  });
9790
9811
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9791
9812
  const { handleSuccess } = useRouteModal();
@@ -9828,27 +9849,6 @@ const EmailForm = ({ order }) => {
9828
9849
  }
9829
9850
  ) });
9830
9851
  };
9831
- const schema$4 = objectType({
9832
- email: stringType().email()
9833
- });
9834
- const CustomItems = () => {
9835
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9836
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9837
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9838
- ] });
9839
- };
9840
- const CustomItemsForm = () => {
9841
- const form = reactHookForm.useForm({
9842
- resolver: zod.zodResolver(schema$3)
9843
- });
9844
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9845
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9846
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9847
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9848
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9849
- ] }) })
9850
- ] }) });
9851
- };
9852
9852
  const schema$3 = objectType({
9853
9853
  email: stringType().email()
9854
9854
  });
@@ -11453,6 +11453,112 @@ function getPromotionIds(items, shippingMethods) {
11453
11453
  }
11454
11454
  return Array.from(promotionIds);
11455
11455
  }
11456
+ const SalesChannel = () => {
11457
+ const { id } = reactRouterDom.useParams();
11458
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11459
+ id,
11460
+ {
11461
+ fields: "+sales_channel_id"
11462
+ },
11463
+ {
11464
+ enabled: !!id
11465
+ }
11466
+ );
11467
+ if (isError) {
11468
+ throw error;
11469
+ }
11470
+ const ISrEADY = !!draft_order && !isPending;
11471
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11472
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11473
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11474
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11475
+ ] }),
11476
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11477
+ ] });
11478
+ };
11479
+ const SalesChannelForm = ({ order }) => {
11480
+ const form = reactHookForm.useForm({
11481
+ defaultValues: {
11482
+ sales_channel_id: order.sales_channel_id || ""
11483
+ },
11484
+ resolver: zod.zodResolver(schema$2)
11485
+ });
11486
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11487
+ const { handleSuccess } = useRouteModal();
11488
+ const onSubmit = form.handleSubmit(async (data) => {
11489
+ await mutateAsync(
11490
+ {
11491
+ sales_channel_id: data.sales_channel_id
11492
+ },
11493
+ {
11494
+ onSuccess: () => {
11495
+ ui.toast.success("Sales channel updated");
11496
+ handleSuccess();
11497
+ },
11498
+ onError: (error) => {
11499
+ ui.toast.error(error.message);
11500
+ }
11501
+ }
11502
+ );
11503
+ });
11504
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11505
+ KeyboundForm,
11506
+ {
11507
+ className: "flex flex-1 flex-col overflow-hidden",
11508
+ onSubmit,
11509
+ children: [
11510
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11511
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11512
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11513
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11514
+ ] }) })
11515
+ ]
11516
+ }
11517
+ ) });
11518
+ };
11519
+ const SalesChannelField = ({ control, order }) => {
11520
+ const salesChannels = useComboboxData({
11521
+ queryFn: async (params) => {
11522
+ return await sdk.admin.salesChannel.list(params);
11523
+ },
11524
+ queryKey: ["sales-channels"],
11525
+ getOptions: (data) => {
11526
+ return data.sales_channels.map((salesChannel) => ({
11527
+ label: salesChannel.name,
11528
+ value: salesChannel.id
11529
+ }));
11530
+ },
11531
+ defaultValue: order.sales_channel_id || void 0
11532
+ });
11533
+ return /* @__PURE__ */ jsxRuntime.jsx(
11534
+ Form$2.Field,
11535
+ {
11536
+ control,
11537
+ name: "sales_channel_id",
11538
+ render: ({ field }) => {
11539
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11541
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11542
+ Combobox,
11543
+ {
11544
+ options: salesChannels.options,
11545
+ fetchNextPage: salesChannels.fetchNextPage,
11546
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11547
+ searchValue: salesChannels.searchValue,
11548
+ onSearchValueChange: salesChannels.onSearchValueChange,
11549
+ placeholder: "Select sales channel",
11550
+ ...field
11551
+ }
11552
+ ) }),
11553
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11554
+ ] });
11555
+ }
11556
+ }
11557
+ );
11558
+ };
11559
+ const schema$2 = objectType({
11560
+ sales_channel_id: stringType().min(1)
11561
+ });
11456
11562
  const ShippingAddress = () => {
11457
11563
  const { id } = reactRouterDom.useParams();
11458
11564
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11485,7 +11591,7 @@ const ShippingAddressForm = ({ order }) => {
11485
11591
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11486
11592
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11487
11593
  },
11488
- resolver: zod.zodResolver(schema$2)
11594
+ resolver: zod.zodResolver(schema$1)
11489
11595
  });
11490
11596
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11491
11597
  const { handleSuccess } = useRouteModal();
@@ -11655,663 +11761,81 @@ const ShippingAddressForm = ({ order }) => {
11655
11761
  }
11656
11762
  ) });
11657
11763
  };
11658
- const schema$2 = addressSchema;
11659
- const TransferOwnership = () => {
11764
+ const schema$1 = addressSchema;
11765
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11766
+ const Shipping = () => {
11767
+ var _a;
11660
11768
  const { id } = reactRouterDom.useParams();
11661
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
11662
- fields: "id,customer_id,customer.*"
11769
+ const { order, isPending, isError, error } = useOrder(id, {
11770
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11663
11771
  });
11772
+ const {
11773
+ order: preview,
11774
+ isPending: isPreviewPending,
11775
+ isError: isPreviewError,
11776
+ error: previewError
11777
+ } = useOrderPreview(id);
11778
+ useInitiateOrderEdit({ preview });
11779
+ const { onCancel } = useCancelOrderEdit({ preview });
11664
11780
  if (isError) {
11665
11781
  throw error;
11666
11782
  }
11667
- const isReady = !isPending && !!draft_order;
11668
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11669
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11670
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
11671
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
11672
- ] }),
11673
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
11674
- ] });
11783
+ if (isPreviewError) {
11784
+ throw previewError;
11785
+ }
11786
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11787
+ const isReady = preview && !isPreviewPending && order && !isPending;
11788
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11789
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11790
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11791
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11792
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11793
+ ] }) }) }),
11794
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11795
+ ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11796
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11797
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11798
+ ] }) });
11675
11799
  };
11676
- const TransferOwnershipForm = ({ order }) => {
11677
- var _a, _b;
11678
- const form = reactHookForm.useForm({
11679
- defaultValues: {
11680
- customer_id: order.customer_id || ""
11800
+ const ShippingForm = ({ preview, order }) => {
11801
+ var _a;
11802
+ const { setIsOpen } = useStackedModal();
11803
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11804
+ const [data, setData] = React.useState(null);
11805
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11806
+ const { shipping_options } = useShippingOptions(
11807
+ {
11808
+ id: appliedShippingOptionIds,
11809
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11681
11810
  },
11682
- resolver: zod.zodResolver(schema$1)
11683
- });
11684
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11811
+ {
11812
+ enabled: appliedShippingOptionIds.length > 0
11813
+ }
11814
+ );
11815
+ const uniqueShippingProfiles = React.useMemo(() => {
11816
+ const profiles = /* @__PURE__ */ new Map();
11817
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
11818
+ profiles.set(profile.id, profile);
11819
+ });
11820
+ shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11821
+ profiles.set(option.shipping_profile_id, option.shipping_profile);
11822
+ });
11823
+ return Array.from(profiles.values());
11824
+ }, [order.items, shipping_options]);
11685
11825
  const { handleSuccess } = useRouteModal();
11686
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
11687
- const currentCustomer = order.customer ? {
11688
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
11689
- value: order.customer.id
11690
- } : null;
11691
- const onSubmit = form.handleSubmit(async (data) => {
11692
- await mutateAsync(
11693
- { customer_id: data.customer_id },
11694
- {
11695
- onSuccess: () => {
11696
- ui.toast.success("Customer updated");
11697
- handleSuccess();
11698
- },
11699
- onError: (error) => {
11700
- ui.toast.error(error.message);
11701
- }
11702
- }
11703
- );
11704
- });
11705
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11706
- KeyboundForm,
11707
- {
11708
- className: "flex flex-1 flex-col overflow-hidden",
11709
- onSubmit,
11710
- children: [
11711
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
11712
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
11713
- currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
11714
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11715
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
11716
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
11717
- ] }),
11718
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
11719
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
11720
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
11721
- ] })
11722
- ] }),
11723
- /* @__PURE__ */ jsxRuntime.jsx(
11724
- CustomerField,
11725
- {
11726
- control: form.control,
11727
- currentCustomerId: order.customer_id
11728
- }
11729
- )
11730
- ] }),
11731
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11732
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
11733
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11734
- ] }) })
11735
- ]
11736
- }
11737
- ) });
11738
- };
11739
- const CustomerField = ({ control, currentCustomerId }) => {
11740
- const customers = useComboboxData({
11741
- queryFn: async (params) => {
11742
- return await sdk.admin.customer.list({
11743
- ...params,
11744
- id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
11745
- });
11746
- },
11747
- queryKey: ["customers"],
11748
- getOptions: (data) => {
11749
- return data.customers.map((customer) => {
11750
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
11751
- return {
11752
- label: name ? `${name} (${customer.email})` : customer.email,
11753
- value: customer.id
11754
- };
11755
- });
11756
- }
11757
- });
11758
- return /* @__PURE__ */ jsxRuntime.jsx(
11759
- Form$2.Field,
11760
- {
11761
- name: "customer_id",
11762
- control,
11763
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
11764
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11765
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
11766
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
11767
- ] }),
11768
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11769
- Combobox,
11770
- {
11771
- options: customers.options,
11772
- fetchNextPage: customers.fetchNextPage,
11773
- isFetchingNextPage: customers.isFetchingNextPage,
11774
- searchValue: customers.searchValue,
11775
- onSearchValueChange: customers.onSearchValueChange,
11776
- placeholder: "Select customer",
11777
- ...field
11778
- }
11779
- ) }),
11780
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11781
- ] })
11782
- }
11783
- );
11784
- };
11785
- const Illustration = () => {
11786
- return /* @__PURE__ */ jsxRuntime.jsxs(
11787
- "svg",
11788
- {
11789
- width: "280",
11790
- height: "180",
11791
- viewBox: "0 0 280 180",
11792
- fill: "none",
11793
- xmlns: "http://www.w3.org/2000/svg",
11794
- children: [
11795
- /* @__PURE__ */ jsxRuntime.jsx(
11796
- "rect",
11797
- {
11798
- x: "0.00428286",
11799
- y: "-0.742904",
11800
- width: "33.5",
11801
- height: "65.5",
11802
- rx: "6.75",
11803
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
11804
- fill: "#D4D4D8",
11805
- stroke: "#52525B",
11806
- strokeWidth: "1.5"
11807
- }
11808
- ),
11809
- /* @__PURE__ */ jsxRuntime.jsx(
11810
- "rect",
11811
- {
11812
- x: "0.00428286",
11813
- y: "-0.742904",
11814
- width: "33.5",
11815
- height: "65.5",
11816
- rx: "6.75",
11817
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
11818
- fill: "white",
11819
- stroke: "#52525B",
11820
- strokeWidth: "1.5"
11821
- }
11822
- ),
11823
- /* @__PURE__ */ jsxRuntime.jsx(
11824
- "path",
11825
- {
11826
- d: "M180.579 107.142L179.126 107.959",
11827
- stroke: "#52525B",
11828
- strokeWidth: "1.5",
11829
- strokeLinecap: "round",
11830
- strokeLinejoin: "round"
11831
- }
11832
- ),
11833
- /* @__PURE__ */ jsxRuntime.jsx(
11834
- "path",
11835
- {
11836
- opacity: "0.88",
11837
- d: "M182.305 109.546L180.257 109.534",
11838
- stroke: "#52525B",
11839
- strokeWidth: "1.5",
11840
- strokeLinecap: "round",
11841
- strokeLinejoin: "round"
11842
- }
11843
- ),
11844
- /* @__PURE__ */ jsxRuntime.jsx(
11845
- "path",
11846
- {
11847
- opacity: "0.75",
11848
- d: "M180.551 111.93L179.108 111.096",
11849
- stroke: "#52525B",
11850
- strokeWidth: "1.5",
11851
- strokeLinecap: "round",
11852
- strokeLinejoin: "round"
11853
- }
11854
- ),
11855
- /* @__PURE__ */ jsxRuntime.jsx(
11856
- "path",
11857
- {
11858
- opacity: "0.63",
11859
- d: "M176.347 112.897L176.354 111.73",
11860
- stroke: "#52525B",
11861
- strokeWidth: "1.5",
11862
- strokeLinecap: "round",
11863
- strokeLinejoin: "round"
11864
- }
11865
- ),
11866
- /* @__PURE__ */ jsxRuntime.jsx(
11867
- "path",
11868
- {
11869
- opacity: "0.5",
11870
- d: "M172.153 111.881L173.606 111.064",
11871
- stroke: "#52525B",
11872
- strokeWidth: "1.5",
11873
- strokeLinecap: "round",
11874
- strokeLinejoin: "round"
11875
- }
11876
- ),
11877
- /* @__PURE__ */ jsxRuntime.jsx(
11878
- "path",
11879
- {
11880
- opacity: "0.38",
11881
- d: "M170.428 109.478L172.476 109.489",
11882
- stroke: "#52525B",
11883
- strokeWidth: "1.5",
11884
- strokeLinecap: "round",
11885
- strokeLinejoin: "round"
11886
- }
11887
- ),
11888
- /* @__PURE__ */ jsxRuntime.jsx(
11889
- "path",
11890
- {
11891
- opacity: "0.25",
11892
- d: "M172.181 107.094L173.624 107.928",
11893
- stroke: "#52525B",
11894
- strokeWidth: "1.5",
11895
- strokeLinecap: "round",
11896
- strokeLinejoin: "round"
11897
- }
11898
- ),
11899
- /* @__PURE__ */ jsxRuntime.jsx(
11900
- "path",
11901
- {
11902
- opacity: "0.13",
11903
- d: "M176.386 106.126L176.379 107.294",
11904
- stroke: "#52525B",
11905
- strokeWidth: "1.5",
11906
- strokeLinecap: "round",
11907
- strokeLinejoin: "round"
11908
- }
11909
- ),
11910
- /* @__PURE__ */ jsxRuntime.jsx(
11911
- "rect",
11912
- {
11913
- width: "12",
11914
- height: "3",
11915
- rx: "1.5",
11916
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
11917
- fill: "#D4D4D8"
11918
- }
11919
- ),
11920
- /* @__PURE__ */ jsxRuntime.jsx(
11921
- "rect",
11922
- {
11923
- x: "0.00428286",
11924
- y: "-0.742904",
11925
- width: "33.5",
11926
- height: "65.5",
11927
- rx: "6.75",
11928
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
11929
- fill: "#D4D4D8",
11930
- stroke: "#52525B",
11931
- strokeWidth: "1.5"
11932
- }
11933
- ),
11934
- /* @__PURE__ */ jsxRuntime.jsx(
11935
- "rect",
11936
- {
11937
- x: "0.00428286",
11938
- y: "-0.742904",
11939
- width: "33.5",
11940
- height: "65.5",
11941
- rx: "6.75",
11942
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
11943
- fill: "white",
11944
- stroke: "#52525B",
11945
- strokeWidth: "1.5"
11946
- }
11947
- ),
11948
- /* @__PURE__ */ jsxRuntime.jsx(
11949
- "rect",
11950
- {
11951
- width: "12",
11952
- height: "3",
11953
- rx: "1.5",
11954
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
11955
- fill: "#D4D4D8"
11956
- }
11957
- ),
11958
- /* @__PURE__ */ jsxRuntime.jsx(
11959
- "rect",
11960
- {
11961
- width: "17",
11962
- height: "3",
11963
- rx: "1.5",
11964
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
11965
- fill: "#D4D4D8"
11966
- }
11967
- ),
11968
- /* @__PURE__ */ jsxRuntime.jsx(
11969
- "rect",
11970
- {
11971
- width: "12",
11972
- height: "3",
11973
- rx: "1.5",
11974
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
11975
- fill: "#D4D4D8"
11976
- }
11977
- ),
11978
- /* @__PURE__ */ jsxRuntime.jsx(
11979
- "path",
11980
- {
11981
- 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",
11982
- fill: "#A1A1AA"
11983
- }
11984
- ),
11985
- /* @__PURE__ */ jsxRuntime.jsx(
11986
- "rect",
11987
- {
11988
- width: "17",
11989
- height: "3",
11990
- rx: "1.5",
11991
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
11992
- fill: "#A1A1AA"
11993
- }
11994
- ),
11995
- /* @__PURE__ */ jsxRuntime.jsx(
11996
- "rect",
11997
- {
11998
- width: "12",
11999
- height: "3",
12000
- rx: "1.5",
12001
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12002
- fill: "#A1A1AA"
12003
- }
12004
- ),
12005
- /* @__PURE__ */ jsxRuntime.jsx(
12006
- "path",
12007
- {
12008
- 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",
12009
- fill: "#52525B"
12010
- }
12011
- ),
12012
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12013
- "path",
12014
- {
12015
- d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12016
- stroke: "#A1A1AA",
12017
- strokeWidth: "1.5",
12018
- strokeLinecap: "round",
12019
- strokeLinejoin: "round"
12020
- }
12021
- ) }),
12022
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12023
- "path",
12024
- {
12025
- d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12026
- stroke: "#A1A1AA",
12027
- strokeWidth: "1.5",
12028
- strokeLinecap: "round",
12029
- strokeLinejoin: "round"
12030
- }
12031
- ) }),
12032
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12033
- "path",
12034
- {
12035
- d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12036
- stroke: "#A1A1AA",
12037
- strokeWidth: "1.5",
12038
- strokeLinecap: "round",
12039
- strokeLinejoin: "round"
12040
- }
12041
- ) }),
12042
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12043
- "path",
12044
- {
12045
- d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12046
- stroke: "#A1A1AA",
12047
- strokeWidth: "1.5",
12048
- strokeLinecap: "round",
12049
- strokeLinejoin: "round"
12050
- }
12051
- ) }),
12052
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12053
- "path",
12054
- {
12055
- d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12056
- stroke: "#A1A1AA",
12057
- strokeWidth: "1.5",
12058
- strokeLinecap: "round",
12059
- strokeLinejoin: "round"
12060
- }
12061
- ) }),
12062
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12063
- "path",
12064
- {
12065
- d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12066
- stroke: "#A1A1AA",
12067
- strokeWidth: "1.5",
12068
- strokeLinecap: "round",
12069
- strokeLinejoin: "round"
12070
- }
12071
- ) }),
12072
- /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12073
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12074
- "rect",
12075
- {
12076
- width: "12",
12077
- height: "12",
12078
- fill: "white",
12079
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12080
- }
12081
- ) }),
12082
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12083
- "rect",
12084
- {
12085
- width: "12",
12086
- height: "12",
12087
- fill: "white",
12088
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12089
- }
12090
- ) }),
12091
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12092
- "rect",
12093
- {
12094
- width: "12",
12095
- height: "12",
12096
- fill: "white",
12097
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12098
- }
12099
- ) }),
12100
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12101
- "rect",
12102
- {
12103
- width: "12",
12104
- height: "12",
12105
- fill: "white",
12106
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12107
- }
12108
- ) }),
12109
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12110
- "rect",
12111
- {
12112
- width: "12",
12113
- height: "12",
12114
- fill: "white",
12115
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12116
- }
12117
- ) }),
12118
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12119
- "rect",
12120
- {
12121
- width: "12",
12122
- height: "12",
12123
- fill: "white",
12124
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12125
- }
12126
- ) })
12127
- ] })
12128
- ]
12129
- }
12130
- );
12131
- };
12132
- const schema$1 = objectType({
12133
- customer_id: stringType().min(1)
12134
- });
12135
- const SalesChannel = () => {
12136
- const { id } = reactRouterDom.useParams();
12137
- const { draft_order, isPending, isError, error } = useDraftOrder(
12138
- id,
12139
- {
12140
- fields: "+sales_channel_id"
12141
- },
12142
- {
12143
- enabled: !!id
12144
- }
12145
- );
12146
- if (isError) {
12147
- throw error;
12148
- }
12149
- const ISrEADY = !!draft_order && !isPending;
12150
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12151
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12152
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12153
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12154
- ] }),
12155
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12156
- ] });
12157
- };
12158
- const SalesChannelForm = ({ order }) => {
12159
- const form = reactHookForm.useForm({
12160
- defaultValues: {
12161
- sales_channel_id: order.sales_channel_id || ""
12162
- },
12163
- resolver: zod.zodResolver(schema)
12164
- });
12165
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12166
- const { handleSuccess } = useRouteModal();
12167
- const onSubmit = form.handleSubmit(async (data) => {
12168
- await mutateAsync(
12169
- {
12170
- sales_channel_id: data.sales_channel_id
12171
- },
12172
- {
12173
- onSuccess: () => {
12174
- ui.toast.success("Sales channel updated");
12175
- handleSuccess();
12176
- },
12177
- onError: (error) => {
12178
- ui.toast.error(error.message);
12179
- }
12180
- }
12181
- );
12182
- });
12183
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12184
- KeyboundForm,
12185
- {
12186
- className: "flex flex-1 flex-col overflow-hidden",
12187
- onSubmit,
12188
- children: [
12189
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12190
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12191
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12192
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12193
- ] }) })
12194
- ]
12195
- }
12196
- ) });
12197
- };
12198
- const SalesChannelField = ({ control, order }) => {
12199
- const salesChannels = useComboboxData({
12200
- queryFn: async (params) => {
12201
- return await sdk.admin.salesChannel.list(params);
12202
- },
12203
- queryKey: ["sales-channels"],
12204
- getOptions: (data) => {
12205
- return data.sales_channels.map((salesChannel) => ({
12206
- label: salesChannel.name,
12207
- value: salesChannel.id
12208
- }));
12209
- },
12210
- defaultValue: order.sales_channel_id || void 0
12211
- });
12212
- return /* @__PURE__ */ jsxRuntime.jsx(
12213
- Form$2.Field,
12214
- {
12215
- control,
12216
- name: "sales_channel_id",
12217
- render: ({ field }) => {
12218
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12219
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12220
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12221
- Combobox,
12222
- {
12223
- options: salesChannels.options,
12224
- fetchNextPage: salesChannels.fetchNextPage,
12225
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12226
- searchValue: salesChannels.searchValue,
12227
- onSearchValueChange: salesChannels.onSearchValueChange,
12228
- placeholder: "Select sales channel",
12229
- ...field
12230
- }
12231
- ) }),
12232
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12233
- ] });
12234
- }
12235
- }
12236
- );
12237
- };
12238
- const schema = objectType({
12239
- sales_channel_id: stringType().min(1)
12240
- });
12241
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
12242
- const Shipping = () => {
12243
- var _a;
12244
- const { id } = reactRouterDom.useParams();
12245
- const { order, isPending, isError, error } = useOrder(id, {
12246
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
12247
- });
12248
- const {
12249
- order: preview,
12250
- isPending: isPreviewPending,
12251
- isError: isPreviewError,
12252
- error: previewError
12253
- } = useOrderPreview(id);
12254
- useInitiateOrderEdit({ preview });
12255
- const { onCancel } = useCancelOrderEdit({ preview });
12256
- if (isError) {
12257
- throw error;
12258
- }
12259
- if (isPreviewError) {
12260
- throw previewError;
12261
- }
12262
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
12263
- const isReady = preview && !isPreviewPending && order && !isPending;
12264
- return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
12265
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
12266
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
12267
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
12268
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
12269
- ] }) }) }),
12270
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
12271
- ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12272
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
12273
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
12274
- ] }) });
12275
- };
12276
- const ShippingForm = ({ preview, order }) => {
12277
- var _a;
12278
- const { setIsOpen } = useStackedModal();
12279
- const [isSubmitting, setIsSubmitting] = React.useState(false);
12280
- const [data, setData] = React.useState(null);
12281
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
12282
- const { shipping_options } = useShippingOptions(
12283
- {
12284
- id: appliedShippingOptionIds,
12285
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
12286
- },
12287
- {
12288
- enabled: appliedShippingOptionIds.length > 0
12289
- }
12290
- );
12291
- const uniqueShippingProfiles = React.useMemo(() => {
12292
- const profiles = /* @__PURE__ */ new Map();
12293
- getUniqueShippingProfiles(order.items).forEach((profile) => {
12294
- profiles.set(profile.id, profile);
12295
- });
12296
- shipping_options == null ? void 0 : shipping_options.forEach((option) => {
12297
- profiles.set(option.shipping_profile_id, option.shipping_profile);
12298
- });
12299
- return Array.from(profiles.values());
12300
- }, [order.items, shipping_options]);
12301
- const { handleSuccess } = useRouteModal();
12302
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
12303
- const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
12304
- const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
12305
- const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
12306
- const onSubmit = async () => {
12307
- setIsSubmitting(true);
12308
- let requestSucceeded = false;
12309
- await requestOrderEdit(void 0, {
12310
- onError: (e) => {
12311
- ui.toast.error(`Failed to request order edit: ${e.message}`);
12312
- },
12313
- onSuccess: () => {
12314
- requestSucceeded = true;
11826
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11827
+ const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
11828
+ const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
11829
+ const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
11830
+ const onSubmit = async () => {
11831
+ setIsSubmitting(true);
11832
+ let requestSucceeded = false;
11833
+ await requestOrderEdit(void 0, {
11834
+ onError: (e) => {
11835
+ ui.toast.error(`Failed to request order edit: ${e.message}`);
11836
+ },
11837
+ onSuccess: () => {
11838
+ requestSucceeded = true;
12315
11839
  }
12316
11840
  });
12317
11841
  if (!requestSucceeded) {
@@ -12915,136 +12439,612 @@ const LocationField = ({ control, setValue }) => {
12915
12439
  Form$2.Field,
12916
12440
  {
12917
12441
  control,
12918
- name: "location_id",
12919
- render: ({ field: { onChange, ...field } }) => {
12920
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12921
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12922
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
12923
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12924
- ] }),
12925
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12926
- Combobox,
12442
+ name: "location_id",
12443
+ render: ({ field: { onChange, ...field } }) => {
12444
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12445
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12446
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
12447
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12448
+ ] }),
12449
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12450
+ Combobox,
12451
+ {
12452
+ options: locations.options,
12453
+ fetchNextPage: locations.fetchNextPage,
12454
+ isFetchingNextPage: locations.isFetchingNextPage,
12455
+ searchValue: locations.searchValue,
12456
+ onSearchValueChange: locations.onSearchValueChange,
12457
+ placeholder: "Select location",
12458
+ onChange: (value) => {
12459
+ setValue("shipping_option_id", "", {
12460
+ shouldDirty: true,
12461
+ shouldTouch: true
12462
+ });
12463
+ onChange(value);
12464
+ },
12465
+ ...field
12466
+ }
12467
+ ) })
12468
+ ] }) });
12469
+ }
12470
+ }
12471
+ );
12472
+ };
12473
+ const ShippingOptionField = ({
12474
+ shippingProfileId,
12475
+ preview,
12476
+ control
12477
+ }) => {
12478
+ var _a;
12479
+ const locationId = reactHookForm.useWatch({ control, name: "location_id" });
12480
+ const shippingOptions = useComboboxData({
12481
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12482
+ queryFn: async (params) => {
12483
+ return await sdk.admin.shippingOption.list({
12484
+ ...params,
12485
+ stock_location_id: locationId,
12486
+ shipping_profile_id: shippingProfileId
12487
+ });
12488
+ },
12489
+ getOptions: (data) => {
12490
+ return data.shipping_options.map((option) => {
12491
+ var _a2;
12492
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12493
+ (r) => r.attribute === "is_return" && r.value === "true"
12494
+ )) {
12495
+ return void 0;
12496
+ }
12497
+ return {
12498
+ label: option.name,
12499
+ value: option.id
12500
+ };
12501
+ }).filter(Boolean);
12502
+ },
12503
+ enabled: !!locationId && !!shippingProfileId,
12504
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12505
+ });
12506
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12507
+ return /* @__PURE__ */ jsxRuntime.jsx(
12508
+ Form$2.Field,
12509
+ {
12510
+ control,
12511
+ name: "shipping_option_id",
12512
+ render: ({ field }) => {
12513
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12514
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12515
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
12516
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12517
+ ] }),
12518
+ /* @__PURE__ */ jsxRuntime.jsx(
12519
+ ConditionalTooltip,
12520
+ {
12521
+ content: tooltipContent,
12522
+ showTooltip: !locationId || !shippingProfileId,
12523
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12524
+ Combobox,
12525
+ {
12526
+ options: shippingOptions.options,
12527
+ fetchNextPage: shippingOptions.fetchNextPage,
12528
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12529
+ searchValue: shippingOptions.searchValue,
12530
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12531
+ placeholder: "Select shipping option",
12532
+ ...field,
12533
+ disabled: !locationId || !shippingProfileId
12534
+ }
12535
+ ) }) })
12536
+ }
12537
+ )
12538
+ ] }) });
12539
+ }
12540
+ }
12541
+ );
12542
+ };
12543
+ const CustomAmountField = ({
12544
+ control,
12545
+ currencyCode
12546
+ }) => {
12547
+ return /* @__PURE__ */ jsxRuntime.jsx(
12548
+ Form$2.Field,
12549
+ {
12550
+ control,
12551
+ name: "custom_amount",
12552
+ render: ({ field: { onChange, ...field } }) => {
12553
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12554
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12555
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12556
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12557
+ ] }),
12558
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12559
+ ui.CurrencyInput,
12560
+ {
12561
+ ...field,
12562
+ onValueChange: (value) => onChange(value),
12563
+ symbol: getNativeSymbol(currencyCode),
12564
+ code: currencyCode
12565
+ }
12566
+ ) })
12567
+ ] });
12568
+ }
12569
+ }
12570
+ );
12571
+ };
12572
+ const TransferOwnership = () => {
12573
+ const { id } = reactRouterDom.useParams();
12574
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12575
+ fields: "id,customer_id,customer.*"
12576
+ });
12577
+ if (isError) {
12578
+ throw error;
12579
+ }
12580
+ const isReady = !isPending && !!draft_order;
12581
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12582
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12583
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12584
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12585
+ ] }),
12586
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12587
+ ] });
12588
+ };
12589
+ const TransferOwnershipForm = ({ order }) => {
12590
+ var _a, _b;
12591
+ const form = reactHookForm.useForm({
12592
+ defaultValues: {
12593
+ customer_id: order.customer_id || ""
12594
+ },
12595
+ resolver: zod.zodResolver(schema)
12596
+ });
12597
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12598
+ const { handleSuccess } = useRouteModal();
12599
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12600
+ const currentCustomer = order.customer ? {
12601
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12602
+ value: order.customer.id
12603
+ } : null;
12604
+ const onSubmit = form.handleSubmit(async (data) => {
12605
+ await mutateAsync(
12606
+ { customer_id: data.customer_id },
12607
+ {
12608
+ onSuccess: () => {
12609
+ ui.toast.success("Customer updated");
12610
+ handleSuccess();
12611
+ },
12612
+ onError: (error) => {
12613
+ ui.toast.error(error.message);
12614
+ }
12615
+ }
12616
+ );
12617
+ });
12618
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12619
+ KeyboundForm,
12620
+ {
12621
+ className: "flex flex-1 flex-col overflow-hidden",
12622
+ onSubmit,
12623
+ children: [
12624
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12625
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12626
+ currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12627
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12628
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12629
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12630
+ ] }),
12631
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12632
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12633
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12634
+ ] })
12635
+ ] }),
12636
+ /* @__PURE__ */ jsxRuntime.jsx(
12637
+ CustomerField,
12638
+ {
12639
+ control: form.control,
12640
+ currentCustomerId: order.customer_id
12641
+ }
12642
+ )
12643
+ ] }),
12644
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12645
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12646
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12647
+ ] }) })
12648
+ ]
12649
+ }
12650
+ ) });
12651
+ };
12652
+ const CustomerField = ({ control, currentCustomerId }) => {
12653
+ const customers = useComboboxData({
12654
+ queryFn: async (params) => {
12655
+ return await sdk.admin.customer.list({
12656
+ ...params,
12657
+ id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12658
+ });
12659
+ },
12660
+ queryKey: ["customers"],
12661
+ getOptions: (data) => {
12662
+ return data.customers.map((customer) => {
12663
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12664
+ return {
12665
+ label: name ? `${name} (${customer.email})` : customer.email,
12666
+ value: customer.id
12667
+ };
12668
+ });
12669
+ }
12670
+ });
12671
+ return /* @__PURE__ */ jsxRuntime.jsx(
12672
+ Form$2.Field,
12673
+ {
12674
+ name: "customer_id",
12675
+ control,
12676
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
12677
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12678
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
12679
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
12680
+ ] }),
12681
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12682
+ Combobox,
12683
+ {
12684
+ options: customers.options,
12685
+ fetchNextPage: customers.fetchNextPage,
12686
+ isFetchingNextPage: customers.isFetchingNextPage,
12687
+ searchValue: customers.searchValue,
12688
+ onSearchValueChange: customers.onSearchValueChange,
12689
+ placeholder: "Select customer",
12690
+ ...field
12691
+ }
12692
+ ) }),
12693
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12694
+ ] })
12695
+ }
12696
+ );
12697
+ };
12698
+ const Illustration = () => {
12699
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12700
+ "svg",
12701
+ {
12702
+ width: "280",
12703
+ height: "180",
12704
+ viewBox: "0 0 280 180",
12705
+ fill: "none",
12706
+ xmlns: "http://www.w3.org/2000/svg",
12707
+ children: [
12708
+ /* @__PURE__ */ jsxRuntime.jsx(
12709
+ "rect",
12710
+ {
12711
+ x: "0.00428286",
12712
+ y: "-0.742904",
12713
+ width: "33.5",
12714
+ height: "65.5",
12715
+ rx: "6.75",
12716
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
12717
+ fill: "#D4D4D8",
12718
+ stroke: "#52525B",
12719
+ strokeWidth: "1.5"
12720
+ }
12721
+ ),
12722
+ /* @__PURE__ */ jsxRuntime.jsx(
12723
+ "rect",
12724
+ {
12725
+ x: "0.00428286",
12726
+ y: "-0.742904",
12727
+ width: "33.5",
12728
+ height: "65.5",
12729
+ rx: "6.75",
12730
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
12731
+ fill: "white",
12732
+ stroke: "#52525B",
12733
+ strokeWidth: "1.5"
12734
+ }
12735
+ ),
12736
+ /* @__PURE__ */ jsxRuntime.jsx(
12737
+ "path",
12738
+ {
12739
+ d: "M180.579 107.142L179.126 107.959",
12740
+ stroke: "#52525B",
12741
+ strokeWidth: "1.5",
12742
+ strokeLinecap: "round",
12743
+ strokeLinejoin: "round"
12744
+ }
12745
+ ),
12746
+ /* @__PURE__ */ jsxRuntime.jsx(
12747
+ "path",
12748
+ {
12749
+ opacity: "0.88",
12750
+ d: "M182.305 109.546L180.257 109.534",
12751
+ stroke: "#52525B",
12752
+ strokeWidth: "1.5",
12753
+ strokeLinecap: "round",
12754
+ strokeLinejoin: "round"
12755
+ }
12756
+ ),
12757
+ /* @__PURE__ */ jsxRuntime.jsx(
12758
+ "path",
12759
+ {
12760
+ opacity: "0.75",
12761
+ d: "M180.551 111.93L179.108 111.096",
12762
+ stroke: "#52525B",
12763
+ strokeWidth: "1.5",
12764
+ strokeLinecap: "round",
12765
+ strokeLinejoin: "round"
12766
+ }
12767
+ ),
12768
+ /* @__PURE__ */ jsxRuntime.jsx(
12769
+ "path",
12770
+ {
12771
+ opacity: "0.63",
12772
+ d: "M176.347 112.897L176.354 111.73",
12773
+ stroke: "#52525B",
12774
+ strokeWidth: "1.5",
12775
+ strokeLinecap: "round",
12776
+ strokeLinejoin: "round"
12777
+ }
12778
+ ),
12779
+ /* @__PURE__ */ jsxRuntime.jsx(
12780
+ "path",
12781
+ {
12782
+ opacity: "0.5",
12783
+ d: "M172.153 111.881L173.606 111.064",
12784
+ stroke: "#52525B",
12785
+ strokeWidth: "1.5",
12786
+ strokeLinecap: "round",
12787
+ strokeLinejoin: "round"
12788
+ }
12789
+ ),
12790
+ /* @__PURE__ */ jsxRuntime.jsx(
12791
+ "path",
12792
+ {
12793
+ opacity: "0.38",
12794
+ d: "M170.428 109.478L172.476 109.489",
12795
+ stroke: "#52525B",
12796
+ strokeWidth: "1.5",
12797
+ strokeLinecap: "round",
12798
+ strokeLinejoin: "round"
12799
+ }
12800
+ ),
12801
+ /* @__PURE__ */ jsxRuntime.jsx(
12802
+ "path",
12803
+ {
12804
+ opacity: "0.25",
12805
+ d: "M172.181 107.094L173.624 107.928",
12806
+ stroke: "#52525B",
12807
+ strokeWidth: "1.5",
12808
+ strokeLinecap: "round",
12809
+ strokeLinejoin: "round"
12810
+ }
12811
+ ),
12812
+ /* @__PURE__ */ jsxRuntime.jsx(
12813
+ "path",
12814
+ {
12815
+ opacity: "0.13",
12816
+ d: "M176.386 106.126L176.379 107.294",
12817
+ stroke: "#52525B",
12818
+ strokeWidth: "1.5",
12819
+ strokeLinecap: "round",
12820
+ strokeLinejoin: "round"
12821
+ }
12822
+ ),
12823
+ /* @__PURE__ */ jsxRuntime.jsx(
12824
+ "rect",
12825
+ {
12826
+ width: "12",
12827
+ height: "3",
12828
+ rx: "1.5",
12829
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12830
+ fill: "#D4D4D8"
12831
+ }
12832
+ ),
12833
+ /* @__PURE__ */ jsxRuntime.jsx(
12834
+ "rect",
12835
+ {
12836
+ x: "0.00428286",
12837
+ y: "-0.742904",
12838
+ width: "33.5",
12839
+ height: "65.5",
12840
+ rx: "6.75",
12841
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12842
+ fill: "#D4D4D8",
12843
+ stroke: "#52525B",
12844
+ strokeWidth: "1.5"
12845
+ }
12846
+ ),
12847
+ /* @__PURE__ */ jsxRuntime.jsx(
12848
+ "rect",
12849
+ {
12850
+ x: "0.00428286",
12851
+ y: "-0.742904",
12852
+ width: "33.5",
12853
+ height: "65.5",
12854
+ rx: "6.75",
12855
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12856
+ fill: "white",
12857
+ stroke: "#52525B",
12858
+ strokeWidth: "1.5"
12859
+ }
12860
+ ),
12861
+ /* @__PURE__ */ jsxRuntime.jsx(
12862
+ "rect",
12863
+ {
12864
+ width: "12",
12865
+ height: "3",
12866
+ rx: "1.5",
12867
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12868
+ fill: "#D4D4D8"
12869
+ }
12870
+ ),
12871
+ /* @__PURE__ */ jsxRuntime.jsx(
12872
+ "rect",
12873
+ {
12874
+ width: "17",
12875
+ height: "3",
12876
+ rx: "1.5",
12877
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12878
+ fill: "#D4D4D8"
12879
+ }
12880
+ ),
12881
+ /* @__PURE__ */ jsxRuntime.jsx(
12882
+ "rect",
12883
+ {
12884
+ width: "12",
12885
+ height: "3",
12886
+ rx: "1.5",
12887
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12888
+ fill: "#D4D4D8"
12889
+ }
12890
+ ),
12891
+ /* @__PURE__ */ jsxRuntime.jsx(
12892
+ "path",
12893
+ {
12894
+ 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",
12895
+ fill: "#A1A1AA"
12896
+ }
12897
+ ),
12898
+ /* @__PURE__ */ jsxRuntime.jsx(
12899
+ "rect",
12900
+ {
12901
+ width: "17",
12902
+ height: "3",
12903
+ rx: "1.5",
12904
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12905
+ fill: "#A1A1AA"
12906
+ }
12907
+ ),
12908
+ /* @__PURE__ */ jsxRuntime.jsx(
12909
+ "rect",
12910
+ {
12911
+ width: "12",
12912
+ height: "3",
12913
+ rx: "1.5",
12914
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12915
+ fill: "#A1A1AA"
12916
+ }
12917
+ ),
12918
+ /* @__PURE__ */ jsxRuntime.jsx(
12919
+ "path",
12920
+ {
12921
+ 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",
12922
+ fill: "#52525B"
12923
+ }
12924
+ ),
12925
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12926
+ "path",
12927
+ {
12928
+ d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12929
+ stroke: "#A1A1AA",
12930
+ strokeWidth: "1.5",
12931
+ strokeLinecap: "round",
12932
+ strokeLinejoin: "round"
12933
+ }
12934
+ ) }),
12935
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12936
+ "path",
12937
+ {
12938
+ d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12939
+ stroke: "#A1A1AA",
12940
+ strokeWidth: "1.5",
12941
+ strokeLinecap: "round",
12942
+ strokeLinejoin: "round"
12943
+ }
12944
+ ) }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12946
+ "path",
12947
+ {
12948
+ d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12949
+ stroke: "#A1A1AA",
12950
+ strokeWidth: "1.5",
12951
+ strokeLinecap: "round",
12952
+ strokeLinejoin: "round"
12953
+ }
12954
+ ) }),
12955
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12956
+ "path",
12957
+ {
12958
+ d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12959
+ stroke: "#A1A1AA",
12960
+ strokeWidth: "1.5",
12961
+ strokeLinecap: "round",
12962
+ strokeLinejoin: "round"
12963
+ }
12964
+ ) }),
12965
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12966
+ "path",
12967
+ {
12968
+ d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12969
+ stroke: "#A1A1AA",
12970
+ strokeWidth: "1.5",
12971
+ strokeLinecap: "round",
12972
+ strokeLinejoin: "round"
12973
+ }
12974
+ ) }),
12975
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12976
+ "path",
12977
+ {
12978
+ d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12979
+ stroke: "#A1A1AA",
12980
+ strokeWidth: "1.5",
12981
+ strokeLinecap: "round",
12982
+ strokeLinejoin: "round"
12983
+ }
12984
+ ) }),
12985
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12986
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12987
+ "rect",
12927
12988
  {
12928
- options: locations.options,
12929
- fetchNextPage: locations.fetchNextPage,
12930
- isFetchingNextPage: locations.isFetchingNextPage,
12931
- searchValue: locations.searchValue,
12932
- onSearchValueChange: locations.onSearchValueChange,
12933
- placeholder: "Select location",
12934
- onChange: (value) => {
12935
- setValue("shipping_option_id", "", {
12936
- shouldDirty: true,
12937
- shouldTouch: true
12938
- });
12939
- onChange(value);
12940
- },
12941
- ...field
12989
+ width: "12",
12990
+ height: "12",
12991
+ fill: "white",
12992
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12942
12993
  }
12943
- ) })
12944
- ] }) });
12945
- }
12946
- }
12947
- );
12948
- };
12949
- const ShippingOptionField = ({
12950
- shippingProfileId,
12951
- preview,
12952
- control
12953
- }) => {
12954
- var _a;
12955
- const locationId = reactHookForm.useWatch({ control, name: "location_id" });
12956
- const shippingOptions = useComboboxData({
12957
- queryKey: ["shipping_options", locationId, shippingProfileId],
12958
- queryFn: async (params) => {
12959
- return await sdk.admin.shippingOption.list({
12960
- ...params,
12961
- stock_location_id: locationId,
12962
- shipping_profile_id: shippingProfileId
12963
- });
12964
- },
12965
- getOptions: (data) => {
12966
- return data.shipping_options.map((option) => {
12967
- var _a2;
12968
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12969
- (r) => r.attribute === "is_return" && r.value === "true"
12970
- )) {
12971
- return void 0;
12972
- }
12973
- return {
12974
- label: option.name,
12975
- value: option.id
12976
- };
12977
- }).filter(Boolean);
12978
- },
12979
- enabled: !!locationId && !!shippingProfileId,
12980
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12981
- });
12982
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12983
- return /* @__PURE__ */ jsxRuntime.jsx(
12984
- Form$2.Field,
12985
- {
12986
- control,
12987
- name: "shipping_option_id",
12988
- render: ({ field }) => {
12989
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12990
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12991
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
12992
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12993
- ] }),
12994
- /* @__PURE__ */ jsxRuntime.jsx(
12995
- ConditionalTooltip,
12994
+ ) }),
12995
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12996
+ "rect",
12996
12997
  {
12997
- content: tooltipContent,
12998
- showTooltip: !locationId || !shippingProfileId,
12999
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13000
- Combobox,
13001
- {
13002
- options: shippingOptions.options,
13003
- fetchNextPage: shippingOptions.fetchNextPage,
13004
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
13005
- searchValue: shippingOptions.searchValue,
13006
- onSearchValueChange: shippingOptions.onSearchValueChange,
13007
- placeholder: "Select shipping option",
13008
- ...field,
13009
- disabled: !locationId || !shippingProfileId
13010
- }
13011
- ) }) })
12998
+ width: "12",
12999
+ height: "12",
13000
+ fill: "white",
13001
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
13012
13002
  }
13013
- )
13014
- ] }) });
13015
- }
13016
- }
13017
- );
13018
- };
13019
- const CustomAmountField = ({
13020
- control,
13021
- currencyCode
13022
- }) => {
13023
- return /* @__PURE__ */ jsxRuntime.jsx(
13024
- Form$2.Field,
13025
- {
13026
- control,
13027
- name: "custom_amount",
13028
- render: ({ field: { onChange, ...field } }) => {
13029
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
13030
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
13033
- ] }),
13034
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13035
- ui.CurrencyInput,
13003
+ ) }),
13004
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13005
+ "rect",
13036
13006
  {
13037
- ...field,
13038
- onValueChange: (value) => onChange(value),
13039
- symbol: getNativeSymbol(currencyCode),
13040
- code: currencyCode
13007
+ width: "12",
13008
+ height: "12",
13009
+ fill: "white",
13010
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
13011
+ }
13012
+ ) }),
13013
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13014
+ "rect",
13015
+ {
13016
+ width: "12",
13017
+ height: "12",
13018
+ fill: "white",
13019
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
13020
+ }
13021
+ ) }),
13022
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13023
+ "rect",
13024
+ {
13025
+ width: "12",
13026
+ height: "12",
13027
+ fill: "white",
13028
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
13029
+ }
13030
+ ) }),
13031
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13032
+ "rect",
13033
+ {
13034
+ width: "12",
13035
+ height: "12",
13036
+ fill: "white",
13037
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
13041
13038
  }
13042
13039
  ) })
13043
- ] });
13044
- }
13040
+ ] })
13041
+ ]
13045
13042
  }
13046
13043
  );
13047
13044
  };
13045
+ const schema = objectType({
13046
+ customer_id: stringType().min(1)
13047
+ });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13069,14 +13069,14 @@ const routeModule = {
13069
13069
  Component: BillingAddress,
13070
13070
  path: "/draft-orders/:id/billing-address"
13071
13071
  },
13072
- {
13073
- Component: Email,
13074
- path: "/draft-orders/:id/email"
13075
- },
13076
13072
  {
13077
13073
  Component: CustomItems,
13078
13074
  path: "/draft-orders/:id/custom-items"
13079
13075
  },
13076
+ {
13077
+ Component: Email,
13078
+ path: "/draft-orders/:id/email"
13079
+ },
13080
13080
  {
13081
13081
  Component: Items,
13082
13082
  path: "/draft-orders/:id/items"
@@ -13089,21 +13089,21 @@ const routeModule = {
13089
13089
  Component: Promotions,
13090
13090
  path: "/draft-orders/:id/promotions"
13091
13091
  },
13092
- {
13093
- Component: ShippingAddress,
13094
- path: "/draft-orders/:id/shipping-address"
13095
- },
13096
- {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13099
- },
13100
13092
  {
13101
13093
  Component: SalesChannel,
13102
13094
  path: "/draft-orders/:id/sales-channel"
13103
13095
  },
13096
+ {
13097
+ Component: ShippingAddress,
13098
+ path: "/draft-orders/:id/shipping-address"
13099
+ },
13104
13100
  {
13105
13101
  Component: Shipping,
13106
13102
  path: "/draft-orders/:id/shipping"
13103
+ },
13104
+ {
13105
+ Component: TransferOwnership,
13106
+ path: "/draft-orders/:id/transfer-ownership"
13107
13107
  }
13108
13108
  ]
13109
13109
  }