Migrate to a monorepo structure (#2909)
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
import {
|
||||
Column,
|
||||
ColumnType,
|
||||
MatchColumnsStepProps,
|
||||
} from '@/spreadsheet-import/steps/components/MatchColumnsStep/MatchColumnsStep';
|
||||
import { Field } from '@/spreadsheet-import/types';
|
||||
|
||||
import { uniqueEntries } from './uniqueEntries';
|
||||
|
||||
export const setColumn = <T extends string>(
|
||||
oldColumn: Column<T>,
|
||||
field?: Field<T>,
|
||||
data?: MatchColumnsStepProps<T>['data'],
|
||||
): Column<T> => {
|
||||
switch (field?.fieldType.type) {
|
||||
case 'select':
|
||||
return {
|
||||
...oldColumn,
|
||||
type: ColumnType.matchedSelect,
|
||||
value: field.key,
|
||||
matchedOptions: uniqueEntries(data || [], oldColumn.index),
|
||||
};
|
||||
case 'checkbox':
|
||||
return {
|
||||
index: oldColumn.index,
|
||||
type: ColumnType.matchedCheckbox,
|
||||
value: field.key,
|
||||
header: oldColumn.header,
|
||||
};
|
||||
case 'input':
|
||||
return {
|
||||
index: oldColumn.index,
|
||||
type: ColumnType.matched,
|
||||
value: field.key,
|
||||
header: oldColumn.header,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
index: oldColumn.index,
|
||||
header: oldColumn.header,
|
||||
type: ColumnType.empty,
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user