export const columnReducer = (state, action)=>{
    switch(action.type){
        case 'toggle':
            {
                const { column } = action.payload;
                const withToggledColumn = state.map((col)=>{
                    if (col?.name === column) {
                        return {
                            ...col,
                            active: !col.active
                        };
                    }
                    return col;
                });
                return withToggledColumn;
            }
        case 'move':
            {
                const { fromIndex, toIndex } = action.payload;
                const withMovedColumn = [
                    ...state
                ];
                const [columnToMove] = withMovedColumn.splice(fromIndex, 1);
                withMovedColumn.splice(toIndex, 0, columnToMove);
                return withMovedColumn;
            }
        case 'set':
            {
                const { columns } = action.payload;
                return columns;
            }
        default:
            return state;
    }
};

//# sourceMappingURL=columnReducer.js.map