@medusajs/draft-order 2.10.4-snapshot-20251007075945 → 2.10.4-snapshot-20251007081528

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