@medusajs/draft-order 2.11.0-snapshot-20251020120939 → 2.11.0

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.
@@ -9571,6 +9571,27 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
+ const CustomItems = () => {
9575
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9576
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9577
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9578
+ ] });
9579
+ };
9580
+ const CustomItemsForm = () => {
9581
+ const form = reactHookForm.useForm({
9582
+ resolver: zod.zodResolver(schema$5)
9583
+ });
9584
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9589
+ ] }) })
9590
+ ] }) });
9591
+ };
9592
+ const schema$5 = objectType({
9593
+ email: stringType().email()
9594
+ });
9574
9595
  const BillingAddress = () => {
9575
9596
  const { id } = reactRouterDom.useParams();
9576
9597
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9603,7 +9624,7 @@ const BillingAddressForm = ({ order }) => {
9603
9624
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
9625
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
9626
  },
9606
- resolver: zod.zodResolver(schema$5)
9627
+ resolver: zod.zodResolver(schema$4)
9607
9628
  });
9608
9629
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
9630
  const { handleSuccess } = useRouteModal();
@@ -9760,96 +9781,7 @@ const BillingAddressForm = ({ order }) => {
9760
9781
  }
9761
9782
  ) });
9762
9783
  };
9763
- const schema$5 = addressSchema;
9764
- const CustomItems = () => {
9765
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9766
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9767
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9768
- ] });
9769
- };
9770
- const CustomItemsForm = () => {
9771
- const form = reactHookForm.useForm({
9772
- resolver: zod.zodResolver(schema$4)
9773
- });
9774
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9775
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9776
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9778
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9779
- ] }) })
9780
- ] }) });
9781
- };
9782
- const schema$4 = objectType({
9783
- email: stringType().email()
9784
- });
9785
- const Email = () => {
9786
- const { id } = reactRouterDom.useParams();
9787
- const { order, isPending, isError, error } = useOrder(id, {
9788
- fields: "+email"
9789
- });
9790
- if (isError) {
9791
- throw error;
9792
- }
9793
- const isReady = !isPending && !!order;
9794
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9795
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9796
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9797
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9798
- ] }),
9799
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9800
- ] });
9801
- };
9802
- const EmailForm = ({ order }) => {
9803
- const form = reactHookForm.useForm({
9804
- defaultValues: {
9805
- email: order.email ?? ""
9806
- },
9807
- resolver: zod.zodResolver(schema$3)
9808
- });
9809
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9810
- const { handleSuccess } = useRouteModal();
9811
- const onSubmit = form.handleSubmit(async (data) => {
9812
- await mutateAsync(
9813
- { email: data.email },
9814
- {
9815
- onSuccess: () => {
9816
- handleSuccess();
9817
- },
9818
- onError: (error) => {
9819
- ui.toast.error(error.message);
9820
- }
9821
- }
9822
- );
9823
- });
9824
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9825
- KeyboundForm,
9826
- {
9827
- className: "flex flex-1 flex-col overflow-hidden",
9828
- onSubmit,
9829
- children: [
9830
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9831
- Form$2.Field,
9832
- {
9833
- control: form.control,
9834
- name: "email",
9835
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9836
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9837
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9838
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9839
- ] })
9840
- }
9841
- ) }),
9842
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9843
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9844
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9845
- ] }) })
9846
- ]
9847
- }
9848
- ) });
9849
- };
9850
- const schema$3 = objectType({
9851
- email: stringType().email()
9852
- });
9784
+ const schema$4 = addressSchema;
9853
9785
  const NumberInput = React.forwardRef(
9854
9786
  ({
9855
9787
  value,
@@ -10824,78 +10756,252 @@ const customItemSchema = objectType({
10824
10756
  quantity: numberType(),
10825
10757
  unit_price: unionType([numberType(), stringType()])
10826
10758
  });
10827
- const PROMOTION_QUERY_KEY = "promotions";
10828
- const promotionsQueryKeys = {
10829
- list: (query2) => [
10830
- PROMOTION_QUERY_KEY,
10831
- query2 ? query2 : void 0
10832
- ],
10833
- detail: (id, query2) => [
10834
- PROMOTION_QUERY_KEY,
10835
- id,
10836
- query2 ? query2 : void 0
10837
- ]
10838
- };
10839
- const usePromotions = (query2, options) => {
10840
- const { data, ...rest } = reactQuery.useQuery({
10841
- queryKey: promotionsQueryKeys.list(query2),
10842
- queryFn: async () => sdk.admin.promotion.list(query2),
10843
- ...options
10844
- });
10845
- return { ...data, ...rest };
10846
- };
10847
- const Promotions = () => {
10759
+ const Email = () => {
10848
10760
  const { id } = reactRouterDom.useParams();
10849
- const {
10850
- order: preview,
10851
- isError: isPreviewError,
10852
- error: previewError
10853
- } = useOrderPreview(id, void 0);
10854
- useInitiateOrderEdit({ preview });
10855
- const { onCancel } = useCancelOrderEdit({ preview });
10856
- if (isPreviewError) {
10857
- throw previewError;
10761
+ const { order, isPending, isError, error } = useOrder(id, {
10762
+ fields: "+email"
10763
+ });
10764
+ if (isError) {
10765
+ throw error;
10858
10766
  }
10859
- const isReady = !!preview;
10860
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
10861
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
10862
- isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
10767
+ const isReady = !isPending && !!order;
10768
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10769
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10770
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10771
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10772
+ ] }),
10773
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10863
10774
  ] });
10864
10775
  };
10865
- const PromotionForm = ({ preview }) => {
10866
- const { items, shipping_methods } = preview;
10867
- const [isSubmitting, setIsSubmitting] = React.useState(false);
10868
- const [comboboxValue, setComboboxValue] = React.useState("");
10776
+ const EmailForm = ({ order }) => {
10777
+ const form = reactHookForm.useForm({
10778
+ defaultValues: {
10779
+ email: order.email ?? ""
10780
+ },
10781
+ resolver: zod.zodResolver(schema$3)
10782
+ });
10783
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10869
10784
  const { handleSuccess } = useRouteModal();
10870
- const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
10871
- const promoIds = getPromotionIds(items, shipping_methods);
10872
- const { promotions, isPending, isError, error } = usePromotions(
10785
+ const onSubmit = form.handleSubmit(async (data) => {
10786
+ await mutateAsync(
10787
+ { email: data.email },
10788
+ {
10789
+ onSuccess: () => {
10790
+ handleSuccess();
10791
+ },
10792
+ onError: (error) => {
10793
+ ui.toast.error(error.message);
10794
+ }
10795
+ }
10796
+ );
10797
+ });
10798
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10799
+ KeyboundForm,
10873
10800
  {
10874
- id: promoIds
10801
+ className: "flex flex-1 flex-col overflow-hidden",
10802
+ onSubmit,
10803
+ children: [
10804
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10805
+ Form$2.Field,
10806
+ {
10807
+ control: form.control,
10808
+ name: "email",
10809
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10810
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10811
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10812
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10813
+ ] })
10814
+ }
10815
+ ) }),
10816
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10817
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10818
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10819
+ ] }) })
10820
+ ]
10821
+ }
10822
+ ) });
10823
+ };
10824
+ const schema$3 = objectType({
10825
+ email: stringType().email()
10826
+ });
10827
+ const SalesChannel = () => {
10828
+ const { id } = reactRouterDom.useParams();
10829
+ const { draft_order, isPending, isError, error } = useDraftOrder(
10830
+ id,
10831
+ {
10832
+ fields: "+sales_channel_id"
10875
10833
  },
10876
10834
  {
10877
- enabled: !!promoIds.length
10835
+ enabled: !!id
10878
10836
  }
10879
10837
  );
10880
- const comboboxData = useComboboxData({
10881
- queryKey: ["promotions", "combobox", promoIds],
10882
- queryFn: async (params) => {
10883
- return await sdk.admin.promotion.list({
10884
- ...params,
10885
- id: {
10886
- $nin: promoIds
10887
- }
10888
- });
10838
+ if (isError) {
10839
+ throw error;
10840
+ }
10841
+ const ISrEADY = !!draft_order && !isPending;
10842
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10843
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
10845
+ /* @__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" }) })
10846
+ ] }),
10847
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
10848
+ ] });
10849
+ };
10850
+ const SalesChannelForm = ({ order }) => {
10851
+ const form = reactHookForm.useForm({
10852
+ defaultValues: {
10853
+ sales_channel_id: order.sales_channel_id || ""
10889
10854
  },
10890
- getOptions: (data) => {
10891
- return data.promotions.map((promotion) => ({
10892
- label: promotion.code,
10893
- value: promotion.code
10894
- }));
10895
- }
10855
+ resolver: zod.zodResolver(schema$2)
10896
10856
  });
10897
- const add = async (value) => {
10898
- if (!value) {
10857
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10858
+ const { handleSuccess } = useRouteModal();
10859
+ const onSubmit = form.handleSubmit(async (data) => {
10860
+ await mutateAsync(
10861
+ {
10862
+ sales_channel_id: data.sales_channel_id
10863
+ },
10864
+ {
10865
+ onSuccess: () => {
10866
+ ui.toast.success("Sales channel updated");
10867
+ handleSuccess();
10868
+ },
10869
+ onError: (error) => {
10870
+ ui.toast.error(error.message);
10871
+ }
10872
+ }
10873
+ );
10874
+ });
10875
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10876
+ KeyboundForm,
10877
+ {
10878
+ className: "flex flex-1 flex-col overflow-hidden",
10879
+ onSubmit,
10880
+ children: [
10881
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
10882
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10883
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10884
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10885
+ ] }) })
10886
+ ]
10887
+ }
10888
+ ) });
10889
+ };
10890
+ const SalesChannelField = ({ control, order }) => {
10891
+ const salesChannels = useComboboxData({
10892
+ queryFn: async (params) => {
10893
+ return await sdk.admin.salesChannel.list(params);
10894
+ },
10895
+ queryKey: ["sales-channels"],
10896
+ getOptions: (data) => {
10897
+ return data.sales_channels.map((salesChannel) => ({
10898
+ label: salesChannel.name,
10899
+ value: salesChannel.id
10900
+ }));
10901
+ },
10902
+ defaultValue: order.sales_channel_id || void 0
10903
+ });
10904
+ return /* @__PURE__ */ jsxRuntime.jsx(
10905
+ Form$2.Field,
10906
+ {
10907
+ control,
10908
+ name: "sales_channel_id",
10909
+ render: ({ field }) => {
10910
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10911
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
10912
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
10913
+ Combobox,
10914
+ {
10915
+ options: salesChannels.options,
10916
+ fetchNextPage: salesChannels.fetchNextPage,
10917
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
10918
+ searchValue: salesChannels.searchValue,
10919
+ onSearchValueChange: salesChannels.onSearchValueChange,
10920
+ placeholder: "Select sales channel",
10921
+ ...field
10922
+ }
10923
+ ) }),
10924
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10925
+ ] });
10926
+ }
10927
+ }
10928
+ );
10929
+ };
10930
+ const schema$2 = objectType({
10931
+ sales_channel_id: stringType().min(1)
10932
+ });
10933
+ const PROMOTION_QUERY_KEY = "promotions";
10934
+ const promotionsQueryKeys = {
10935
+ list: (query2) => [
10936
+ PROMOTION_QUERY_KEY,
10937
+ query2 ? query2 : void 0
10938
+ ],
10939
+ detail: (id, query2) => [
10940
+ PROMOTION_QUERY_KEY,
10941
+ id,
10942
+ query2 ? query2 : void 0
10943
+ ]
10944
+ };
10945
+ const usePromotions = (query2, options) => {
10946
+ const { data, ...rest } = reactQuery.useQuery({
10947
+ queryKey: promotionsQueryKeys.list(query2),
10948
+ queryFn: async () => sdk.admin.promotion.list(query2),
10949
+ ...options
10950
+ });
10951
+ return { ...data, ...rest };
10952
+ };
10953
+ const Promotions = () => {
10954
+ const { id } = reactRouterDom.useParams();
10955
+ const {
10956
+ order: preview,
10957
+ isError: isPreviewError,
10958
+ error: previewError
10959
+ } = useOrderPreview(id, void 0);
10960
+ useInitiateOrderEdit({ preview });
10961
+ const { onCancel } = useCancelOrderEdit({ preview });
10962
+ if (isPreviewError) {
10963
+ throw previewError;
10964
+ }
10965
+ const isReady = !!preview;
10966
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
10967
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
10968
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
10969
+ ] });
10970
+ };
10971
+ const PromotionForm = ({ preview }) => {
10972
+ const { items, shipping_methods } = preview;
10973
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
10974
+ const [comboboxValue, setComboboxValue] = React.useState("");
10975
+ const { handleSuccess } = useRouteModal();
10976
+ const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
10977
+ const promoIds = getPromotionIds(items, shipping_methods);
10978
+ const { promotions, isPending, isError, error } = usePromotions(
10979
+ {
10980
+ id: promoIds
10981
+ },
10982
+ {
10983
+ enabled: !!promoIds.length
10984
+ }
10985
+ );
10986
+ const comboboxData = useComboboxData({
10987
+ queryKey: ["promotions", "combobox", promoIds],
10988
+ queryFn: async (params) => {
10989
+ return await sdk.admin.promotion.list({
10990
+ ...params,
10991
+ id: {
10992
+ $nin: promoIds
10993
+ }
10994
+ });
10995
+ },
10996
+ getOptions: (data) => {
10997
+ return data.promotions.map((promotion) => ({
10998
+ label: promotion.code,
10999
+ value: promotion.code
11000
+ }));
11001
+ }
11002
+ });
11003
+ const add = async (value) => {
11004
+ if (!value) {
10899
11005
  return;
10900
11006
  }
10901
11007
  addPromotions(
@@ -11101,507 +11207,51 @@ function getPromotionIds(items, shippingMethods) {
11101
11207
  }
11102
11208
  return Array.from(promotionIds);
11103
11209
  }
11104
- const InlineTip = React.forwardRef(
11105
- ({ variant = "tip", label, className, children, ...props }, ref) => {
11106
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
11107
- return /* @__PURE__ */ jsxRuntime.jsxs(
11108
- "div",
11109
- {
11110
- ref,
11111
- className: ui.clx(
11112
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
11113
- className
11114
- ),
11115
- ...props,
11116
- children: [
11117
- /* @__PURE__ */ jsxRuntime.jsx(
11118
- "div",
11119
- {
11120
- role: "presentation",
11121
- className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
11122
- "bg-ui-tag-orange-icon": variant === "warning"
11123
- })
11124
- }
11125
- ),
11126
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
11127
- /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
11128
- labelValue,
11129
- ":"
11130
- ] }),
11131
- " ",
11132
- children
11133
- ] })
11134
- ]
11135
- }
11136
- );
11137
- }
11138
- );
11139
- InlineTip.displayName = "InlineTip";
11140
- const MetadataFieldSchema = objectType({
11141
- key: stringType(),
11142
- disabled: booleanType().optional(),
11143
- value: anyType()
11144
- });
11145
- const MetadataSchema = objectType({
11146
- metadata: arrayType(MetadataFieldSchema)
11147
- });
11148
- const Metadata = () => {
11210
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11211
+ const Shipping = () => {
11212
+ var _a;
11149
11213
  const { id } = reactRouterDom.useParams();
11150
11214
  const { order, isPending, isError, error } = useOrder(id, {
11151
- fields: "metadata"
11215
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11152
11216
  });
11217
+ const {
11218
+ order: preview,
11219
+ isPending: isPreviewPending,
11220
+ isError: isPreviewError,
11221
+ error: previewError
11222
+ } = useOrderPreview(id);
11223
+ useInitiateOrderEdit({ preview });
11224
+ const { onCancel } = useCancelOrderEdit({ preview });
11153
11225
  if (isError) {
11154
11226
  throw error;
11155
11227
  }
11156
- const isReady = !isPending && !!order;
11157
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11158
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11159
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
11160
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
11161
- ] }),
11162
- !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
11163
- ] });
11228
+ if (isPreviewError) {
11229
+ throw previewError;
11230
+ }
11231
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11232
+ const isReady = preview && !isPreviewPending && order && !isPending;
11233
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11234
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11235
+ /* @__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: [
11236
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11237
+ /* @__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." }) })
11238
+ ] }) }) }),
11239
+ /* @__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" }) }) })
11240
+ ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11241
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11242
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11243
+ ] }) });
11164
11244
  };
11165
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
11166
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
11167
- const MetadataForm = ({ orderId, metadata }) => {
11168
- const { handleSuccess } = useRouteModal();
11169
- const hasUneditableRows = getHasUneditableRows(metadata);
11170
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
11171
- const form = reactHookForm.useForm({
11172
- defaultValues: {
11173
- metadata: getDefaultValues(metadata)
11174
- },
11175
- resolver: zod.zodResolver(MetadataSchema)
11176
- });
11177
- const handleSubmit = form.handleSubmit(async (data) => {
11178
- const parsedData = parseValues(data);
11179
- await mutateAsync(
11180
- {
11181
- metadata: parsedData
11182
- },
11183
- {
11184
- onSuccess: () => {
11185
- ui.toast.success("Metadata updated");
11186
- handleSuccess();
11187
- },
11188
- onError: (error) => {
11189
- ui.toast.error(error.message);
11190
- }
11191
- }
11192
- );
11193
- });
11194
- const { fields, insert, remove } = reactHookForm.useFieldArray({
11195
- control: form.control,
11196
- name: "metadata"
11197
- });
11198
- function deleteRow(index) {
11199
- remove(index);
11200
- if (fields.length === 1) {
11201
- insert(0, {
11202
- key: "",
11203
- value: "",
11204
- disabled: false
11205
- });
11206
- }
11207
- }
11208
- function insertRow(index, position) {
11209
- insert(index + (position === "above" ? 0 : 1), {
11210
- key: "",
11211
- value: "",
11212
- disabled: false
11213
- });
11214
- }
11215
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11216
- KeyboundForm,
11217
- {
11218
- onSubmit: handleSubmit,
11219
- className: "flex flex-1 flex-col overflow-hidden",
11220
- children: [
11221
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
11222
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
11223
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
11224
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
11225
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
11226
- ] }),
11227
- fields.map((field, index) => {
11228
- const isDisabled = field.disabled || false;
11229
- let placeholder = "-";
11230
- if (typeof field.value === "object") {
11231
- placeholder = "{ ... }";
11232
- }
11233
- if (Array.isArray(field.value)) {
11234
- placeholder = "[ ... ]";
11235
- }
11236
- return /* @__PURE__ */ jsxRuntime.jsx(
11237
- ConditionalTooltip,
11238
- {
11239
- showTooltip: isDisabled,
11240
- content: "This row is disabled because it contains non-primitive data.",
11241
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
11242
- /* @__PURE__ */ jsxRuntime.jsxs(
11243
- "div",
11244
- {
11245
- className: ui.clx("grid grid-cols-2 divide-x", {
11246
- "overflow-hidden rounded-b-lg": index === fields.length - 1
11247
- }),
11248
- children: [
11249
- /* @__PURE__ */ jsxRuntime.jsx(
11250
- Form$2.Field,
11251
- {
11252
- control: form.control,
11253
- name: `metadata.${index}.key`,
11254
- render: ({ field: field2 }) => {
11255
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11256
- GridInput,
11257
- {
11258
- "aria-labelledby": METADATA_KEY_LABEL_ID,
11259
- ...field2,
11260
- disabled: isDisabled,
11261
- placeholder: "Key"
11262
- }
11263
- ) }) });
11264
- }
11265
- }
11266
- ),
11267
- /* @__PURE__ */ jsxRuntime.jsx(
11268
- Form$2.Field,
11269
- {
11270
- control: form.control,
11271
- name: `metadata.${index}.value`,
11272
- render: ({ field: { value, ...field2 } }) => {
11273
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11274
- GridInput,
11275
- {
11276
- "aria-labelledby": METADATA_VALUE_LABEL_ID,
11277
- ...field2,
11278
- value: isDisabled ? placeholder : value,
11279
- disabled: isDisabled,
11280
- placeholder: "Value"
11281
- }
11282
- ) }) });
11283
- }
11284
- }
11285
- )
11286
- ]
11287
- }
11288
- ),
11289
- /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
11290
- /* @__PURE__ */ jsxRuntime.jsx(
11291
- ui.DropdownMenu.Trigger,
11292
- {
11293
- className: ui.clx(
11294
- "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
11295
- {
11296
- hidden: isDisabled
11297
- }
11298
- ),
11299
- disabled: isDisabled,
11300
- asChild: true,
11301
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
11302
- }
11303
- ),
11304
- /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
11305
- /* @__PURE__ */ jsxRuntime.jsxs(
11306
- ui.DropdownMenu.Item,
11307
- {
11308
- className: "gap-x-2",
11309
- onClick: () => insertRow(index, "above"),
11310
- children: [
11311
- /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
11312
- "Insert row above"
11313
- ]
11314
- }
11315
- ),
11316
- /* @__PURE__ */ jsxRuntime.jsxs(
11317
- ui.DropdownMenu.Item,
11318
- {
11319
- className: "gap-x-2",
11320
- onClick: () => insertRow(index, "below"),
11321
- children: [
11322
- /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
11323
- "Insert row below"
11324
- ]
11325
- }
11326
- ),
11327
- /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
11328
- /* @__PURE__ */ jsxRuntime.jsxs(
11329
- ui.DropdownMenu.Item,
11330
- {
11331
- className: "gap-x-2",
11332
- onClick: () => deleteRow(index),
11333
- children: [
11334
- /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
11335
- "Delete row"
11336
- ]
11337
- }
11338
- )
11339
- ] })
11340
- ] })
11341
- ] })
11342
- },
11343
- field.id
11344
- );
11345
- })
11346
- ] }),
11347
- hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
11348
- ] }),
11349
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11350
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11351
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11352
- ] }) })
11353
- ]
11354
- }
11355
- ) });
11356
- };
11357
- const GridInput = React.forwardRef(({ className, ...props }, ref) => {
11358
- return /* @__PURE__ */ jsxRuntime.jsx(
11359
- "input",
11360
- {
11361
- ref,
11362
- ...props,
11363
- autoComplete: "off",
11364
- className: ui.clx(
11365
- "txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
11366
- className
11367
- )
11368
- }
11369
- );
11370
- });
11371
- GridInput.displayName = "MetadataForm.GridInput";
11372
- const PlaceholderInner = () => {
11373
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
11374
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
11375
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11376
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
11377
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
11378
- ] }) })
11379
- ] });
11380
- };
11381
- const EDITABLE_TYPES = ["string", "number", "boolean"];
11382
- function getDefaultValues(metadata) {
11383
- if (!metadata || !Object.keys(metadata).length) {
11384
- return [
11385
- {
11386
- key: "",
11387
- value: "",
11388
- disabled: false
11389
- }
11390
- ];
11391
- }
11392
- return Object.entries(metadata).map(([key, value]) => {
11393
- if (!EDITABLE_TYPES.includes(typeof value)) {
11394
- return {
11395
- key,
11396
- value,
11397
- disabled: true
11398
- };
11399
- }
11400
- let stringValue = value;
11401
- if (typeof value !== "string") {
11402
- stringValue = JSON.stringify(value);
11403
- }
11404
- return {
11405
- key,
11406
- value: stringValue,
11407
- original_key: key
11408
- };
11409
- });
11410
- }
11411
- function parseValues(values) {
11412
- const metadata = values.metadata;
11413
- const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
11414
- if (isEmpty) {
11415
- return null;
11416
- }
11417
- const update = {};
11418
- metadata.forEach((field) => {
11419
- let key = field.key;
11420
- let value = field.value;
11421
- const disabled = field.disabled;
11422
- if (!key || !value) {
11423
- return;
11424
- }
11425
- if (disabled) {
11426
- update[key] = value;
11427
- return;
11428
- }
11429
- key = key.trim();
11430
- value = value.trim();
11431
- if (value === "true") {
11432
- update[key] = true;
11433
- } else if (value === "false") {
11434
- update[key] = false;
11435
- } else {
11436
- const parsedNumber = parseFloat(value);
11437
- if (!isNaN(parsedNumber)) {
11438
- update[key] = parsedNumber;
11439
- } else {
11440
- update[key] = value;
11441
- }
11442
- }
11443
- });
11444
- return update;
11445
- }
11446
- function getHasUneditableRows(metadata) {
11447
- if (!metadata) {
11448
- return false;
11449
- }
11450
- return Object.values(metadata).some(
11451
- (value) => !EDITABLE_TYPES.includes(typeof value)
11452
- );
11453
- }
11454
- const SalesChannel = () => {
11455
- const { id } = reactRouterDom.useParams();
11456
- const { draft_order, isPending, isError, error } = useDraftOrder(
11457
- id,
11458
- {
11459
- fields: "+sales_channel_id"
11460
- },
11461
- {
11462
- enabled: !!id
11463
- }
11464
- );
11465
- if (isError) {
11466
- throw error;
11467
- }
11468
- const ISrEADY = !!draft_order && !isPending;
11469
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11470
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11471
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11472
- /* @__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" }) })
11473
- ] }),
11474
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11475
- ] });
11476
- };
11477
- const SalesChannelForm = ({ order }) => {
11478
- const form = reactHookForm.useForm({
11479
- defaultValues: {
11480
- sales_channel_id: order.sales_channel_id || ""
11481
- },
11482
- resolver: zod.zodResolver(schema$2)
11483
- });
11484
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
- const { handleSuccess } = useRouteModal();
11486
- const onSubmit = form.handleSubmit(async (data) => {
11487
- await mutateAsync(
11488
- {
11489
- sales_channel_id: data.sales_channel_id
11490
- },
11491
- {
11492
- onSuccess: () => {
11493
- ui.toast.success("Sales channel updated");
11494
- handleSuccess();
11495
- },
11496
- onError: (error) => {
11497
- ui.toast.error(error.message);
11498
- }
11499
- }
11500
- );
11501
- });
11502
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11503
- KeyboundForm,
11504
- {
11505
- className: "flex flex-1 flex-col overflow-hidden",
11506
- onSubmit,
11507
- children: [
11508
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11509
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11510
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11511
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11512
- ] }) })
11513
- ]
11514
- }
11515
- ) });
11516
- };
11517
- const SalesChannelField = ({ control, order }) => {
11518
- const salesChannels = useComboboxData({
11519
- queryFn: async (params) => {
11520
- return await sdk.admin.salesChannel.list(params);
11521
- },
11522
- queryKey: ["sales-channels"],
11523
- getOptions: (data) => {
11524
- return data.sales_channels.map((salesChannel) => ({
11525
- label: salesChannel.name,
11526
- value: salesChannel.id
11527
- }));
11528
- },
11529
- defaultValue: order.sales_channel_id || void 0
11530
- });
11531
- return /* @__PURE__ */ jsxRuntime.jsx(
11532
- Form$2.Field,
11533
- {
11534
- control,
11535
- name: "sales_channel_id",
11536
- render: ({ field }) => {
11537
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11538
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11539
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11540
- Combobox,
11541
- {
11542
- options: salesChannels.options,
11543
- fetchNextPage: salesChannels.fetchNextPage,
11544
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11545
- searchValue: salesChannels.searchValue,
11546
- onSearchValueChange: salesChannels.onSearchValueChange,
11547
- placeholder: "Select sales channel",
11548
- ...field
11549
- }
11550
- ) }),
11551
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11552
- ] });
11553
- }
11554
- }
11555
- );
11556
- };
11557
- const schema$2 = objectType({
11558
- sales_channel_id: stringType().min(1)
11559
- });
11560
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11561
- const Shipping = () => {
11562
- var _a;
11563
- const { id } = reactRouterDom.useParams();
11564
- const { order, isPending, isError, error } = useOrder(id, {
11565
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11566
- });
11567
- const {
11568
- order: preview,
11569
- isPending: isPreviewPending,
11570
- isError: isPreviewError,
11571
- error: previewError
11572
- } = useOrderPreview(id);
11573
- useInitiateOrderEdit({ preview });
11574
- const { onCancel } = useCancelOrderEdit({ preview });
11575
- if (isError) {
11576
- throw error;
11577
- }
11578
- if (isPreviewError) {
11579
- throw previewError;
11580
- }
11581
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11582
- const isReady = preview && !isPreviewPending && order && !isPending;
11583
- return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11584
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11585
- /* @__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: [
11586
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11587
- /* @__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." }) })
11588
- ] }) }) }),
11589
- /* @__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" }) }) })
11590
- ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11591
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11592
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11593
- ] }) });
11594
- };
11595
- const ShippingForm = ({ preview, order }) => {
11596
- var _a;
11597
- const { setIsOpen } = useStackedModal();
11598
- const [isSubmitting, setIsSubmitting] = React.useState(false);
11599
- const [data, setData] = React.useState(null);
11600
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11601
- const { shipping_options } = useShippingOptions(
11602
- {
11603
- id: appliedShippingOptionIds,
11604
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11245
+ const ShippingForm = ({ preview, order }) => {
11246
+ var _a;
11247
+ const { setIsOpen } = useStackedModal();
11248
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11249
+ const [data, setData] = React.useState(null);
11250
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11251
+ const { shipping_options } = useShippingOptions(
11252
+ {
11253
+ id: appliedShippingOptionIds,
11254
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11605
11255
  },
11606
11256
  {
11607
11257
  enabled: appliedShippingOptionIds.length > 0
@@ -13038,11 +12688,361 @@ const Illustration = () => {
13038
12688
  ] })
13039
12689
  ]
13040
12690
  }
13041
- );
12691
+ );
12692
+ };
12693
+ const schema = objectType({
12694
+ customer_id: stringType().min(1)
12695
+ });
12696
+ const InlineTip = React.forwardRef(
12697
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
12698
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
12699
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12700
+ "div",
12701
+ {
12702
+ ref,
12703
+ className: ui.clx(
12704
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
12705
+ className
12706
+ ),
12707
+ ...props,
12708
+ children: [
12709
+ /* @__PURE__ */ jsxRuntime.jsx(
12710
+ "div",
12711
+ {
12712
+ role: "presentation",
12713
+ className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
12714
+ "bg-ui-tag-orange-icon": variant === "warning"
12715
+ })
12716
+ }
12717
+ ),
12718
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
12719
+ /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
12720
+ labelValue,
12721
+ ":"
12722
+ ] }),
12723
+ " ",
12724
+ children
12725
+ ] })
12726
+ ]
12727
+ }
12728
+ );
12729
+ }
12730
+ );
12731
+ InlineTip.displayName = "InlineTip";
12732
+ const MetadataFieldSchema = objectType({
12733
+ key: stringType(),
12734
+ disabled: booleanType().optional(),
12735
+ value: anyType()
12736
+ });
12737
+ const MetadataSchema = objectType({
12738
+ metadata: arrayType(MetadataFieldSchema)
12739
+ });
12740
+ const Metadata = () => {
12741
+ const { id } = reactRouterDom.useParams();
12742
+ const { order, isPending, isError, error } = useOrder(id, {
12743
+ fields: "metadata"
12744
+ });
12745
+ if (isError) {
12746
+ throw error;
12747
+ }
12748
+ const isReady = !isPending && !!order;
12749
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12750
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12751
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
12752
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
12753
+ ] }),
12754
+ !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
12755
+ ] });
12756
+ };
12757
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
12758
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
12759
+ const MetadataForm = ({ orderId, metadata }) => {
12760
+ const { handleSuccess } = useRouteModal();
12761
+ const hasUneditableRows = getHasUneditableRows(metadata);
12762
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
12763
+ const form = reactHookForm.useForm({
12764
+ defaultValues: {
12765
+ metadata: getDefaultValues(metadata)
12766
+ },
12767
+ resolver: zod.zodResolver(MetadataSchema)
12768
+ });
12769
+ const handleSubmit = form.handleSubmit(async (data) => {
12770
+ const parsedData = parseValues(data);
12771
+ await mutateAsync(
12772
+ {
12773
+ metadata: parsedData
12774
+ },
12775
+ {
12776
+ onSuccess: () => {
12777
+ ui.toast.success("Metadata updated");
12778
+ handleSuccess();
12779
+ },
12780
+ onError: (error) => {
12781
+ ui.toast.error(error.message);
12782
+ }
12783
+ }
12784
+ );
12785
+ });
12786
+ const { fields, insert, remove } = reactHookForm.useFieldArray({
12787
+ control: form.control,
12788
+ name: "metadata"
12789
+ });
12790
+ function deleteRow(index) {
12791
+ remove(index);
12792
+ if (fields.length === 1) {
12793
+ insert(0, {
12794
+ key: "",
12795
+ value: "",
12796
+ disabled: false
12797
+ });
12798
+ }
12799
+ }
12800
+ function insertRow(index, position) {
12801
+ insert(index + (position === "above" ? 0 : 1), {
12802
+ key: "",
12803
+ value: "",
12804
+ disabled: false
12805
+ });
12806
+ }
12807
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12808
+ KeyboundForm,
12809
+ {
12810
+ onSubmit: handleSubmit,
12811
+ className: "flex flex-1 flex-col overflow-hidden",
12812
+ children: [
12813
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
12814
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
12815
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
12816
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
12817
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
12818
+ ] }),
12819
+ fields.map((field, index) => {
12820
+ const isDisabled = field.disabled || false;
12821
+ let placeholder = "-";
12822
+ if (typeof field.value === "object") {
12823
+ placeholder = "{ ... }";
12824
+ }
12825
+ if (Array.isArray(field.value)) {
12826
+ placeholder = "[ ... ]";
12827
+ }
12828
+ return /* @__PURE__ */ jsxRuntime.jsx(
12829
+ ConditionalTooltip,
12830
+ {
12831
+ showTooltip: isDisabled,
12832
+ content: "This row is disabled because it contains non-primitive data.",
12833
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
12834
+ /* @__PURE__ */ jsxRuntime.jsxs(
12835
+ "div",
12836
+ {
12837
+ className: ui.clx("grid grid-cols-2 divide-x", {
12838
+ "overflow-hidden rounded-b-lg": index === fields.length - 1
12839
+ }),
12840
+ children: [
12841
+ /* @__PURE__ */ jsxRuntime.jsx(
12842
+ Form$2.Field,
12843
+ {
12844
+ control: form.control,
12845
+ name: `metadata.${index}.key`,
12846
+ render: ({ field: field2 }) => {
12847
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12848
+ GridInput,
12849
+ {
12850
+ "aria-labelledby": METADATA_KEY_LABEL_ID,
12851
+ ...field2,
12852
+ disabled: isDisabled,
12853
+ placeholder: "Key"
12854
+ }
12855
+ ) }) });
12856
+ }
12857
+ }
12858
+ ),
12859
+ /* @__PURE__ */ jsxRuntime.jsx(
12860
+ Form$2.Field,
12861
+ {
12862
+ control: form.control,
12863
+ name: `metadata.${index}.value`,
12864
+ render: ({ field: { value, ...field2 } }) => {
12865
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12866
+ GridInput,
12867
+ {
12868
+ "aria-labelledby": METADATA_VALUE_LABEL_ID,
12869
+ ...field2,
12870
+ value: isDisabled ? placeholder : value,
12871
+ disabled: isDisabled,
12872
+ placeholder: "Value"
12873
+ }
12874
+ ) }) });
12875
+ }
12876
+ }
12877
+ )
12878
+ ]
12879
+ }
12880
+ ),
12881
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
12882
+ /* @__PURE__ */ jsxRuntime.jsx(
12883
+ ui.DropdownMenu.Trigger,
12884
+ {
12885
+ className: ui.clx(
12886
+ "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
12887
+ {
12888
+ hidden: isDisabled
12889
+ }
12890
+ ),
12891
+ disabled: isDisabled,
12892
+ asChild: true,
12893
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
12894
+ }
12895
+ ),
12896
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
12897
+ /* @__PURE__ */ jsxRuntime.jsxs(
12898
+ ui.DropdownMenu.Item,
12899
+ {
12900
+ className: "gap-x-2",
12901
+ onClick: () => insertRow(index, "above"),
12902
+ children: [
12903
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
12904
+ "Insert row above"
12905
+ ]
12906
+ }
12907
+ ),
12908
+ /* @__PURE__ */ jsxRuntime.jsxs(
12909
+ ui.DropdownMenu.Item,
12910
+ {
12911
+ className: "gap-x-2",
12912
+ onClick: () => insertRow(index, "below"),
12913
+ children: [
12914
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
12915
+ "Insert row below"
12916
+ ]
12917
+ }
12918
+ ),
12919
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
12920
+ /* @__PURE__ */ jsxRuntime.jsxs(
12921
+ ui.DropdownMenu.Item,
12922
+ {
12923
+ className: "gap-x-2",
12924
+ onClick: () => deleteRow(index),
12925
+ children: [
12926
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
12927
+ "Delete row"
12928
+ ]
12929
+ }
12930
+ )
12931
+ ] })
12932
+ ] })
12933
+ ] })
12934
+ },
12935
+ field.id
12936
+ );
12937
+ })
12938
+ ] }),
12939
+ hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
12940
+ ] }),
12941
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12942
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12943
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12944
+ ] }) })
12945
+ ]
12946
+ }
12947
+ ) });
13042
12948
  };
13043
- const schema = objectType({
13044
- customer_id: stringType().min(1)
12949
+ const GridInput = React.forwardRef(({ className, ...props }, ref) => {
12950
+ return /* @__PURE__ */ jsxRuntime.jsx(
12951
+ "input",
12952
+ {
12953
+ ref,
12954
+ ...props,
12955
+ autoComplete: "off",
12956
+ className: ui.clx(
12957
+ "txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
12958
+ className
12959
+ )
12960
+ }
12961
+ );
13045
12962
  });
12963
+ GridInput.displayName = "MetadataForm.GridInput";
12964
+ const PlaceholderInner = () => {
12965
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
12966
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
12967
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12968
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
12969
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
12970
+ ] }) })
12971
+ ] });
12972
+ };
12973
+ const EDITABLE_TYPES = ["string", "number", "boolean"];
12974
+ function getDefaultValues(metadata) {
12975
+ if (!metadata || !Object.keys(metadata).length) {
12976
+ return [
12977
+ {
12978
+ key: "",
12979
+ value: "",
12980
+ disabled: false
12981
+ }
12982
+ ];
12983
+ }
12984
+ return Object.entries(metadata).map(([key, value]) => {
12985
+ if (!EDITABLE_TYPES.includes(typeof value)) {
12986
+ return {
12987
+ key,
12988
+ value,
12989
+ disabled: true
12990
+ };
12991
+ }
12992
+ let stringValue = value;
12993
+ if (typeof value !== "string") {
12994
+ stringValue = JSON.stringify(value);
12995
+ }
12996
+ return {
12997
+ key,
12998
+ value: stringValue,
12999
+ original_key: key
13000
+ };
13001
+ });
13002
+ }
13003
+ function parseValues(values) {
13004
+ const metadata = values.metadata;
13005
+ const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
13006
+ if (isEmpty) {
13007
+ return null;
13008
+ }
13009
+ const update = {};
13010
+ metadata.forEach((field) => {
13011
+ let key = field.key;
13012
+ let value = field.value;
13013
+ const disabled = field.disabled;
13014
+ if (!key || !value) {
13015
+ return;
13016
+ }
13017
+ if (disabled) {
13018
+ update[key] = value;
13019
+ return;
13020
+ }
13021
+ key = key.trim();
13022
+ value = value.trim();
13023
+ if (value === "true") {
13024
+ update[key] = true;
13025
+ } else if (value === "false") {
13026
+ update[key] = false;
13027
+ } else {
13028
+ const parsedNumber = parseFloat(value);
13029
+ if (!isNaN(parsedNumber)) {
13030
+ update[key] = parsedNumber;
13031
+ } else {
13032
+ update[key] = value;
13033
+ }
13034
+ }
13035
+ });
13036
+ return update;
13037
+ }
13038
+ function getHasUneditableRows(metadata) {
13039
+ if (!metadata) {
13040
+ return false;
13041
+ }
13042
+ return Object.values(metadata).some(
13043
+ (value) => !EDITABLE_TYPES.includes(typeof value)
13044
+ );
13045
+ }
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
13048
13048
  routes: [
@@ -13063,34 +13063,30 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
- {
13067
- Component: BillingAddress,
13068
- path: "/draft-orders/:id/billing-address"
13069
- },
13070
13066
  {
13071
13067
  Component: CustomItems,
13072
13068
  path: "/draft-orders/:id/custom-items"
13073
13069
  },
13074
13070
  {
13075
- Component: Email,
13076
- path: "/draft-orders/:id/email"
13071
+ Component: BillingAddress,
13072
+ path: "/draft-orders/:id/billing-address"
13077
13073
  },
13078
13074
  {
13079
13075
  Component: Items,
13080
13076
  path: "/draft-orders/:id/items"
13081
13077
  },
13082
13078
  {
13083
- Component: Promotions,
13084
- path: "/draft-orders/:id/promotions"
13085
- },
13086
- {
13087
- Component: Metadata,
13088
- path: "/draft-orders/:id/metadata"
13079
+ Component: Email,
13080
+ path: "/draft-orders/:id/email"
13089
13081
  },
13090
13082
  {
13091
13083
  Component: SalesChannel,
13092
13084
  path: "/draft-orders/:id/sales-channel"
13093
13085
  },
13086
+ {
13087
+ Component: Promotions,
13088
+ path: "/draft-orders/:id/promotions"
13089
+ },
13094
13090
  {
13095
13091
  Component: Shipping,
13096
13092
  path: "/draft-orders/:id/shipping"
@@ -13102,6 +13098,10 @@ const routeModule = {
13102
13098
  {
13103
13099
  Component: TransferOwnership,
13104
13100
  path: "/draft-orders/:id/transfer-ownership"
13101
+ },
13102
+ {
13103
+ Component: Metadata,
13104
+ path: "/draft-orders/:id/metadata"
13105
13105
  }
13106
13106
  ]
13107
13107
  }