@airplane/views
Version:
A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.
31 lines (30 loc) • 706 B
JavaScript
import { isEqual } from "lodash-es";
const reducer = (state, action) => {
switch (action.type) {
case "changeRowSelection": {
const {
rows
} = action;
if (rows.length === state.selectedRows.length && rows.every((row, index) => isEqual(row, state.selectedRows[index]))) {
return state;
}
return {
...state,
selectedRows: rows,
selectedRow: rows.length === 1 ? rows[0] : void 0
};
}
case "setRowActionResult": {
return {
...state,
rowActionResult: action.result
};
}
default:
throw new Error("invalid action");
}
};
export {
reducer
};
//# sourceMappingURL=reducer.js.map