* feat: wip implement back-end call csv import * fix: rebase IconBrandTwitter missing * feat: person and company csv import * fix: test & clean * fix: clean & test
19 lines
584 B
TypeScript
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) || [];
|