Fix frontend form factory action types
This commit is contained in:
parent
c3cb2b5a3c
commit
ed59ac0e62
@ -21,8 +21,10 @@ import { SelectField } from '../components/SelectField';
|
|||||||
import { SelectFieldMany } from '../components/SelectFieldMany';
|
import { SelectFieldMany } from '../components/SelectFieldMany';
|
||||||
import { SwitchField } from '../components/SwitchField';
|
import { SwitchField } from '../components/SwitchField';
|
||||||
import FormImagePicker from '../components/FormImagePicker';
|
import FormImagePicker from '../components/FormImagePicker';
|
||||||
import type { RootState } from '../stores/store';
|
import type { AppDispatch, RootState } from '../stores/store';
|
||||||
import type { AsyncThunk } from '@reduxjs/toolkit';
|
|
||||||
|
type DispatchableAction = Parameters<AppDispatch>[0];
|
||||||
|
type FormThunkAction<Arg> = (arg: Arg) => DispatchableAction;
|
||||||
|
|
||||||
// Field types supported by the factory
|
// Field types supported by the factory
|
||||||
export type FormFieldType =
|
export type FormFieldType =
|
||||||
@ -61,9 +63,9 @@ interface FormPageConfig<T> {
|
|||||||
singularTitle: string;
|
singularTitle: string;
|
||||||
mode: 'create' | 'edit';
|
mode: 'create' | 'edit';
|
||||||
sliceSelector: (state: RootState) => { [key: string]: T | T[] };
|
sliceSelector: (state: RootState) => { [key: string]: T | T[] };
|
||||||
fetchAction?: AsyncThunk<unknown, { id: string }, object>;
|
fetchAction?: FormThunkAction<{ id: string }>;
|
||||||
createAction?: AsyncThunk<unknown, T, object>;
|
createAction?: FormThunkAction<T>;
|
||||||
updateAction?: AsyncThunk<unknown, { id: string; data: T }, object>;
|
updateAction?: FormThunkAction<{ id: string; data: T }>;
|
||||||
permission: string;
|
permission: string;
|
||||||
initialValues: T;
|
initialValues: T;
|
||||||
fields: FormFieldConfig[];
|
fields: FormFieldConfig[];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user