import type { GridRowId } from '../../types' import type { UpdateEditAction } from '../actions' import { createReducer } from '../utils/createReducer' export type GridEditState = { columnId: string rowId: GridRowId } | null export default createReducer({ initialState: null, reducers: { updateEdit(state, action: UpdateEditAction) { return action.payload }, }, }) export const selectEdit = (state: GridEditState) => state export const selectIsEditing = (state: GridEditState) => !!state export const selectIsEditingCell = ( state: GridEditState, { rowId, columnId }: { rowId: GridRowId; columnId: string } ) => state?.columnId === columnId && state?.rowId === rowId export const selectIsEditingCellInColumn = ( state: GridEditState, columnId: string ) => state?.columnId === columnId