import React from 'react'; import { FieldErrors, FieldValues, SubmitHandler, UseFormGetValues, UseFormReset, UseFormSetValue } from 'react-hook-form'; import { AlertColor, AlertPropsColorOverrides } from '@mui/material/Alert'; import { OverridableStringUnion } from '@mui/types'; import { AxiosError } from 'axios'; import { ObjectSchema } from 'yup'; import { ItemSchemaColumnsType, Id, Item, SchemaType, DataSchemaColumnsType, OnSuccessEvent, OptionsAC, FormFieldLayout, TargetApiParamsLocal, TargetApiPostParamsLocal, GetGenericModelListPropsLocal, GridEnrichedBySchemaColDef, ExtraValidators, GetGenericModelPropsLocal, UpdateDataBySchema, AutocompleteItem, FieldKey, PartialItem, TField, PaginationModel, ModelMeta } from '../@types'; export interface LoadSinglePageDataProps { model: string; objId?: Id; objTitleField?: FieldKey; optionsACModels?: string[]; defaults?: PartialItem; extraValidators?: ExtraValidators; fieldsLayout?: FormFieldLayout[]; } export interface PageFormType { id: Id; model: string | null; modelVerboseName?: string | null; modelVerboseNamePlural?: string | null; schema: SchemaType | null; columns?: GridEnrichedBySchemaColDef[] | null; initialValues: Item | null; validationSchema: ObjectSchema | null; objTitleField?: FieldKey; } export interface FormTools { errors: FieldErrors>; reset: UseFormReset>; getValues: UseFormGetValues>; setValue: UseFormSetValue>; isDirty: boolean; } export interface OnEditModelType { fieldKey?: FieldKey; index?: number; model: string; id: Id; labelKey: string; setValue?: UseFormSetValue>; getValues?: UseFormGetValues>; fieldsLayout?: FormFieldLayout[]; initialValuesPartial?: PartialItem; } export interface OnEditRelatedModelType { model: string; id: Id; relatedModel: string; relatedModelId: Id; newRow: Item; schema: SchemaType; onlyAddExisting?: boolean; } export interface onEditModelDataGridSaveType { model: string; id: Id; newRow: Item; schema: SchemaType; } export interface OnDeleteRelatedModelType { model: string; id: Id; relatedModel: string; relatedModelId: Id; } export interface SnackBarType { open?: boolean; msg?: string; severity?: OverridableStringUnion; } type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; export interface DialogType { open: boolean; loading?: boolean; title?: string; Body?: React.ReactNode; Actions?: React.ReactNode; isCancelDisabled?: boolean; size?: DialogSize; } export type DRFReactBySchemaSubmitHandler = (...args: [...[model: string, id: Id], ...Parameters>]) => Promise; export interface APIWrapperContextType { usuaria: Item | null; updateUsuaria: () => void; isLoggedIn: () => Promise; onSubmit: DRFReactBySchemaSubmitHandler; loadSinglePageData: (p: LoadSinglePageDataProps) => Promise | AxiosError>; handleLoading: (p: boolean) => void; optionsAC: OptionsAC | null; setOptionsAC: (x: Partial>) => void; onEditModel: (p: OnEditModelType) => void; pageForm: PageFormType | null; resetPageForm: () => void; formTools?: FormTools; onEditModelDataGridSave: (p: onEditModelDataGridSaveType) => Promise | AxiosError>; onEditModelSave: (p: Item) => Promise; onDeleteModel: (model: string, id: Id, onSuccess?: OnSuccessEvent) => void; onEditRelatedModelSave: (p: OnEditRelatedModelType) => Promise | ItemSchemaColumnsType | AxiosError>; onDeleteRelatedModel: (p: OnDeleteRelatedModelType) => Promise; exportExcelData: ({ model, modelParent, modelParentId, paginationModel, }: { model: string; modelParent?: string; modelParentId?: Id; paginationModel: PaginationModel; }) => Promise; rawUpdateDataBySchema: (props: UpdateDataBySchema) => Promise | AxiosError>; rawDeleteData: (model: string, id: Id) => Promise; onTriggerSnackBar: (p: SnackBarType) => void; setDialog: (newState: Partial | null) => void; getRawData: (route: string) => Promise; getAutoComplete: (model: string, queryParams?: string[]) => Promise; getGenericModel: (x: GetGenericModelPropsLocal) => Promise | AxiosError>; getGenericModelList: (x: GetGenericModelListPropsLocal) => Promise | AxiosError>; getAllModels: () => Promise; loginByPayload: (payload: Item) => Promise; getSignUpOptions: () => Promise; signUp: (data: Item) => Promise | AxiosError>; signOut: () => void; requestPasswordReset: (email: string) => Promise; confirmPasswordReset: (data: Item) => Promise; changePassword: (data: Item) => Promise; postData: (params: TargetApiPostParamsLocal) => Promise | AxiosError>; editModel: React.RefObject>; updateModel: (p: TargetApiParamsLocal) => Promise | AxiosError>; populateOptionsAC: (optionsACModels: string[]) => void; isMobile: boolean; /** Resolves verbose_name/verbose_name_plural from a model schema. */ getModelMeta: (model: string) => Promise; } export declare const APIWrapperContext: React.Context>; export declare function useAPIWrapper(): APIWrapperContextType; export {}; //# sourceMappingURL=APIWrapperContext.d.ts.map