@appello/services
Version:
Services package with api / graphql
16 lines (15 loc) • 1.01 kB
TypeScript
import { ResponseErrors } from '@appello/common';
import { FieldPath, FieldValues, UseFormSetError } from 'react-hook-form';
interface CreateProcessApiErrorParams {
onGlobalError: (message: string, errors: ResponseErrors) => void;
onUnknownErrors: (message: string, errors: ResponseErrors) => void;
onManualHandleError?: (errors: ResponseErrors) => void;
}
export interface ProcessApiErrorParams<TFormValues extends FieldValues> extends Partial<CreateProcessApiErrorParams> {
errors: ResponseErrors;
fields?: Record<string, FieldPath<TFormValues>> | FieldPath<TFormValues>[];
setFormError?: UseFormSetError<TFormValues>;
setFieldError?: (name: FieldPath<TFormValues>, message: string) => void;
}
export declare function createProcessApiErrorResponse(config: CreateProcessApiErrorParams): <TFormValues extends FieldValues>({ errors, fields, setFormError, setFieldError, onGlobalError, onUnknownErrors, onManualHandleError, }: ProcessApiErrorParams<TFormValues>) => void;
export {};