@medusajs/draft-order 2.11.2-preview-20251029060154 → 2.11.2-preview-20251029090152

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.
@@ -9565,74 +9565,6 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
- const Email = () => {
9569
- const { id } = useParams();
9570
- const { order, isPending, isError, error } = useOrder(id, {
9571
- fields: "+email"
9572
- });
9573
- if (isError) {
9574
- throw error;
9575
- }
9576
- const isReady = !isPending && !!order;
9577
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9578
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9579
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9580
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9581
- ] }),
9582
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9583
- ] });
9584
- };
9585
- const EmailForm = ({ order }) => {
9586
- const form = useForm({
9587
- defaultValues: {
9588
- email: order.email ?? ""
9589
- },
9590
- resolver: zodResolver(schema$5)
9591
- });
9592
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9593
- const { handleSuccess } = useRouteModal();
9594
- const onSubmit = form.handleSubmit(async (data) => {
9595
- await mutateAsync(
9596
- { email: data.email },
9597
- {
9598
- onSuccess: () => {
9599
- handleSuccess();
9600
- },
9601
- onError: (error) => {
9602
- toast.error(error.message);
9603
- }
9604
- }
9605
- );
9606
- });
9607
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9608
- KeyboundForm,
9609
- {
9610
- className: "flex flex-1 flex-col overflow-hidden",
9611
- onSubmit,
9612
- children: [
9613
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9614
- Form$2.Field,
9615
- {
9616
- control: form.control,
9617
- name: "email",
9618
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9619
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9620
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9621
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9622
- ] })
9623
- }
9624
- ) }),
9625
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9626
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9627
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9628
- ] }) })
9629
- ]
9630
- }
9631
- ) });
9632
- };
9633
- const schema$5 = objectType({
9634
- email: stringType().email()
9635
- });
9636
9568
  const BillingAddress = () => {
9637
9569
  const { id } = useParams();
9638
9570
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9665,7 +9597,7 @@ const BillingAddressForm = ({ order }) => {
9665
9597
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9666
9598
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9667
9599
  },
9668
- resolver: zodResolver(schema$4)
9600
+ resolver: zodResolver(schema$5)
9669
9601
  });
9670
9602
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9671
9603
  const { handleSuccess } = useRouteModal();
@@ -9822,7 +9754,28 @@ const BillingAddressForm = ({ order }) => {
9822
9754
  }
9823
9755
  ) });
9824
9756
  };
9825
- const schema$4 = addressSchema;
9757
+ const schema$5 = addressSchema;
9758
+ const CustomItems = () => {
9759
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
+ ] });
9763
+ };
9764
+ const CustomItemsForm = () => {
9765
+ const form = useForm({
9766
+ resolver: zodResolver(schema$4)
9767
+ });
9768
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
+ ] }) })
9774
+ ] }) });
9775
+ };
9776
+ const schema$4 = objectType({
9777
+ email: stringType().email()
9778
+ });
9826
9779
  const NumberInput = forwardRef(
9827
9780
  ({
9828
9781
  value,
@@ -10797,54 +10750,10 @@ const customItemSchema = objectType({
10797
10750
  quantity: numberType(),
10798
10751
  unit_price: unionType([numberType(), stringType()])
10799
10752
  });
10800
- const InlineTip = forwardRef(
10801
- ({ variant = "tip", label, className, children, ...props }, ref) => {
10802
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10803
- return /* @__PURE__ */ jsxs(
10804
- "div",
10805
- {
10806
- ref,
10807
- className: clx(
10808
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10809
- className
10810
- ),
10811
- ...props,
10812
- children: [
10813
- /* @__PURE__ */ jsx(
10814
- "div",
10815
- {
10816
- role: "presentation",
10817
- className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10818
- "bg-ui-tag-orange-icon": variant === "warning"
10819
- })
10820
- }
10821
- ),
10822
- /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
10823
- /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10824
- labelValue,
10825
- ":"
10826
- ] }),
10827
- " ",
10828
- children
10829
- ] })
10830
- ]
10831
- }
10832
- );
10833
- }
10834
- );
10835
- InlineTip.displayName = "InlineTip";
10836
- const MetadataFieldSchema = objectType({
10837
- key: stringType(),
10838
- disabled: booleanType().optional(),
10839
- value: anyType()
10840
- });
10841
- const MetadataSchema = objectType({
10842
- metadata: arrayType(MetadataFieldSchema)
10843
- });
10844
- const Metadata = () => {
10753
+ const Email = () => {
10845
10754
  const { id } = useParams();
10846
10755
  const { order, isPending, isError, error } = useOrder(id, {
10847
- fields: "metadata"
10756
+ fields: "+email"
10848
10757
  });
10849
10758
  if (isError) {
10850
10759
  throw error;
@@ -10852,33 +10761,26 @@ const Metadata = () => {
10852
10761
  const isReady = !isPending && !!order;
10853
10762
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10854
10763
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10855
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
10856
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10764
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
10765
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10857
10766
  ] }),
10858
- !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10767
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
10859
10768
  ] });
10860
10769
  };
10861
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10862
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10863
- const MetadataForm = ({ orderId, metadata }) => {
10864
- const { handleSuccess } = useRouteModal();
10865
- const hasUneditableRows = getHasUneditableRows(metadata);
10866
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10770
+ const EmailForm = ({ order }) => {
10867
10771
  const form = useForm({
10868
10772
  defaultValues: {
10869
- metadata: getDefaultValues(metadata)
10773
+ email: order.email ?? ""
10870
10774
  },
10871
- resolver: zodResolver(MetadataSchema)
10775
+ resolver: zodResolver(schema$3)
10872
10776
  });
10873
- const handleSubmit = form.handleSubmit(async (data) => {
10874
- const parsedData = parseValues(data);
10777
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10778
+ const { handleSuccess } = useRouteModal();
10779
+ const onSubmit = form.handleSubmit(async (data) => {
10875
10780
  await mutateAsync(
10876
- {
10877
- metadata: parsedData
10878
- },
10781
+ { email: data.email },
10879
10782
  {
10880
10783
  onSuccess: () => {
10881
- toast.success("Metadata updated");
10882
10784
  handleSuccess();
10883
10785
  },
10884
10786
  onError: (error) => {
@@ -10887,266 +10789,35 @@ const MetadataForm = ({ orderId, metadata }) => {
10887
10789
  }
10888
10790
  );
10889
10791
  });
10890
- const { fields, insert, remove } = useFieldArray({
10891
- control: form.control,
10892
- name: "metadata"
10893
- });
10894
- function deleteRow(index) {
10895
- remove(index);
10896
- if (fields.length === 1) {
10897
- insert(0, {
10898
- key: "",
10899
- value: "",
10900
- disabled: false
10901
- });
10902
- }
10903
- }
10904
- function insertRow(index, position) {
10905
- insert(index + (position === "above" ? 0 : 1), {
10906
- key: "",
10907
- value: "",
10908
- disabled: false
10909
- });
10910
- }
10911
10792
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10912
10793
  KeyboundForm,
10913
10794
  {
10914
- onSubmit: handleSubmit,
10915
10795
  className: "flex flex-1 flex-col overflow-hidden",
10796
+ onSubmit,
10916
10797
  children: [
10917
- /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
10918
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
10919
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
10920
- /* @__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" }) }),
10921
- /* @__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" }) })
10922
- ] }),
10923
- fields.map((field, index) => {
10924
- const isDisabled = field.disabled || false;
10925
- let placeholder = "-";
10926
- if (typeof field.value === "object") {
10927
- placeholder = "{ ... }";
10928
- }
10929
- if (Array.isArray(field.value)) {
10930
- placeholder = "[ ... ]";
10931
- }
10932
- return /* @__PURE__ */ jsx(
10933
- ConditionalTooltip,
10934
- {
10935
- showTooltip: isDisabled,
10936
- content: "This row is disabled because it contains non-primitive data.",
10937
- children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
10938
- /* @__PURE__ */ jsxs(
10939
- "div",
10940
- {
10941
- className: clx("grid grid-cols-2 divide-x", {
10942
- "overflow-hidden rounded-b-lg": index === fields.length - 1
10943
- }),
10944
- children: [
10945
- /* @__PURE__ */ jsx(
10946
- Form$2.Field,
10947
- {
10948
- control: form.control,
10949
- name: `metadata.${index}.key`,
10950
- render: ({ field: field2 }) => {
10951
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
10952
- GridInput,
10953
- {
10954
- "aria-labelledby": METADATA_KEY_LABEL_ID,
10955
- ...field2,
10956
- disabled: isDisabled,
10957
- placeholder: "Key"
10958
- }
10959
- ) }) });
10960
- }
10961
- }
10962
- ),
10963
- /* @__PURE__ */ jsx(
10964
- Form$2.Field,
10965
- {
10966
- control: form.control,
10967
- name: `metadata.${index}.value`,
10968
- render: ({ field: { value, ...field2 } }) => {
10969
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
10970
- GridInput,
10971
- {
10972
- "aria-labelledby": METADATA_VALUE_LABEL_ID,
10973
- ...field2,
10974
- value: isDisabled ? placeholder : value,
10975
- disabled: isDisabled,
10976
- placeholder: "Value"
10977
- }
10978
- ) }) });
10979
- }
10980
- }
10981
- )
10982
- ]
10983
- }
10984
- ),
10985
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [
10986
- /* @__PURE__ */ jsx(
10987
- DropdownMenu.Trigger,
10988
- {
10989
- className: clx(
10990
- "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
10991
- {
10992
- hidden: isDisabled
10993
- }
10994
- ),
10995
- disabled: isDisabled,
10996
- asChild: true,
10997
- children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
10998
- }
10999
- ),
11000
- /* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
11001
- /* @__PURE__ */ jsxs(
11002
- DropdownMenu.Item,
11003
- {
11004
- className: "gap-x-2",
11005
- onClick: () => insertRow(index, "above"),
11006
- children: [
11007
- /* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
11008
- "Insert row above"
11009
- ]
11010
- }
11011
- ),
11012
- /* @__PURE__ */ jsxs(
11013
- DropdownMenu.Item,
11014
- {
11015
- className: "gap-x-2",
11016
- onClick: () => insertRow(index, "below"),
11017
- children: [
11018
- /* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
11019
- "Insert row below"
11020
- ]
11021
- }
11022
- ),
11023
- /* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
11024
- /* @__PURE__ */ jsxs(
11025
- DropdownMenu.Item,
11026
- {
11027
- className: "gap-x-2",
11028
- onClick: () => deleteRow(index),
11029
- children: [
11030
- /* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
11031
- "Delete row"
11032
- ]
11033
- }
11034
- )
11035
- ] })
11036
- ] })
11037
- ] })
11038
- },
11039
- field.id
11040
- );
11041
- })
11042
- ] }),
11043
- 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." })
11044
- ] }),
11045
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11046
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10798
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
10799
+ Form$2.Field,
10800
+ {
10801
+ control: form.control,
10802
+ name: "email",
10803
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10804
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
10805
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10806
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10807
+ ] })
10808
+ }
10809
+ ) }),
10810
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10811
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11047
10812
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11048
10813
  ] }) })
11049
10814
  ]
11050
10815
  }
11051
10816
  ) });
11052
10817
  };
11053
- const GridInput = forwardRef(({ className, ...props }, ref) => {
11054
- return /* @__PURE__ */ jsx(
11055
- "input",
11056
- {
11057
- ref,
11058
- ...props,
11059
- autoComplete: "off",
11060
- className: clx(
11061
- "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",
11062
- className
11063
- )
11064
- }
11065
- );
10818
+ const schema$3 = objectType({
10819
+ email: stringType().email()
11066
10820
  });
11067
- GridInput.displayName = "MetadataForm.GridInput";
11068
- const PlaceholderInner = () => {
11069
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
11070
- /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
11071
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11072
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
11073
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
11074
- ] }) })
11075
- ] });
11076
- };
11077
- const EDITABLE_TYPES = ["string", "number", "boolean"];
11078
- function getDefaultValues(metadata) {
11079
- if (!metadata || !Object.keys(metadata).length) {
11080
- return [
11081
- {
11082
- key: "",
11083
- value: "",
11084
- disabled: false
11085
- }
11086
- ];
11087
- }
11088
- return Object.entries(metadata).map(([key, value]) => {
11089
- if (!EDITABLE_TYPES.includes(typeof value)) {
11090
- return {
11091
- key,
11092
- value,
11093
- disabled: true
11094
- };
11095
- }
11096
- let stringValue = value;
11097
- if (typeof value !== "string") {
11098
- stringValue = JSON.stringify(value);
11099
- }
11100
- return {
11101
- key,
11102
- value: stringValue,
11103
- original_key: key
11104
- };
11105
- });
11106
- }
11107
- function parseValues(values) {
11108
- const metadata = values.metadata;
11109
- const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
11110
- if (isEmpty) {
11111
- return null;
11112
- }
11113
- const update = {};
11114
- metadata.forEach((field) => {
11115
- let key = field.key;
11116
- let value = field.value;
11117
- const disabled = field.disabled;
11118
- if (!key || !value) {
11119
- return;
11120
- }
11121
- if (disabled) {
11122
- update[key] = value;
11123
- return;
11124
- }
11125
- key = key.trim();
11126
- value = value.trim();
11127
- if (value === "true") {
11128
- update[key] = true;
11129
- } else if (value === "false") {
11130
- update[key] = false;
11131
- } else {
11132
- const parsedNumber = parseFloat(value);
11133
- if (!isNaN(parsedNumber)) {
11134
- update[key] = parsedNumber;
11135
- } else {
11136
- update[key] = value;
11137
- }
11138
- }
11139
- });
11140
- return update;
11141
- }
11142
- function getHasUneditableRows(metadata) {
11143
- if (!metadata) {
11144
- return false;
11145
- }
11146
- return Object.values(metadata).some(
11147
- (value) => !EDITABLE_TYPES.includes(typeof value)
11148
- );
11149
- }
11150
10821
  const PROMOTION_QUERY_KEY = "promotions";
11151
10822
  const promotionsQueryKeys = {
11152
10823
  list: (query2) => [
@@ -11318,133 +10989,462 @@ const PromotionForm = ({ preview }) => {
11318
10989
  ] }) })
11319
10990
  ] });
11320
10991
  };
11321
- const PromotionItem = ({
11322
- promotion,
11323
- orderId,
11324
- isLoading
11325
- }) => {
11326
- var _a;
11327
- const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
11328
- const onRemove = async () => {
11329
- removePromotions(
11330
- {
11331
- promo_codes: [promotion.code]
11332
- },
10992
+ const PromotionItem = ({
10993
+ promotion,
10994
+ orderId,
10995
+ isLoading
10996
+ }) => {
10997
+ var _a;
10998
+ const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
10999
+ const onRemove = async () => {
11000
+ removePromotions(
11001
+ {
11002
+ promo_codes: [promotion.code]
11003
+ },
11004
+ {
11005
+ onError: (e) => {
11006
+ toast.error(e.message);
11007
+ }
11008
+ }
11009
+ );
11010
+ };
11011
+ const displayValue = getDisplayValue(promotion);
11012
+ return /* @__PURE__ */ jsxs(
11013
+ "div",
11014
+ {
11015
+ className: clx(
11016
+ "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11017
+ {
11018
+ "animate-pulse": isLoading
11019
+ }
11020
+ ),
11021
+ children: [
11022
+ /* @__PURE__ */ jsxs("div", { children: [
11023
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11024
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11025
+ displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11026
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11027
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
11028
+ ] }),
11029
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11030
+ ] })
11031
+ ] }),
11032
+ /* @__PURE__ */ jsx(
11033
+ IconButton,
11034
+ {
11035
+ size: "small",
11036
+ type: "button",
11037
+ variant: "transparent",
11038
+ onClick: onRemove,
11039
+ isLoading: isPending || isLoading,
11040
+ children: /* @__PURE__ */ jsx(XMark, {})
11041
+ }
11042
+ )
11043
+ ]
11044
+ },
11045
+ promotion.id
11046
+ );
11047
+ };
11048
+ function getDisplayValue(promotion) {
11049
+ var _a, _b, _c, _d;
11050
+ const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11051
+ if (!value) {
11052
+ return null;
11053
+ }
11054
+ if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11055
+ const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11056
+ if (!currency) {
11057
+ return null;
11058
+ }
11059
+ return getLocaleAmount(value, currency);
11060
+ } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11061
+ return formatPercentage(value);
11062
+ }
11063
+ return null;
11064
+ }
11065
+ const formatter = new Intl.NumberFormat([], {
11066
+ style: "percent",
11067
+ minimumFractionDigits: 2
11068
+ });
11069
+ const formatPercentage = (value, isPercentageValue = false) => {
11070
+ let val = value || 0;
11071
+ if (!isPercentageValue) {
11072
+ val = val / 100;
11073
+ }
11074
+ return formatter.format(val);
11075
+ };
11076
+ function getPromotionIds(items, shippingMethods) {
11077
+ const promotionIds = /* @__PURE__ */ new Set();
11078
+ for (const item of items) {
11079
+ if (item.adjustments) {
11080
+ for (const adjustment of item.adjustments) {
11081
+ if (adjustment.promotion_id) {
11082
+ promotionIds.add(adjustment.promotion_id);
11083
+ }
11084
+ }
11085
+ }
11086
+ }
11087
+ for (const shippingMethod of shippingMethods) {
11088
+ if (shippingMethod.adjustments) {
11089
+ for (const adjustment of shippingMethod.adjustments) {
11090
+ if (adjustment.promotion_id) {
11091
+ promotionIds.add(adjustment.promotion_id);
11092
+ }
11093
+ }
11094
+ }
11095
+ }
11096
+ return Array.from(promotionIds);
11097
+ }
11098
+ const InlineTip = forwardRef(
11099
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
11100
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
11101
+ return /* @__PURE__ */ jsxs(
11102
+ "div",
11103
+ {
11104
+ ref,
11105
+ className: clx(
11106
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
11107
+ className
11108
+ ),
11109
+ ...props,
11110
+ children: [
11111
+ /* @__PURE__ */ jsx(
11112
+ "div",
11113
+ {
11114
+ role: "presentation",
11115
+ className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
11116
+ "bg-ui-tag-orange-icon": variant === "warning"
11117
+ })
11118
+ }
11119
+ ),
11120
+ /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
11121
+ /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
11122
+ labelValue,
11123
+ ":"
11124
+ ] }),
11125
+ " ",
11126
+ children
11127
+ ] })
11128
+ ]
11129
+ }
11130
+ );
11131
+ }
11132
+ );
11133
+ InlineTip.displayName = "InlineTip";
11134
+ const MetadataFieldSchema = objectType({
11135
+ key: stringType(),
11136
+ disabled: booleanType().optional(),
11137
+ value: anyType()
11138
+ });
11139
+ const MetadataSchema = objectType({
11140
+ metadata: arrayType(MetadataFieldSchema)
11141
+ });
11142
+ const Metadata = () => {
11143
+ const { id } = useParams();
11144
+ const { order, isPending, isError, error } = useOrder(id, {
11145
+ fields: "metadata"
11146
+ });
11147
+ if (isError) {
11148
+ throw error;
11149
+ }
11150
+ const isReady = !isPending && !!order;
11151
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11152
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11153
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
11154
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
11155
+ ] }),
11156
+ !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
11157
+ ] });
11158
+ };
11159
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
11160
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
11161
+ const MetadataForm = ({ orderId, metadata }) => {
11162
+ const { handleSuccess } = useRouteModal();
11163
+ const hasUneditableRows = getHasUneditableRows(metadata);
11164
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
11165
+ const form = useForm({
11166
+ defaultValues: {
11167
+ metadata: getDefaultValues(metadata)
11168
+ },
11169
+ resolver: zodResolver(MetadataSchema)
11170
+ });
11171
+ const handleSubmit = form.handleSubmit(async (data) => {
11172
+ const parsedData = parseValues(data);
11173
+ await mutateAsync(
11174
+ {
11175
+ metadata: parsedData
11176
+ },
11177
+ {
11178
+ onSuccess: () => {
11179
+ toast.success("Metadata updated");
11180
+ handleSuccess();
11181
+ },
11182
+ onError: (error) => {
11183
+ toast.error(error.message);
11184
+ }
11185
+ }
11186
+ );
11187
+ });
11188
+ const { fields, insert, remove } = useFieldArray({
11189
+ control: form.control,
11190
+ name: "metadata"
11191
+ });
11192
+ function deleteRow(index) {
11193
+ remove(index);
11194
+ if (fields.length === 1) {
11195
+ insert(0, {
11196
+ key: "",
11197
+ value: "",
11198
+ disabled: false
11199
+ });
11200
+ }
11201
+ }
11202
+ function insertRow(index, position) {
11203
+ insert(index + (position === "above" ? 0 : 1), {
11204
+ key: "",
11205
+ value: "",
11206
+ disabled: false
11207
+ });
11208
+ }
11209
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11210
+ KeyboundForm,
11211
+ {
11212
+ onSubmit: handleSubmit,
11213
+ className: "flex flex-1 flex-col overflow-hidden",
11214
+ children: [
11215
+ /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
11216
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
11217
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
11218
+ /* @__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" }) }),
11219
+ /* @__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" }) })
11220
+ ] }),
11221
+ fields.map((field, index) => {
11222
+ const isDisabled = field.disabled || false;
11223
+ let placeholder = "-";
11224
+ if (typeof field.value === "object") {
11225
+ placeholder = "{ ... }";
11226
+ }
11227
+ if (Array.isArray(field.value)) {
11228
+ placeholder = "[ ... ]";
11229
+ }
11230
+ return /* @__PURE__ */ jsx(
11231
+ ConditionalTooltip,
11232
+ {
11233
+ showTooltip: isDisabled,
11234
+ content: "This row is disabled because it contains non-primitive data.",
11235
+ children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
11236
+ /* @__PURE__ */ jsxs(
11237
+ "div",
11238
+ {
11239
+ className: clx("grid grid-cols-2 divide-x", {
11240
+ "overflow-hidden rounded-b-lg": index === fields.length - 1
11241
+ }),
11242
+ children: [
11243
+ /* @__PURE__ */ jsx(
11244
+ Form$2.Field,
11245
+ {
11246
+ control: form.control,
11247
+ name: `metadata.${index}.key`,
11248
+ render: ({ field: field2 }) => {
11249
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11250
+ GridInput,
11251
+ {
11252
+ "aria-labelledby": METADATA_KEY_LABEL_ID,
11253
+ ...field2,
11254
+ disabled: isDisabled,
11255
+ placeholder: "Key"
11256
+ }
11257
+ ) }) });
11258
+ }
11259
+ }
11260
+ ),
11261
+ /* @__PURE__ */ jsx(
11262
+ Form$2.Field,
11263
+ {
11264
+ control: form.control,
11265
+ name: `metadata.${index}.value`,
11266
+ render: ({ field: { value, ...field2 } }) => {
11267
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11268
+ GridInput,
11269
+ {
11270
+ "aria-labelledby": METADATA_VALUE_LABEL_ID,
11271
+ ...field2,
11272
+ value: isDisabled ? placeholder : value,
11273
+ disabled: isDisabled,
11274
+ placeholder: "Value"
11275
+ }
11276
+ ) }) });
11277
+ }
11278
+ }
11279
+ )
11280
+ ]
11281
+ }
11282
+ ),
11283
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
11284
+ /* @__PURE__ */ jsx(
11285
+ DropdownMenu.Trigger,
11286
+ {
11287
+ className: clx(
11288
+ "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
11289
+ {
11290
+ hidden: isDisabled
11291
+ }
11292
+ ),
11293
+ disabled: isDisabled,
11294
+ asChild: true,
11295
+ children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
11296
+ }
11297
+ ),
11298
+ /* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
11299
+ /* @__PURE__ */ jsxs(
11300
+ DropdownMenu.Item,
11301
+ {
11302
+ className: "gap-x-2",
11303
+ onClick: () => insertRow(index, "above"),
11304
+ children: [
11305
+ /* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
11306
+ "Insert row above"
11307
+ ]
11308
+ }
11309
+ ),
11310
+ /* @__PURE__ */ jsxs(
11311
+ DropdownMenu.Item,
11312
+ {
11313
+ className: "gap-x-2",
11314
+ onClick: () => insertRow(index, "below"),
11315
+ children: [
11316
+ /* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
11317
+ "Insert row below"
11318
+ ]
11319
+ }
11320
+ ),
11321
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
11322
+ /* @__PURE__ */ jsxs(
11323
+ DropdownMenu.Item,
11324
+ {
11325
+ className: "gap-x-2",
11326
+ onClick: () => deleteRow(index),
11327
+ children: [
11328
+ /* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
11329
+ "Delete row"
11330
+ ]
11331
+ }
11332
+ )
11333
+ ] })
11334
+ ] })
11335
+ ] })
11336
+ },
11337
+ field.id
11338
+ );
11339
+ })
11340
+ ] }),
11341
+ 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." })
11342
+ ] }),
11343
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11344
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11345
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11346
+ ] }) })
11347
+ ]
11348
+ }
11349
+ ) });
11350
+ };
11351
+ const GridInput = forwardRef(({ className, ...props }, ref) => {
11352
+ return /* @__PURE__ */ jsx(
11353
+ "input",
11354
+ {
11355
+ ref,
11356
+ ...props,
11357
+ autoComplete: "off",
11358
+ className: clx(
11359
+ "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",
11360
+ className
11361
+ )
11362
+ }
11363
+ );
11364
+ });
11365
+ GridInput.displayName = "MetadataForm.GridInput";
11366
+ const PlaceholderInner = () => {
11367
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
11368
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
11369
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11370
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
11371
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
11372
+ ] }) })
11373
+ ] });
11374
+ };
11375
+ const EDITABLE_TYPES = ["string", "number", "boolean"];
11376
+ function getDefaultValues(metadata) {
11377
+ if (!metadata || !Object.keys(metadata).length) {
11378
+ return [
11333
11379
  {
11334
- onError: (e) => {
11335
- toast.error(e.message);
11336
- }
11380
+ key: "",
11381
+ value: "",
11382
+ disabled: false
11337
11383
  }
11338
- );
11339
- };
11340
- const displayValue = getDisplayValue(promotion);
11341
- return /* @__PURE__ */ jsxs(
11342
- "div",
11343
- {
11344
- className: clx(
11345
- "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11346
- {
11347
- "animate-pulse": isLoading
11348
- }
11349
- ),
11350
- children: [
11351
- /* @__PURE__ */ jsxs("div", { children: [
11352
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11353
- /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11354
- displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11355
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11356
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
11357
- ] }),
11358
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11359
- ] })
11360
- ] }),
11361
- /* @__PURE__ */ jsx(
11362
- IconButton,
11363
- {
11364
- size: "small",
11365
- type: "button",
11366
- variant: "transparent",
11367
- onClick: onRemove,
11368
- isLoading: isPending || isLoading,
11369
- children: /* @__PURE__ */ jsx(XMark, {})
11370
- }
11371
- )
11372
- ]
11373
- },
11374
- promotion.id
11375
- );
11376
- };
11377
- function getDisplayValue(promotion) {
11378
- var _a, _b, _c, _d;
11379
- const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11380
- if (!value) {
11381
- return null;
11384
+ ];
11382
11385
  }
11383
- if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11384
- const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11385
- if (!currency) {
11386
- return null;
11386
+ return Object.entries(metadata).map(([key, value]) => {
11387
+ if (!EDITABLE_TYPES.includes(typeof value)) {
11388
+ return {
11389
+ key,
11390
+ value,
11391
+ disabled: true
11392
+ };
11387
11393
  }
11388
- return getLocaleAmount(value, currency);
11389
- } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11390
- return formatPercentage(value);
11391
- }
11392
- return null;
11394
+ let stringValue = value;
11395
+ if (typeof value !== "string") {
11396
+ stringValue = JSON.stringify(value);
11397
+ }
11398
+ return {
11399
+ key,
11400
+ value: stringValue,
11401
+ original_key: key
11402
+ };
11403
+ });
11393
11404
  }
11394
- const formatter = new Intl.NumberFormat([], {
11395
- style: "percent",
11396
- minimumFractionDigits: 2
11397
- });
11398
- const formatPercentage = (value, isPercentageValue = false) => {
11399
- let val = value || 0;
11400
- if (!isPercentageValue) {
11401
- val = val / 100;
11405
+ function parseValues(values) {
11406
+ const metadata = values.metadata;
11407
+ const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
11408
+ if (isEmpty) {
11409
+ return null;
11402
11410
  }
11403
- return formatter.format(val);
11404
- };
11405
- function getPromotionIds(items, shippingMethods) {
11406
- const promotionIds = /* @__PURE__ */ new Set();
11407
- for (const item of items) {
11408
- if (item.adjustments) {
11409
- for (const adjustment of item.adjustments) {
11410
- if (adjustment.promotion_id) {
11411
- promotionIds.add(adjustment.promotion_id);
11412
- }
11413
- }
11411
+ const update = {};
11412
+ metadata.forEach((field) => {
11413
+ let key = field.key;
11414
+ let value = field.value;
11415
+ const disabled = field.disabled;
11416
+ if (!key || !value) {
11417
+ return;
11414
11418
  }
11415
- }
11416
- for (const shippingMethod of shippingMethods) {
11417
- if (shippingMethod.adjustments) {
11418
- for (const adjustment of shippingMethod.adjustments) {
11419
- if (adjustment.promotion_id) {
11420
- promotionIds.add(adjustment.promotion_id);
11421
- }
11419
+ if (disabled) {
11420
+ update[key] = value;
11421
+ return;
11422
+ }
11423
+ key = key.trim();
11424
+ value = value.trim();
11425
+ if (value === "true") {
11426
+ update[key] = true;
11427
+ } else if (value === "false") {
11428
+ update[key] = false;
11429
+ } else {
11430
+ const parsedNumber = parseFloat(value);
11431
+ if (!isNaN(parsedNumber)) {
11432
+ update[key] = parsedNumber;
11433
+ } else {
11434
+ update[key] = value;
11422
11435
  }
11423
11436
  }
11437
+ });
11438
+ return update;
11439
+ }
11440
+ function getHasUneditableRows(metadata) {
11441
+ if (!metadata) {
11442
+ return false;
11424
11443
  }
11425
- return Array.from(promotionIds);
11444
+ return Object.values(metadata).some(
11445
+ (value) => !EDITABLE_TYPES.includes(typeof value)
11446
+ );
11426
11447
  }
11427
- const CustomItems = () => {
11428
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11429
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
11430
- /* @__PURE__ */ jsx(CustomItemsForm, {})
11431
- ] });
11432
- };
11433
- const CustomItemsForm = () => {
11434
- const form = useForm({
11435
- resolver: zodResolver(schema$3)
11436
- });
11437
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11438
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
11439
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11440
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11441
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
11442
- ] }) })
11443
- ] }) });
11444
- };
11445
- const schema$3 = objectType({
11446
- email: stringType().email()
11447
- });
11448
11448
  const SalesChannel = () => {
11449
11449
  const { id } = useParams();
11450
11450
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -13057,29 +13057,29 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
- {
13061
- Component: Email,
13062
- path: "/draft-orders/:id/email"
13063
- },
13064
13060
  {
13065
13061
  Component: BillingAddress,
13066
13062
  path: "/draft-orders/:id/billing-address"
13067
13063
  },
13064
+ {
13065
+ Component: CustomItems,
13066
+ path: "/draft-orders/:id/custom-items"
13067
+ },
13068
13068
  {
13069
13069
  Component: Items,
13070
13070
  path: "/draft-orders/:id/items"
13071
13071
  },
13072
13072
  {
13073
- Component: Metadata,
13074
- path: "/draft-orders/:id/metadata"
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13075
13075
  },
13076
13076
  {
13077
13077
  Component: Promotions,
13078
13078
  path: "/draft-orders/:id/promotions"
13079
13079
  },
13080
13080
  {
13081
- Component: CustomItems,
13082
- path: "/draft-orders/:id/custom-items"
13081
+ Component: Metadata,
13082
+ path: "/draft-orders/:id/metadata"
13083
13083
  },
13084
13084
  {
13085
13085
  Component: SalesChannel,