@medusajs/draft-order 2.10.2-preview-20250911120205 → 2.10.2-preview-20250911180158

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.
@@ -9573,6 +9573,196 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
+ const BillingAddress = () => {
9577
+ const { id } = reactRouterDom.useParams();
9578
+ const { order, isPending, isError, error } = useOrder(id, {
9579
+ fields: "+billing_address"
9580
+ });
9581
+ if (isError) {
9582
+ throw error;
9583
+ }
9584
+ const isReady = !isPending && !!order;
9585
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9586
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9589
+ ] }),
9590
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9591
+ ] });
9592
+ };
9593
+ const BillingAddressForm = ({ order }) => {
9594
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9595
+ const form = reactHookForm.useForm({
9596
+ defaultValues: {
9597
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9598
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9599
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9600
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9601
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9602
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9603
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9604
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9605
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9606
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9607
+ },
9608
+ resolver: zod.zodResolver(schema$5)
9609
+ });
9610
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9611
+ const { handleSuccess } = useRouteModal();
9612
+ const onSubmit = form.handleSubmit(async (data) => {
9613
+ await mutateAsync(
9614
+ { billing_address: data },
9615
+ {
9616
+ onSuccess: () => {
9617
+ handleSuccess();
9618
+ },
9619
+ onError: (error) => {
9620
+ ui.toast.error(error.message);
9621
+ }
9622
+ }
9623
+ );
9624
+ });
9625
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9626
+ KeyboundForm,
9627
+ {
9628
+ className: "flex flex-1 flex-col overflow-hidden",
9629
+ onSubmit,
9630
+ children: [
9631
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9632
+ /* @__PURE__ */ jsxRuntime.jsx(
9633
+ Form$2.Field,
9634
+ {
9635
+ control: form.control,
9636
+ name: "country_code",
9637
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9640
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
+ ] })
9642
+ }
9643
+ ),
9644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9645
+ /* @__PURE__ */ jsxRuntime.jsx(
9646
+ Form$2.Field,
9647
+ {
9648
+ control: form.control,
9649
+ name: "first_name",
9650
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9653
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9654
+ ] })
9655
+ }
9656
+ ),
9657
+ /* @__PURE__ */ jsxRuntime.jsx(
9658
+ Form$2.Field,
9659
+ {
9660
+ control: form.control,
9661
+ name: "last_name",
9662
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9665
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9666
+ ] })
9667
+ }
9668
+ )
9669
+ ] }),
9670
+ /* @__PURE__ */ jsxRuntime.jsx(
9671
+ Form$2.Field,
9672
+ {
9673
+ control: form.control,
9674
+ name: "company",
9675
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9678
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9679
+ ] })
9680
+ }
9681
+ ),
9682
+ /* @__PURE__ */ jsxRuntime.jsx(
9683
+ Form$2.Field,
9684
+ {
9685
+ control: form.control,
9686
+ name: "address_1",
9687
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9690
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9691
+ ] })
9692
+ }
9693
+ ),
9694
+ /* @__PURE__ */ jsxRuntime.jsx(
9695
+ Form$2.Field,
9696
+ {
9697
+ control: form.control,
9698
+ name: "address_2",
9699
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9702
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9703
+ ] })
9704
+ }
9705
+ ),
9706
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9707
+ /* @__PURE__ */ jsxRuntime.jsx(
9708
+ Form$2.Field,
9709
+ {
9710
+ control: form.control,
9711
+ name: "postal_code",
9712
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9715
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9716
+ ] })
9717
+ }
9718
+ ),
9719
+ /* @__PURE__ */ jsxRuntime.jsx(
9720
+ Form$2.Field,
9721
+ {
9722
+ control: form.control,
9723
+ name: "city",
9724
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
+ ] })
9729
+ }
9730
+ )
9731
+ ] }),
9732
+ /* @__PURE__ */ jsxRuntime.jsx(
9733
+ Form$2.Field,
9734
+ {
9735
+ control: form.control,
9736
+ name: "province",
9737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9741
+ ] })
9742
+ }
9743
+ ),
9744
+ /* @__PURE__ */ jsxRuntime.jsx(
9745
+ Form$2.Field,
9746
+ {
9747
+ control: form.control,
9748
+ name: "phone",
9749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9753
+ ] })
9754
+ }
9755
+ )
9756
+ ] }) }),
9757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9758
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9759
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9760
+ ] }) })
9761
+ ]
9762
+ }
9763
+ ) });
9764
+ };
9765
+ const schema$5 = addressSchema;
9576
9766
  const CustomItems = () => {
9577
9767
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9578
9768
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9581,7 +9771,7 @@ const CustomItems = () => {
9581
9771
  };
9582
9772
  const CustomItemsForm = () => {
9583
9773
  const form = reactHookForm.useForm({
9584
- resolver: zod.zodResolver(schema$5)
9774
+ resolver: zod.zodResolver(schema$4)
9585
9775
  });
9586
9776
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9587
9777
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9591,46 +9781,114 @@ const CustomItemsForm = () => {
9591
9781
  ] }) })
9592
9782
  ] }) });
9593
9783
  };
9594
- const schema$5 = objectType({
9784
+ const schema$4 = objectType({
9595
9785
  email: stringType().email()
9596
9786
  });
9597
- const NumberInput = React.forwardRef(
9598
- ({
9599
- value,
9600
- onChange,
9601
- size = "base",
9602
- min = 0,
9603
- max = 100,
9604
- step = 1,
9605
- className,
9606
- disabled,
9607
- ...props
9608
- }, ref) => {
9609
- const handleChange = (event) => {
9610
- const newValue = event.target.value === "" ? min : Number(event.target.value);
9611
- if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
9612
- onChange(newValue);
9613
- }
9614
- };
9615
- const handleIncrement = () => {
9616
- const newValue = value + step;
9617
- if (max === void 0 || newValue <= max) {
9618
- onChange(newValue);
9619
- }
9620
- };
9621
- const handleDecrement = () => {
9622
- const newValue = value - step;
9623
- if (min === void 0 || newValue >= min) {
9624
- onChange(newValue);
9625
- }
9626
- };
9627
- return /* @__PURE__ */ jsxRuntime.jsxs(
9628
- "div",
9787
+ const Email = () => {
9788
+ const { id } = reactRouterDom.useParams();
9789
+ const { order, isPending, isError, error } = useOrder(id, {
9790
+ fields: "+email"
9791
+ });
9792
+ if (isError) {
9793
+ throw error;
9794
+ }
9795
+ const isReady = !isPending && !!order;
9796
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9797
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9798
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9799
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9800
+ ] }),
9801
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9802
+ ] });
9803
+ };
9804
+ const EmailForm = ({ order }) => {
9805
+ const form = reactHookForm.useForm({
9806
+ defaultValues: {
9807
+ email: order.email ?? ""
9808
+ },
9809
+ resolver: zod.zodResolver(schema$3)
9810
+ });
9811
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9812
+ const { handleSuccess } = useRouteModal();
9813
+ const onSubmit = form.handleSubmit(async (data) => {
9814
+ await mutateAsync(
9815
+ { email: data.email },
9629
9816
  {
9630
- className: ui.clx(
9631
- "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
9632
- "[&:has(input:focus)]:shadow-borders-interactive-with-active",
9633
- {
9817
+ onSuccess: () => {
9818
+ handleSuccess();
9819
+ },
9820
+ onError: (error) => {
9821
+ ui.toast.error(error.message);
9822
+ }
9823
+ }
9824
+ );
9825
+ });
9826
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9827
+ KeyboundForm,
9828
+ {
9829
+ className: "flex flex-1 flex-col overflow-hidden",
9830
+ onSubmit,
9831
+ children: [
9832
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9833
+ Form$2.Field,
9834
+ {
9835
+ control: form.control,
9836
+ name: "email",
9837
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9838
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9839
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9840
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9841
+ ] })
9842
+ }
9843
+ ) }),
9844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9845
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9847
+ ] }) })
9848
+ ]
9849
+ }
9850
+ ) });
9851
+ };
9852
+ const schema$3 = objectType({
9853
+ email: stringType().email()
9854
+ });
9855
+ const NumberInput = React.forwardRef(
9856
+ ({
9857
+ value,
9858
+ onChange,
9859
+ size = "base",
9860
+ min = 0,
9861
+ max = 100,
9862
+ step = 1,
9863
+ className,
9864
+ disabled,
9865
+ ...props
9866
+ }, ref) => {
9867
+ const handleChange = (event) => {
9868
+ const newValue = event.target.value === "" ? min : Number(event.target.value);
9869
+ if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
9870
+ onChange(newValue);
9871
+ }
9872
+ };
9873
+ const handleIncrement = () => {
9874
+ const newValue = value + step;
9875
+ if (max === void 0 || newValue <= max) {
9876
+ onChange(newValue);
9877
+ }
9878
+ };
9879
+ const handleDecrement = () => {
9880
+ const newValue = value - step;
9881
+ if (min === void 0 || newValue >= min) {
9882
+ onChange(newValue);
9883
+ }
9884
+ };
9885
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9886
+ "div",
9887
+ {
9888
+ className: ui.clx(
9889
+ "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
9890
+ "[&:has(input:focus)]:shadow-borders-interactive-with-active",
9891
+ {
9634
9892
  "h-7": size === "small",
9635
9893
  "h-8": size === "base"
9636
9894
  },
@@ -11195,1629 +11453,1160 @@ function getPromotionIds(items, shippingMethods) {
11195
11453
  }
11196
11454
  return Array.from(promotionIds);
11197
11455
  }
11198
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11199
- const Shipping = () => {
11200
- var _a;
11456
+ const SalesChannel = () => {
11201
11457
  const { id } = reactRouterDom.useParams();
11202
- const { order, isPending, isError, error } = useOrder(id, {
11203
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11204
- });
11205
- const {
11206
- order: preview,
11207
- isPending: isPreviewPending,
11208
- isError: isPreviewError,
11209
- error: previewError
11210
- } = useOrderPreview(id);
11211
- useInitiateOrderEdit({ preview });
11212
- const { onCancel } = useCancelOrderEdit({ preview });
11213
- if (isError) {
11214
- throw error;
11215
- }
11216
- if (isPreviewError) {
11217
- throw previewError;
11218
- }
11219
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11220
- const isReady = preview && !isPreviewPending && order && !isPending;
11221
- return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11222
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11223
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11224
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11225
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11226
- ] }) }) }),
11227
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11228
- ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11229
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11230
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11231
- ] }) });
11232
- };
11233
- const ShippingForm = ({ preview, order }) => {
11234
- var _a;
11235
- const { setIsOpen } = useStackedModal();
11236
- const [isSubmitting, setIsSubmitting] = React.useState(false);
11237
- const [data, setData] = React.useState(null);
11238
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11239
- const { shipping_options } = useShippingOptions(
11458
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11459
+ id,
11240
11460
  {
11241
- id: appliedShippingOptionIds,
11242
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11461
+ fields: "+sales_channel_id"
11243
11462
  },
11244
11463
  {
11245
- enabled: appliedShippingOptionIds.length > 0
11464
+ enabled: !!id
11246
11465
  }
11247
11466
  );
11248
- const uniqueShippingProfiles = React.useMemo(() => {
11249
- const profiles = /* @__PURE__ */ new Map();
11250
- getUniqueShippingProfiles(order.items).forEach((profile) => {
11251
- profiles.set(profile.id, profile);
11252
- });
11253
- shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11254
- profiles.set(option.shipping_profile_id, option.shipping_profile);
11255
- });
11256
- return Array.from(profiles.values());
11257
- }, [order.items, shipping_options]);
11467
+ if (isError) {
11468
+ throw error;
11469
+ }
11470
+ const ISrEADY = !!draft_order && !isPending;
11471
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11472
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11473
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11474
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11475
+ ] }),
11476
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11477
+ ] });
11478
+ };
11479
+ const SalesChannelForm = ({ order }) => {
11480
+ const form = reactHookForm.useForm({
11481
+ defaultValues: {
11482
+ sales_channel_id: order.sales_channel_id || ""
11483
+ },
11484
+ resolver: zod.zodResolver(schema$2)
11485
+ });
11486
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11258
11487
  const { handleSuccess } = useRouteModal();
11259
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11260
- const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
11261
- const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
11262
- const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
11263
- const onSubmit = async () => {
11264
- setIsSubmitting(true);
11265
- let requestSucceeded = false;
11266
- await requestOrderEdit(void 0, {
11267
- onError: (e) => {
11268
- ui.toast.error(`Failed to request order edit: ${e.message}`);
11269
- },
11270
- onSuccess: () => {
11271
- requestSucceeded = true;
11272
- }
11273
- });
11274
- if (!requestSucceeded) {
11275
- setIsSubmitting(false);
11276
- return;
11277
- }
11278
- await confirmOrderEdit(void 0, {
11279
- onError: (e) => {
11280
- ui.toast.error(`Failed to confirm order edit: ${e.message}`);
11281
- },
11282
- onSuccess: () => {
11283
- handleSuccess();
11488
+ const onSubmit = form.handleSubmit(async (data) => {
11489
+ await mutateAsync(
11490
+ {
11491
+ sales_channel_id: data.sales_channel_id
11284
11492
  },
11285
- onSettled: () => {
11286
- setIsSubmitting(false);
11287
- }
11288
- });
11289
- };
11290
- const onKeydown = React.useCallback(
11291
- (e) => {
11292
- if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
11293
- if (data || isSubmitting) {
11294
- return;
11493
+ {
11494
+ onSuccess: () => {
11495
+ ui.toast.success("Sales channel updated");
11496
+ handleSuccess();
11497
+ },
11498
+ onError: (error) => {
11499
+ ui.toast.error(error.message);
11295
11500
  }
11296
- onSubmit();
11297
11501
  }
11502
+ );
11503
+ });
11504
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11505
+ KeyboundForm,
11506
+ {
11507
+ className: "flex flex-1 flex-col overflow-hidden",
11508
+ onSubmit,
11509
+ children: [
11510
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11511
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11512
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11513
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11514
+ ] }) })
11515
+ ]
11516
+ }
11517
+ ) });
11518
+ };
11519
+ const SalesChannelField = ({ control, order }) => {
11520
+ const salesChannels = useComboboxData({
11521
+ queryFn: async (params) => {
11522
+ return await sdk.admin.salesChannel.list(params);
11298
11523
  },
11299
- [data, isSubmitting, onSubmit]
11524
+ queryKey: ["sales-channels"],
11525
+ getOptions: (data) => {
11526
+ return data.sales_channels.map((salesChannel) => ({
11527
+ label: salesChannel.name,
11528
+ value: salesChannel.id
11529
+ }));
11530
+ },
11531
+ defaultValue: order.sales_channel_id || void 0
11532
+ });
11533
+ return /* @__PURE__ */ jsxRuntime.jsx(
11534
+ Form$2.Field,
11535
+ {
11536
+ control,
11537
+ name: "sales_channel_id",
11538
+ render: ({ field }) => {
11539
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11541
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11542
+ Combobox,
11543
+ {
11544
+ options: salesChannels.options,
11545
+ fetchNextPage: salesChannels.fetchNextPage,
11546
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11547
+ searchValue: salesChannels.searchValue,
11548
+ onSearchValueChange: salesChannels.onSearchValueChange,
11549
+ placeholder: "Select sales channel",
11550
+ ...field
11551
+ }
11552
+ ) }),
11553
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11554
+ ] });
11555
+ }
11556
+ }
11300
11557
  );
11301
- React.useEffect(() => {
11302
- document.addEventListener("keydown", onKeydown);
11303
- return () => {
11304
- document.removeEventListener("keydown", onKeydown);
11305
- };
11306
- }, [onKeydown]);
11307
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
11308
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11309
- /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
11310
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11311
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11312
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11313
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
11314
- ] }),
11315
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11316
- /* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
11317
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
11558
+ };
11559
+ const schema$2 = objectType({
11560
+ sales_channel_id: stringType().min(1)
11561
+ });
11562
+ const ShippingAddress = () => {
11563
+ const { id } = reactRouterDom.useParams();
11564
+ const { order, isPending, isError, error } = useOrder(id, {
11565
+ fields: "+shipping_address"
11566
+ });
11567
+ if (isError) {
11568
+ throw error;
11569
+ }
11570
+ const isReady = !isPending && !!order;
11571
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11572
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11573
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11574
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11575
+ ] }),
11576
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11577
+ ] });
11578
+ };
11579
+ const ShippingAddressForm = ({ order }) => {
11580
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11581
+ const form = reactHookForm.useForm({
11582
+ defaultValues: {
11583
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11584
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11585
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11586
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11587
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11588
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11589
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11590
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11591
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11592
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11593
+ },
11594
+ resolver: zod.zodResolver(schema$1)
11595
+ });
11596
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11597
+ const { handleSuccess } = useRouteModal();
11598
+ const onSubmit = form.handleSubmit(async (data) => {
11599
+ await mutateAsync(
11600
+ {
11601
+ shipping_address: {
11602
+ first_name: data.first_name,
11603
+ last_name: data.last_name,
11604
+ company: data.company,
11605
+ address_1: data.address_1,
11606
+ address_2: data.address_2,
11607
+ city: data.city,
11608
+ province: data.province,
11609
+ country_code: data.country_code,
11610
+ postal_code: data.postal_code,
11611
+ phone: data.phone
11612
+ }
11613
+ },
11614
+ {
11615
+ onSuccess: () => {
11616
+ handleSuccess();
11617
+ },
11618
+ onError: (error) => {
11619
+ ui.toast.error(error.message);
11620
+ }
11621
+ }
11622
+ );
11623
+ });
11624
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11625
+ KeyboundForm,
11626
+ {
11627
+ className: "flex flex-1 flex-col overflow-hidden",
11628
+ onSubmit,
11629
+ children: [
11630
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
11631
+ /* @__PURE__ */ jsxRuntime.jsx(
11632
+ Form$2.Field,
11633
+ {
11634
+ control: form.control,
11635
+ name: "country_code",
11636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11640
+ ] })
11641
+ }
11642
+ ),
11643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11318
11644
  /* @__PURE__ */ jsxRuntime.jsx(
11319
- ui.Text,
11645
+ Form$2.Field,
11320
11646
  {
11321
- size: "xsmall",
11322
- weight: "plus",
11323
- className: "text-ui-fg-muted",
11324
- children: "Shipping profile"
11647
+ control: form.control,
11648
+ name: "first_name",
11649
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11653
+ ] })
11325
11654
  }
11326
11655
  ),
11327
11656
  /* @__PURE__ */ jsxRuntime.jsx(
11328
- ui.Text,
11657
+ Form$2.Field,
11329
11658
  {
11330
- size: "xsmall",
11331
- weight: "plus",
11332
- className: "text-ui-fg-muted",
11333
- children: "Action"
11659
+ control: form.control,
11660
+ name: "last_name",
11661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11665
+ ] })
11334
11666
  }
11335
11667
  )
11336
11668
  ] }),
11337
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
11338
- var _a2, _b, _c, _d, _e, _f, _g;
11339
- const items = getItemsWithShippingProfile(
11340
- profile.id,
11341
- order.items
11342
- );
11343
- const hasItems = items.length > 0;
11344
- const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
11345
- (option) => option.shipping_profile_id === profile.id
11346
- );
11347
- const shippingMethod = preview.shipping_methods.find(
11348
- (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
11349
- );
11350
- const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
11351
- (action) => action.action === "SHIPPING_ADD"
11352
- );
11353
- return /* @__PURE__ */ jsxRuntime.jsxs(
11354
- radixUi.Accordion.Item,
11669
+ /* @__PURE__ */ jsxRuntime.jsx(
11670
+ Form$2.Field,
11671
+ {
11672
+ control: form.control,
11673
+ name: "company",
11674
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11678
+ ] })
11679
+ }
11680
+ ),
11681
+ /* @__PURE__ */ jsxRuntime.jsx(
11682
+ Form$2.Field,
11683
+ {
11684
+ control: form.control,
11685
+ name: "address_1",
11686
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11690
+ ] })
11691
+ }
11692
+ ),
11693
+ /* @__PURE__ */ jsxRuntime.jsx(
11694
+ Form$2.Field,
11695
+ {
11696
+ control: form.control,
11697
+ name: "address_2",
11698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11702
+ ] })
11703
+ }
11704
+ ),
11705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11706
+ /* @__PURE__ */ jsxRuntime.jsx(
11707
+ Form$2.Field,
11355
11708
  {
11356
- value: profile.id,
11357
- className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
11358
- children: [
11359
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2 flex items-center justify-between gap-3", children: [
11360
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full overflow-hidden", children: [
11361
- /* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
11362
- ui.IconButton,
11363
- {
11364
- size: "2xsmall",
11365
- variant: "transparent",
11366
- className: "group/trigger",
11367
- disabled: !hasItems,
11368
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90 transition-transform" })
11369
- }
11370
- ) }),
11371
- !shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
11372
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 rounded-md shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-6 rounded bg-ui-bg-component-hover flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
11373
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-1", children: [
11374
- /* @__PURE__ */ jsxRuntime.jsx(
11375
- ui.Text,
11376
- {
11377
- size: "small",
11378
- weight: "plus",
11379
- leading: "compact",
11380
- children: profile.name
11381
- }
11382
- ),
11383
- /* @__PURE__ */ jsxRuntime.jsxs(
11384
- ui.Text,
11385
- {
11386
- size: "small",
11387
- leading: "compact",
11388
- className: "text-ui-fg-subtle",
11389
- children: [
11390
- items.length,
11391
- " ",
11392
- pluralize(items.length, "items", "item")
11393
- ]
11394
- }
11395
- )
11396
- ] })
11397
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start flex-1 w-full overflow-hidden", children: [
11398
- /* @__PURE__ */ jsxRuntime.jsx(
11399
- ui.Tooltip,
11400
- {
11401
- content: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: items.map((item) => {
11402
- var _a3, _b2, _c2;
11403
- return /* @__PURE__ */ jsxRuntime.jsx(
11404
- "li",
11405
- {
11406
- children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
11407
- },
11408
- item.id
11409
- );
11410
- }) }),
11411
- children: /* @__PURE__ */ jsxRuntime.jsxs(
11412
- ui.Badge,
11413
- {
11414
- className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
11415
- size: "xsmall",
11416
- children: [
11417
- /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
11418
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate", children: [
11419
- items.reduce(
11420
- (acc, item) => acc + item.quantity,
11421
- 0
11422
- ),
11423
- "x",
11424
- " ",
11425
- pluralize(items.length, "items", "item")
11426
- ] })
11427
- ]
11428
- }
11429
- )
11430
- }
11431
- ),
11432
- /* @__PURE__ */ jsxRuntime.jsx(
11433
- ui.Tooltip,
11434
- {
11435
- content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
11436
- children: /* @__PURE__ */ jsxRuntime.jsxs(
11437
- ui.Badge,
11438
- {
11439
- className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
11440
- size: "xsmall",
11441
- children: [
11442
- /* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
11443
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
11444
- ]
11445
- }
11446
- )
11447
- }
11448
- ),
11449
- /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
11450
- ui.Badge,
11451
- {
11452
- className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
11453
- size: "xsmall",
11454
- children: [
11455
- /* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
11456
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: shippingOption.name })
11457
- ]
11458
- }
11459
- ) })
11460
- ] })
11461
- ] }),
11462
- shippingOption ? /* @__PURE__ */ jsxRuntime.jsx(
11463
- ActionMenu,
11464
- {
11465
- groups: [
11466
- {
11467
- actions: [
11468
- hasItems ? {
11469
- label: "Edit shipping option",
11470
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Channels, {}),
11471
- onClick: () => {
11472
- setIsOpen(
11473
- STACKED_FOCUS_MODAL_ID,
11474
- true
11475
- );
11476
- setData({
11477
- shippingProfileId: profile.id,
11478
- shippingOption,
11479
- shippingMethod
11480
- });
11481
- }
11482
- } : void 0,
11483
- {
11484
- label: "Remove shipping option",
11485
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
11486
- onClick: () => {
11487
- if (shippingMethod) {
11488
- if (addShippingMethodAction) {
11489
- removeActionShippingMethod(
11490
- addShippingMethodAction.id
11491
- );
11492
- } else {
11493
- removeShippingMethod(
11494
- shippingMethod.id
11495
- );
11496
- }
11497
- }
11498
- }
11499
- }
11500
- ].filter(Boolean)
11501
- }
11502
- ]
11503
- }
11504
- ) : /* @__PURE__ */ jsxRuntime.jsx(
11505
- StackedModalTrigger,
11506
- {
11507
- shippingProfileId: profile.id,
11508
- shippingOption,
11509
- shippingMethod,
11510
- setData,
11511
- children: "Add shipping option"
11512
- }
11513
- )
11514
- ] }),
11515
- /* @__PURE__ */ jsxRuntime.jsxs(radixUi.Accordion.Content, { children: [
11516
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11517
- items.map((item, idx) => {
11518
- var _a3, _b2, _c2, _d2, _e2;
11519
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11520
- /* @__PURE__ */ jsxRuntime.jsxs(
11521
- "div",
11522
- {
11523
- className: "px-3 flex items-center gap-x-3",
11524
- children: [
11525
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-[56px] flex flex-col justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
11526
- ui.Divider,
11527
- {
11528
- variant: "dashed",
11529
- orientation: "vertical"
11530
- }
11531
- ) }),
11532
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 flex items-center gap-x-3", children: [
11533
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 flex items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
11534
- ui.Text,
11535
- {
11536
- size: "small",
11537
- leading: "compact",
11538
- className: "text-ui-fg-subtle",
11539
- children: [
11540
- item.quantity,
11541
- "x"
11542
- ]
11543
- }
11544
- ) }),
11545
- /* @__PURE__ */ jsxRuntime.jsx(Thumbnail, { thumbnail: item.thumbnail }),
11546
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11547
- /* @__PURE__ */ jsxRuntime.jsxs(
11548
- ui.Text,
11549
- {
11550
- size: "small",
11551
- leading: "compact",
11552
- weight: "plus",
11553
- children: [
11554
- (_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
11555
- " (",
11556
- (_c2 = item.variant) == null ? void 0 : _c2.title,
11557
- ")"
11558
- ]
11559
- }
11560
- ),
11561
- /* @__PURE__ */ jsxRuntime.jsx(
11562
- ui.Text,
11563
- {
11564
- size: "small",
11565
- leading: "compact",
11566
- className: "text-ui-fg-subtle",
11567
- children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
11568
- }
11569
- )
11570
- ] })
11571
- ] })
11572
- ]
11573
- },
11574
- item.id
11575
- ),
11576
- idx !== items.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" })
11577
- ] }, item.id);
11578
- })
11579
- ] })
11580
- ]
11581
- },
11582
- profile.id
11583
- );
11584
- }) })
11585
- ] }) })
11586
- ] }) }),
11587
- /* @__PURE__ */ jsxRuntime.jsx(
11588
- StackedFocusModal,
11589
- {
11590
- id: STACKED_FOCUS_MODAL_ID,
11591
- onOpenChangeCallback: (open) => {
11592
- if (!open) {
11593
- setData(null);
11709
+ control: form.control,
11710
+ name: "postal_code",
11711
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11715
+ ] })
11716
+ }
11717
+ ),
11718
+ /* @__PURE__ */ jsxRuntime.jsx(
11719
+ Form$2.Field,
11720
+ {
11721
+ control: form.control,
11722
+ name: "city",
11723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11727
+ ] })
11728
+ }
11729
+ )
11730
+ ] }),
11731
+ /* @__PURE__ */ jsxRuntime.jsx(
11732
+ Form$2.Field,
11733
+ {
11734
+ control: form.control,
11735
+ name: "province",
11736
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11740
+ ] })
11594
11741
  }
11595
- return open;
11596
- },
11597
- children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
11598
- }
11599
- )
11600
- ] }),
11601
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
11602
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11603
- /* @__PURE__ */ jsxRuntime.jsx(
11604
- ui.Button,
11605
- {
11606
- size: "small",
11607
- type: "button",
11608
- isLoading: isSubmitting,
11609
- onClick: onSubmit,
11610
- children: "Save"
11611
- }
11612
- )
11613
- ] }) })
11614
- ] });
11742
+ ),
11743
+ /* @__PURE__ */ jsxRuntime.jsx(
11744
+ Form$2.Field,
11745
+ {
11746
+ control: form.control,
11747
+ name: "phone",
11748
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11752
+ ] })
11753
+ }
11754
+ )
11755
+ ] }) }),
11756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11758
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11759
+ ] }) })
11760
+ ]
11761
+ }
11762
+ ) });
11615
11763
  };
11616
- const StackedModalTrigger = ({
11617
- shippingProfileId,
11618
- shippingOption,
11619
- shippingMethod,
11620
- setData,
11621
- children
11622
- }) => {
11623
- const { setIsOpen, getIsOpen } = useStackedModal();
11624
- const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
11625
- const onToggle = () => {
11626
- if (isOpen) {
11627
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11628
- setData(null);
11629
- } else {
11630
- setIsOpen(STACKED_FOCUS_MODAL_ID, true);
11631
- setData({
11632
- shippingProfileId,
11633
- shippingOption,
11634
- shippingMethod
11635
- });
11636
- }
11637
- };
11638
- return /* @__PURE__ */ jsxRuntime.jsx(
11639
- ui.Button,
11640
- {
11641
- size: "small",
11642
- variant: "secondary",
11643
- onClick: onToggle,
11644
- className: "text-ui-fg-primary shrink-0",
11645
- children
11646
- }
11647
- );
11648
- };
11649
- const ShippingProfileForm = ({
11650
- data,
11651
- order,
11652
- preview
11653
- }) => {
11654
- var _a, _b, _c, _d, _e, _f;
11655
- const { setIsOpen } = useStackedModal();
11656
- const form = reactHookForm.useForm({
11657
- resolver: zod.zodResolver(shippingMethodSchema),
11658
- defaultValues: {
11659
- 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,
11660
- shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
11661
- custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
11662
- }
11764
+ const schema$1 = addressSchema;
11765
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11766
+ const Shipping = () => {
11767
+ var _a;
11768
+ const { id } = reactRouterDom.useParams();
11769
+ const { order, isPending, isError, error } = useOrder(id, {
11770
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11663
11771
  });
11664
- const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
11665
11772
  const {
11666
- mutateAsync: updateShippingMethod,
11667
- isPending: isUpdatingShippingMethod
11668
- } = useDraftOrderUpdateShippingMethod(order.id);
11669
- const onSubmit = form.handleSubmit(async (values) => {
11670
- if (lodash.isEqual(values, form.formState.defaultValues)) {
11671
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11672
- return;
11773
+ order: preview,
11774
+ isPending: isPreviewPending,
11775
+ isError: isPreviewError,
11776
+ error: previewError
11777
+ } = useOrderPreview(id);
11778
+ useInitiateOrderEdit({ preview });
11779
+ const { onCancel } = useCancelOrderEdit({ preview });
11780
+ if (isError) {
11781
+ throw error;
11782
+ }
11783
+ if (isPreviewError) {
11784
+ throw previewError;
11785
+ }
11786
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11787
+ const isReady = preview && !isPreviewPending && order && !isPending;
11788
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11789
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11790
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11791
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11792
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11793
+ ] }) }) }),
11794
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11795
+ ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11796
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11797
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11798
+ ] }) });
11799
+ };
11800
+ const ShippingForm = ({ preview, order }) => {
11801
+ var _a;
11802
+ const { setIsOpen } = useStackedModal();
11803
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11804
+ const [data, setData] = React.useState(null);
11805
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11806
+ const { shipping_options } = useShippingOptions(
11807
+ {
11808
+ id: appliedShippingOptionIds,
11809
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11810
+ },
11811
+ {
11812
+ enabled: appliedShippingOptionIds.length > 0
11673
11813
  }
11674
- if (data.shippingMethod) {
11675
- await updateShippingMethod(
11676
- {
11677
- method_id: data.shippingMethod.id,
11678
- shipping_option_id: values.shipping_option_id,
11679
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
11680
- },
11681
- {
11682
- onError: (e) => {
11683
- ui.toast.error(e.message);
11684
- },
11685
- onSuccess: () => {
11686
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11687
- }
11688
- }
11689
- );
11814
+ );
11815
+ const uniqueShippingProfiles = React.useMemo(() => {
11816
+ const profiles = /* @__PURE__ */ new Map();
11817
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
11818
+ profiles.set(profile.id, profile);
11819
+ });
11820
+ shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11821
+ profiles.set(option.shipping_profile_id, option.shipping_profile);
11822
+ });
11823
+ return Array.from(profiles.values());
11824
+ }, [order.items, shipping_options]);
11825
+ const { handleSuccess } = useRouteModal();
11826
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11827
+ const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
11828
+ const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
11829
+ const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
11830
+ const onSubmit = async () => {
11831
+ setIsSubmitting(true);
11832
+ let requestSucceeded = false;
11833
+ await requestOrderEdit(void 0, {
11834
+ onError: (e) => {
11835
+ ui.toast.error(`Failed to request order edit: ${e.message}`);
11836
+ },
11837
+ onSuccess: () => {
11838
+ requestSucceeded = true;
11839
+ }
11840
+ });
11841
+ if (!requestSucceeded) {
11842
+ setIsSubmitting(false);
11690
11843
  return;
11691
11844
  }
11692
- await addShippingMethod(
11693
- {
11694
- shipping_option_id: values.shipping_option_id,
11695
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
11845
+ await confirmOrderEdit(void 0, {
11846
+ onError: (e) => {
11847
+ ui.toast.error(`Failed to confirm order edit: ${e.message}`);
11696
11848
  },
11697
- {
11698
- onError: (e) => {
11699
- ui.toast.error(e.message);
11700
- },
11701
- onSuccess: () => {
11702
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11849
+ onSuccess: () => {
11850
+ handleSuccess();
11851
+ },
11852
+ onSettled: () => {
11853
+ setIsSubmitting(false);
11854
+ }
11855
+ });
11856
+ };
11857
+ const onKeydown = React.useCallback(
11858
+ (e) => {
11859
+ if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
11860
+ if (data || isSubmitting) {
11861
+ return;
11703
11862
  }
11863
+ onSubmit();
11704
11864
  }
11705
- );
11706
- });
11707
- return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11708
- KeyboundForm,
11709
- {
11710
- className: "flex h-full flex-col overflow-hidden",
11711
- onSubmit,
11712
- children: [
11713
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
11714
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11715
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11716
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11717
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.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." }) })
11718
- ] }),
11719
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11720
- /* @__PURE__ */ jsxRuntime.jsx(
11721
- LocationField,
11722
- {
11723
- control: form.control,
11724
- setValue: form.setValue
11725
- }
11726
- ),
11727
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11728
- /* @__PURE__ */ jsxRuntime.jsx(
11729
- ShippingOptionField,
11730
- {
11731
- shippingProfileId: data.shippingProfileId,
11732
- preview,
11733
- control: form.control
11734
- }
11735
- ),
11736
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11737
- /* @__PURE__ */ jsxRuntime.jsx(
11738
- CustomAmountField,
11739
- {
11740
- control: form.control,
11741
- currencyCode: order.currency_code
11742
- }
11743
- ),
11744
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11745
- /* @__PURE__ */ jsxRuntime.jsx(
11746
- ItemsPreview,
11747
- {
11748
- order,
11749
- shippingProfileId: data.shippingProfileId
11750
- }
11751
- )
11752
- ] }) }) }),
11753
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
11754
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11755
- /* @__PURE__ */ jsxRuntime.jsx(
11756
- ui.Button,
11757
- {
11758
- size: "small",
11759
- type: "submit",
11760
- isLoading: isPending || isUpdatingShippingMethod,
11761
- children: data.shippingMethod ? "Update" : "Add"
11762
- }
11763
- )
11764
- ] }) })
11765
- ]
11766
- }
11767
- ) }) });
11768
- };
11769
- const shippingMethodSchema = objectType({
11770
- location_id: stringType(),
11771
- shipping_option_id: stringType(),
11772
- custom_amount: unionType([numberType(), stringType()]).optional()
11773
- });
11774
- const ItemsPreview = ({ order, shippingProfileId }) => {
11775
- const matches = order.items.filter(
11776
- (item) => {
11777
- var _a, _b, _c;
11778
- return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
11779
- }
11865
+ },
11866
+ [data, isSubmitting, onSubmit]
11780
11867
  );
11781
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
11782
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11783
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
11784
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
11785
- ] }) }),
11786
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
11787
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
11788
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
11789
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
11790
- ] }),
11791
- /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(
11792
- "div",
11793
- {
11794
- className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
11795
- children: [
11796
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
11797
- /* @__PURE__ */ jsxRuntime.jsx(
11798
- Thumbnail,
11799
- {
11800
- thumbnail: item.thumbnail,
11801
- alt: item.product_title ?? void 0
11802
- }
11803
- ),
11804
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11805
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
11806
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
11807
- /* @__PURE__ */ jsxRuntime.jsxs(
11808
- ui.Text,
11809
- {
11810
- size: "small",
11811
- leading: "compact",
11812
- className: "text-ui-fg-subtle",
11813
- children: [
11814
- "(",
11815
- item.variant_title,
11816
- ")"
11817
- ]
11818
- }
11819
- )
11820
- ] }),
11821
- /* @__PURE__ */ jsxRuntime.jsx(
11822
- ui.Text,
11823
- {
11824
- size: "small",
11825
- leading: "compact",
11826
- className: "text-ui-fg-subtle",
11827
- children: item.variant_sku
11828
- }
11829
- )
11830
- ] })
11831
- ] }),
11832
- /* @__PURE__ */ jsxRuntime.jsxs(
11868
+ React.useEffect(() => {
11869
+ document.addEventListener("keydown", onKeydown);
11870
+ return () => {
11871
+ document.removeEventListener("keydown", onKeydown);
11872
+ };
11873
+ }, [onKeydown]);
11874
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
11875
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11876
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
11877
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11878
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11879
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11880
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
11881
+ ] }),
11882
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11883
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
11884
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
11885
+ /* @__PURE__ */ jsxRuntime.jsx(
11833
11886
  ui.Text,
11834
11887
  {
11835
- size: "small",
11836
- leading: "compact",
11837
- className: "text-ui-fg-subtle",
11838
- children: [
11839
- item.quantity,
11840
- "x"
11841
- ]
11888
+ size: "xsmall",
11889
+ weight: "plus",
11890
+ className: "text-ui-fg-muted",
11891
+ children: "Shipping profile"
11892
+ }
11893
+ ),
11894
+ /* @__PURE__ */ jsxRuntime.jsx(
11895
+ ui.Text,
11896
+ {
11897
+ size: "xsmall",
11898
+ weight: "plus",
11899
+ className: "text-ui-fg-muted",
11900
+ children: "Action"
11842
11901
  }
11843
11902
  )
11844
- ]
11845
- },
11846
- item.id
11847
- )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
11848
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
11849
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
11850
- 'No items found for "',
11851
- query,
11852
- '".'
11853
- ] })
11854
- ] }) })
11855
- ] })
11856
- ] });
11857
- };
11858
- const LocationField = ({ control, setValue }) => {
11859
- const locations = useComboboxData({
11860
- queryKey: ["locations"],
11861
- queryFn: async (params) => {
11862
- return await sdk.admin.stockLocation.list(params);
11863
- },
11864
- getOptions: (data) => {
11865
- return data.stock_locations.map((location) => ({
11866
- label: location.name,
11867
- value: location.id
11868
- }));
11869
- }
11870
- });
11871
- return /* @__PURE__ */ jsxRuntime.jsx(
11872
- Form$2.Field,
11873
- {
11874
- control,
11875
- name: "location_id",
11876
- render: ({ field: { onChange, ...field } }) => {
11877
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11878
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11879
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
11880
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
11881
- ] }),
11882
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11883
- Combobox,
11884
- {
11885
- options: locations.options,
11886
- fetchNextPage: locations.fetchNextPage,
11887
- isFetchingNextPage: locations.isFetchingNextPage,
11888
- searchValue: locations.searchValue,
11889
- onSearchValueChange: locations.onSearchValueChange,
11890
- placeholder: "Select location",
11891
- onChange: (value) => {
11892
- setValue("shipping_option_id", "", {
11893
- shouldDirty: true,
11894
- shouldTouch: true
11895
- });
11896
- onChange(value);
11897
- },
11898
- ...field
11899
- }
11900
- ) })
11901
- ] }) });
11902
- }
11903
- }
11904
- );
11905
- };
11906
- const ShippingOptionField = ({
11907
- shippingProfileId,
11908
- preview,
11909
- control
11910
- }) => {
11911
- var _a;
11912
- const locationId = reactHookForm.useWatch({ control, name: "location_id" });
11913
- const shippingOptions = useComboboxData({
11914
- queryKey: ["shipping_options", locationId, shippingProfileId],
11915
- queryFn: async (params) => {
11916
- return await sdk.admin.shippingOption.list({
11917
- ...params,
11918
- stock_location_id: locationId,
11919
- shipping_profile_id: shippingProfileId
11920
- });
11921
- },
11922
- getOptions: (data) => {
11923
- return data.shipping_options.map((option) => {
11924
- var _a2;
11925
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
11926
- (r) => r.attribute === "is_return" && r.value === "true"
11927
- )) {
11928
- return void 0;
11929
- }
11930
- return {
11931
- label: option.name,
11932
- value: option.id
11933
- };
11934
- }).filter(Boolean);
11935
- },
11936
- enabled: !!locationId && !!shippingProfileId,
11937
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
11938
- });
11939
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
11940
- return /* @__PURE__ */ jsxRuntime.jsx(
11941
- Form$2.Field,
11942
- {
11943
- control,
11944
- name: "shipping_option_id",
11945
- render: ({ field }) => {
11946
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11947
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11948
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
11949
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
11950
- ] }),
11951
- /* @__PURE__ */ jsxRuntime.jsx(
11952
- ConditionalTooltip,
11953
- {
11954
- content: tooltipContent,
11955
- showTooltip: !locationId || !shippingProfileId,
11956
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11957
- Combobox,
11958
- {
11959
- options: shippingOptions.options,
11960
- fetchNextPage: shippingOptions.fetchNextPage,
11961
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
11962
- searchValue: shippingOptions.searchValue,
11963
- onSearchValueChange: shippingOptions.onSearchValueChange,
11964
- placeholder: "Select shipping option",
11965
- ...field,
11966
- disabled: !locationId || !shippingProfileId
11967
- }
11968
- ) }) })
11969
- }
11970
- )
11971
- ] }) });
11972
- }
11973
- }
11974
- );
11975
- };
11976
- const CustomAmountField = ({
11977
- control,
11978
- currencyCode
11979
- }) => {
11980
- return /* @__PURE__ */ jsxRuntime.jsx(
11981
- Form$2.Field,
11982
- {
11983
- control,
11984
- name: "custom_amount",
11985
- render: ({ field: { onChange, ...field } }) => {
11986
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11987
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11988
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
11989
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
11990
11903
  ] }),
11991
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11992
- ui.CurrencyInput,
11993
- {
11994
- ...field,
11995
- onValueChange: (value) => onChange(value),
11996
- symbol: getNativeSymbol(currencyCode),
11997
- code: currencyCode
11998
- }
11999
- ) })
12000
- ] });
12001
- }
12002
- }
12003
- );
12004
- };
12005
- const ShippingAddress = () => {
12006
- const { id } = reactRouterDom.useParams();
12007
- const { order, isPending, isError, error } = useOrder(id, {
12008
- fields: "+shipping_address"
12009
- });
12010
- if (isError) {
12011
- throw error;
12012
- }
12013
- const isReady = !isPending && !!order;
12014
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12015
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12016
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12017
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12018
- ] }),
12019
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12020
- ] });
12021
- };
12022
- const ShippingAddressForm = ({ order }) => {
12023
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12024
- const form = reactHookForm.useForm({
12025
- defaultValues: {
12026
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12027
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12028
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12029
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12030
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12031
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12032
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12033
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12034
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12035
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12036
- },
12037
- resolver: zod.zodResolver(schema$4)
12038
- });
12039
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12040
- const { handleSuccess } = useRouteModal();
12041
- const onSubmit = form.handleSubmit(async (data) => {
12042
- await mutateAsync(
12043
- {
12044
- shipping_address: {
12045
- first_name: data.first_name,
12046
- last_name: data.last_name,
12047
- company: data.company,
12048
- address_1: data.address_1,
12049
- address_2: data.address_2,
12050
- city: data.city,
12051
- province: data.province,
12052
- country_code: data.country_code,
12053
- postal_code: data.postal_code,
12054
- phone: data.phone
12055
- }
12056
- },
12057
- {
12058
- onSuccess: () => {
12059
- handleSuccess();
12060
- },
12061
- onError: (error) => {
12062
- ui.toast.error(error.message);
12063
- }
12064
- }
12065
- );
12066
- });
12067
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12068
- KeyboundForm,
12069
- {
12070
- className: "flex flex-1 flex-col overflow-hidden",
12071
- onSubmit,
12072
- children: [
12073
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12074
- /* @__PURE__ */ jsxRuntime.jsx(
12075
- Form$2.Field,
12076
- {
12077
- control: form.control,
12078
- name: "country_code",
12079
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12080
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12081
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12082
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12083
- ] })
12084
- }
12085
- ),
12086
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12087
- /* @__PURE__ */ jsxRuntime.jsx(
12088
- Form$2.Field,
12089
- {
12090
- control: form.control,
12091
- name: "first_name",
12092
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12093
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12094
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12095
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12096
- ] })
12097
- }
12098
- ),
12099
- /* @__PURE__ */ jsxRuntime.jsx(
12100
- Form$2.Field,
12101
- {
12102
- control: form.control,
12103
- name: "last_name",
12104
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12105
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12106
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12107
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12108
- ] })
12109
- }
12110
- )
12111
- ] }),
12112
- /* @__PURE__ */ jsxRuntime.jsx(
12113
- Form$2.Field,
12114
- {
12115
- control: form.control,
12116
- name: "company",
12117
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12118
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12119
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12120
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12121
- ] })
12122
- }
12123
- ),
12124
- /* @__PURE__ */ jsxRuntime.jsx(
12125
- Form$2.Field,
12126
- {
12127
- control: form.control,
12128
- name: "address_1",
12129
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12130
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12131
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12132
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12133
- ] })
12134
- }
12135
- ),
12136
- /* @__PURE__ */ jsxRuntime.jsx(
12137
- Form$2.Field,
12138
- {
12139
- control: form.control,
12140
- name: "address_2",
12141
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12142
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12143
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12144
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12145
- ] })
12146
- }
12147
- ),
12148
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12149
- /* @__PURE__ */ jsxRuntime.jsx(
12150
- Form$2.Field,
12151
- {
12152
- control: form.control,
12153
- name: "postal_code",
12154
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12155
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12156
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12157
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12158
- ] })
12159
- }
12160
- ),
12161
- /* @__PURE__ */ jsxRuntime.jsx(
12162
- Form$2.Field,
11904
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
11905
+ var _a2, _b, _c, _d, _e, _f, _g;
11906
+ const items = getItemsWithShippingProfile(
11907
+ profile.id,
11908
+ order.items
11909
+ );
11910
+ const hasItems = items.length > 0;
11911
+ const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
11912
+ (option) => option.shipping_profile_id === profile.id
11913
+ );
11914
+ const shippingMethod = preview.shipping_methods.find(
11915
+ (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
11916
+ );
11917
+ const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
11918
+ (action) => action.action === "SHIPPING_ADD"
11919
+ );
11920
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11921
+ radixUi.Accordion.Item,
12163
11922
  {
12164
- control: form.control,
12165
- name: "city",
12166
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12167
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12168
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12169
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12170
- ] })
12171
- }
12172
- )
12173
- ] }),
12174
- /* @__PURE__ */ jsxRuntime.jsx(
12175
- Form$2.Field,
12176
- {
12177
- control: form.control,
12178
- name: "province",
12179
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12180
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12181
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12182
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12183
- ] })
12184
- }
12185
- ),
12186
- /* @__PURE__ */ jsxRuntime.jsx(
12187
- Form$2.Field,
12188
- {
12189
- control: form.control,
12190
- name: "phone",
12191
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12192
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12193
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12194
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12195
- ] })
12196
- }
12197
- )
12198
- ] }) }),
12199
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12200
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12201
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12202
- ] }) })
12203
- ]
12204
- }
12205
- ) });
12206
- };
12207
- const schema$4 = addressSchema;
12208
- const TransferOwnership = () => {
12209
- const { id } = reactRouterDom.useParams();
12210
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12211
- fields: "id,customer_id,customer.*"
12212
- });
12213
- if (isError) {
12214
- throw error;
12215
- }
12216
- const isReady = !isPending && !!draft_order;
12217
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12218
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12219
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12220
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12221
- ] }),
12222
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12223
- ] });
12224
- };
12225
- const TransferOwnershipForm = ({ order }) => {
12226
- var _a, _b;
12227
- const form = reactHookForm.useForm({
12228
- defaultValues: {
12229
- customer_id: order.customer_id || ""
12230
- },
12231
- resolver: zod.zodResolver(schema$3)
12232
- });
12233
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12234
- const { handleSuccess } = useRouteModal();
12235
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12236
- const currentCustomer = order.customer ? {
12237
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12238
- value: order.customer.id
12239
- } : null;
12240
- const onSubmit = form.handleSubmit(async (data) => {
12241
- await mutateAsync(
12242
- { customer_id: data.customer_id },
12243
- {
12244
- onSuccess: () => {
12245
- ui.toast.success("Customer updated");
12246
- handleSuccess();
12247
- },
12248
- onError: (error) => {
12249
- ui.toast.error(error.message);
12250
- }
12251
- }
12252
- );
12253
- });
12254
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12255
- KeyboundForm,
12256
- {
12257
- className: "flex flex-1 flex-col overflow-hidden",
12258
- onSubmit,
12259
- children: [
12260
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12261
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12262
- currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12263
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12264
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12265
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12266
- ] }),
12267
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12268
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12269
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12270
- ] })
12271
- ] }),
12272
- /* @__PURE__ */ jsxRuntime.jsx(
12273
- CustomerField,
12274
- {
12275
- control: form.control,
12276
- currentCustomerId: order.customer_id
12277
- }
12278
- )
12279
- ] }),
12280
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12281
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12282
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12283
- ] }) })
12284
- ]
12285
- }
12286
- ) });
12287
- };
12288
- const CustomerField = ({ control, currentCustomerId }) => {
12289
- const customers = useComboboxData({
12290
- queryFn: async (params) => {
12291
- return await sdk.admin.customer.list({
12292
- ...params,
12293
- id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12294
- });
12295
- },
12296
- queryKey: ["customers"],
12297
- getOptions: (data) => {
12298
- return data.customers.map((customer) => {
12299
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12300
- return {
12301
- label: name ? `${name} (${customer.email})` : customer.email,
12302
- value: customer.id
12303
- };
12304
- });
12305
- }
12306
- });
12307
- return /* @__PURE__ */ jsxRuntime.jsx(
12308
- Form$2.Field,
12309
- {
12310
- name: "customer_id",
12311
- control,
12312
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
12313
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12314
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
12315
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
12316
- ] }),
12317
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12318
- Combobox,
12319
- {
12320
- options: customers.options,
12321
- fetchNextPage: customers.fetchNextPage,
12322
- isFetchingNextPage: customers.isFetchingNextPage,
12323
- searchValue: customers.searchValue,
12324
- onSearchValueChange: customers.onSearchValueChange,
12325
- placeholder: "Select customer",
12326
- ...field
12327
- }
12328
- ) }),
12329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12330
- ] })
12331
- }
12332
- );
12333
- };
12334
- const Illustration = () => {
12335
- return /* @__PURE__ */ jsxRuntime.jsxs(
12336
- "svg",
12337
- {
12338
- width: "280",
12339
- height: "180",
12340
- viewBox: "0 0 280 180",
12341
- fill: "none",
12342
- xmlns: "http://www.w3.org/2000/svg",
12343
- children: [
12344
- /* @__PURE__ */ jsxRuntime.jsx(
12345
- "rect",
12346
- {
12347
- x: "0.00428286",
12348
- y: "-0.742904",
12349
- width: "33.5",
12350
- height: "65.5",
12351
- rx: "6.75",
12352
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
12353
- fill: "#D4D4D8",
12354
- stroke: "#52525B",
12355
- strokeWidth: "1.5"
12356
- }
12357
- ),
12358
- /* @__PURE__ */ jsxRuntime.jsx(
12359
- "rect",
12360
- {
12361
- x: "0.00428286",
12362
- y: "-0.742904",
12363
- width: "33.5",
12364
- height: "65.5",
12365
- rx: "6.75",
12366
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
12367
- fill: "white",
12368
- stroke: "#52525B",
12369
- strokeWidth: "1.5"
12370
- }
12371
- ),
12372
- /* @__PURE__ */ jsxRuntime.jsx(
12373
- "path",
12374
- {
12375
- d: "M180.579 107.142L179.126 107.959",
12376
- stroke: "#52525B",
12377
- strokeWidth: "1.5",
12378
- strokeLinecap: "round",
12379
- strokeLinejoin: "round"
12380
- }
12381
- ),
12382
- /* @__PURE__ */ jsxRuntime.jsx(
12383
- "path",
12384
- {
12385
- opacity: "0.88",
12386
- d: "M182.305 109.546L180.257 109.534",
12387
- stroke: "#52525B",
12388
- strokeWidth: "1.5",
12389
- strokeLinecap: "round",
12390
- strokeLinejoin: "round"
12391
- }
12392
- ),
12393
- /* @__PURE__ */ jsxRuntime.jsx(
12394
- "path",
12395
- {
12396
- opacity: "0.75",
12397
- d: "M180.551 111.93L179.108 111.096",
12398
- stroke: "#52525B",
12399
- strokeWidth: "1.5",
12400
- strokeLinecap: "round",
12401
- strokeLinejoin: "round"
12402
- }
12403
- ),
12404
- /* @__PURE__ */ jsxRuntime.jsx(
12405
- "path",
12406
- {
12407
- opacity: "0.63",
12408
- d: "M176.347 112.897L176.354 111.73",
12409
- stroke: "#52525B",
12410
- strokeWidth: "1.5",
12411
- strokeLinecap: "round",
12412
- strokeLinejoin: "round"
12413
- }
12414
- ),
12415
- /* @__PURE__ */ jsxRuntime.jsx(
12416
- "path",
12417
- {
12418
- opacity: "0.5",
12419
- d: "M172.153 111.881L173.606 111.064",
12420
- stroke: "#52525B",
12421
- strokeWidth: "1.5",
12422
- strokeLinecap: "round",
12423
- strokeLinejoin: "round"
12424
- }
12425
- ),
12426
- /* @__PURE__ */ jsxRuntime.jsx(
12427
- "path",
12428
- {
12429
- opacity: "0.38",
12430
- d: "M170.428 109.478L172.476 109.489",
12431
- stroke: "#52525B",
12432
- strokeWidth: "1.5",
12433
- strokeLinecap: "round",
12434
- strokeLinejoin: "round"
12435
- }
12436
- ),
12437
- /* @__PURE__ */ jsxRuntime.jsx(
12438
- "path",
12439
- {
12440
- opacity: "0.25",
12441
- d: "M172.181 107.094L173.624 107.928",
12442
- stroke: "#52525B",
12443
- strokeWidth: "1.5",
12444
- strokeLinecap: "round",
12445
- strokeLinejoin: "round"
12446
- }
12447
- ),
12448
- /* @__PURE__ */ jsxRuntime.jsx(
12449
- "path",
12450
- {
12451
- opacity: "0.13",
12452
- d: "M176.386 106.126L176.379 107.294",
12453
- stroke: "#52525B",
12454
- strokeWidth: "1.5",
12455
- strokeLinecap: "round",
12456
- strokeLinejoin: "round"
12457
- }
12458
- ),
12459
- /* @__PURE__ */ jsxRuntime.jsx(
12460
- "rect",
12461
- {
12462
- width: "12",
12463
- height: "3",
12464
- rx: "1.5",
12465
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12466
- fill: "#D4D4D8"
12467
- }
12468
- ),
12469
- /* @__PURE__ */ jsxRuntime.jsx(
12470
- "rect",
12471
- {
12472
- x: "0.00428286",
12473
- y: "-0.742904",
12474
- width: "33.5",
12475
- height: "65.5",
12476
- rx: "6.75",
12477
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12478
- fill: "#D4D4D8",
12479
- stroke: "#52525B",
12480
- strokeWidth: "1.5"
12481
- }
12482
- ),
12483
- /* @__PURE__ */ jsxRuntime.jsx(
12484
- "rect",
12485
- {
12486
- x: "0.00428286",
12487
- y: "-0.742904",
12488
- width: "33.5",
12489
- height: "65.5",
12490
- rx: "6.75",
12491
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12492
- fill: "white",
12493
- stroke: "#52525B",
12494
- strokeWidth: "1.5"
12495
- }
12496
- ),
12497
- /* @__PURE__ */ jsxRuntime.jsx(
12498
- "rect",
12499
- {
12500
- width: "12",
12501
- height: "3",
12502
- rx: "1.5",
12503
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12504
- fill: "#D4D4D8"
12505
- }
12506
- ),
12507
- /* @__PURE__ */ jsxRuntime.jsx(
12508
- "rect",
12509
- {
12510
- width: "17",
12511
- height: "3",
12512
- rx: "1.5",
12513
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12514
- fill: "#D4D4D8"
12515
- }
12516
- ),
12517
- /* @__PURE__ */ jsxRuntime.jsx(
12518
- "rect",
12519
- {
12520
- width: "12",
12521
- height: "3",
12522
- rx: "1.5",
12523
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12524
- fill: "#D4D4D8"
12525
- }
12526
- ),
12527
- /* @__PURE__ */ jsxRuntime.jsx(
12528
- "path",
12529
- {
12530
- 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",
12531
- fill: "#A1A1AA"
12532
- }
12533
- ),
12534
- /* @__PURE__ */ jsxRuntime.jsx(
12535
- "rect",
12536
- {
12537
- width: "17",
12538
- height: "3",
12539
- rx: "1.5",
12540
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12541
- fill: "#A1A1AA"
12542
- }
12543
- ),
12544
- /* @__PURE__ */ jsxRuntime.jsx(
12545
- "rect",
12546
- {
12547
- width: "12",
12548
- height: "3",
12549
- rx: "1.5",
12550
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12551
- fill: "#A1A1AA"
12552
- }
12553
- ),
12554
- /* @__PURE__ */ jsxRuntime.jsx(
12555
- "path",
12556
- {
12557
- 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",
12558
- fill: "#52525B"
12559
- }
12560
- ),
12561
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12562
- "path",
12563
- {
12564
- d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12565
- stroke: "#A1A1AA",
12566
- strokeWidth: "1.5",
12567
- strokeLinecap: "round",
12568
- strokeLinejoin: "round"
12569
- }
12570
- ) }),
12571
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12572
- "path",
12573
- {
12574
- d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12575
- stroke: "#A1A1AA",
12576
- strokeWidth: "1.5",
12577
- strokeLinecap: "round",
12578
- strokeLinejoin: "round"
12579
- }
12580
- ) }),
12581
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12582
- "path",
12583
- {
12584
- d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12585
- stroke: "#A1A1AA",
12586
- strokeWidth: "1.5",
12587
- strokeLinecap: "round",
12588
- strokeLinejoin: "round"
12589
- }
12590
- ) }),
12591
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12592
- "path",
12593
- {
12594
- d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12595
- stroke: "#A1A1AA",
12596
- strokeWidth: "1.5",
12597
- strokeLinecap: "round",
12598
- strokeLinejoin: "round"
12599
- }
12600
- ) }),
12601
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12602
- "path",
12603
- {
12604
- d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12605
- stroke: "#A1A1AA",
12606
- strokeWidth: "1.5",
12607
- strokeLinecap: "round",
12608
- strokeLinejoin: "round"
12609
- }
12610
- ) }),
12611
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12612
- "path",
12613
- {
12614
- d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12615
- stroke: "#A1A1AA",
12616
- strokeWidth: "1.5",
12617
- strokeLinecap: "round",
12618
- strokeLinejoin: "round"
12619
- }
12620
- ) }),
12621
- /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12622
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12623
- "rect",
12624
- {
12625
- width: "12",
12626
- height: "12",
12627
- fill: "white",
12628
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
11923
+ value: profile.id,
11924
+ className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
11925
+ children: [
11926
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2 flex items-center justify-between gap-3", children: [
11927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full overflow-hidden", children: [
11928
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
11929
+ ui.IconButton,
11930
+ {
11931
+ size: "2xsmall",
11932
+ variant: "transparent",
11933
+ className: "group/trigger",
11934
+ disabled: !hasItems,
11935
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90 transition-transform" })
11936
+ }
11937
+ ) }),
11938
+ !shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
11939
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 rounded-md shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-6 rounded bg-ui-bg-component-hover flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
11940
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-1", children: [
11941
+ /* @__PURE__ */ jsxRuntime.jsx(
11942
+ ui.Text,
11943
+ {
11944
+ size: "small",
11945
+ weight: "plus",
11946
+ leading: "compact",
11947
+ children: profile.name
11948
+ }
11949
+ ),
11950
+ /* @__PURE__ */ jsxRuntime.jsxs(
11951
+ ui.Text,
11952
+ {
11953
+ size: "small",
11954
+ leading: "compact",
11955
+ className: "text-ui-fg-subtle",
11956
+ children: [
11957
+ items.length,
11958
+ " ",
11959
+ pluralize(items.length, "items", "item")
11960
+ ]
11961
+ }
11962
+ )
11963
+ ] })
11964
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start flex-1 w-full overflow-hidden", children: [
11965
+ /* @__PURE__ */ jsxRuntime.jsx(
11966
+ ui.Tooltip,
11967
+ {
11968
+ content: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: items.map((item) => {
11969
+ var _a3, _b2, _c2;
11970
+ return /* @__PURE__ */ jsxRuntime.jsx(
11971
+ "li",
11972
+ {
11973
+ children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
11974
+ },
11975
+ item.id
11976
+ );
11977
+ }) }),
11978
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
11979
+ ui.Badge,
11980
+ {
11981
+ className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
11982
+ size: "xsmall",
11983
+ children: [
11984
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
11985
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate", children: [
11986
+ items.reduce(
11987
+ (acc, item) => acc + item.quantity,
11988
+ 0
11989
+ ),
11990
+ "x",
11991
+ " ",
11992
+ pluralize(items.length, "items", "item")
11993
+ ] })
11994
+ ]
11995
+ }
11996
+ )
11997
+ }
11998
+ ),
11999
+ /* @__PURE__ */ jsxRuntime.jsx(
12000
+ ui.Tooltip,
12001
+ {
12002
+ content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
12003
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
12004
+ ui.Badge,
12005
+ {
12006
+ className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
12007
+ size: "xsmall",
12008
+ children: [
12009
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
12010
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
12011
+ ]
12012
+ }
12013
+ )
12014
+ }
12015
+ ),
12016
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
12017
+ ui.Badge,
12018
+ {
12019
+ className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
12020
+ size: "xsmall",
12021
+ children: [
12022
+ /* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
12023
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: shippingOption.name })
12024
+ ]
12025
+ }
12026
+ ) })
12027
+ ] })
12028
+ ] }),
12029
+ shippingOption ? /* @__PURE__ */ jsxRuntime.jsx(
12030
+ ActionMenu,
12031
+ {
12032
+ groups: [
12033
+ {
12034
+ actions: [
12035
+ hasItems ? {
12036
+ label: "Edit shipping option",
12037
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Channels, {}),
12038
+ onClick: () => {
12039
+ setIsOpen(
12040
+ STACKED_FOCUS_MODAL_ID,
12041
+ true
12042
+ );
12043
+ setData({
12044
+ shippingProfileId: profile.id,
12045
+ shippingOption,
12046
+ shippingMethod
12047
+ });
12048
+ }
12049
+ } : void 0,
12050
+ {
12051
+ label: "Remove shipping option",
12052
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
12053
+ onClick: () => {
12054
+ if (shippingMethod) {
12055
+ if (addShippingMethodAction) {
12056
+ removeActionShippingMethod(
12057
+ addShippingMethodAction.id
12058
+ );
12059
+ } else {
12060
+ removeShippingMethod(
12061
+ shippingMethod.id
12062
+ );
12063
+ }
12064
+ }
12065
+ }
12066
+ }
12067
+ ].filter(Boolean)
12068
+ }
12069
+ ]
12070
+ }
12071
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
12072
+ StackedModalTrigger,
12073
+ {
12074
+ shippingProfileId: profile.id,
12075
+ shippingOption,
12076
+ shippingMethod,
12077
+ setData,
12078
+ children: "Add shipping option"
12079
+ }
12080
+ )
12081
+ ] }),
12082
+ /* @__PURE__ */ jsxRuntime.jsxs(radixUi.Accordion.Content, { children: [
12083
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
12084
+ items.map((item, idx) => {
12085
+ var _a3, _b2, _c2, _d2, _e2;
12086
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12087
+ /* @__PURE__ */ jsxRuntime.jsxs(
12088
+ "div",
12089
+ {
12090
+ className: "px-3 flex items-center gap-x-3",
12091
+ children: [
12092
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-[56px] flex flex-col justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
12093
+ ui.Divider,
12094
+ {
12095
+ variant: "dashed",
12096
+ orientation: "vertical"
12097
+ }
12098
+ ) }),
12099
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 flex items-center gap-x-3", children: [
12100
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 flex items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
12101
+ ui.Text,
12102
+ {
12103
+ size: "small",
12104
+ leading: "compact",
12105
+ className: "text-ui-fg-subtle",
12106
+ children: [
12107
+ item.quantity,
12108
+ "x"
12109
+ ]
12110
+ }
12111
+ ) }),
12112
+ /* @__PURE__ */ jsxRuntime.jsx(Thumbnail, { thumbnail: item.thumbnail }),
12113
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12114
+ /* @__PURE__ */ jsxRuntime.jsxs(
12115
+ ui.Text,
12116
+ {
12117
+ size: "small",
12118
+ leading: "compact",
12119
+ weight: "plus",
12120
+ children: [
12121
+ (_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
12122
+ " (",
12123
+ (_c2 = item.variant) == null ? void 0 : _c2.title,
12124
+ ")"
12125
+ ]
12126
+ }
12127
+ ),
12128
+ /* @__PURE__ */ jsxRuntime.jsx(
12129
+ ui.Text,
12130
+ {
12131
+ size: "small",
12132
+ leading: "compact",
12133
+ className: "text-ui-fg-subtle",
12134
+ children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
12135
+ }
12136
+ )
12137
+ ] })
12138
+ ] })
12139
+ ]
12140
+ },
12141
+ item.id
12142
+ ),
12143
+ idx !== items.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" })
12144
+ ] }, item.id);
12145
+ })
12146
+ ] })
12147
+ ]
12148
+ },
12149
+ profile.id
12150
+ );
12151
+ }) })
12152
+ ] }) })
12153
+ ] }) }),
12154
+ /* @__PURE__ */ jsxRuntime.jsx(
12155
+ StackedFocusModal,
12156
+ {
12157
+ id: STACKED_FOCUS_MODAL_ID,
12158
+ onOpenChangeCallback: (open) => {
12159
+ if (!open) {
12160
+ setData(null);
12629
12161
  }
12630
- ) }),
12631
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12632
- "rect",
12162
+ return open;
12163
+ },
12164
+ children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
12165
+ }
12166
+ )
12167
+ ] }),
12168
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
12169
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12170
+ /* @__PURE__ */ jsxRuntime.jsx(
12171
+ ui.Button,
12172
+ {
12173
+ size: "small",
12174
+ type: "button",
12175
+ isLoading: isSubmitting,
12176
+ onClick: onSubmit,
12177
+ children: "Save"
12178
+ }
12179
+ )
12180
+ ] }) })
12181
+ ] });
12182
+ };
12183
+ const StackedModalTrigger = ({
12184
+ shippingProfileId,
12185
+ shippingOption,
12186
+ shippingMethod,
12187
+ setData,
12188
+ children
12189
+ }) => {
12190
+ const { setIsOpen, getIsOpen } = useStackedModal();
12191
+ const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
12192
+ const onToggle = () => {
12193
+ if (isOpen) {
12194
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12195
+ setData(null);
12196
+ } else {
12197
+ setIsOpen(STACKED_FOCUS_MODAL_ID, true);
12198
+ setData({
12199
+ shippingProfileId,
12200
+ shippingOption,
12201
+ shippingMethod
12202
+ });
12203
+ }
12204
+ };
12205
+ return /* @__PURE__ */ jsxRuntime.jsx(
12206
+ ui.Button,
12207
+ {
12208
+ size: "small",
12209
+ variant: "secondary",
12210
+ onClick: onToggle,
12211
+ className: "text-ui-fg-primary shrink-0",
12212
+ children
12213
+ }
12214
+ );
12215
+ };
12216
+ const ShippingProfileForm = ({
12217
+ data,
12218
+ order,
12219
+ preview
12220
+ }) => {
12221
+ var _a, _b, _c, _d, _e, _f;
12222
+ const { setIsOpen } = useStackedModal();
12223
+ const form = reactHookForm.useForm({
12224
+ resolver: zod.zodResolver(shippingMethodSchema),
12225
+ defaultValues: {
12226
+ 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,
12227
+ shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12228
+ custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12229
+ }
12230
+ });
12231
+ const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12232
+ const {
12233
+ mutateAsync: updateShippingMethod,
12234
+ isPending: isUpdatingShippingMethod
12235
+ } = useDraftOrderUpdateShippingMethod(order.id);
12236
+ const onSubmit = form.handleSubmit(async (values) => {
12237
+ if (lodash.isEqual(values, form.formState.defaultValues)) {
12238
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12239
+ return;
12240
+ }
12241
+ if (data.shippingMethod) {
12242
+ await updateShippingMethod(
12243
+ {
12244
+ method_id: data.shippingMethod.id,
12245
+ shipping_option_id: values.shipping_option_id,
12246
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12247
+ },
12248
+ {
12249
+ onError: (e) => {
12250
+ ui.toast.error(e.message);
12251
+ },
12252
+ onSuccess: () => {
12253
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12254
+ }
12255
+ }
12256
+ );
12257
+ return;
12258
+ }
12259
+ await addShippingMethod(
12260
+ {
12261
+ shipping_option_id: values.shipping_option_id,
12262
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12263
+ },
12264
+ {
12265
+ onError: (e) => {
12266
+ ui.toast.error(e.message);
12267
+ },
12268
+ onSuccess: () => {
12269
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12270
+ }
12271
+ }
12272
+ );
12273
+ });
12274
+ return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12275
+ KeyboundForm,
12276
+ {
12277
+ className: "flex h-full flex-col overflow-hidden",
12278
+ onSubmit,
12279
+ children: [
12280
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
12281
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
12282
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12283
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
12284
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.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." }) })
12285
+ ] }),
12286
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
12287
+ /* @__PURE__ */ jsxRuntime.jsx(
12288
+ LocationField,
12633
12289
  {
12634
- width: "12",
12635
- height: "12",
12636
- fill: "white",
12637
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12290
+ control: form.control,
12291
+ setValue: form.setValue
12638
12292
  }
12639
- ) }),
12640
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12641
- "rect",
12293
+ ),
12294
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
12295
+ /* @__PURE__ */ jsxRuntime.jsx(
12296
+ ShippingOptionField,
12642
12297
  {
12643
- width: "12",
12644
- height: "12",
12645
- fill: "white",
12646
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12298
+ shippingProfileId: data.shippingProfileId,
12299
+ preview,
12300
+ control: form.control
12647
12301
  }
12648
- ) }),
12649
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12650
- "rect",
12302
+ ),
12303
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
12304
+ /* @__PURE__ */ jsxRuntime.jsx(
12305
+ CustomAmountField,
12651
12306
  {
12652
- width: "12",
12653
- height: "12",
12654
- fill: "white",
12655
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12307
+ control: form.control,
12308
+ currencyCode: order.currency_code
12656
12309
  }
12657
- ) }),
12658
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12659
- "rect",
12310
+ ),
12311
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
12312
+ /* @__PURE__ */ jsxRuntime.jsx(
12313
+ ItemsPreview,
12660
12314
  {
12661
- width: "12",
12662
- height: "12",
12663
- fill: "white",
12664
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12315
+ order,
12316
+ shippingProfileId: data.shippingProfileId
12665
12317
  }
12666
- ) }),
12667
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12668
- "rect",
12318
+ )
12319
+ ] }) }) }),
12320
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
12321
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12322
+ /* @__PURE__ */ jsxRuntime.jsx(
12323
+ ui.Button,
12669
12324
  {
12670
- width: "12",
12671
- height: "12",
12672
- fill: "white",
12673
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12325
+ size: "small",
12326
+ type: "submit",
12327
+ isLoading: isPending || isUpdatingShippingMethod,
12328
+ children: data.shippingMethod ? "Update" : "Add"
12674
12329
  }
12675
- ) })
12676
- ] })
12330
+ )
12331
+ ] }) })
12677
12332
  ]
12678
12333
  }
12679
- );
12334
+ ) }) });
12680
12335
  };
12681
- const schema$3 = objectType({
12682
- customer_id: stringType().min(1)
12336
+ const shippingMethodSchema = objectType({
12337
+ location_id: stringType(),
12338
+ shipping_option_id: stringType(),
12339
+ custom_amount: unionType([numberType(), stringType()]).optional()
12683
12340
  });
12684
- const SalesChannel = () => {
12685
- const { id } = reactRouterDom.useParams();
12686
- const { draft_order, isPending, isError, error } = useDraftOrder(
12687
- id,
12688
- {
12689
- fields: "+sales_channel_id"
12690
- },
12691
- {
12692
- enabled: !!id
12341
+ const ItemsPreview = ({ order, shippingProfileId }) => {
12342
+ const matches = order.items.filter(
12343
+ (item) => {
12344
+ var _a, _b, _c;
12345
+ return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12693
12346
  }
12694
12347
  );
12695
- if (isError) {
12696
- throw error;
12697
- }
12698
- const ISrEADY = !!draft_order && !isPending;
12699
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12700
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12701
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12702
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12703
- ] }),
12704
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12348
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
12349
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12350
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12351
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12352
+ ] }) }),
12353
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12354
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
12355
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
12356
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
12357
+ ] }),
12358
+ /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(
12359
+ "div",
12360
+ {
12361
+ className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
12362
+ children: [
12363
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
12364
+ /* @__PURE__ */ jsxRuntime.jsx(
12365
+ Thumbnail,
12366
+ {
12367
+ thumbnail: item.thumbnail,
12368
+ alt: item.product_title ?? void 0
12369
+ }
12370
+ ),
12371
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12372
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
12373
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12374
+ /* @__PURE__ */ jsxRuntime.jsxs(
12375
+ ui.Text,
12376
+ {
12377
+ size: "small",
12378
+ leading: "compact",
12379
+ className: "text-ui-fg-subtle",
12380
+ children: [
12381
+ "(",
12382
+ item.variant_title,
12383
+ ")"
12384
+ ]
12385
+ }
12386
+ )
12387
+ ] }),
12388
+ /* @__PURE__ */ jsxRuntime.jsx(
12389
+ ui.Text,
12390
+ {
12391
+ size: "small",
12392
+ leading: "compact",
12393
+ className: "text-ui-fg-subtle",
12394
+ children: item.variant_sku
12395
+ }
12396
+ )
12397
+ ] })
12398
+ ] }),
12399
+ /* @__PURE__ */ jsxRuntime.jsxs(
12400
+ ui.Text,
12401
+ {
12402
+ size: "small",
12403
+ leading: "compact",
12404
+ className: "text-ui-fg-subtle",
12405
+ children: [
12406
+ item.quantity,
12407
+ "x"
12408
+ ]
12409
+ }
12410
+ )
12411
+ ]
12412
+ },
12413
+ item.id
12414
+ )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
12415
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12416
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
12417
+ 'No items found for "',
12418
+ query,
12419
+ '".'
12420
+ ] })
12421
+ ] }) })
12422
+ ] })
12705
12423
  ] });
12706
12424
  };
12707
- const SalesChannelForm = ({ order }) => {
12708
- const form = reactHookForm.useForm({
12709
- defaultValues: {
12710
- sales_channel_id: order.sales_channel_id || ""
12425
+ const LocationField = ({ control, setValue }) => {
12426
+ const locations = useComboboxData({
12427
+ queryKey: ["locations"],
12428
+ queryFn: async (params) => {
12429
+ return await sdk.admin.stockLocation.list(params);
12711
12430
  },
12712
- resolver: zod.zodResolver(schema$2)
12431
+ getOptions: (data) => {
12432
+ return data.stock_locations.map((location) => ({
12433
+ label: location.name,
12434
+ value: location.id
12435
+ }));
12436
+ }
12713
12437
  });
12714
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12715
- const { handleSuccess } = useRouteModal();
12716
- const onSubmit = form.handleSubmit(async (data) => {
12717
- await mutateAsync(
12718
- {
12719
- sales_channel_id: data.sales_channel_id
12720
- },
12721
- {
12722
- onSuccess: () => {
12723
- ui.toast.success("Sales channel updated");
12724
- handleSuccess();
12725
- },
12726
- onError: (error) => {
12727
- ui.toast.error(error.message);
12728
- }
12438
+ return /* @__PURE__ */ jsxRuntime.jsx(
12439
+ Form$2.Field,
12440
+ {
12441
+ control,
12442
+ name: "location_id",
12443
+ render: ({ field: { onChange, ...field } }) => {
12444
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12445
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12446
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
12447
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12448
+ ] }),
12449
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12450
+ Combobox,
12451
+ {
12452
+ options: locations.options,
12453
+ fetchNextPage: locations.fetchNextPage,
12454
+ isFetchingNextPage: locations.isFetchingNextPage,
12455
+ searchValue: locations.searchValue,
12456
+ onSearchValueChange: locations.onSearchValueChange,
12457
+ placeholder: "Select location",
12458
+ onChange: (value) => {
12459
+ setValue("shipping_option_id", "", {
12460
+ shouldDirty: true,
12461
+ shouldTouch: true
12462
+ });
12463
+ onChange(value);
12464
+ },
12465
+ ...field
12466
+ }
12467
+ ) })
12468
+ ] }) });
12729
12469
  }
12730
- );
12731
- });
12732
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12733
- KeyboundForm,
12734
- {
12735
- className: "flex flex-1 flex-col overflow-hidden",
12736
- onSubmit,
12737
- children: [
12738
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12739
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12740
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12741
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12742
- ] }) })
12743
- ]
12744
12470
  }
12745
- ) });
12471
+ );
12746
12472
  };
12747
- const SalesChannelField = ({ control, order }) => {
12748
- const salesChannels = useComboboxData({
12473
+ const ShippingOptionField = ({
12474
+ shippingProfileId,
12475
+ preview,
12476
+ control
12477
+ }) => {
12478
+ var _a;
12479
+ const locationId = reactHookForm.useWatch({ control, name: "location_id" });
12480
+ const shippingOptions = useComboboxData({
12481
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12749
12482
  queryFn: async (params) => {
12750
- return await sdk.admin.salesChannel.list(params);
12483
+ return await sdk.admin.shippingOption.list({
12484
+ ...params,
12485
+ stock_location_id: locationId,
12486
+ shipping_profile_id: shippingProfileId
12487
+ });
12751
12488
  },
12752
- queryKey: ["sales-channels"],
12753
12489
  getOptions: (data) => {
12754
- return data.sales_channels.map((salesChannel) => ({
12755
- label: salesChannel.name,
12756
- value: salesChannel.id
12757
- }));
12490
+ return data.shipping_options.map((option) => {
12491
+ var _a2;
12492
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12493
+ (r) => r.attribute === "is_return" && r.value === "true"
12494
+ )) {
12495
+ return void 0;
12496
+ }
12497
+ return {
12498
+ label: option.name,
12499
+ value: option.id
12500
+ };
12501
+ }).filter(Boolean);
12758
12502
  },
12759
- defaultValue: order.sales_channel_id || void 0
12503
+ enabled: !!locationId && !!shippingProfileId,
12504
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12760
12505
  });
12506
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12761
12507
  return /* @__PURE__ */ jsxRuntime.jsx(
12762
12508
  Form$2.Field,
12763
12509
  {
12764
12510
  control,
12765
- name: "sales_channel_id",
12511
+ name: "shipping_option_id",
12766
12512
  render: ({ field }) => {
12767
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12768
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12513
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12514
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12515
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
12516
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12517
+ ] }),
12518
+ /* @__PURE__ */ jsxRuntime.jsx(
12519
+ ConditionalTooltip,
12520
+ {
12521
+ content: tooltipContent,
12522
+ showTooltip: !locationId || !shippingProfileId,
12523
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12524
+ Combobox,
12525
+ {
12526
+ options: shippingOptions.options,
12527
+ fetchNextPage: shippingOptions.fetchNextPage,
12528
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12529
+ searchValue: shippingOptions.searchValue,
12530
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12531
+ placeholder: "Select shipping option",
12532
+ ...field,
12533
+ disabled: !locationId || !shippingProfileId
12534
+ }
12535
+ ) }) })
12536
+ }
12537
+ )
12538
+ ] }) });
12539
+ }
12540
+ }
12541
+ );
12542
+ };
12543
+ const CustomAmountField = ({
12544
+ control,
12545
+ currencyCode
12546
+ }) => {
12547
+ return /* @__PURE__ */ jsxRuntime.jsx(
12548
+ Form$2.Field,
12549
+ {
12550
+ control,
12551
+ name: "custom_amount",
12552
+ render: ({ field: { onChange, ...field } }) => {
12553
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12554
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12555
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12556
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12557
+ ] }),
12769
12558
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12770
- Combobox,
12559
+ ui.CurrencyInput,
12771
12560
  {
12772
- options: salesChannels.options,
12773
- fetchNextPage: salesChannels.fetchNextPage,
12774
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12775
- searchValue: salesChannels.searchValue,
12776
- onSearchValueChange: salesChannels.onSearchValueChange,
12777
- placeholder: "Select sales channel",
12778
- ...field
12561
+ ...field,
12562
+ onValueChange: (value) => onChange(value),
12563
+ symbol: getNativeSymbol(currencyCode),
12564
+ code: currencyCode
12779
12565
  }
12780
- ) }),
12781
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12566
+ ) })
12782
12567
  ] });
12783
12568
  }
12784
12569
  }
12785
12570
  );
12786
12571
  };
12787
- const schema$2 = objectType({
12788
- sales_channel_id: stringType().min(1)
12789
- });
12790
- const Email = () => {
12572
+ const TransferOwnership = () => {
12791
12573
  const { id } = reactRouterDom.useParams();
12792
- const { order, isPending, isError, error } = useOrder(id, {
12793
- fields: "+email"
12574
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12575
+ fields: "id,customer_id,customer.*"
12794
12576
  });
12795
12577
  if (isError) {
12796
12578
  throw error;
12797
12579
  }
12798
- const isReady = !isPending && !!order;
12580
+ const isReady = !isPending && !!draft_order;
12799
12581
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12800
12582
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12801
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
12802
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12583
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12584
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12803
12585
  ] }),
12804
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
12586
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12805
12587
  ] });
12806
12588
  };
12807
- const EmailForm = ({ order }) => {
12589
+ const TransferOwnershipForm = ({ order }) => {
12590
+ var _a, _b;
12808
12591
  const form = reactHookForm.useForm({
12809
12592
  defaultValues: {
12810
- email: order.email ?? ""
12593
+ customer_id: order.customer_id || ""
12811
12594
  },
12812
- resolver: zod.zodResolver(schema$1)
12595
+ resolver: zod.zodResolver(schema)
12813
12596
  });
12814
12597
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12815
12598
  const { handleSuccess } = useRouteModal();
12599
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12600
+ const currentCustomer = order.customer ? {
12601
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12602
+ value: order.customer.id
12603
+ } : null;
12816
12604
  const onSubmit = form.handleSubmit(async (data) => {
12817
12605
  await mutateAsync(
12818
- { email: data.email },
12606
+ { customer_id: data.customer_id },
12819
12607
  {
12820
12608
  onSuccess: () => {
12609
+ ui.toast.success("Customer updated");
12821
12610
  handleSuccess();
12822
12611
  },
12823
12612
  onError: (error) => {
@@ -12832,219 +12621,430 @@ const EmailForm = ({ order }) => {
12832
12621
  className: "flex flex-1 flex-col overflow-hidden",
12833
12622
  onSubmit,
12834
12623
  children: [
12835
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
12836
- Form$2.Field,
12837
- {
12838
- control: form.control,
12839
- name: "email",
12840
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12841
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
12842
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12843
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12624
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12625
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12626
+ currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12627
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12628
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12629
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12630
+ ] }),
12631
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12632
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12633
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12844
12634
  ] })
12845
- }
12846
- ) }),
12847
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12848
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12635
+ ] }),
12636
+ /* @__PURE__ */ jsxRuntime.jsx(
12637
+ CustomerField,
12638
+ {
12639
+ control: form.control,
12640
+ currentCustomerId: order.customer_id
12641
+ }
12642
+ )
12643
+ ] }),
12644
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12645
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12849
12646
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12850
12647
  ] }) })
12851
12648
  ]
12852
12649
  }
12853
12650
  ) });
12854
12651
  };
12855
- const schema$1 = objectType({
12856
- email: stringType().email()
12857
- });
12858
- const BillingAddress = () => {
12859
- const { id } = reactRouterDom.useParams();
12860
- const { order, isPending, isError, error } = useOrder(id, {
12861
- fields: "+billing_address"
12862
- });
12863
- if (isError) {
12864
- throw error;
12865
- }
12866
- const isReady = !isPending && !!order;
12867
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12868
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12869
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12870
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12871
- ] }),
12872
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12873
- ] });
12874
- };
12875
- const BillingAddressForm = ({ order }) => {
12876
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12877
- const form = reactHookForm.useForm({
12878
- defaultValues: {
12879
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12880
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12881
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12882
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12883
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12884
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12885
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12886
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12887
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12888
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12652
+ const CustomerField = ({ control, currentCustomerId }) => {
12653
+ const customers = useComboboxData({
12654
+ queryFn: async (params) => {
12655
+ return await sdk.admin.customer.list({
12656
+ ...params,
12657
+ id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12658
+ });
12889
12659
  },
12890
- resolver: zod.zodResolver(schema)
12891
- });
12892
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12893
- const { handleSuccess } = useRouteModal();
12894
- const onSubmit = form.handleSubmit(async (data) => {
12895
- await mutateAsync(
12896
- { billing_address: data },
12897
- {
12898
- onSuccess: () => {
12899
- handleSuccess();
12900
- },
12901
- onError: (error) => {
12902
- ui.toast.error(error.message);
12903
- }
12904
- }
12905
- );
12660
+ queryKey: ["customers"],
12661
+ getOptions: (data) => {
12662
+ return data.customers.map((customer) => {
12663
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12664
+ return {
12665
+ label: name ? `${name} (${customer.email})` : customer.email,
12666
+ value: customer.id
12667
+ };
12668
+ });
12669
+ }
12906
12670
  });
12907
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12908
- KeyboundForm,
12671
+ return /* @__PURE__ */ jsxRuntime.jsx(
12672
+ Form$2.Field,
12909
12673
  {
12910
- className: "flex flex-1 flex-col overflow-hidden",
12911
- onSubmit,
12674
+ name: "customer_id",
12675
+ control,
12676
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
12677
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12678
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
12679
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
12680
+ ] }),
12681
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12682
+ Combobox,
12683
+ {
12684
+ options: customers.options,
12685
+ fetchNextPage: customers.fetchNextPage,
12686
+ isFetchingNextPage: customers.isFetchingNextPage,
12687
+ searchValue: customers.searchValue,
12688
+ onSearchValueChange: customers.onSearchValueChange,
12689
+ placeholder: "Select customer",
12690
+ ...field
12691
+ }
12692
+ ) }),
12693
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12694
+ ] })
12695
+ }
12696
+ );
12697
+ };
12698
+ const Illustration = () => {
12699
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12700
+ "svg",
12701
+ {
12702
+ width: "280",
12703
+ height: "180",
12704
+ viewBox: "0 0 280 180",
12705
+ fill: "none",
12706
+ xmlns: "http://www.w3.org/2000/svg",
12912
12707
  children: [
12913
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12914
- /* @__PURE__ */ jsxRuntime.jsx(
12915
- Form$2.Field,
12708
+ /* @__PURE__ */ jsxRuntime.jsx(
12709
+ "rect",
12710
+ {
12711
+ x: "0.00428286",
12712
+ y: "-0.742904",
12713
+ width: "33.5",
12714
+ height: "65.5",
12715
+ rx: "6.75",
12716
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
12717
+ fill: "#D4D4D8",
12718
+ stroke: "#52525B",
12719
+ strokeWidth: "1.5"
12720
+ }
12721
+ ),
12722
+ /* @__PURE__ */ jsxRuntime.jsx(
12723
+ "rect",
12724
+ {
12725
+ x: "0.00428286",
12726
+ y: "-0.742904",
12727
+ width: "33.5",
12728
+ height: "65.5",
12729
+ rx: "6.75",
12730
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
12731
+ fill: "white",
12732
+ stroke: "#52525B",
12733
+ strokeWidth: "1.5"
12734
+ }
12735
+ ),
12736
+ /* @__PURE__ */ jsxRuntime.jsx(
12737
+ "path",
12738
+ {
12739
+ d: "M180.579 107.142L179.126 107.959",
12740
+ stroke: "#52525B",
12741
+ strokeWidth: "1.5",
12742
+ strokeLinecap: "round",
12743
+ strokeLinejoin: "round"
12744
+ }
12745
+ ),
12746
+ /* @__PURE__ */ jsxRuntime.jsx(
12747
+ "path",
12748
+ {
12749
+ opacity: "0.88",
12750
+ d: "M182.305 109.546L180.257 109.534",
12751
+ stroke: "#52525B",
12752
+ strokeWidth: "1.5",
12753
+ strokeLinecap: "round",
12754
+ strokeLinejoin: "round"
12755
+ }
12756
+ ),
12757
+ /* @__PURE__ */ jsxRuntime.jsx(
12758
+ "path",
12759
+ {
12760
+ opacity: "0.75",
12761
+ d: "M180.551 111.93L179.108 111.096",
12762
+ stroke: "#52525B",
12763
+ strokeWidth: "1.5",
12764
+ strokeLinecap: "round",
12765
+ strokeLinejoin: "round"
12766
+ }
12767
+ ),
12768
+ /* @__PURE__ */ jsxRuntime.jsx(
12769
+ "path",
12770
+ {
12771
+ opacity: "0.63",
12772
+ d: "M176.347 112.897L176.354 111.73",
12773
+ stroke: "#52525B",
12774
+ strokeWidth: "1.5",
12775
+ strokeLinecap: "round",
12776
+ strokeLinejoin: "round"
12777
+ }
12778
+ ),
12779
+ /* @__PURE__ */ jsxRuntime.jsx(
12780
+ "path",
12781
+ {
12782
+ opacity: "0.5",
12783
+ d: "M172.153 111.881L173.606 111.064",
12784
+ stroke: "#52525B",
12785
+ strokeWidth: "1.5",
12786
+ strokeLinecap: "round",
12787
+ strokeLinejoin: "round"
12788
+ }
12789
+ ),
12790
+ /* @__PURE__ */ jsxRuntime.jsx(
12791
+ "path",
12792
+ {
12793
+ opacity: "0.38",
12794
+ d: "M170.428 109.478L172.476 109.489",
12795
+ stroke: "#52525B",
12796
+ strokeWidth: "1.5",
12797
+ strokeLinecap: "round",
12798
+ strokeLinejoin: "round"
12799
+ }
12800
+ ),
12801
+ /* @__PURE__ */ jsxRuntime.jsx(
12802
+ "path",
12803
+ {
12804
+ opacity: "0.25",
12805
+ d: "M172.181 107.094L173.624 107.928",
12806
+ stroke: "#52525B",
12807
+ strokeWidth: "1.5",
12808
+ strokeLinecap: "round",
12809
+ strokeLinejoin: "round"
12810
+ }
12811
+ ),
12812
+ /* @__PURE__ */ jsxRuntime.jsx(
12813
+ "path",
12814
+ {
12815
+ opacity: "0.13",
12816
+ d: "M176.386 106.126L176.379 107.294",
12817
+ stroke: "#52525B",
12818
+ strokeWidth: "1.5",
12819
+ strokeLinecap: "round",
12820
+ strokeLinejoin: "round"
12821
+ }
12822
+ ),
12823
+ /* @__PURE__ */ jsxRuntime.jsx(
12824
+ "rect",
12825
+ {
12826
+ width: "12",
12827
+ height: "3",
12828
+ rx: "1.5",
12829
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12830
+ fill: "#D4D4D8"
12831
+ }
12832
+ ),
12833
+ /* @__PURE__ */ jsxRuntime.jsx(
12834
+ "rect",
12835
+ {
12836
+ x: "0.00428286",
12837
+ y: "-0.742904",
12838
+ width: "33.5",
12839
+ height: "65.5",
12840
+ rx: "6.75",
12841
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12842
+ fill: "#D4D4D8",
12843
+ stroke: "#52525B",
12844
+ strokeWidth: "1.5"
12845
+ }
12846
+ ),
12847
+ /* @__PURE__ */ jsxRuntime.jsx(
12848
+ "rect",
12849
+ {
12850
+ x: "0.00428286",
12851
+ y: "-0.742904",
12852
+ width: "33.5",
12853
+ height: "65.5",
12854
+ rx: "6.75",
12855
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12856
+ fill: "white",
12857
+ stroke: "#52525B",
12858
+ strokeWidth: "1.5"
12859
+ }
12860
+ ),
12861
+ /* @__PURE__ */ jsxRuntime.jsx(
12862
+ "rect",
12863
+ {
12864
+ width: "12",
12865
+ height: "3",
12866
+ rx: "1.5",
12867
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12868
+ fill: "#D4D4D8"
12869
+ }
12870
+ ),
12871
+ /* @__PURE__ */ jsxRuntime.jsx(
12872
+ "rect",
12873
+ {
12874
+ width: "17",
12875
+ height: "3",
12876
+ rx: "1.5",
12877
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12878
+ fill: "#D4D4D8"
12879
+ }
12880
+ ),
12881
+ /* @__PURE__ */ jsxRuntime.jsx(
12882
+ "rect",
12883
+ {
12884
+ width: "12",
12885
+ height: "3",
12886
+ rx: "1.5",
12887
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12888
+ fill: "#D4D4D8"
12889
+ }
12890
+ ),
12891
+ /* @__PURE__ */ jsxRuntime.jsx(
12892
+ "path",
12893
+ {
12894
+ d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
12895
+ fill: "#A1A1AA"
12896
+ }
12897
+ ),
12898
+ /* @__PURE__ */ jsxRuntime.jsx(
12899
+ "rect",
12900
+ {
12901
+ width: "17",
12902
+ height: "3",
12903
+ rx: "1.5",
12904
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12905
+ fill: "#A1A1AA"
12906
+ }
12907
+ ),
12908
+ /* @__PURE__ */ jsxRuntime.jsx(
12909
+ "rect",
12910
+ {
12911
+ width: "12",
12912
+ height: "3",
12913
+ rx: "1.5",
12914
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12915
+ fill: "#A1A1AA"
12916
+ }
12917
+ ),
12918
+ /* @__PURE__ */ jsxRuntime.jsx(
12919
+ "path",
12920
+ {
12921
+ d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
12922
+ fill: "#52525B"
12923
+ }
12924
+ ),
12925
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12926
+ "path",
12927
+ {
12928
+ d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12929
+ stroke: "#A1A1AA",
12930
+ strokeWidth: "1.5",
12931
+ strokeLinecap: "round",
12932
+ strokeLinejoin: "round"
12933
+ }
12934
+ ) }),
12935
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12936
+ "path",
12937
+ {
12938
+ d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12939
+ stroke: "#A1A1AA",
12940
+ strokeWidth: "1.5",
12941
+ strokeLinecap: "round",
12942
+ strokeLinejoin: "round"
12943
+ }
12944
+ ) }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12946
+ "path",
12947
+ {
12948
+ d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12949
+ stroke: "#A1A1AA",
12950
+ strokeWidth: "1.5",
12951
+ strokeLinecap: "round",
12952
+ strokeLinejoin: "round"
12953
+ }
12954
+ ) }),
12955
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12956
+ "path",
12957
+ {
12958
+ d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12959
+ stroke: "#A1A1AA",
12960
+ strokeWidth: "1.5",
12961
+ strokeLinecap: "round",
12962
+ strokeLinejoin: "round"
12963
+ }
12964
+ ) }),
12965
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12966
+ "path",
12967
+ {
12968
+ d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12969
+ stroke: "#A1A1AA",
12970
+ strokeWidth: "1.5",
12971
+ strokeLinecap: "round",
12972
+ strokeLinejoin: "round"
12973
+ }
12974
+ ) }),
12975
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12976
+ "path",
12977
+ {
12978
+ d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12979
+ stroke: "#A1A1AA",
12980
+ strokeWidth: "1.5",
12981
+ strokeLinecap: "round",
12982
+ strokeLinejoin: "round"
12983
+ }
12984
+ ) }),
12985
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12986
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12987
+ "rect",
12916
12988
  {
12917
- control: form.control,
12918
- name: "country_code",
12919
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12922
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
- ] })
12989
+ width: "12",
12990
+ height: "12",
12991
+ fill: "white",
12992
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12924
12993
  }
12925
- ),
12926
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12927
- /* @__PURE__ */ jsxRuntime.jsx(
12928
- Form$2.Field,
12929
- {
12930
- control: form.control,
12931
- name: "first_name",
12932
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12934
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12935
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12936
- ] })
12937
- }
12938
- ),
12939
- /* @__PURE__ */ jsxRuntime.jsx(
12940
- Form$2.Field,
12941
- {
12942
- control: form.control,
12943
- name: "last_name",
12944
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12948
- ] })
12949
- }
12950
- )
12951
- ] }),
12952
- /* @__PURE__ */ jsxRuntime.jsx(
12953
- Form$2.Field,
12994
+ ) }),
12995
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12996
+ "rect",
12954
12997
  {
12955
- control: form.control,
12956
- name: "company",
12957
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12959
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12960
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12961
- ] })
12998
+ width: "12",
12999
+ height: "12",
13000
+ fill: "white",
13001
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12962
13002
  }
12963
- ),
12964
- /* @__PURE__ */ jsxRuntime.jsx(
12965
- Form$2.Field,
13003
+ ) }),
13004
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13005
+ "rect",
12966
13006
  {
12967
- control: form.control,
12968
- name: "address_1",
12969
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12972
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12973
- ] })
13007
+ width: "12",
13008
+ height: "12",
13009
+ fill: "white",
13010
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12974
13011
  }
12975
- ),
12976
- /* @__PURE__ */ jsxRuntime.jsx(
12977
- Form$2.Field,
13012
+ ) }),
13013
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13014
+ "rect",
12978
13015
  {
12979
- control: form.control,
12980
- name: "address_2",
12981
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12985
- ] })
13016
+ width: "12",
13017
+ height: "12",
13018
+ fill: "white",
13019
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12986
13020
  }
12987
- ),
12988
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12989
- /* @__PURE__ */ jsxRuntime.jsx(
12990
- Form$2.Field,
12991
- {
12992
- control: form.control,
12993
- name: "postal_code",
12994
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12997
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12998
- ] })
12999
- }
13000
- ),
13001
- /* @__PURE__ */ jsxRuntime.jsx(
13002
- Form$2.Field,
13003
- {
13004
- control: form.control,
13005
- name: "city",
13006
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13009
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13010
- ] })
13011
- }
13012
- )
13013
- ] }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(
13015
- Form$2.Field,
13021
+ ) }),
13022
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13023
+ "rect",
13016
13024
  {
13017
- control: form.control,
13018
- name: "province",
13019
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13020
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13021
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13022
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13023
- ] })
13025
+ width: "12",
13026
+ height: "12",
13027
+ fill: "white",
13028
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
13024
13029
  }
13025
- ),
13026
- /* @__PURE__ */ jsxRuntime.jsx(
13027
- Form$2.Field,
13030
+ ) }),
13031
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13032
+ "rect",
13028
13033
  {
13029
- control: form.control,
13030
- name: "phone",
13031
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13034
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13035
- ] })
13034
+ width: "12",
13035
+ height: "12",
13036
+ fill: "white",
13037
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
13036
13038
  }
13037
- )
13038
- ] }) }),
13039
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13040
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13041
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13042
- ] }) })
13039
+ ) })
13040
+ ] })
13043
13041
  ]
13044
13042
  }
13045
- ) });
13043
+ );
13046
13044
  };
13047
- const schema = addressSchema;
13045
+ const schema = objectType({
13046
+ customer_id: stringType().min(1)
13047
+ });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13065,10 +13065,18 @@ const routeModule = {
13065
13065
  handle,
13066
13066
  loader,
13067
13067
  children: [
13068
+ {
13069
+ Component: BillingAddress,
13070
+ path: "/draft-orders/:id/billing-address"
13071
+ },
13068
13072
  {
13069
13073
  Component: CustomItems,
13070
13074
  path: "/draft-orders/:id/custom-items"
13071
13075
  },
13076
+ {
13077
+ Component: Email,
13078
+ path: "/draft-orders/:id/email"
13079
+ },
13072
13080
  {
13073
13081
  Component: Items,
13074
13082
  path: "/draft-orders/:id/items"
@@ -13082,28 +13090,20 @@ const routeModule = {
13082
13090
  path: "/draft-orders/:id/promotions"
13083
13091
  },
13084
13092
  {
13085
- Component: Shipping,
13086
- path: "/draft-orders/:id/shipping"
13093
+ Component: SalesChannel,
13094
+ path: "/draft-orders/:id/sales-channel"
13087
13095
  },
13088
13096
  {
13089
13097
  Component: ShippingAddress,
13090
13098
  path: "/draft-orders/:id/shipping-address"
13091
13099
  },
13092
13100
  {
13093
- Component: TransferOwnership,
13094
- path: "/draft-orders/:id/transfer-ownership"
13095
- },
13096
- {
13097
- Component: SalesChannel,
13098
- path: "/draft-orders/:id/sales-channel"
13099
- },
13100
- {
13101
- Component: Email,
13102
- path: "/draft-orders/:id/email"
13101
+ Component: Shipping,
13102
+ path: "/draft-orders/:id/shipping"
13103
13103
  },
13104
13104
  {
13105
- Component: BillingAddress,
13106
- path: "/draft-orders/:id/billing-address"
13105
+ Component: TransferOwnership,
13106
+ path: "/draft-orders/:id/transfer-ownership"
13107
13107
  }
13108
13108
  ]
13109
13109
  }