@medusajs/draft-order 3.0.0-snapshot-20251104004624 → 3.0.0-snapshot-20251104011621

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