Refactor required fields check on Bulk CSV upload (#59)

Related to https://github.com/etkecc/synapse-admin/pull/32
This commit is contained in:
jamazi 2024-10-17 22:56:19 +03:00 committed by GitHub
parent 0d021021df
commit 11a5cac709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -121,11 +121,7 @@ const FilePicker = () => {
const verifyCsv = ({ data, meta, errors }: ParseResult<ImportLine>, { setValues, setStats, setError }) => { const verifyCsv = ({ data, meta, errors }: ParseResult<ImportLine>, { setValues, setStats, setError }) => {
/* First, verify the presence of required fields */ /* First, verify the presence of required fields */
const missingFields = expectedFields.filter(eF => { const missingFields = expectedFields.filter(eF => !meta.fields?.find(mF => eF === mF));
const result = meta.fields?.find(mF => eF === mF);
if (result === undefined) { return eF; } // missing field
return undefined; // field found
});
if (missingFields.length > 0) { if (missingFields.length > 0) {
setError(translate("import_users.error.required_field", { field: missingFields[0] })); setError(translate("import_users.error.required_field", { field: missingFields[0] }));