done adding multipule events

This commit is contained in:
Kfir Dayan 2023-03-28 17:49:02 +03:00
parent 0b0a5efe5c
commit b8d0a40315
2 changed files with 11 additions and 20 deletions

View file

@ -7,14 +7,17 @@ const uuid = require('uuid').v4();
export default class Ics {
generateIcsOutputFromGames = (games: GoogleCalendarEvent[]) => {
// let icsOutput = '';
// for (let game of games) {
// icsOutput += this.generateIcsOutputFromGame(game);
// }
// console.log(icsOutput)
// return icsOutput;
return this.generateIcsOutputFromGame(games[0])
let output = [];
games.forEach((game) => {
output.push(this.generateIcsOutputFromGame(game));
});
const { error, value } = ics.createEvents(output);
if (error) {
console.log(error);
return '';
}
return value;
}
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
@ -36,12 +39,6 @@ export default class Ics {
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
uid: uuid.toString(),
};
const { error, value } = ics.createEvent(icsEvent);
if (error) {
console.log(error);
return '';
}
return value;
return icsEvent;
}
}

View file

@ -1,8 +1,6 @@
import GoogleCalendar from './GoogleCalendar';
import GameSource from './GameSource';
// import ics from 'ics';
import fs from 'fs';
import { GoogleCalendarEvent } from './types';
import Ics from './Ics';
@ -44,8 +42,4 @@ const start = async () => {
console.log("ICS FILE GENERATED In: " + outputFileLocation)
}
start();