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>
This commit is contained in:
@ -9,17 +9,17 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import { z } from 'zod';
|
||||
import { uniqueEntries } from './uniqueEntries';
|
||||
|
||||
export const setColumn = (
|
||||
oldColumn: SpreadsheetColumn,
|
||||
field?: SpreadsheetImportField,
|
||||
export const setColumn = <T extends string>(
|
||||
oldColumn: SpreadsheetColumn<T>,
|
||||
field?: SpreadsheetImportField<T>,
|
||||
data?: MatchColumnsStepProps['data'],
|
||||
): SpreadsheetColumn => {
|
||||
): SpreadsheetColumn<T> => {
|
||||
if (field?.fieldType.type === 'select') {
|
||||
const fieldOptions = field.fieldType.options;
|
||||
const uniqueData = uniqueEntries(
|
||||
data || [],
|
||||
oldColumn.index,
|
||||
) as SpreadsheetMatchedOptions[];
|
||||
) as SpreadsheetMatchedOptions<T>[];
|
||||
|
||||
const matchedOptions = uniqueData.map((record) => {
|
||||
const value = fieldOptions.find(
|
||||
@ -28,8 +28,8 @@ export const setColumn = (
|
||||
fieldOption.label === record.entry,
|
||||
)?.value;
|
||||
return value
|
||||
? ({ ...record, value } as SpreadsheetMatchedOptions)
|
||||
: (record as SpreadsheetMatchedOptions);
|
||||
? ({ ...record, value } as SpreadsheetMatchedOptions<T>)
|
||||
: (record as SpreadsheetMatchedOptions<T>);
|
||||
});
|
||||
const allMatched =
|
||||
matchedOptions.filter((o) => o.value).length === uniqueData?.length;
|
||||
@ -77,8 +77,8 @@ export const setColumn = (
|
||||
fieldOption.value === entry || fieldOption.label === entry,
|
||||
)?.value;
|
||||
return value
|
||||
? ({ entry, value } as SpreadsheetMatchedOptions)
|
||||
: ({ entry } as SpreadsheetMatchedOptions);
|
||||
? ({ entry, value } as SpreadsheetMatchedOptions<T>)
|
||||
: ({ entry } as SpreadsheetMatchedOptions<T>);
|
||||
});
|
||||
const areAllMatched =
|
||||
matchedOptions.filter((option) => option.value).length ===
|
||||
|
||||
Reference in New Issue
Block a user