parseGoogleSheet from db

This commit is contained in:
arc-alex
2023-11-24 16:49:37 +01:00
parent d32d8a547d
commit 111df94d6d
3 changed files with 26 additions and 1 deletions
+22
View File
@@ -1,6 +1,7 @@
import { generateId } from 'ontime-utils';
import {
Alias,
GoogleSheet,
OntimeRundown,
OSCSettings,
OscSubscription,
@@ -284,3 +285,24 @@ export const parseUserFields = (data): UserFields => {
}
return { ...newUserFields };
};
/**
* Parse Google Sheet portion of an entry
* @param {object} data - data object
* @param {boolean} enforce - whether to create a definition if one is missing
* @returns {object} - event object data
*/
export const parseGoogleSheet = (data, enforce) => {
const newSheet: GoogleSheet = {
id: '',
worksheet: '',
};
if ('googleSheet' in data) {
console.log('Found Google Sheet definition, importing...');
newSheet.id ??= data.googleSheet?.id;
newSheet.worksheet ??= data.googleSheet?.worksheet;
return newSheet;
} else if (enforce) {
return newSheet;
}
};