@medusajs/draft-order 2.10.2-preview-20250904031023 → 2.10.2-preview-20250904090151

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.
@@ -9765,74 +9765,6 @@ const CustomItemsForm = () => {
9765
9765
  const schema$4 = objectType({
9766
9766
  email: stringType().email()
9767
9767
  });
9768
- const Email = () => {
9769
- const { id } = useParams();
9770
- const { order, isPending, isError, error } = useOrder(id, {
9771
- fields: "+email"
9772
- });
9773
- if (isError) {
9774
- throw error;
9775
- }
9776
- const isReady = !isPending && !!order;
9777
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9778
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9779
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9780
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9781
- ] }),
9782
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9783
- ] });
9784
- };
9785
- const EmailForm = ({ order }) => {
9786
- const form = useForm({
9787
- defaultValues: {
9788
- email: order.email ?? ""
9789
- },
9790
- resolver: zodResolver(schema$3)
9791
- });
9792
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9793
- const { handleSuccess } = useRouteModal();
9794
- const onSubmit = form.handleSubmit(async (data) => {
9795
- await mutateAsync(
9796
- { email: data.email },
9797
- {
9798
- onSuccess: () => {
9799
- handleSuccess();
9800
- },
9801
- onError: (error) => {
9802
- toast.error(error.message);
9803
- }
9804
- }
9805
- );
9806
- });
9807
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9808
- KeyboundForm,
9809
- {
9810
- className: "flex flex-1 flex-col overflow-hidden",
9811
- onSubmit,
9812
- children: [
9813
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9814
- Form$2.Field,
9815
- {
9816
- control: form.control,
9817
- name: "email",
9818
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9819
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9820
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9821
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9822
- ] })
9823
- }
9824
- ) }),
9825
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9826
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9827
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9828
- ] }) })
9829
- ]
9830
- }
9831
- ) });
9832
- };
9833
- const schema$3 = objectType({
9834
- email: stringType().email()
9835
- });
9836
9768
  const NumberInput = forwardRef(
9837
9769
  ({
9838
9770
  value,
@@ -10807,385 +10739,108 @@ const customItemSchema = objectType({
10807
10739
  quantity: numberType(),
10808
10740
  unit_price: unionType([numberType(), stringType()])
10809
10741
  });
10810
- const PROMOTION_QUERY_KEY = "promotions";
10811
- const promotionsQueryKeys = {
10812
- list: (query2) => [
10813
- PROMOTION_QUERY_KEY,
10814
- query2 ? query2 : void 0
10815
- ],
10816
- detail: (id, query2) => [
10817
- PROMOTION_QUERY_KEY,
10818
- id,
10819
- query2 ? query2 : void 0
10820
- ]
10821
- };
10822
- const usePromotions = (query2, options) => {
10823
- const { data, ...rest } = useQuery({
10824
- queryKey: promotionsQueryKeys.list(query2),
10825
- queryFn: async () => sdk.admin.promotion.list(query2),
10826
- ...options
10827
- });
10828
- return { ...data, ...rest };
10829
- };
10830
- const Promotions = () => {
10742
+ const InlineTip = forwardRef(
10743
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
10744
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10745
+ return /* @__PURE__ */ jsxs(
10746
+ "div",
10747
+ {
10748
+ ref,
10749
+ className: clx(
10750
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10751
+ className
10752
+ ),
10753
+ ...props,
10754
+ children: [
10755
+ /* @__PURE__ */ jsx(
10756
+ "div",
10757
+ {
10758
+ role: "presentation",
10759
+ className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10760
+ "bg-ui-tag-orange-icon": variant === "warning"
10761
+ })
10762
+ }
10763
+ ),
10764
+ /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
10765
+ /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10766
+ labelValue,
10767
+ ":"
10768
+ ] }),
10769
+ " ",
10770
+ children
10771
+ ] })
10772
+ ]
10773
+ }
10774
+ );
10775
+ }
10776
+ );
10777
+ InlineTip.displayName = "InlineTip";
10778
+ const MetadataFieldSchema = objectType({
10779
+ key: stringType(),
10780
+ disabled: booleanType().optional(),
10781
+ value: anyType()
10782
+ });
10783
+ const MetadataSchema = objectType({
10784
+ metadata: arrayType(MetadataFieldSchema)
10785
+ });
10786
+ const Metadata = () => {
10831
10787
  const { id } = useParams();
10832
- const {
10833
- order: preview,
10834
- isError: isPreviewError,
10835
- error: previewError
10836
- } = useOrderPreview(id, void 0);
10837
- useInitiateOrderEdit({ preview });
10838
- const { onCancel } = useCancelOrderEdit({ preview });
10839
- if (isPreviewError) {
10840
- throw previewError;
10788
+ const { order, isPending, isError, error } = useOrder(id, {
10789
+ fields: "metadata"
10790
+ });
10791
+ if (isError) {
10792
+ throw error;
10841
10793
  }
10842
- const isReady = !!preview;
10843
- return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
10844
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
10845
- isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
10794
+ const isReady = !isPending && !!order;
10795
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10796
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10797
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
10798
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10799
+ ] }),
10800
+ !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10846
10801
  ] });
10847
10802
  };
10848
- const PromotionForm = ({ preview }) => {
10849
- const { items, shipping_methods } = preview;
10850
- const [isSubmitting, setIsSubmitting] = useState(false);
10851
- const [comboboxValue, setComboboxValue] = useState("");
10803
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10804
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10805
+ const MetadataForm = ({ orderId, metadata }) => {
10852
10806
  const { handleSuccess } = useRouteModal();
10853
- const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
10854
- const promoCodes = getPromotionCodes(items, shipping_methods);
10855
- const { promotions, isPending, isError, error } = usePromotions(
10856
- {
10857
- code: promoCodes
10858
- },
10859
- {
10860
- enabled: !!promoCodes.length
10861
- }
10862
- );
10863
- const comboboxData = useComboboxData({
10864
- queryKey: ["promotions", "combobox", promoCodes],
10865
- queryFn: async (params) => {
10866
- return await sdk.admin.promotion.list({
10867
- ...params,
10868
- code: {
10869
- $nin: promoCodes
10870
- }
10871
- });
10807
+ const hasUneditableRows = getHasUneditableRows(metadata);
10808
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10809
+ const form = useForm({
10810
+ defaultValues: {
10811
+ metadata: getDefaultValues(metadata)
10872
10812
  },
10873
- getOptions: (data) => {
10874
- return data.promotions.map((promotion) => ({
10875
- label: promotion.code,
10876
- value: promotion.code
10877
- }));
10878
- }
10813
+ resolver: zodResolver(MetadataSchema)
10879
10814
  });
10880
- const add = async (value) => {
10881
- if (!value) {
10882
- return;
10883
- }
10884
- addPromotions(
10815
+ const handleSubmit = form.handleSubmit(async (data) => {
10816
+ const parsedData = parseValues(data);
10817
+ await mutateAsync(
10885
10818
  {
10886
- promo_codes: [value]
10819
+ metadata: parsedData
10887
10820
  },
10888
10821
  {
10889
- onError: (e) => {
10890
- toast.error(e.message);
10891
- comboboxData.onSearchValueChange("");
10892
- setComboboxValue("");
10893
- },
10894
10822
  onSuccess: () => {
10895
- comboboxData.onSearchValueChange("");
10896
- setComboboxValue("");
10823
+ toast.success("Metadata updated");
10824
+ handleSuccess();
10825
+ },
10826
+ onError: (error) => {
10827
+ toast.error(error.message);
10897
10828
  }
10898
10829
  }
10899
10830
  );
10900
- };
10901
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
10902
- const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
10903
- const onSubmit = async () => {
10904
- setIsSubmitting(true);
10905
- let requestSucceeded = false;
10906
- await requestOrderEdit(void 0, {
10907
- onError: (e) => {
10908
- toast.error(e.message);
10909
- },
10910
- onSuccess: () => {
10911
- requestSucceeded = true;
10912
- }
10913
- });
10914
- if (!requestSucceeded) {
10915
- setIsSubmitting(false);
10916
- return;
10917
- }
10918
- await confirmOrderEdit(void 0, {
10919
- onError: (e) => {
10920
- toast.error(e.message);
10921
- },
10922
- onSuccess: () => {
10923
- handleSuccess();
10924
- },
10925
- onSettled: () => {
10926
- setIsSubmitting(false);
10927
- }
10928
- });
10929
- };
10930
- if (isError) {
10931
- throw error;
10932
- }
10933
- return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
10934
- /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
10935
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
10936
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
10937
- /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
10938
- /* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
10939
- ] }),
10940
- /* @__PURE__ */ jsx(
10941
- Combobox,
10942
- {
10943
- id: "promotion-combobox",
10944
- "aria-describedby": "promotion-combobox-hint",
10945
- isFetchingNextPage: comboboxData.isFetchingNextPage,
10946
- fetchNextPage: comboboxData.fetchNextPage,
10947
- options: comboboxData.options,
10948
- onSearchValueChange: comboboxData.onSearchValueChange,
10949
- searchValue: comboboxData.searchValue,
10950
- disabled: comboboxData.disabled || isAddingPromotions,
10951
- onChange: add,
10952
- value: comboboxValue
10953
- }
10954
- )
10955
- ] }),
10956
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
10957
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
10958
- PromotionItem,
10959
- {
10960
- promotion,
10961
- orderId: preview.id,
10962
- isLoading: isPending
10963
- },
10964
- promotion.id
10965
- )) })
10966
- ] }) }),
10967
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10968
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10969
- /* @__PURE__ */ jsx(
10970
- Button,
10971
- {
10972
- size: "small",
10973
- type: "submit",
10974
- isLoading: isSubmitting || isAddingPromotions,
10975
- children: "Save"
10976
- }
10977
- )
10978
- ] }) })
10979
- ] });
10980
- };
10981
- const PromotionItem = ({
10982
- promotion,
10983
- orderId,
10984
- isLoading
10985
- }) => {
10986
- var _a;
10987
- const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
10988
- const onRemove = async () => {
10989
- removePromotions(
10990
- {
10991
- promo_codes: [promotion.code]
10992
- },
10993
- {
10994
- onError: (e) => {
10995
- toast.error(e.message);
10996
- }
10997
- }
10998
- );
10999
- };
11000
- const displayValue = getDisplayValue(promotion);
11001
- return /* @__PURE__ */ jsxs(
11002
- "div",
11003
- {
11004
- className: clx(
11005
- "px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
11006
- {
11007
- "animate-pulse": isLoading
11008
- }
11009
- ),
11010
- children: [
11011
- /* @__PURE__ */ jsxs("div", { children: [
11012
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11013
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
11014
- displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11015
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11016
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
11017
- ] }),
11018
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11019
- ] })
11020
- ] }),
11021
- /* @__PURE__ */ jsx(
11022
- IconButton,
11023
- {
11024
- size: "small",
11025
- type: "button",
11026
- variant: "transparent",
11027
- onClick: onRemove,
11028
- isLoading: isPending || isLoading,
11029
- children: /* @__PURE__ */ jsx(XMark, {})
11030
- }
11031
- )
11032
- ]
11033
- },
11034
- promotion.id
11035
- );
11036
- };
11037
- function getDisplayValue(promotion) {
11038
- var _a, _b, _c, _d;
11039
- const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11040
- if (!value) {
11041
- return null;
11042
- }
11043
- if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11044
- const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11045
- if (!currency) {
11046
- return null;
11047
- }
11048
- return getLocaleAmount(value, currency);
11049
- } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11050
- return formatPercentage(value);
11051
- }
11052
- return null;
11053
- }
11054
- const formatter = new Intl.NumberFormat([], {
11055
- style: "percent",
11056
- minimumFractionDigits: 2
11057
- });
11058
- const formatPercentage = (value, isPercentageValue = false) => {
11059
- let val = value || 0;
11060
- if (!isPercentageValue) {
11061
- val = val / 100;
11062
- }
11063
- return formatter.format(val);
11064
- };
11065
- function getPromotionCodes(items, shippingMethods) {
11066
- const codes = /* @__PURE__ */ new Set();
11067
- for (const item of items) {
11068
- if (item.adjustments) {
11069
- for (const adjustment of item.adjustments) {
11070
- if (adjustment.code) {
11071
- codes.add(adjustment.code);
11072
- }
11073
- }
11074
- }
11075
- }
11076
- for (const shippingMethod of shippingMethods) {
11077
- if (shippingMethod.adjustments) {
11078
- for (const adjustment of shippingMethod.adjustments) {
11079
- if (adjustment.code) {
11080
- codes.add(adjustment.code);
11081
- }
11082
- }
11083
- }
11084
- }
11085
- return Array.from(codes);
11086
- }
11087
- const InlineTip = forwardRef(
11088
- ({ variant = "tip", label, className, children, ...props }, ref) => {
11089
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
11090
- return /* @__PURE__ */ jsxs(
11091
- "div",
11092
- {
11093
- ref,
11094
- className: clx(
11095
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
11096
- className
11097
- ),
11098
- ...props,
11099
- children: [
11100
- /* @__PURE__ */ jsx(
11101
- "div",
11102
- {
11103
- role: "presentation",
11104
- className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
11105
- "bg-ui-tag-orange-icon": variant === "warning"
11106
- })
11107
- }
11108
- ),
11109
- /* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
11110
- /* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
11111
- labelValue,
11112
- ":"
11113
- ] }),
11114
- " ",
11115
- children
11116
- ] })
11117
- ]
11118
- }
11119
- );
11120
- }
11121
- );
11122
- InlineTip.displayName = "InlineTip";
11123
- const MetadataFieldSchema = objectType({
11124
- key: stringType(),
11125
- disabled: booleanType().optional(),
11126
- value: anyType()
11127
- });
11128
- const MetadataSchema = objectType({
11129
- metadata: arrayType(MetadataFieldSchema)
11130
- });
11131
- const Metadata = () => {
11132
- const { id } = useParams();
11133
- const { order, isPending, isError, error } = useOrder(id, {
11134
- fields: "metadata"
11135
- });
11136
- if (isError) {
11137
- throw error;
11138
- }
11139
- const isReady = !isPending && !!order;
11140
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11141
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11142
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
11143
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
11144
- ] }),
11145
- !isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
11146
- ] });
11147
- };
11148
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
11149
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
11150
- const MetadataForm = ({ orderId, metadata }) => {
11151
- const { handleSuccess } = useRouteModal();
11152
- const hasUneditableRows = getHasUneditableRows(metadata);
11153
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
11154
- const form = useForm({
11155
- defaultValues: {
11156
- metadata: getDefaultValues(metadata)
11157
- },
11158
- resolver: zodResolver(MetadataSchema)
11159
- });
11160
- const handleSubmit = form.handleSubmit(async (data) => {
11161
- const parsedData = parseValues(data);
11162
- await mutateAsync(
11163
- {
11164
- metadata: parsedData
11165
- },
11166
- {
11167
- onSuccess: () => {
11168
- toast.success("Metadata updated");
11169
- handleSuccess();
11170
- },
11171
- onError: (error) => {
11172
- toast.error(error.message);
11173
- }
11174
- }
11175
- );
11176
- });
11177
- const { fields, insert, remove } = useFieldArray({
11178
- control: form.control,
11179
- name: "metadata"
11180
- });
11181
- function deleteRow(index) {
11182
- remove(index);
11183
- if (fields.length === 1) {
11184
- insert(0, {
11185
- key: "",
11186
- value: "",
11187
- disabled: false
11188
- });
10831
+ });
10832
+ const { fields, insert, remove } = useFieldArray({
10833
+ control: form.control,
10834
+ name: "metadata"
10835
+ });
10836
+ function deleteRow(index) {
10837
+ remove(index);
10838
+ if (fields.length === 1) {
10839
+ insert(0, {
10840
+ key: "",
10841
+ value: "",
10842
+ disabled: false
10843
+ });
11189
10844
  }
11190
10845
  }
11191
10846
  function insertRow(index, position) {
@@ -11430,116 +11085,287 @@ function getHasUneditableRows(metadata) {
11430
11085
  if (!metadata) {
11431
11086
  return false;
11432
11087
  }
11433
- return Object.values(metadata).some(
11434
- (value) => !EDITABLE_TYPES.includes(typeof value)
11435
- );
11436
- }
11437
- const SalesChannel = () => {
11438
- const { id } = useParams();
11439
- const { draft_order, isPending, isError, error } = useDraftOrder(
11440
- id,
11088
+ return Object.values(metadata).some(
11089
+ (value) => !EDITABLE_TYPES.includes(typeof value)
11090
+ );
11091
+ }
11092
+ const PROMOTION_QUERY_KEY = "promotions";
11093
+ const promotionsQueryKeys = {
11094
+ list: (query2) => [
11095
+ PROMOTION_QUERY_KEY,
11096
+ query2 ? query2 : void 0
11097
+ ],
11098
+ detail: (id, query2) => [
11099
+ PROMOTION_QUERY_KEY,
11100
+ id,
11101
+ query2 ? query2 : void 0
11102
+ ]
11103
+ };
11104
+ const usePromotions = (query2, options) => {
11105
+ const { data, ...rest } = useQuery({
11106
+ queryKey: promotionsQueryKeys.list(query2),
11107
+ queryFn: async () => sdk.admin.promotion.list(query2),
11108
+ ...options
11109
+ });
11110
+ return { ...data, ...rest };
11111
+ };
11112
+ const Promotions = () => {
11113
+ const { id } = useParams();
11114
+ const {
11115
+ order: preview,
11116
+ isError: isPreviewError,
11117
+ error: previewError
11118
+ } = useOrderPreview(id, void 0);
11119
+ useInitiateOrderEdit({ preview });
11120
+ const { onCancel } = useCancelOrderEdit({ preview });
11121
+ if (isPreviewError) {
11122
+ throw previewError;
11123
+ }
11124
+ const isReady = !!preview;
11125
+ return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
11126
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
11127
+ isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
11128
+ ] });
11129
+ };
11130
+ const PromotionForm = ({ preview }) => {
11131
+ const { items, shipping_methods } = preview;
11132
+ const [isSubmitting, setIsSubmitting] = useState(false);
11133
+ const [comboboxValue, setComboboxValue] = useState("");
11134
+ const { handleSuccess } = useRouteModal();
11135
+ const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11136
+ const promoCodes = getPromotionCodes(items, shipping_methods);
11137
+ const { promotions, isPending, isError, error } = usePromotions(
11441
11138
  {
11442
- fields: "+sales_channel_id"
11139
+ code: promoCodes
11443
11140
  },
11444
11141
  {
11445
- enabled: !!id
11142
+ enabled: !!promoCodes.length
11446
11143
  }
11447
11144
  );
11145
+ const comboboxData = useComboboxData({
11146
+ queryKey: ["promotions", "combobox", promoCodes],
11147
+ queryFn: async (params) => {
11148
+ return await sdk.admin.promotion.list({
11149
+ ...params,
11150
+ code: {
11151
+ $nin: promoCodes
11152
+ }
11153
+ });
11154
+ },
11155
+ getOptions: (data) => {
11156
+ return data.promotions.map((promotion) => ({
11157
+ label: promotion.code,
11158
+ value: promotion.code
11159
+ }));
11160
+ }
11161
+ });
11162
+ const add = async (value) => {
11163
+ if (!value) {
11164
+ return;
11165
+ }
11166
+ addPromotions(
11167
+ {
11168
+ promo_codes: [value]
11169
+ },
11170
+ {
11171
+ onError: (e) => {
11172
+ toast.error(e.message);
11173
+ comboboxData.onSearchValueChange("");
11174
+ setComboboxValue("");
11175
+ },
11176
+ onSuccess: () => {
11177
+ comboboxData.onSearchValueChange("");
11178
+ setComboboxValue("");
11179
+ }
11180
+ }
11181
+ );
11182
+ };
11183
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11184
+ const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
11185
+ const onSubmit = async () => {
11186
+ setIsSubmitting(true);
11187
+ let requestSucceeded = false;
11188
+ await requestOrderEdit(void 0, {
11189
+ onError: (e) => {
11190
+ toast.error(e.message);
11191
+ },
11192
+ onSuccess: () => {
11193
+ requestSucceeded = true;
11194
+ }
11195
+ });
11196
+ if (!requestSucceeded) {
11197
+ setIsSubmitting(false);
11198
+ return;
11199
+ }
11200
+ await confirmOrderEdit(void 0, {
11201
+ onError: (e) => {
11202
+ toast.error(e.message);
11203
+ },
11204
+ onSuccess: () => {
11205
+ handleSuccess();
11206
+ },
11207
+ onSettled: () => {
11208
+ setIsSubmitting(false);
11209
+ }
11210
+ });
11211
+ };
11448
11212
  if (isError) {
11449
11213
  throw error;
11450
11214
  }
11451
- const ISrEADY = !!draft_order && !isPending;
11452
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11453
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11454
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11455
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11456
- ] }),
11457
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11215
+ return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
11216
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
11217
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
11218
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11219
+ /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
11220
+ /* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
11221
+ ] }),
11222
+ /* @__PURE__ */ jsx(
11223
+ Combobox,
11224
+ {
11225
+ id: "promotion-combobox",
11226
+ "aria-describedby": "promotion-combobox-hint",
11227
+ isFetchingNextPage: comboboxData.isFetchingNextPage,
11228
+ fetchNextPage: comboboxData.fetchNextPage,
11229
+ options: comboboxData.options,
11230
+ onSearchValueChange: comboboxData.onSearchValueChange,
11231
+ searchValue: comboboxData.searchValue,
11232
+ disabled: comboboxData.disabled || isAddingPromotions,
11233
+ onChange: add,
11234
+ value: comboboxValue
11235
+ }
11236
+ )
11237
+ ] }),
11238
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11239
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
11240
+ PromotionItem,
11241
+ {
11242
+ promotion,
11243
+ orderId: preview.id,
11244
+ isLoading: isPending
11245
+ },
11246
+ promotion.id
11247
+ )) })
11248
+ ] }) }),
11249
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11250
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11251
+ /* @__PURE__ */ jsx(
11252
+ Button,
11253
+ {
11254
+ size: "small",
11255
+ type: "submit",
11256
+ isLoading: isSubmitting || isAddingPromotions,
11257
+ children: "Save"
11258
+ }
11259
+ )
11260
+ ] }) })
11458
11261
  ] });
11459
11262
  };
11460
- const SalesChannelForm = ({ order }) => {
11461
- const form = useForm({
11462
- defaultValues: {
11463
- sales_channel_id: order.sales_channel_id || ""
11464
- },
11465
- resolver: zodResolver(schema$2)
11466
- });
11467
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11468
- const { handleSuccess } = useRouteModal();
11469
- const onSubmit = form.handleSubmit(async (data) => {
11470
- await mutateAsync(
11263
+ const PromotionItem = ({
11264
+ promotion,
11265
+ orderId,
11266
+ isLoading
11267
+ }) => {
11268
+ var _a;
11269
+ const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
11270
+ const onRemove = async () => {
11271
+ removePromotions(
11471
11272
  {
11472
- sales_channel_id: data.sales_channel_id
11273
+ promo_codes: [promotion.code]
11473
11274
  },
11474
11275
  {
11475
- onSuccess: () => {
11476
- toast.success("Sales channel updated");
11477
- handleSuccess();
11478
- },
11479
- onError: (error) => {
11480
- toast.error(error.message);
11276
+ onError: (e) => {
11277
+ toast.error(e.message);
11481
11278
  }
11482
11279
  }
11483
11280
  );
11484
- });
11485
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11486
- KeyboundForm,
11281
+ };
11282
+ const displayValue = getDisplayValue(promotion);
11283
+ return /* @__PURE__ */ jsxs(
11284
+ "div",
11487
11285
  {
11488
- className: "flex flex-1 flex-col overflow-hidden",
11489
- onSubmit,
11286
+ className: clx(
11287
+ "px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
11288
+ {
11289
+ "animate-pulse": isLoading
11290
+ }
11291
+ ),
11490
11292
  children: [
11491
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11492
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11493
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11494
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11495
- ] }) })
11496
- ]
11497
- }
11498
- ) });
11499
- };
11500
- const SalesChannelField = ({ control, order }) => {
11501
- const salesChannels = useComboboxData({
11502
- queryFn: async (params) => {
11503
- return await sdk.admin.salesChannel.list(params);
11504
- },
11505
- queryKey: ["sales-channels"],
11506
- getOptions: (data) => {
11507
- return data.sales_channels.map((salesChannel) => ({
11508
- label: salesChannel.name,
11509
- value: salesChannel.id
11510
- }));
11511
- },
11512
- defaultValue: order.sales_channel_id || void 0
11513
- });
11514
- return /* @__PURE__ */ jsx(
11515
- Form$2.Field,
11516
- {
11517
- control,
11518
- name: "sales_channel_id",
11519
- render: ({ field }) => {
11520
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11521
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11522
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11523
- Combobox,
11524
- {
11525
- options: salesChannels.options,
11526
- fetchNextPage: salesChannels.fetchNextPage,
11527
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11528
- searchValue: salesChannels.searchValue,
11529
- onSearchValueChange: salesChannels.onSearchValueChange,
11530
- placeholder: "Select sales channel",
11531
- ...field
11532
- }
11533
- ) }),
11534
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11535
- ] });
11536
- }
11537
- }
11293
+ /* @__PURE__ */ jsxs("div", { children: [
11294
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11295
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
11296
+ displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11297
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11298
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
11299
+ ] }),
11300
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11301
+ ] })
11302
+ ] }),
11303
+ /* @__PURE__ */ jsx(
11304
+ IconButton,
11305
+ {
11306
+ size: "small",
11307
+ type: "button",
11308
+ variant: "transparent",
11309
+ onClick: onRemove,
11310
+ isLoading: isPending || isLoading,
11311
+ children: /* @__PURE__ */ jsx(XMark, {})
11312
+ }
11313
+ )
11314
+ ]
11315
+ },
11316
+ promotion.id
11538
11317
  );
11539
11318
  };
11540
- const schema$2 = objectType({
11541
- sales_channel_id: stringType().min(1)
11319
+ function getDisplayValue(promotion) {
11320
+ var _a, _b, _c, _d;
11321
+ const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11322
+ if (!value) {
11323
+ return null;
11324
+ }
11325
+ if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11326
+ const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11327
+ if (!currency) {
11328
+ return null;
11329
+ }
11330
+ return getLocaleAmount(value, currency);
11331
+ } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11332
+ return formatPercentage(value);
11333
+ }
11334
+ return null;
11335
+ }
11336
+ const formatter = new Intl.NumberFormat([], {
11337
+ style: "percent",
11338
+ minimumFractionDigits: 2
11542
11339
  });
11340
+ const formatPercentage = (value, isPercentageValue = false) => {
11341
+ let val = value || 0;
11342
+ if (!isPercentageValue) {
11343
+ val = val / 100;
11344
+ }
11345
+ return formatter.format(val);
11346
+ };
11347
+ function getPromotionCodes(items, shippingMethods) {
11348
+ const codes = /* @__PURE__ */ new Set();
11349
+ for (const item of items) {
11350
+ if (item.adjustments) {
11351
+ for (const adjustment of item.adjustments) {
11352
+ if (adjustment.code) {
11353
+ codes.add(adjustment.code);
11354
+ }
11355
+ }
11356
+ }
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
+ }
11364
+ }
11365
+ }
11366
+ }
11367
+ return Array.from(codes);
11368
+ }
11543
11369
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11544
11370
  const Shipping = () => {
11545
11371
  var _a;
@@ -12347,6 +12173,112 @@ const CustomAmountField = ({
12347
12173
  }
12348
12174
  );
12349
12175
  };
12176
+ const SalesChannel = () => {
12177
+ const { id } = useParams();
12178
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12179
+ id,
12180
+ {
12181
+ fields: "+sales_channel_id"
12182
+ },
12183
+ {
12184
+ enabled: !!id
12185
+ }
12186
+ );
12187
+ if (isError) {
12188
+ throw error;
12189
+ }
12190
+ const ISrEADY = !!draft_order && !isPending;
12191
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12192
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12193
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12194
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12195
+ ] }),
12196
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12197
+ ] });
12198
+ };
12199
+ const SalesChannelForm = ({ order }) => {
12200
+ const form = useForm({
12201
+ defaultValues: {
12202
+ sales_channel_id: order.sales_channel_id || ""
12203
+ },
12204
+ resolver: zodResolver(schema$3)
12205
+ });
12206
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12207
+ const { handleSuccess } = useRouteModal();
12208
+ const onSubmit = form.handleSubmit(async (data) => {
12209
+ await mutateAsync(
12210
+ {
12211
+ sales_channel_id: data.sales_channel_id
12212
+ },
12213
+ {
12214
+ onSuccess: () => {
12215
+ toast.success("Sales channel updated");
12216
+ handleSuccess();
12217
+ },
12218
+ onError: (error) => {
12219
+ toast.error(error.message);
12220
+ }
12221
+ }
12222
+ );
12223
+ });
12224
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12225
+ KeyboundForm,
12226
+ {
12227
+ className: "flex flex-1 flex-col overflow-hidden",
12228
+ onSubmit,
12229
+ children: [
12230
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12231
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12232
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12233
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12234
+ ] }) })
12235
+ ]
12236
+ }
12237
+ ) });
12238
+ };
12239
+ const SalesChannelField = ({ control, order }) => {
12240
+ const salesChannels = useComboboxData({
12241
+ queryFn: async (params) => {
12242
+ return await sdk.admin.salesChannel.list(params);
12243
+ },
12244
+ queryKey: ["sales-channels"],
12245
+ getOptions: (data) => {
12246
+ return data.sales_channels.map((salesChannel) => ({
12247
+ label: salesChannel.name,
12248
+ value: salesChannel.id
12249
+ }));
12250
+ },
12251
+ defaultValue: order.sales_channel_id || void 0
12252
+ });
12253
+ return /* @__PURE__ */ jsx(
12254
+ Form$2.Field,
12255
+ {
12256
+ control,
12257
+ name: "sales_channel_id",
12258
+ render: ({ field }) => {
12259
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12260
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12261
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12262
+ Combobox,
12263
+ {
12264
+ options: salesChannels.options,
12265
+ fetchNextPage: salesChannels.fetchNextPage,
12266
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12267
+ searchValue: salesChannels.searchValue,
12268
+ onSearchValueChange: salesChannels.onSearchValueChange,
12269
+ placeholder: "Select sales channel",
12270
+ ...field
12271
+ }
12272
+ ) }),
12273
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12274
+ ] });
12275
+ }
12276
+ }
12277
+ );
12278
+ };
12279
+ const schema$3 = objectType({
12280
+ sales_channel_id: stringType().min(1)
12281
+ });
12350
12282
  const ShippingAddress = () => {
12351
12283
  const { id } = useParams();
12352
12284
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12379,7 +12311,7 @@ const ShippingAddressForm = ({ order }) => {
12379
12311
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12380
12312
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12381
12313
  },
12382
- resolver: zodResolver(schema$1)
12314
+ resolver: zodResolver(schema$2)
12383
12315
  });
12384
12316
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12385
12317
  const { handleSuccess } = useRouteModal();
@@ -12549,7 +12481,7 @@ const ShippingAddressForm = ({ order }) => {
12549
12481
  }
12550
12482
  ) });
12551
12483
  };
12552
- const schema$1 = addressSchema;
12484
+ const schema$2 = addressSchema;
12553
12485
  const TransferOwnership = () => {
12554
12486
  const { id } = useParams();
12555
12487
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12573,7 +12505,7 @@ const TransferOwnershipForm = ({ order }) => {
12573
12505
  defaultValues: {
12574
12506
  customer_id: order.customer_id || ""
12575
12507
  },
12576
- resolver: zodResolver(schema)
12508
+ resolver: zodResolver(schema$1)
12577
12509
  });
12578
12510
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12579
12511
  const { handleSuccess } = useRouteModal();
@@ -13023,9 +12955,77 @@ const Illustration = () => {
13023
12955
  }
13024
12956
  );
13025
12957
  };
13026
- const schema = objectType({
12958
+ const schema$1 = objectType({
13027
12959
  customer_id: stringType().min(1)
13028
12960
  });
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;
12970
+ 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 })
12976
+ ] });
12977
+ };
12978
+ const EmailForm = ({ order }) => {
12979
+ const form = useForm({
12980
+ defaultValues: {
12981
+ email: order.email ?? ""
12982
+ },
12983
+ resolver: zodResolver(schema)
12984
+ });
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
+ ) });
13025
+ };
13026
+ const schema = objectType({
13027
+ email: stringType().email()
13028
+ });
13029
13029
  const widgetModule = { widgets: [] };
13030
13030
  const routeModule = {
13031
13031
  routes: [
@@ -13054,30 +13054,26 @@ const routeModule = {
13054
13054
  Component: CustomItems,
13055
13055
  path: "/draft-orders/:id/custom-items"
13056
13056
  },
13057
- {
13058
- Component: Email,
13059
- path: "/draft-orders/:id/email"
13060
- },
13061
13057
  {
13062
13058
  Component: Items,
13063
13059
  path: "/draft-orders/:id/items"
13064
13060
  },
13065
- {
13066
- Component: Promotions,
13067
- path: "/draft-orders/:id/promotions"
13068
- },
13069
13061
  {
13070
13062
  Component: Metadata,
13071
13063
  path: "/draft-orders/:id/metadata"
13072
13064
  },
13073
13065
  {
13074
- Component: SalesChannel,
13075
- path: "/draft-orders/:id/sales-channel"
13066
+ Component: Promotions,
13067
+ path: "/draft-orders/:id/promotions"
13076
13068
  },
13077
13069
  {
13078
13070
  Component: Shipping,
13079
13071
  path: "/draft-orders/:id/shipping"
13080
13072
  },
13073
+ {
13074
+ Component: SalesChannel,
13075
+ path: "/draft-orders/:id/sales-channel"
13076
+ },
13081
13077
  {
13082
13078
  Component: ShippingAddress,
13083
13079
  path: "/draft-orders/:id/shipping-address"
@@ -13085,6 +13081,10 @@ const routeModule = {
13085
13081
  {
13086
13082
  Component: TransferOwnership,
13087
13083
  path: "/draft-orders/:id/transfer-ownership"
13084
+ },
13085
+ {
13086
+ Component: Email,
13087
+ path: "/draft-orders/:id/email"
13088
13088
  }
13089
13089
  ]
13090
13090
  }