| 20 | import { buildInitialState, buildState } from './state'; |
| 21 | |
| 22 | function recalculateCalculatedColumns( |
| 23 | row: SheetRow, |
| 24 | payload: CellChangedPayload, |
| 25 | state: ImporterState |
| 26 | ): SheetRow { |
| 27 | const sheetDefinition = state.sheetDefinitions.find( |
| 28 | (s) => s.id === payload.sheetId |
| 29 | ); |
| 30 | |
| 31 | if (sheetDefinition != null) { |
| 32 | const calculatedColumns = sheetDefinition.columns.filter( |
| 33 | (column) => column.type === 'calculated' |
| 34 | ); |
| 35 | |
| 36 | calculatedColumns.forEach((column) => { |
| 37 | row[column.id] = column.typeArguments.getValue(row); |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | return row; |
| 42 | } |
| 43 | |
| 44 | export const reducer = ( |
| 45 | state: ImporterState, |