import type { ReduxAction } from "ee/constants/ReduxActionConstants"; import produce from "immer"; export const createReducer = ( // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any initialState: any, // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any handlers: { [type: string]: (state: any, action: any) => any }, ) => { // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any return function reducer(state = initialState, action: ReduxAction) { if (handlers.hasOwnProperty(action.type)) { return handlers[action.type](state, action); } else { return state; } }; }; export const createImmerReducer = ( // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any initialState: any, // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any handlers: { [type: string]: any }, ) => { // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any return function reducer(state = initialState, action: ReduxAction) { if (handlers.hasOwnProperty(action.type)) { return produce(handlers[action.type])(state, action); } else { return state; } }; };