79f3fbb016
This reverts commit cc71394863.
Regression introduced in https://github.com/twentyhq/twenty/pull/13213
The import/export use an upsert logic and when it goes through the
"update" path it fails due to the connect not being implemented yet
(should be in https://github.com/twentyhq/core-team-issues/issues/1230)
---------
Co-authored-by: prastoin <paul@twenty.com>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import {
|
|
SpreadsheetMatchedSelectColumn,
|
|
SpreadsheetMatchedSelectOptionsColumn,
|
|
} from '@/spreadsheet-import/types/SpreadsheetColumn';
|
|
import { SpreadsheetColumnType } from '@/spreadsheet-import/types/SpreadsheetColumnType';
|
|
import { SpreadsheetMatchedOptions } from '@/spreadsheet-import/types/SpreadsheetMatchedOptions';
|
|
|
|
export const setSubColumn = <T>(
|
|
oldColumn:
|
|
| SpreadsheetMatchedSelectColumn<T>
|
|
| SpreadsheetMatchedSelectOptionsColumn<T>,
|
|
entry: string,
|
|
value: string,
|
|
):
|
|
| SpreadsheetMatchedSelectColumn<T>
|
|
| SpreadsheetMatchedSelectOptionsColumn<T> => {
|
|
const shouldUnselectValue =
|
|
oldColumn.matchedOptions.find((option) => option.entry === entry)?.value ===
|
|
value;
|
|
|
|
const options = oldColumn.matchedOptions.map((option) =>
|
|
option.entry === entry
|
|
? { ...option, value: shouldUnselectValue ? undefined : value }
|
|
: option,
|
|
);
|
|
|
|
const allMatched = options.every(({ value }) => !!value);
|
|
if (allMatched) {
|
|
return {
|
|
...oldColumn,
|
|
matchedOptions: options as SpreadsheetMatchedOptions<T>[],
|
|
type: SpreadsheetColumnType.matchedSelectOptions,
|
|
};
|
|
} else {
|
|
return {
|
|
...oldColumn,
|
|
matchedOptions: options as SpreadsheetMatchedOptions<T>[],
|
|
type: SpreadsheetColumnType.matchedSelect,
|
|
};
|
|
}
|
|
};
|