Use proper submit return type
This commit is contained in:
parent
3de9ae58df
commit
b2e6baf4e9
4 changed files with 10 additions and 8 deletions
|
@ -10,6 +10,7 @@ import SeoForm from "@saleor/components/SeoForm";
|
|||
import VisibilityCard from "@saleor/components/VisibilityCard";
|
||||
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
|
||||
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||
import { sectionNames } from "@saleor/intl";
|
||||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
@ -23,7 +24,7 @@ export interface CollectionCreatePageProps {
|
|||
errors: ProductErrorFragment[];
|
||||
saveButtonBarState: ConfirmButtonTransitionState;
|
||||
onBack: () => void;
|
||||
onSubmit: (data: CollectionCreateData) => Promise<any[]>;
|
||||
onSubmit: (data: CollectionCreateData) => SubmitPromise;
|
||||
}
|
||||
|
||||
const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { OutputData } from "@editorjs/editorjs";
|
||||
import { MetadataFormData } from "@saleor/components/Metadata";
|
||||
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
||||
import useForm, { FormChange, SubmitPromise } from "@saleor/hooks/useForm";
|
||||
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||
import useRichText from "@saleor/utils/richText/useRichText";
|
||||
|
@ -38,11 +38,11 @@ export interface UseCollectionCreateFormResult {
|
|||
|
||||
export interface CollectionCreateFormProps {
|
||||
children: (props: UseCollectionCreateFormResult) => React.ReactNode;
|
||||
onSubmit: (data: CollectionCreateData) => Promise<any[]>;
|
||||
onSubmit: (data: CollectionCreateData) => SubmitPromise;
|
||||
}
|
||||
|
||||
function useCollectionCreateForm(
|
||||
onSubmit: (data: CollectionCreateData) => Promise<any[]>
|
||||
onSubmit: (data: CollectionCreateData) => SubmitPromise
|
||||
): UseCollectionCreateFormResult {
|
||||
const [changed, setChanged] = React.useState(false);
|
||||
const triggerChange = () => setChanged(true);
|
||||
|
|
|
@ -13,6 +13,7 @@ import SeoForm from "@saleor/components/SeoForm";
|
|||
import VisibilityCard from "@saleor/components/VisibilityCard";
|
||||
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
|
||||
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||
import { sectionNames } from "@saleor/intl";
|
||||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
@ -35,7 +36,7 @@ export interface CollectionDetailsPageProps extends PageListProps, ListActions {
|
|||
onImageDelete: () => void;
|
||||
onImageUpload: (file: File) => void;
|
||||
onProductUnassign: (id: string, event: React.MouseEvent<any>) => void;
|
||||
onSubmit: (data: CollectionUpdateData) => Promise<any>;
|
||||
onSubmit: (data: CollectionUpdateData) => SubmitPromise;
|
||||
}
|
||||
|
||||
const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { OutputData } from "@editorjs/editorjs";
|
||||
import { MetadataFormData } from "@saleor/components/Metadata";
|
||||
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
||||
import useForm, { FormChange, SubmitPromise } from "@saleor/hooks/useForm";
|
||||
import { PageDetails_page } from "@saleor/pages/types/PageDetails";
|
||||
import getPublicationData from "@saleor/utils/data/getPublicationData";
|
||||
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
||||
|
@ -38,12 +38,12 @@ export interface UsePageUpdateFormResult {
|
|||
export interface PageFormProps {
|
||||
children: (props: UsePageUpdateFormResult) => React.ReactNode;
|
||||
page: PageDetails_page;
|
||||
onSubmit: (data: PageData) => Promise<any[]>;
|
||||
onSubmit: (data: PageData) => SubmitPromise;
|
||||
}
|
||||
|
||||
function usePageForm(
|
||||
page: PageDetails_page,
|
||||
onSubmit: (data: PageData) => Promise<any[]>
|
||||
onSubmit: (data: PageData) => SubmitPromise
|
||||
): UsePageUpdateFormResult {
|
||||
const [changed, setChanged] = React.useState(false);
|
||||
const triggerChange = () => setChanged(true);
|
||||
|
|
Loading…
Reference in a new issue