@medusajs/draft-order 2.11.2-preview-20251026090153 → 2.11.2-preview-20251026120206

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