import { ProjectFormState } from "./ProjectFormState.interface" type Action = | { type: 'SET_ERROR'; payload: string | undefined } | { type: 'SET_IS_DISABLED'; payload: boolean } | { type: 'SET_IS_LOADING'; payload: boolean } export const initialState: ProjectFormState = { error: undefined, isDisabled: false, isLoading: true, }; export const reducer = ( state: ProjectFormState, action: Action ): ProjectFormState => { switch (action.type) { case 'SET_ERROR': { return { ...state, error: action.payload }; } case 'SET_IS_DISABLED': { return { ...state, isDisabled: action.payload }; } case 'SET_IS_LOADING': { return { ...state, isLoading: action.payload }; } default: { return state; } } };