Import - fixes (#12569)
<img width="800" alt="Screenshot 2025-06-12 at 15 22 49" src="https://github.com/user-attachments/assets/afaa4ef1-b16c-4c05-ba4a-d77ad2ccfa76" /> To test : - unselect an option on select/multi-select matching (matching step) - match a mutli-select field with an other field closes : https://github.com/twentyhq/core-team-issues/issues/1065 closes : https://github.com/twentyhq/core-team-issues/issues/1066
This commit is contained in:
@ -4,6 +4,7 @@ import { SpreadsheetImportField } from '@/spreadsheet-import/types';
|
||||
import { SpreadsheetColumn } from '@/spreadsheet-import/types/SpreadsheetColumn';
|
||||
import { SpreadsheetColumnType } from '@/spreadsheet-import/types/SpreadsheetColumnType';
|
||||
import { SpreadsheetMatchedOptions } from '@/spreadsheet-import/types/SpreadsheetMatchedOptions';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { z } from 'zod';
|
||||
import { uniqueEntries } from './uniqueEntries';
|
||||
|
||||
@ -45,21 +46,28 @@ export const setColumn = <T extends string>(
|
||||
if (field?.fieldType.type === 'multiSelect') {
|
||||
const fieldOptions = field.fieldType.options;
|
||||
|
||||
const entries = [
|
||||
...new Set(
|
||||
data
|
||||
?.flatMap((row) => {
|
||||
try {
|
||||
let entries: string[] = [];
|
||||
try {
|
||||
entries = [
|
||||
...new Set(
|
||||
data
|
||||
?.flatMap((row) => {
|
||||
const value = row[oldColumn.index];
|
||||
const options = JSON.parse(z.string().parse(value));
|
||||
return z.array(z.string()).parse(options);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.filter((entry) => typeof entry === 'string'),
|
||||
),
|
||||
];
|
||||
})
|
||||
.filter((entry) => typeof entry === 'string'),
|
||||
),
|
||||
];
|
||||
} catch {
|
||||
return {
|
||||
index: oldColumn.index,
|
||||
header: oldColumn.header,
|
||||
type: SpreadsheetColumnType.matchedError,
|
||||
value: field.key,
|
||||
errorMessage: t`column data is not compatible with Multi-Select.`,
|
||||
};
|
||||
}
|
||||
|
||||
const matchedOptions = entries.map((entry) => {
|
||||
const value = fieldOptions.find(
|
||||
|
||||
Reference in New Issue
Block a user