refactor: excel import (#250)

* refactor: public parsing function
This commit is contained in:
Carlos Valente
2022-11-09 22:19:33 +01:00
committed by GitHub
parent b9bc4627df
commit b5a521f625
5 changed files with 6 additions and 40 deletions
+2 -15
View File
@@ -19,19 +19,6 @@ import { generateId } from './generate_id.js';
export const EXCEL_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
export const JSON_MIME = 'application/json';
/**
* @description Whether a string is considered empty
* @param value
* @return {boolean}
*/
export const isStringEmpty = (value) => {
let v = value;
if (typeof value === 'string') {
v = value.replace(/\s+/g, '');
}
return v === '' || !v;
};
/**
* @description Excel array parser
* @param {array} excelData - array with excel sheet
@@ -102,9 +89,9 @@ export const parseExcel_v1 = async (excelData) => {
} else if (j === subtitleIndex) {
event.subtitle = column;
} else if (j === isPublicIndex) {
event.isPublic = isStringEmpty(column);
event.isPublic = Boolean(column);
} else if (j === skipIndex) {
event.skip = isStringEmpty(column);
event.skip = Boolean(column);
} else if (j === notesIndex) {
event.note = column;
} else if (j === colourIndex) {