Files
twenty_crm/front/src/modules/spreadsheet-import/utils/findUnmatchedRequiredFields.ts
Jérémy M 8863bb0035 Import company and person from csv file (#1236)
* feat: wip implement back-end call csv import

* fix: rebase IconBrandTwitter missing

* feat: person and company csv import

* fix: test & clean

* fix: clean & test
2023-08-16 14:18:16 -07:00

19 lines
584 B
TypeScript

import type { Columns } from '@/spreadsheet-import/steps/components/MatchColumnsStep/MatchColumnsStep';
import type { Fields } from '@/spreadsheet-import/types';
export const findUnmatchedRequiredFields = <T extends string>(
fields: Fields<T>,
columns: Columns<T>,
) =>
fields
.filter((field) =>
field.validations?.some((validation) => validation.rule === 'required'),
)
.filter(
(field) =>
columns.findIndex(
(column) => 'value' in column && column.value === field.key,
) === -1,
)
.map((field) => field.label) || [];