Files
twenty_crm/packages/twenty-front/src/modules/spreadsheet-import/utils/uniqueEntries.ts

14 lines
486 B
TypeScript

import uniqBy from 'lodash.uniqby';
import { MatchColumnsStepProps } from '@/spreadsheet-import/steps/components/MatchColumnsStep/MatchColumnsStep';
import { SpreadsheetMatchedOptions } from '@/spreadsheet-import/types/SpreadsheetMatchedOptions';
export const uniqueEntries = (
data: MatchColumnsStepProps['data'],
index: number,
): Partial<SpreadsheetMatchedOptions>[] =>
uniqBy(
data.map((row) => ({ entry: row[index] })),
'entry',
).filter(({ entry }) => !!entry);