@medusajs/draft-order 2.10.0-snapshot-20250828112445 → 2.10.0-snapshot-20250828113245

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.
@@ -4,7 +4,7 @@ import { Tooltip, DropdownMenu, clx, IconButton, useDataTable, DataTable as Data
4
4
  import { useQuery, useQueryClient, useMutation, keepPreviousData, useInfiniteQuery } from "@tanstack/react-query";
5
5
  import React, { useState, useCallback, useMemo, Fragment, createContext, forwardRef, useId, useContext, useTransition, useRef, useImperativeHandle, useDeferredValue, useEffect, Suspense } from "react";
6
6
  import { useSearchParams, Link, useNavigate, Outlet, useBlocker, useLocation, useParams } from "react-router-dom";
7
- import { EllipsisHorizontal, XMark, InformationCircleSolid, XMarkMini, TrianglesMini, CheckMini, EllipseMiniSolid, PlusMini, ExclamationCircleSolid, ArrowPath, FlyingBox, CurrencyDollar, Envelope, Channels, Trash, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Photo, TriangleRightMini, Shopping, Buildings, TruckFast, Plus, ReceiptPercent, EllipsisVertical, ArrowUpMini, ArrowDownMini, Minus, PencilSquare } from "@medusajs/icons";
7
+ import { EllipsisHorizontal, XMark, InformationCircleSolid, XMarkMini, TrianglesMini, CheckMini, EllipseMiniSolid, PlusMini, ExclamationCircleSolid, ArrowPath, FlyingBox, CurrencyDollar, Envelope, Channels, Trash, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Photo, TriangleRightMini, Shopping, Buildings, TruckFast, Plus, ReceiptPercent, Minus, PencilSquare, EllipsisVertical, ArrowUpMini, ArrowDownMini } from "@medusajs/icons";
8
8
  import Medusa from "@medusajs/js-sdk";
9
9
  import { format, formatDistance, sub, subDays, subMonths } from "date-fns";
10
10
  import { enUS } from "date-fns/locale";
@@ -9744,75 +9744,10 @@ const BillingAddressForm = ({ order }) => {
9744
9744
  ) });
9745
9745
  };
9746
9746
  const schema$5 = addressSchema;
9747
- const CustomItems = () => {
9748
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9749
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9750
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9751
- ] });
9752
- };
9753
- const CustomItemsForm = () => {
9754
- const form = useForm({
9755
- resolver: zodResolver(schema$4)
9756
- });
9757
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9758
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9759
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9760
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9761
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9762
- ] }) })
9763
- ] }) });
9764
- };
9765
- const schema$4 = objectType({
9766
- email: stringType().email()
9767
- });
9768
- const InlineTip = forwardRef(
9769
- ({ variant = "tip", label, className, children, ...props }, ref) => {
9770
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
9771
- return /* @__PURE__ */ jsxs(
9772
- "div",
9773
- {
9774
- ref,
9775
- className: clx(
9776
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
9777
- className
9778
- ),
9779
- ...props,
9780
- children: [
9781
- /* @__PURE__ */ jsx(
9782
- "div",
9783
- {
9784
- role: "presentation",
9785
- className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
9786
- "bg-ui-tag-orange-icon": variant === "warning"
9787
- })
9788
- }
9789
- ),
9790
- /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
9791
- /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
9792
- labelValue,
9793
- ":"
9794
- ] }),
9795
- " ",
9796
- children
9797
- ] })
9798
- ]
9799
- }
9800
- );
9801
- }
9802
- );
9803
- InlineTip.displayName = "InlineTip";
9804
- const MetadataFieldSchema = objectType({
9805
- key: stringType(),
9806
- disabled: booleanType().optional(),
9807
- value: anyType()
9808
- });
9809
- const MetadataSchema = objectType({
9810
- metadata: arrayType(MetadataFieldSchema)
9811
- });
9812
- const Metadata = () => {
9747
+ const Email = () => {
9813
9748
  const { id } = useParams();
9814
9749
  const { order, isPending, isError, error } = useOrder(id, {
9815
- fields: "metadata"
9750
+ fields: "+email"
9816
9751
  });
9817
9752
  if (isError) {
9818
9753
  throw error;
@@ -9820,33 +9755,26 @@ const Metadata = () => {
9820
9755
  const isReady = !isPending && !!order;
9821
9756
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9822
9757
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9823
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
9824
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
9758
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9759
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9825
9760
  ] }),
9826
- !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
9761
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9827
9762
  ] });
9828
9763
  };
9829
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
9830
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
9831
- const MetadataForm = ({ orderId, metadata }) => {
9832
- const { handleSuccess } = useRouteModal();
9833
- const hasUneditableRows = getHasUneditableRows(metadata);
9834
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
9764
+ const EmailForm = ({ order }) => {
9835
9765
  const form = useForm({
9836
9766
  defaultValues: {
9837
- metadata: getDefaultValues(metadata)
9767
+ email: order.email ?? ""
9838
9768
  },
9839
- resolver: zodResolver(MetadataSchema)
9769
+ resolver: zodResolver(schema$4)
9840
9770
  });
9841
- const handleSubmit = form.handleSubmit(async (data) => {
9842
- const parsedData = parseValues(data);
9771
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9772
+ const { handleSuccess } = useRouteModal();
9773
+ const onSubmit = form.handleSubmit(async (data) => {
9843
9774
  await mutateAsync(
9844
- {
9845
- metadata: parsedData
9846
- },
9775
+ { email: data.email },
9847
9776
  {
9848
9777
  onSuccess: () => {
9849
- toast.success("Metadata updated");
9850
9778
  handleSuccess();
9851
9779
  },
9852
9780
  onError: (error) => {
@@ -9855,347 +9783,116 @@ const MetadataForm = ({ orderId, metadata }) => {
9855
9783
  }
9856
9784
  );
9857
9785
  });
9858
- const { fields, insert, remove } = useFieldArray({
9859
- control: form.control,
9860
- name: "metadata"
9861
- });
9862
- function deleteRow(index) {
9863
- remove(index);
9864
- if (fields.length === 1) {
9865
- insert(0, {
9866
- key: "",
9867
- value: "",
9868
- disabled: false
9869
- });
9870
- }
9871
- }
9872
- function insertRow(index, position) {
9873
- insert(index + (position === "above" ? 0 : 1), {
9874
- key: "",
9875
- value: "",
9876
- disabled: false
9877
- });
9878
- }
9879
9786
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9880
9787
  KeyboundForm,
9881
9788
  {
9882
- onSubmit: handleSubmit,
9883
9789
  className: "flex flex-1 flex-col overflow-hidden",
9790
+ onSubmit,
9884
9791
  children: [
9885
- /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
9886
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
9887
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
9888
- /* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
9889
- /* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
9890
- ] }),
9891
- fields.map((field, index) => {
9892
- const isDisabled = field.disabled || false;
9893
- let placeholder = "-";
9894
- if (typeof field.value === "object") {
9895
- placeholder = "{ ... }";
9896
- }
9897
- if (Array.isArray(field.value)) {
9898
- placeholder = "[ ... ]";
9899
- }
9900
- return /* @__PURE__ */ jsx(
9901
- ConditionalTooltip,
9792
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9793
+ Form$2.Field,
9794
+ {
9795
+ control: form.control,
9796
+ name: "email",
9797
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9798
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9799
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9800
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9801
+ ] })
9802
+ }
9803
+ ) }),
9804
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9805
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9806
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9807
+ ] }) })
9808
+ ]
9809
+ }
9810
+ ) });
9811
+ };
9812
+ const schema$4 = objectType({
9813
+ email: stringType().email()
9814
+ });
9815
+ const NumberInput = forwardRef(
9816
+ ({
9817
+ value,
9818
+ onChange,
9819
+ size = "base",
9820
+ min = 0,
9821
+ max = 100,
9822
+ step = 1,
9823
+ className,
9824
+ disabled,
9825
+ ...props
9826
+ }, ref) => {
9827
+ const handleChange = (event) => {
9828
+ const newValue = event.target.value === "" ? min : Number(event.target.value);
9829
+ if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
9830
+ onChange(newValue);
9831
+ }
9832
+ };
9833
+ const handleIncrement = () => {
9834
+ const newValue = value + step;
9835
+ if (max === void 0 || newValue <= max) {
9836
+ onChange(newValue);
9837
+ }
9838
+ };
9839
+ const handleDecrement = () => {
9840
+ const newValue = value - step;
9841
+ if (min === void 0 || newValue >= min) {
9842
+ onChange(newValue);
9843
+ }
9844
+ };
9845
+ return /* @__PURE__ */ jsxs(
9846
+ "div",
9847
+ {
9848
+ className: clx(
9849
+ "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
9850
+ "[&:has(input:focus)]:shadow-borders-interactive-with-active",
9851
+ {
9852
+ "h-7": size === "small",
9853
+ "h-8": size === "base"
9854
+ },
9855
+ className
9856
+ ),
9857
+ children: [
9858
+ /* @__PURE__ */ jsx(
9859
+ "input",
9860
+ {
9861
+ ref,
9862
+ type: "number",
9863
+ value,
9864
+ onChange: handleChange,
9865
+ min,
9866
+ max,
9867
+ step,
9868
+ className: clx(
9869
+ "flex-1 px-2 py-1 bg-transparent txt-compact-small text-ui-fg-base outline-none [appearance:textfield]",
9870
+ "[&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
9871
+ "placeholder:text-ui-fg-muted"
9872
+ ),
9873
+ ...props
9874
+ }
9875
+ ),
9876
+ /* @__PURE__ */ jsxs(
9877
+ "button",
9878
+ {
9879
+ className: clx(
9880
+ "flex items-center justify-center outline-none transition-fg",
9881
+ "disabled:cursor-not-allowed disabled:text-ui-fg-muted",
9882
+ "focus:bg-ui-bg-field-component-hover",
9883
+ "hover:bg-ui-bg-field-component-hover",
9902
9884
  {
9903
- showTooltip: isDisabled,
9904
- content: "This row is disabled because it contains non-primitive data.",
9905
- children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
9906
- /* @__PURE__ */ jsxs(
9907
- "div",
9908
- {
9909
- className: clx("grid grid-cols-2 divide-x", {
9910
- "overflow-hidden rounded-b-lg": index === fields.length - 1
9911
- }),
9912
- children: [
9913
- /* @__PURE__ */ jsx(
9914
- Form$2.Field,
9915
- {
9916
- control: form.control,
9917
- name: `metadata.${index}.key`,
9918
- render: ({ field: field2 }) => {
9919
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
9920
- GridInput,
9921
- {
9922
- "aria-labelledby": METADATA_KEY_LABEL_ID,
9923
- ...field2,
9924
- disabled: isDisabled,
9925
- placeholder: "Key"
9926
- }
9927
- ) }) });
9928
- }
9929
- }
9930
- ),
9931
- /* @__PURE__ */ jsx(
9932
- Form$2.Field,
9933
- {
9934
- control: form.control,
9935
- name: `metadata.${index}.value`,
9936
- render: ({ field: { value, ...field2 } }) => {
9937
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
9938
- GridInput,
9939
- {
9940
- "aria-labelledby": METADATA_VALUE_LABEL_ID,
9941
- ...field2,
9942
- value: isDisabled ? placeholder : value,
9943
- disabled: isDisabled,
9944
- placeholder: "Value"
9945
- }
9946
- ) }) });
9947
- }
9948
- }
9949
- )
9950
- ]
9951
- }
9952
- ),
9953
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [
9954
- /* @__PURE__ */ jsx(
9955
- DropdownMenu.Trigger,
9956
- {
9957
- className: clx(
9958
- "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
9959
- {
9960
- hidden: isDisabled
9961
- }
9962
- ),
9963
- disabled: isDisabled,
9964
- asChild: true,
9965
- children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
9966
- }
9967
- ),
9968
- /* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
9969
- /* @__PURE__ */ jsxs(
9970
- DropdownMenu.Item,
9971
- {
9972
- className: "gap-x-2",
9973
- onClick: () => insertRow(index, "above"),
9974
- children: [
9975
- /* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
9976
- "Insert row above"
9977
- ]
9978
- }
9979
- ),
9980
- /* @__PURE__ */ jsxs(
9981
- DropdownMenu.Item,
9982
- {
9983
- className: "gap-x-2",
9984
- onClick: () => insertRow(index, "below"),
9985
- children: [
9986
- /* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
9987
- "Insert row below"
9988
- ]
9989
- }
9990
- ),
9991
- /* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
9992
- /* @__PURE__ */ jsxs(
9993
- DropdownMenu.Item,
9994
- {
9995
- className: "gap-x-2",
9996
- onClick: () => deleteRow(index),
9997
- children: [
9998
- /* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
9999
- "Delete row"
10000
- ]
10001
- }
10002
- )
10003
- ] })
10004
- ] })
10005
- ] })
10006
- },
10007
- field.id
10008
- );
10009
- })
10010
- ] }),
10011
- hasUneditableRows && /* @__PURE__ */ 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." })
10012
- ] }),
10013
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10014
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10015
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10016
- ] }) })
10017
- ]
10018
- }
10019
- ) });
10020
- };
10021
- const GridInput = forwardRef(({ className, ...props }, ref) => {
10022
- return /* @__PURE__ */ jsx(
10023
- "input",
10024
- {
10025
- ref,
10026
- ...props,
10027
- autoComplete: "off",
10028
- className: clx(
10029
- "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",
10030
- className
10031
- )
10032
- }
10033
- );
10034
- });
10035
- GridInput.displayName = "MetadataForm.GridInput";
10036
- const PlaceholderInner = () => {
10037
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
10038
- /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
10039
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10040
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
10041
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
10042
- ] }) })
10043
- ] });
10044
- };
10045
- const EDITABLE_TYPES = ["string", "number", "boolean"];
10046
- function getDefaultValues(metadata) {
10047
- if (!metadata || !Object.keys(metadata).length) {
10048
- return [
10049
- {
10050
- key: "",
10051
- value: "",
10052
- disabled: false
10053
- }
10054
- ];
10055
- }
10056
- return Object.entries(metadata).map(([key, value]) => {
10057
- if (!EDITABLE_TYPES.includes(typeof value)) {
10058
- return {
10059
- key,
10060
- value,
10061
- disabled: true
10062
- };
10063
- }
10064
- let stringValue = value;
10065
- if (typeof value !== "string") {
10066
- stringValue = JSON.stringify(value);
10067
- }
10068
- return {
10069
- key,
10070
- value: stringValue,
10071
- original_key: key
10072
- };
10073
- });
10074
- }
10075
- function parseValues(values) {
10076
- const metadata = values.metadata;
10077
- const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
10078
- if (isEmpty) {
10079
- return null;
10080
- }
10081
- const update = {};
10082
- metadata.forEach((field) => {
10083
- let key = field.key;
10084
- let value = field.value;
10085
- const disabled = field.disabled;
10086
- if (!key || !value) {
10087
- return;
10088
- }
10089
- if (disabled) {
10090
- update[key] = value;
10091
- return;
10092
- }
10093
- key = key.trim();
10094
- value = value.trim();
10095
- if (value === "true") {
10096
- update[key] = true;
10097
- } else if (value === "false") {
10098
- update[key] = false;
10099
- } else {
10100
- const parsedNumber = parseFloat(value);
10101
- if (!isNaN(parsedNumber)) {
10102
- update[key] = parsedNumber;
10103
- } else {
10104
- update[key] = value;
10105
- }
10106
- }
10107
- });
10108
- return update;
10109
- }
10110
- function getHasUneditableRows(metadata) {
10111
- if (!metadata) {
10112
- return false;
10113
- }
10114
- return Object.values(metadata).some(
10115
- (value) => !EDITABLE_TYPES.includes(typeof value)
10116
- );
10117
- }
10118
- const NumberInput = forwardRef(
10119
- ({
10120
- value,
10121
- onChange,
10122
- size = "base",
10123
- min = 0,
10124
- max = 100,
10125
- step = 1,
10126
- className,
10127
- disabled,
10128
- ...props
10129
- }, ref) => {
10130
- const handleChange = (event) => {
10131
- const newValue = event.target.value === "" ? min : Number(event.target.value);
10132
- if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
10133
- onChange(newValue);
10134
- }
10135
- };
10136
- const handleIncrement = () => {
10137
- const newValue = value + step;
10138
- if (max === void 0 || newValue <= max) {
10139
- onChange(newValue);
10140
- }
10141
- };
10142
- const handleDecrement = () => {
10143
- const newValue = value - step;
10144
- if (min === void 0 || newValue >= min) {
10145
- onChange(newValue);
10146
- }
10147
- };
10148
- return /* @__PURE__ */ jsxs(
10149
- "div",
10150
- {
10151
- className: clx(
10152
- "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
10153
- "[&:has(input:focus)]:shadow-borders-interactive-with-active",
10154
- {
10155
- "h-7": size === "small",
10156
- "h-8": size === "base"
10157
- },
10158
- className
10159
- ),
10160
- children: [
10161
- /* @__PURE__ */ jsx(
10162
- "input",
10163
- {
10164
- ref,
10165
- type: "number",
10166
- value,
10167
- onChange: handleChange,
10168
- min,
10169
- max,
10170
- step,
10171
- className: clx(
10172
- "flex-1 px-2 py-1 bg-transparent txt-compact-small text-ui-fg-base outline-none [appearance:textfield]",
10173
- "[&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
10174
- "placeholder:text-ui-fg-muted"
9885
+ "size-7": size === "small",
9886
+ "size-8": size === "base"
9887
+ }
10175
9888
  ),
10176
- ...props
10177
- }
10178
- ),
10179
- /* @__PURE__ */ jsxs(
10180
- "button",
10181
- {
10182
- className: clx(
10183
- "flex items-center justify-center outline-none transition-fg",
10184
- "disabled:cursor-not-allowed disabled:text-ui-fg-muted",
10185
- "focus:bg-ui-bg-field-component-hover",
10186
- "hover:bg-ui-bg-field-component-hover",
10187
- {
10188
- "size-7": size === "small",
10189
- "size-8": size === "base"
10190
- }
10191
- ),
10192
- type: "button",
10193
- onClick: handleDecrement,
10194
- disabled: min !== void 0 && value <= min || disabled,
10195
- children: [
10196
- /* @__PURE__ */ jsx(Minus, {}),
10197
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: `Decrease by ${step}` })
10198
- ]
9889
+ type: "button",
9890
+ onClick: handleDecrement,
9891
+ disabled: min !== void 0 && value <= min || disabled,
9892
+ children: [
9893
+ /* @__PURE__ */ jsx(Minus, {}),
9894
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: `Decrease by ${step}` })
9895
+ ]
10199
9896
  }
10200
9897
  ),
10201
9898
  /* @__PURE__ */ jsxs(
@@ -10976,119 +10673,469 @@ const useColumns = () => {
10976
10673
  ];
10977
10674
  }, []);
10978
10675
  };
10979
- const CustomItemForm = ({ orderId, currencyCode }) => {
10980
- const { setIsOpen } = useStackedModal();
10981
- const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
10982
- const form = useForm({
10983
- defaultValues: {
10984
- title: "",
10985
- quantity: 1,
10986
- unit_price: ""
10987
- },
10988
- resolver: zodResolver(customItemSchema)
10989
- });
10990
- const onSubmit = form.handleSubmit(async (data) => {
10991
- await addItems(
10992
- {
10993
- items: [
10994
- {
10995
- title: data.title,
10996
- quantity: data.quantity,
10997
- unit_price: convertNumber(data.unit_price)
10998
- }
10999
- ]
11000
- },
10676
+ const CustomItemForm = ({ orderId, currencyCode }) => {
10677
+ const { setIsOpen } = useStackedModal();
10678
+ const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
10679
+ const form = useForm({
10680
+ defaultValues: {
10681
+ title: "",
10682
+ quantity: 1,
10683
+ unit_price: ""
10684
+ },
10685
+ resolver: zodResolver(customItemSchema)
10686
+ });
10687
+ const onSubmit = form.handleSubmit(async (data) => {
10688
+ await addItems(
10689
+ {
10690
+ items: [
10691
+ {
10692
+ title: data.title,
10693
+ quantity: data.quantity,
10694
+ unit_price: convertNumber(data.unit_price)
10695
+ }
10696
+ ]
10697
+ },
10698
+ {
10699
+ onSuccess: () => {
10700
+ setIsOpen(STACKED_MODAL_ID, false);
10701
+ },
10702
+ onError: (e) => {
10703
+ toast.error(e.message);
10704
+ }
10705
+ }
10706
+ );
10707
+ });
10708
+ return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxs(StackedFocusModal.Content, { children: [
10709
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
10710
+ /* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
10711
+ /* @__PURE__ */ jsxs("div", { children: [
10712
+ /* @__PURE__ */ jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Add custom item" }) }),
10713
+ /* @__PURE__ */ jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
10714
+ ] }),
10715
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
10716
+ /* @__PURE__ */ jsx(
10717
+ Form$2.Field,
10718
+ {
10719
+ control: form.control,
10720
+ name: "title",
10721
+ render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10722
+ /* @__PURE__ */ jsxs("div", { children: [
10723
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
10724
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the title of the item" })
10725
+ ] }),
10726
+ /* @__PURE__ */ jsxs("div", { children: [
10727
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10728
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10729
+ ] })
10730
+ ] }) })
10731
+ }
10732
+ ),
10733
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
10734
+ /* @__PURE__ */ jsx(
10735
+ Form$2.Field,
10736
+ {
10737
+ control: form.control,
10738
+ name: "unit_price",
10739
+ render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10740
+ /* @__PURE__ */ jsxs("div", { children: [
10741
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Unit price" }),
10742
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
10743
+ ] }),
10744
+ /* @__PURE__ */ jsxs("div", { children: [
10745
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
10746
+ CurrencyInput,
10747
+ {
10748
+ symbol: getNativeSymbol(currencyCode),
10749
+ code: currencyCode,
10750
+ onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
10751
+ ...field
10752
+ }
10753
+ ) }),
10754
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10755
+ ] })
10756
+ ] }) })
10757
+ }
10758
+ ),
10759
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
10760
+ /* @__PURE__ */ jsx(
10761
+ Form$2.Field,
10762
+ {
10763
+ control: form.control,
10764
+ name: "quantity",
10765
+ render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10766
+ /* @__PURE__ */ jsxs("div", { children: [
10767
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
10768
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10769
+ ] }),
10770
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 w-full", children: [
10771
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10772
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10773
+ ] })
10774
+ ] }) })
10775
+ }
10776
+ )
10777
+ ] }) }) }),
10778
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10779
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10780
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10781
+ ] }) })
10782
+ ] }) }) });
10783
+ };
10784
+ const customItemSchema = objectType({
10785
+ title: stringType().min(1),
10786
+ quantity: numberType(),
10787
+ unit_price: unionType([numberType(), stringType()])
10788
+ });
10789
+ const InlineTip = forwardRef(
10790
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
10791
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10792
+ return /* @__PURE__ */ jsxs(
10793
+ "div",
10794
+ {
10795
+ ref,
10796
+ className: clx(
10797
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10798
+ className
10799
+ ),
10800
+ ...props,
10801
+ children: [
10802
+ /* @__PURE__ */ jsx(
10803
+ "div",
10804
+ {
10805
+ role: "presentation",
10806
+ className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10807
+ "bg-ui-tag-orange-icon": variant === "warning"
10808
+ })
10809
+ }
10810
+ ),
10811
+ /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
10812
+ /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10813
+ labelValue,
10814
+ ":"
10815
+ ] }),
10816
+ " ",
10817
+ children
10818
+ ] })
10819
+ ]
10820
+ }
10821
+ );
10822
+ }
10823
+ );
10824
+ InlineTip.displayName = "InlineTip";
10825
+ const MetadataFieldSchema = objectType({
10826
+ key: stringType(),
10827
+ disabled: booleanType().optional(),
10828
+ value: anyType()
10829
+ });
10830
+ const MetadataSchema = objectType({
10831
+ metadata: arrayType(MetadataFieldSchema)
10832
+ });
10833
+ const Metadata = () => {
10834
+ const { id } = useParams();
10835
+ const { order, isPending, isError, error } = useOrder(id, {
10836
+ fields: "metadata"
10837
+ });
10838
+ if (isError) {
10839
+ throw error;
10840
+ }
10841
+ const isReady = !isPending && !!order;
10842
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10843
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10844
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
10845
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10846
+ ] }),
10847
+ !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10848
+ ] });
10849
+ };
10850
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10851
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10852
+ const MetadataForm = ({ orderId, metadata }) => {
10853
+ const { handleSuccess } = useRouteModal();
10854
+ const hasUneditableRows = getHasUneditableRows(metadata);
10855
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10856
+ const form = useForm({
10857
+ defaultValues: {
10858
+ metadata: getDefaultValues(metadata)
10859
+ },
10860
+ resolver: zodResolver(MetadataSchema)
10861
+ });
10862
+ const handleSubmit = form.handleSubmit(async (data) => {
10863
+ const parsedData = parseValues(data);
10864
+ await mutateAsync(
10865
+ {
10866
+ metadata: parsedData
10867
+ },
10868
+ {
10869
+ onSuccess: () => {
10870
+ toast.success("Metadata updated");
10871
+ handleSuccess();
10872
+ },
10873
+ onError: (error) => {
10874
+ toast.error(error.message);
10875
+ }
10876
+ }
10877
+ );
10878
+ });
10879
+ const { fields, insert, remove } = useFieldArray({
10880
+ control: form.control,
10881
+ name: "metadata"
10882
+ });
10883
+ function deleteRow(index) {
10884
+ remove(index);
10885
+ if (fields.length === 1) {
10886
+ insert(0, {
10887
+ key: "",
10888
+ value: "",
10889
+ disabled: false
10890
+ });
10891
+ }
10892
+ }
10893
+ function insertRow(index, position) {
10894
+ insert(index + (position === "above" ? 0 : 1), {
10895
+ key: "",
10896
+ value: "",
10897
+ disabled: false
10898
+ });
10899
+ }
10900
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10901
+ KeyboundForm,
10902
+ {
10903
+ onSubmit: handleSubmit,
10904
+ className: "flex flex-1 flex-col overflow-hidden",
10905
+ children: [
10906
+ /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
10907
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
10908
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
10909
+ /* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
10910
+ /* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
10911
+ ] }),
10912
+ fields.map((field, index) => {
10913
+ const isDisabled = field.disabled || false;
10914
+ let placeholder = "-";
10915
+ if (typeof field.value === "object") {
10916
+ placeholder = "{ ... }";
10917
+ }
10918
+ if (Array.isArray(field.value)) {
10919
+ placeholder = "[ ... ]";
10920
+ }
10921
+ return /* @__PURE__ */ jsx(
10922
+ ConditionalTooltip,
10923
+ {
10924
+ showTooltip: isDisabled,
10925
+ content: "This row is disabled because it contains non-primitive data.",
10926
+ children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
10927
+ /* @__PURE__ */ jsxs(
10928
+ "div",
10929
+ {
10930
+ className: clx("grid grid-cols-2 divide-x", {
10931
+ "overflow-hidden rounded-b-lg": index === fields.length - 1
10932
+ }),
10933
+ children: [
10934
+ /* @__PURE__ */ jsx(
10935
+ Form$2.Field,
10936
+ {
10937
+ control: form.control,
10938
+ name: `metadata.${index}.key`,
10939
+ render: ({ field: field2 }) => {
10940
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
10941
+ GridInput,
10942
+ {
10943
+ "aria-labelledby": METADATA_KEY_LABEL_ID,
10944
+ ...field2,
10945
+ disabled: isDisabled,
10946
+ placeholder: "Key"
10947
+ }
10948
+ ) }) });
10949
+ }
10950
+ }
10951
+ ),
10952
+ /* @__PURE__ */ jsx(
10953
+ Form$2.Field,
10954
+ {
10955
+ control: form.control,
10956
+ name: `metadata.${index}.value`,
10957
+ render: ({ field: { value, ...field2 } }) => {
10958
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
10959
+ GridInput,
10960
+ {
10961
+ "aria-labelledby": METADATA_VALUE_LABEL_ID,
10962
+ ...field2,
10963
+ value: isDisabled ? placeholder : value,
10964
+ disabled: isDisabled,
10965
+ placeholder: "Value"
10966
+ }
10967
+ ) }) });
10968
+ }
10969
+ }
10970
+ )
10971
+ ]
10972
+ }
10973
+ ),
10974
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
10975
+ /* @__PURE__ */ jsx(
10976
+ DropdownMenu.Trigger,
10977
+ {
10978
+ className: clx(
10979
+ "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
10980
+ {
10981
+ hidden: isDisabled
10982
+ }
10983
+ ),
10984
+ disabled: isDisabled,
10985
+ asChild: true,
10986
+ children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
10987
+ }
10988
+ ),
10989
+ /* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
10990
+ /* @__PURE__ */ jsxs(
10991
+ DropdownMenu.Item,
10992
+ {
10993
+ className: "gap-x-2",
10994
+ onClick: () => insertRow(index, "above"),
10995
+ children: [
10996
+ /* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
10997
+ "Insert row above"
10998
+ ]
10999
+ }
11000
+ ),
11001
+ /* @__PURE__ */ jsxs(
11002
+ DropdownMenu.Item,
11003
+ {
11004
+ className: "gap-x-2",
11005
+ onClick: () => insertRow(index, "below"),
11006
+ children: [
11007
+ /* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
11008
+ "Insert row below"
11009
+ ]
11010
+ }
11011
+ ),
11012
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
11013
+ /* @__PURE__ */ jsxs(
11014
+ DropdownMenu.Item,
11015
+ {
11016
+ className: "gap-x-2",
11017
+ onClick: () => deleteRow(index),
11018
+ children: [
11019
+ /* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
11020
+ "Delete row"
11021
+ ]
11022
+ }
11023
+ )
11024
+ ] })
11025
+ ] })
11026
+ ] })
11027
+ },
11028
+ field.id
11029
+ );
11030
+ })
11031
+ ] }),
11032
+ hasUneditableRows && /* @__PURE__ */ 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." })
11033
+ ] }),
11034
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11035
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11036
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11037
+ ] }) })
11038
+ ]
11039
+ }
11040
+ ) });
11041
+ };
11042
+ const GridInput = forwardRef(({ className, ...props }, ref) => {
11043
+ return /* @__PURE__ */ jsx(
11044
+ "input",
11045
+ {
11046
+ ref,
11047
+ ...props,
11048
+ autoComplete: "off",
11049
+ className: clx(
11050
+ "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",
11051
+ className
11052
+ )
11053
+ }
11054
+ );
11055
+ });
11056
+ GridInput.displayName = "MetadataForm.GridInput";
11057
+ const PlaceholderInner = () => {
11058
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
11059
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
11060
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11061
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
11062
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
11063
+ ] }) })
11064
+ ] });
11065
+ };
11066
+ const EDITABLE_TYPES = ["string", "number", "boolean"];
11067
+ function getDefaultValues(metadata) {
11068
+ if (!metadata || !Object.keys(metadata).length) {
11069
+ return [
11001
11070
  {
11002
- onSuccess: () => {
11003
- setIsOpen(STACKED_MODAL_ID, false);
11004
- },
11005
- onError: (e) => {
11006
- toast.error(e.message);
11007
- }
11071
+ key: "",
11072
+ value: "",
11073
+ disabled: false
11008
11074
  }
11009
- );
11075
+ ];
11076
+ }
11077
+ return Object.entries(metadata).map(([key, value]) => {
11078
+ if (!EDITABLE_TYPES.includes(typeof value)) {
11079
+ return {
11080
+ key,
11081
+ value,
11082
+ disabled: true
11083
+ };
11084
+ }
11085
+ let stringValue = value;
11086
+ if (typeof value !== "string") {
11087
+ stringValue = JSON.stringify(value);
11088
+ }
11089
+ return {
11090
+ key,
11091
+ value: stringValue,
11092
+ original_key: key
11093
+ };
11010
11094
  });
11011
- return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxs(StackedFocusModal.Content, { children: [
11012
- /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
11013
- /* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
11014
- /* @__PURE__ */ jsxs("div", { children: [
11015
- /* @__PURE__ */ jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Add custom item" }) }),
11016
- /* @__PURE__ */ jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
11017
- ] }),
11018
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11019
- /* @__PURE__ */ jsx(
11020
- Form$2.Field,
11021
- {
11022
- control: form.control,
11023
- name: "title",
11024
- render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11025
- /* @__PURE__ */ jsxs("div", { children: [
11026
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
11027
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the title of the item" })
11028
- ] }),
11029
- /* @__PURE__ */ jsxs("div", { children: [
11030
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11031
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11032
- ] })
11033
- ] }) })
11034
- }
11035
- ),
11036
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11037
- /* @__PURE__ */ jsx(
11038
- Form$2.Field,
11039
- {
11040
- control: form.control,
11041
- name: "unit_price",
11042
- render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11043
- /* @__PURE__ */ jsxs("div", { children: [
11044
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Unit price" }),
11045
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
11046
- ] }),
11047
- /* @__PURE__ */ jsxs("div", { children: [
11048
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11049
- CurrencyInput,
11050
- {
11051
- symbol: getNativeSymbol(currencyCode),
11052
- code: currencyCode,
11053
- onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
11054
- ...field
11055
- }
11056
- ) }),
11057
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11058
- ] })
11059
- ] }) })
11060
- }
11061
- ),
11062
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11063
- /* @__PURE__ */ jsx(
11064
- Form$2.Field,
11065
- {
11066
- control: form.control,
11067
- name: "quantity",
11068
- render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11069
- /* @__PURE__ */ jsxs("div", { children: [
11070
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
11071
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
11072
- ] }),
11073
- /* @__PURE__ */ jsxs("div", { className: "flex-1 w-full", children: [
11074
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
11075
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11076
- ] })
11077
- ] }) })
11078
- }
11079
- )
11080
- ] }) }) }),
11081
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
11082
- /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11083
- /* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
11084
- ] }) })
11085
- ] }) }) });
11086
- };
11087
- const customItemSchema = objectType({
11088
- title: stringType().min(1),
11089
- quantity: numberType(),
11090
- unit_price: unionType([numberType(), stringType()])
11091
- });
11095
+ }
11096
+ function parseValues(values) {
11097
+ const metadata = values.metadata;
11098
+ const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
11099
+ if (isEmpty) {
11100
+ return null;
11101
+ }
11102
+ const update = {};
11103
+ metadata.forEach((field) => {
11104
+ let key = field.key;
11105
+ let value = field.value;
11106
+ const disabled = field.disabled;
11107
+ if (!key || !value) {
11108
+ return;
11109
+ }
11110
+ if (disabled) {
11111
+ update[key] = value;
11112
+ return;
11113
+ }
11114
+ key = key.trim();
11115
+ value = value.trim();
11116
+ if (value === "true") {
11117
+ update[key] = true;
11118
+ } else if (value === "false") {
11119
+ update[key] = false;
11120
+ } else {
11121
+ const parsedNumber = parseFloat(value);
11122
+ if (!isNaN(parsedNumber)) {
11123
+ update[key] = parsedNumber;
11124
+ } else {
11125
+ update[key] = value;
11126
+ }
11127
+ }
11128
+ });
11129
+ return update;
11130
+ }
11131
+ function getHasUneditableRows(metadata) {
11132
+ if (!metadata) {
11133
+ return false;
11134
+ }
11135
+ return Object.values(metadata).some(
11136
+ (value) => !EDITABLE_TYPES.includes(typeof value)
11137
+ );
11138
+ }
11092
11139
  const PROMOTION_QUERY_KEY = "promotions";
11093
11140
  const promotionsQueryKeys = {
11094
11141
  list: (query2) => [
@@ -11354,18 +11401,124 @@ function getPromotionCodes(items, shippingMethods) {
11354
11401
  }
11355
11402
  }
11356
11403
  }
11357
- }
11358
- for (const shippingMethod of shippingMethods) {
11359
- if (shippingMethod.adjustments) {
11360
- for (const adjustment of shippingMethod.adjustments) {
11361
- if (adjustment.code) {
11362
- codes.add(adjustment.code);
11363
- }
11404
+ }
11405
+ for (const shippingMethod of shippingMethods) {
11406
+ if (shippingMethod.adjustments) {
11407
+ for (const adjustment of shippingMethod.adjustments) {
11408
+ if (adjustment.code) {
11409
+ codes.add(adjustment.code);
11410
+ }
11411
+ }
11412
+ }
11413
+ }
11414
+ return Array.from(codes);
11415
+ }
11416
+ const SalesChannel = () => {
11417
+ const { id } = useParams();
11418
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11419
+ id,
11420
+ {
11421
+ fields: "+sales_channel_id"
11422
+ },
11423
+ {
11424
+ enabled: !!id
11425
+ }
11426
+ );
11427
+ if (isError) {
11428
+ throw error;
11429
+ }
11430
+ const ISrEADY = !!draft_order && !isPending;
11431
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11432
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11433
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11434
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11435
+ ] }),
11436
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11437
+ ] });
11438
+ };
11439
+ const SalesChannelForm = ({ order }) => {
11440
+ const form = useForm({
11441
+ defaultValues: {
11442
+ sales_channel_id: order.sales_channel_id || ""
11443
+ },
11444
+ resolver: zodResolver(schema$3)
11445
+ });
11446
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11447
+ const { handleSuccess } = useRouteModal();
11448
+ const onSubmit = form.handleSubmit(async (data) => {
11449
+ await mutateAsync(
11450
+ {
11451
+ sales_channel_id: data.sales_channel_id
11452
+ },
11453
+ {
11454
+ onSuccess: () => {
11455
+ toast.success("Sales channel updated");
11456
+ handleSuccess();
11457
+ },
11458
+ onError: (error) => {
11459
+ toast.error(error.message);
11460
+ }
11461
+ }
11462
+ );
11463
+ });
11464
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11465
+ KeyboundForm,
11466
+ {
11467
+ className: "flex flex-1 flex-col overflow-hidden",
11468
+ onSubmit,
11469
+ children: [
11470
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11471
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11472
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11473
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11474
+ ] }) })
11475
+ ]
11476
+ }
11477
+ ) });
11478
+ };
11479
+ const SalesChannelField = ({ control, order }) => {
11480
+ const salesChannels = useComboboxData({
11481
+ queryFn: async (params) => {
11482
+ return await sdk.admin.salesChannel.list(params);
11483
+ },
11484
+ queryKey: ["sales-channels"],
11485
+ getOptions: (data) => {
11486
+ return data.sales_channels.map((salesChannel) => ({
11487
+ label: salesChannel.name,
11488
+ value: salesChannel.id
11489
+ }));
11490
+ },
11491
+ defaultValue: order.sales_channel_id || void 0
11492
+ });
11493
+ return /* @__PURE__ */ jsx(
11494
+ Form$2.Field,
11495
+ {
11496
+ control,
11497
+ name: "sales_channel_id",
11498
+ render: ({ field }) => {
11499
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11500
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11501
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11502
+ Combobox,
11503
+ {
11504
+ options: salesChannels.options,
11505
+ fetchNextPage: salesChannels.fetchNextPage,
11506
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11507
+ searchValue: salesChannels.searchValue,
11508
+ onSearchValueChange: salesChannels.onSearchValueChange,
11509
+ placeholder: "Select sales channel",
11510
+ ...field
11511
+ }
11512
+ ) }),
11513
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11514
+ ] });
11364
11515
  }
11365
11516
  }
11366
- }
11367
- return Array.from(codes);
11368
- }
11517
+ );
11518
+ };
11519
+ const schema$3 = objectType({
11520
+ sales_channel_id: stringType().min(1)
11521
+ });
11369
11522
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11370
11523
  const Shipping = () => {
11371
11524
  var _a;
@@ -12205,7 +12358,7 @@ const ShippingAddressForm = ({ order }) => {
12205
12358
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12206
12359
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12207
12360
  },
12208
- resolver: zodResolver(schema$3)
12361
+ resolver: zodResolver(schema$2)
12209
12362
  });
12210
12363
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12211
12364
  const { handleSuccess } = useRouteModal();
@@ -12375,7 +12528,7 @@ const ShippingAddressForm = ({ order }) => {
12375
12528
  }
12376
12529
  ) });
12377
12530
  };
12378
- const schema$3 = addressSchema;
12531
+ const schema$2 = addressSchema;
12379
12532
  const TransferOwnership = () => {
12380
12533
  const { id } = useParams();
12381
12534
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12399,7 +12552,7 @@ const TransferOwnershipForm = ({ order }) => {
12399
12552
  defaultValues: {
12400
12553
  customer_id: order.customer_id || ""
12401
12554
  },
12402
- resolver: zodResolver(schema$2)
12555
+ resolver: zodResolver(schema$1)
12403
12556
  });
12404
12557
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12405
12558
  const { handleSuccess } = useRouteModal();
@@ -12849,179 +13002,26 @@ const Illustration = () => {
12849
13002
  }
12850
13003
  );
12851
13004
  };
12852
- const schema$2 = objectType({
12853
- customer_id: stringType().min(1)
12854
- });
12855
- const SalesChannel = () => {
12856
- const { id } = useParams();
12857
- const { draft_order, isPending, isError, error } = useDraftOrder(
12858
- id,
12859
- {
12860
- fields: "+sales_channel_id"
12861
- },
12862
- {
12863
- enabled: !!id
12864
- }
12865
- );
12866
- if (isError) {
12867
- throw error;
12868
- }
12869
- const ISrEADY = !!draft_order && !isPending;
12870
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12871
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12872
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12873
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12874
- ] }),
12875
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12876
- ] });
12877
- };
12878
- const SalesChannelForm = ({ order }) => {
12879
- const form = useForm({
12880
- defaultValues: {
12881
- sales_channel_id: order.sales_channel_id || ""
12882
- },
12883
- resolver: zodResolver(schema$1)
12884
- });
12885
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12886
- const { handleSuccess } = useRouteModal();
12887
- const onSubmit = form.handleSubmit(async (data) => {
12888
- await mutateAsync(
12889
- {
12890
- sales_channel_id: data.sales_channel_id
12891
- },
12892
- {
12893
- onSuccess: () => {
12894
- toast.success("Sales channel updated");
12895
- handleSuccess();
12896
- },
12897
- onError: (error) => {
12898
- toast.error(error.message);
12899
- }
12900
- }
12901
- );
12902
- });
12903
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12904
- KeyboundForm,
12905
- {
12906
- className: "flex flex-1 flex-col overflow-hidden",
12907
- onSubmit,
12908
- children: [
12909
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12910
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12911
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12912
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12913
- ] }) })
12914
- ]
12915
- }
12916
- ) });
12917
- };
12918
- const SalesChannelField = ({ control, order }) => {
12919
- const salesChannels = useComboboxData({
12920
- queryFn: async (params) => {
12921
- return await sdk.admin.salesChannel.list(params);
12922
- },
12923
- queryKey: ["sales-channels"],
12924
- getOptions: (data) => {
12925
- return data.sales_channels.map((salesChannel) => ({
12926
- label: salesChannel.name,
12927
- value: salesChannel.id
12928
- }));
12929
- },
12930
- defaultValue: order.sales_channel_id || void 0
12931
- });
12932
- return /* @__PURE__ */ jsx(
12933
- Form$2.Field,
12934
- {
12935
- control,
12936
- name: "sales_channel_id",
12937
- render: ({ field }) => {
12938
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12939
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12940
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12941
- Combobox,
12942
- {
12943
- options: salesChannels.options,
12944
- fetchNextPage: salesChannels.fetchNextPage,
12945
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12946
- searchValue: salesChannels.searchValue,
12947
- onSearchValueChange: salesChannels.onSearchValueChange,
12948
- placeholder: "Select sales channel",
12949
- ...field
12950
- }
12951
- ) }),
12952
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12953
- ] });
12954
- }
12955
- }
12956
- );
12957
- };
12958
13005
  const schema$1 = objectType({
12959
- sales_channel_id: stringType().min(1)
13006
+ customer_id: stringType().min(1)
12960
13007
  });
12961
- const Email = () => {
12962
- const { id } = useParams();
12963
- const { order, isPending, isError, error } = useOrder(id, {
12964
- fields: "+email"
12965
- });
12966
- if (isError) {
12967
- throw error;
12968
- }
12969
- const isReady = !isPending && !!order;
13008
+ const CustomItems = () => {
12970
13009
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12971
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12972
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
12973
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12974
- ] }),
12975
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
13010
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13011
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
12976
13012
  ] });
12977
13013
  };
12978
- const EmailForm = ({ order }) => {
13014
+ const CustomItemsForm = () => {
12979
13015
  const form = useForm({
12980
- defaultValues: {
12981
- email: order.email ?? ""
12982
- },
12983
13016
  resolver: zodResolver(schema)
12984
13017
  });
12985
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12986
- const { handleSuccess } = useRouteModal();
12987
- const onSubmit = form.handleSubmit(async (data) => {
12988
- await mutateAsync(
12989
- { email: data.email },
12990
- {
12991
- onSuccess: () => {
12992
- handleSuccess();
12993
- },
12994
- onError: (error) => {
12995
- toast.error(error.message);
12996
- }
12997
- }
12998
- );
12999
- });
13000
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
13001
- KeyboundForm,
13002
- {
13003
- className: "flex flex-1 flex-col overflow-hidden",
13004
- onSubmit,
13005
- children: [
13006
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
13007
- Form$2.Field,
13008
- {
13009
- control: form.control,
13010
- name: "email",
13011
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13012
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
13013
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13014
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13015
- ] })
13016
- }
13017
- ) }),
13018
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13019
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13020
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13021
- ] }) })
13022
- ]
13023
- }
13024
- ) });
13018
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13019
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13020
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13021
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13022
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13023
+ ] }) })
13024
+ ] }) });
13025
13025
  };
13026
13026
  const schema = objectType({
13027
13027
  email: stringType().email()
@@ -13051,21 +13051,25 @@ const routeModule = {
13051
13051
  path: "/draft-orders/:id/billing-address"
13052
13052
  },
13053
13053
  {
13054
- Component: CustomItems,
13055
- path: "/draft-orders/:id/custom-items"
13056
- },
13057
- {
13058
- Component: Metadata,
13059
- path: "/draft-orders/:id/metadata"
13054
+ Component: Email,
13055
+ path: "/draft-orders/:id/email"
13060
13056
  },
13061
13057
  {
13062
13058
  Component: Items,
13063
13059
  path: "/draft-orders/:id/items"
13064
13060
  },
13061
+ {
13062
+ Component: Metadata,
13063
+ path: "/draft-orders/:id/metadata"
13064
+ },
13065
13065
  {
13066
13066
  Component: Promotions,
13067
13067
  path: "/draft-orders/:id/promotions"
13068
13068
  },
13069
+ {
13070
+ Component: SalesChannel,
13071
+ path: "/draft-orders/:id/sales-channel"
13072
+ },
13069
13073
  {
13070
13074
  Component: Shipping,
13071
13075
  path: "/draft-orders/:id/shipping"
@@ -13079,12 +13083,8 @@ const routeModule = {
13079
13083
  path: "/draft-orders/:id/transfer-ownership"
13080
13084
  },
13081
13085
  {
13082
- Component: SalesChannel,
13083
- path: "/draft-orders/:id/sales-channel"
13084
- },
13085
- {
13086
- Component: Email,
13087
- path: "/draft-orders/:id/email"
13086
+ Component: CustomItems,
13087
+ path: "/draft-orders/:id/custom-items"
13088
13088
  }
13089
13089
  ]
13090
13090
  }