@medusajs/draft-order 2.11.4-preview-20251106210130 → 2.11.4-preview-20251107000304

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