Skip to content

Commit

Permalink
feat(ui): add dynamic aggregates changes at each update
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Sep 20, 2024
1 parent ea9577d commit dc59b09
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions webapp/src/components/common/MatrixGrid/useMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,27 @@ export function useMatrix(
(update): update is NonNullable<typeof update> => update !== null,
);

// Recalculate aggregates with the updated data
const newAggregates = enableAggregateColumns
? calculateMatrixAggregates(updatedData)
: { min: [], max: [], avg: [], total: [] };

setState({
data: updatedData,
aggregates: currentState.aggregates,
aggregates: newAggregates,
pendingUpdates: [...currentState.pendingUpdates, ...newUpdates],
updateCount: currentState.updateCount
? currentState.updateCount + 1
: 1,
});
},
[currentState, setState],
[
currentState.data,
currentState.pendingUpdates,
currentState.updateCount,
enableAggregateColumns,
setState,
],
);

const handleCellEdit = function (update: GridUpdate) {
Expand Down

0 comments on commit dc59b09

Please sign in to comment.