From b8d0a403150d64765b9a95e1c9004d5a2a7aaea5 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Tue, 28 Mar 2023 17:49:02 +0300 Subject: [PATCH] done adding multipule events --- src/Ics.ts | 25 +++++++++++-------------- src/index.ts | 6 ------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Ics.ts b/src/Ics.ts index 2f66c3d..9e561f3 100644 --- a/src/Ics.ts +++ b/src/Ics.ts @@ -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; } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 7bf1c8a..71be826 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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(); \ No newline at end of file