Use dedicated type to return error promise
This commit is contained in:
parent
3b5c2b26c1
commit
6988316fbc
18 changed files with 39 additions and 24 deletions
|
@ -10,6 +10,7 @@ import Grid from "@saleor/components/Grid";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
|
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { PermissionEnum } from "@saleor/types/globalTypes";
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import { getFormErrors } from "@saleor/utils/errors";
|
import { getFormErrors } from "@saleor/utils/errors";
|
||||||
|
@ -42,7 +43,7 @@ export interface CustomAppDetailsPageProps {
|
||||||
onTokenDelete: (id: string) => void;
|
onTokenDelete: (id: string) => void;
|
||||||
onTokenClose: () => void;
|
onTokenClose: () => void;
|
||||||
onTokenCreate: () => void;
|
onTokenCreate: () => void;
|
||||||
onSubmit: (data: CustomAppDetailsPageFormData) => Promise<any[]>;
|
onSubmit: (data: CustomAppDetailsPageFormData) => SubmitPromise;
|
||||||
onWebhookCreate: () => void;
|
onWebhookCreate: () => void;
|
||||||
onWebhookRemove: (id: string) => void;
|
onWebhookRemove: (id: string) => void;
|
||||||
navigateToWebhookDetails: (id: string) => () => void;
|
navigateToWebhookDetails: (id: string) => () => void;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import SeoForm from "@saleor/components/SeoForm";
|
import SeoForm from "@saleor/components/SeoForm";
|
||||||
import { Tab, TabContainer } from "@saleor/components/Tab";
|
import { Tab, TabContainer } from "@saleor/components/Tab";
|
||||||
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
|
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
||||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||||
|
@ -61,7 +62,7 @@ export interface CategoryUpdatePageProps
|
||||||
};
|
};
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
onImageDelete: () => void;
|
onImageDelete: () => void;
|
||||||
onSubmit: (data: FormData) => Promise<any[]>;
|
onSubmit: (data: FormData) => SubmitPromise;
|
||||||
onImageUpload(file: File);
|
onImageUpload(file: File);
|
||||||
onNextPage();
|
onNextPage();
|
||||||
onPreviousPage();
|
onPreviousPage();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import useForm, { UseFormResult } from "@saleor/hooks/useForm";
|
import useForm, { SubmitPromise, UseFormResult } from "@saleor/hooks/useForm";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export interface FormProps<T> {
|
export interface FormProps<T> {
|
||||||
|
@ -6,7 +6,7 @@ export interface FormProps<T> {
|
||||||
confirmLeave?: boolean;
|
confirmLeave?: boolean;
|
||||||
initial?: T;
|
initial?: T;
|
||||||
resetOnSubmit?: boolean;
|
resetOnSubmit?: boolean;
|
||||||
onSubmit?: (data: T) => Promise<any[]> | void;
|
onSubmit?: (data: T) => SubmitPromise | void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Form<T>(props: FormProps<T>) {
|
function Form<T>(props: FormProps<T>) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Grid from "@saleor/components/Grid";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment";
|
import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
@ -33,7 +34,7 @@ export interface CustomerDetailsPageProps {
|
||||||
errors: AccountErrorFragment[];
|
errors: AccountErrorFragment[];
|
||||||
saveButtonBar: ConfirmButtonTransitionState;
|
saveButtonBar: ConfirmButtonTransitionState;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onSubmit: (data: CustomerDetailsPageFormData) => Promise<any[]>;
|
onSubmit: (data: CustomerDetailsPageFormData) => SubmitPromise;
|
||||||
onViewAllOrdersClick: () => void;
|
onViewAllOrdersClick: () => void;
|
||||||
onRowClick: (id: string) => void;
|
onRowClick: (id: string) => void;
|
||||||
onAddressManageClick: () => void;
|
onAddressManageClick: () => void;
|
||||||
|
|
|
@ -10,6 +10,7 @@ export interface ChangeEvent<TData = any> {
|
||||||
value: TData;
|
value: TData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
export type SubmitPromise = Promise<any[]>;
|
||||||
|
|
||||||
export type FormChange = (event: ChangeEvent, cb?: () => void) => void;
|
export type FormChange = (event: ChangeEvent, cb?: () => void) => void;
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ function handleRefresh<T extends FormData>(
|
||||||
|
|
||||||
function useForm<T extends FormData>(
|
function useForm<T extends FormData>(
|
||||||
initial: T,
|
initial: T,
|
||||||
onSubmit?: (data: T) => Promise<any[]> | void
|
onSubmit?: (data: T) => SubmitPromise | void
|
||||||
): UseFormResult<T> {
|
): UseFormResult<T> {
|
||||||
const [hasChanged, setChanged] = useState(false);
|
const [hasChanged, setChanged] = useState(false);
|
||||||
const [data, setData] = useStateFromProps(initial, {
|
const [data, setData] = useStateFromProps(initial, {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Form from "@saleor/components/Form";
|
||||||
import Grid from "@saleor/components/Grid";
|
import Grid from "@saleor/components/Grid";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment";
|
import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
@ -36,7 +37,7 @@ export interface MenuDetailsPageProps {
|
||||||
onItemAdd: () => void;
|
onItemAdd: () => void;
|
||||||
onItemClick: (id: string, type: MenuItemType) => void;
|
onItemClick: (id: string, type: MenuItemType) => void;
|
||||||
onItemEdit: (id: string) => void;
|
onItemEdit: (id: string) => void;
|
||||||
onSubmit: (data: MenuDetailsSubmitData) => Promise<any[]>;
|
onSubmit: (data: MenuDetailsSubmitData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuDetailsPage: React.FC<MenuDetailsPageProps> = ({
|
const MenuDetailsPage: React.FC<MenuDetailsPageProps> = ({
|
||||||
|
|
|
@ -12,6 +12,7 @@ import Metadata, { MetadataFormData } from "@saleor/components/Metadata";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { UserPermissionProps } from "@saleor/types";
|
import { UserPermissionProps } from "@saleor/types";
|
||||||
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
||||||
|
@ -74,7 +75,7 @@ export interface OrderDetailsPageProps extends UserPermissionProps {
|
||||||
onInvoiceClick(invoiceId: string);
|
onInvoiceClick(invoiceId: string);
|
||||||
onInvoiceGenerate();
|
onInvoiceGenerate();
|
||||||
onInvoiceSend(invoiceId: string);
|
onInvoiceSend(invoiceId: string);
|
||||||
onSubmit(data: MetadataFormData): Promise<any[]>;
|
onSubmit(data: MetadataFormData): SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OrderDetailsPage: React.FC<OrderDetailsPageProps> = props => {
|
const OrderDetailsPage: React.FC<OrderDetailsPageProps> = props => {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import SeoForm from "@saleor/components/SeoForm";
|
||||||
import VisibilityCard from "@saleor/components/VisibilityCard";
|
import VisibilityCard from "@saleor/components/VisibilityCard";
|
||||||
import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment";
|
import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment";
|
||||||
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
||||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||||
|
@ -45,7 +46,7 @@ export interface PageDetailsPageProps {
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onRemove: () => void;
|
onRemove: () => void;
|
||||||
onSubmit: (data: PageDetailsPageFormData) => Promise<any[]>;
|
onSubmit: (data: PageDetailsPageFormData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
|
const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
|
||||||
|
|
|
@ -9,6 +9,7 @@ import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
|
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
|
||||||
import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment";
|
import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { MembersListUrlSortField } from "@saleor/permissionGroups/urls";
|
import { MembersListUrlSortField } from "@saleor/permissionGroups/urls";
|
||||||
import {
|
import {
|
||||||
|
@ -56,7 +57,7 @@ export interface PermissionGroupDetailsPageProps
|
||||||
onAssign: () => void;
|
onAssign: () => void;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onUnassign: (ids: string[]) => void;
|
onUnassign: (ids: string[]) => void;
|
||||||
onSubmit: (data: PermissionGroupDetailsPageFormData) => Promise<any[]>;
|
onSubmit: (data: PermissionGroupDetailsPageFormData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PermissionGroupDetailsPage: React.FC<PermissionGroupDetailsPageProps> = ({
|
const PermissionGroupDetailsPage: React.FC<PermissionGroupDetailsPageProps> = ({
|
||||||
|
|
|
@ -9,7 +9,7 @@ import Metadata from "@saleor/components/Metadata/Metadata";
|
||||||
import { MetadataFormData } from "@saleor/components/Metadata/types";
|
import { MetadataFormData } from "@saleor/components/Metadata/types";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { ChangeEvent, FormChange } from "@saleor/hooks/useForm";
|
import { ChangeEvent, FormChange, SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { maybe } from "@saleor/misc";
|
import { maybe } from "@saleor/misc";
|
||||||
|
@ -61,7 +61,7 @@ export interface ProductTypeDetailsPageProps {
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onHasVariantsToggle: (hasVariants: boolean) => void;
|
onHasVariantsToggle: (hasVariants: boolean) => void;
|
||||||
onSubmit: (data: ProductTypeForm) => Promise<any[]>;
|
onSubmit: (data: ProductTypeForm) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTaxTypeChange(
|
function handleTaxTypeChange(
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { ProductErrorWithAttributesFragment } from "@saleor/fragments/types/Prod
|
||||||
import { TaxTypeFragment } from "@saleor/fragments/types/TaxTypeFragment";
|
import { TaxTypeFragment } from "@saleor/fragments/types/TaxTypeFragment";
|
||||||
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
|
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
|
||||||
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { maybe } from "@saleor/misc";
|
import { maybe } from "@saleor/misc";
|
||||||
|
@ -61,7 +62,7 @@ export interface ProductUpdatePageProps extends ListActions {
|
||||||
onVariantShow: (id: string) => () => void;
|
onVariantShow: (id: string) => () => void;
|
||||||
onVariantReorder: ReorderAction;
|
onVariantReorder: ReorderAction;
|
||||||
onImageDelete: (id: string) => () => void;
|
onImageDelete: (id: string) => () => void;
|
||||||
onSubmit: (data: ProductUpdatePageSubmitData) => Promise<any[]>;
|
onSubmit: (data: ProductUpdatePageSubmitData) => SubmitPromise;
|
||||||
onBack?();
|
onBack?();
|
||||||
onDelete();
|
onDelete();
|
||||||
onImageEdit?(id: string);
|
onImageEdit?(id: string);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { MetadataFormData } from "@saleor/components/Metadata";
|
import { MetadataFormData } from "@saleor/components/Metadata";
|
||||||
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
||||||
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
|
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
|
||||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
import useForm, { FormChange, SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useFormset, {
|
import useFormset, {
|
||||||
FormsetChange,
|
FormsetChange,
|
||||||
FormsetData
|
FormsetData
|
||||||
|
@ -96,7 +96,7 @@ export interface UseProductUpdateFormOpts
|
||||||
export interface ProductUpdateFormProps extends UseProductUpdateFormOpts {
|
export interface ProductUpdateFormProps extends UseProductUpdateFormOpts {
|
||||||
children: (props: UseProductUpdateFormResult) => React.ReactNode;
|
children: (props: UseProductUpdateFormResult) => React.ReactNode;
|
||||||
product: ProductDetails_product;
|
product: ProductDetails_product;
|
||||||
onSubmit: (data: ProductUpdateSubmitData) => Promise<any[]>;
|
onSubmit: (data: ProductUpdateSubmitData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAvailabilityData = ({
|
const getAvailabilityData = ({
|
||||||
|
@ -144,7 +144,7 @@ const getMetadata = (
|
||||||
|
|
||||||
function useProductUpdateForm(
|
function useProductUpdateForm(
|
||||||
product: ProductDetails_product,
|
product: ProductDetails_product,
|
||||||
onSubmit: (data: ProductUpdateSubmitData) => Promise<any[]>,
|
onSubmit: (data: ProductUpdateSubmitData) => SubmitPromise,
|
||||||
opts: UseProductUpdateFormOpts
|
opts: UseProductUpdateFormOpts
|
||||||
): UseProductUpdateFormResult {
|
): UseProductUpdateFormResult {
|
||||||
const [changed, setChanged] = React.useState(false);
|
const [changed, setChanged] = React.useState(false);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { MetadataFormData } from "@saleor/components/Metadata";
|
import { MetadataFormData } from "@saleor/components/Metadata";
|
||||||
import { ProductVariant } from "@saleor/fragments/types/ProductVariant";
|
import { ProductVariant } from "@saleor/fragments/types/ProductVariant";
|
||||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
import useForm, { FormChange, SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useFormset, {
|
import useFormset, {
|
||||||
FormsetChange,
|
FormsetChange,
|
||||||
FormsetData
|
FormsetData
|
||||||
|
@ -57,12 +57,12 @@ export interface ProductVariantUpdateFormProps
|
||||||
extends UseProductVariantUpdateFormOpts {
|
extends UseProductVariantUpdateFormOpts {
|
||||||
children: (props: UseProductVariantUpdateFormResult) => React.ReactNode;
|
children: (props: UseProductVariantUpdateFormResult) => React.ReactNode;
|
||||||
variant: ProductVariant;
|
variant: ProductVariant;
|
||||||
onSubmit: (data: ProductVariantUpdateSubmitData) => Promise<any[]>;
|
onSubmit: (data: ProductVariantUpdateSubmitData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function useProductVariantUpdateForm(
|
function useProductVariantUpdateForm(
|
||||||
variant: ProductVariant,
|
variant: ProductVariant,
|
||||||
onSubmit: (data: ProductVariantUpdateSubmitData) => Promise<any[]>,
|
onSubmit: (data: ProductVariantUpdateSubmitData) => SubmitPromise,
|
||||||
opts: UseProductVariantUpdateFormOpts
|
opts: UseProductVariantUpdateFormOpts
|
||||||
): UseProductVariantUpdateFormResult {
|
): UseProductVariantUpdateFormResult {
|
||||||
const [changed, setChanged] = React.useState(false);
|
const [changed, setChanged] = React.useState(false);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
ShippingZoneDetailsFragment,
|
ShippingZoneDetailsFragment,
|
||||||
ShippingZoneDetailsFragment_warehouses
|
ShippingZoneDetailsFragment_warehouses
|
||||||
} from "@saleor/fragments/types/ShippingZoneDetailsFragment";
|
} from "@saleor/fragments/types/ShippingZoneDetailsFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
|
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -46,7 +47,7 @@ export interface ShippingZoneDetailsPageProps
|
||||||
onPriceRateAdd: () => void;
|
onPriceRateAdd: () => void;
|
||||||
onPriceRateEdit: (id: string) => void;
|
onPriceRateEdit: (id: string) => void;
|
||||||
onRateRemove: (rateId: string) => void;
|
onRateRemove: (rateId: string) => void;
|
||||||
onSubmit: (data: FormData) => Promise<any[]>;
|
onSubmit: (data: FormData) => SubmitPromise;
|
||||||
onWarehouseAdd: () => void;
|
onWarehouseAdd: () => void;
|
||||||
onWeightRateAdd: () => void;
|
onWeightRateAdd: () => void;
|
||||||
onWeightRateEdit: (id: string) => void;
|
onWeightRateEdit: (id: string) => void;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment";
|
import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment";
|
||||||
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { commonMessages, sectionNames } from "@saleor/intl";
|
import { commonMessages, sectionNames } from "@saleor/intl";
|
||||||
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
||||||
|
@ -54,7 +55,7 @@ export interface SiteSettingsPageProps {
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onKeyAdd: () => void;
|
onKeyAdd: () => void;
|
||||||
onKeyRemove: (keyType: AuthorizationKeyType) => void;
|
onKeyRemove: (keyType: AuthorizationKeyType) => void;
|
||||||
onSubmit: (data: SiteSettingsPageFormData) => Promise<any[]>;
|
onSubmit: (data: SiteSettingsPageFormData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function areAddressInputFieldsModified(
|
export function areAddressInputFieldsModified(
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocomplet
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment";
|
import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useLocale from "@saleor/hooks/useLocale";
|
import useLocale from "@saleor/hooks/useLocale";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
@ -50,7 +51,7 @@ export interface StaffDetailsPageProps extends SearchPageProps {
|
||||||
onChangePassword: () => void;
|
onChangePassword: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onImageDelete: () => void;
|
onImageDelete: () => void;
|
||||||
onSubmit: (data: StaffDetailsFormData) => Promise<any[]>;
|
onSubmit: (data: StaffDetailsFormData) => SubmitPromise;
|
||||||
onImageUpload(file: File);
|
onImageUpload(file: File);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
|
|
||||||
async function handleFormSubmit<T>(
|
async function handleFormSubmit<T>(
|
||||||
data: T,
|
data: T,
|
||||||
onSubmit: (data: T) => Promise<any[]>,
|
onSubmit: (data: T) => SubmitPromise,
|
||||||
setChanged: (changed: boolean) => void
|
setChanged: (changed: boolean) => void
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const errors = await onSubmit(data);
|
const errors = await onSubmit(data);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"
|
||||||
import { AddressTypeInput } from "@saleor/customers/types";
|
import { AddressTypeInput } from "@saleor/customers/types";
|
||||||
import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment";
|
import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment";
|
||||||
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
||||||
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { findValueInEnum, maybe } from "@saleor/misc";
|
import { findValueInEnum, maybe } from "@saleor/misc";
|
||||||
|
@ -36,7 +37,7 @@ export interface WarehouseDetailsPageProps {
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onShippingZoneClick: (id: string) => void;
|
onShippingZoneClick: (id: string) => void;
|
||||||
onSubmit: (data: WarehouseDetailsPageFormData) => Promise<any[]>;
|
onSubmit: (data: WarehouseDetailsPageFormData) => SubmitPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
||||||
|
|
Loading…
Reference in a new issue