subhasmitalmg-react-spreadsheet-import
Version:
React spreadsheet import for xlsx and csv files with column matching and validation steps
15 lines (12 loc) • 558 B
JavaScript
import { ColumnType } from '../MatchColumnsStep.js';
const setSubColumn = (oldColumn, entry, value) => {
const options = oldColumn.matchedOptions.map((option) => (option.entry === entry ? { ...option, value } : option));
const allMathced = options.every(({ value }) => !!value);
if (allMathced) {
return { ...oldColumn, matchedOptions: options, type: ColumnType.matchedSelectOptions };
}
else {
return { ...oldColumn, matchedOptions: options, type: ColumnType.matchedSelect };
}
};
export { setSubColumn };