done adding multipule events
This commit is contained in:
parent
0b0a5efe5c
commit
b8d0a40315
2 changed files with 11 additions and 20 deletions
25
src/Ics.ts
25
src/Ics.ts
|
@ -7,14 +7,17 @@ const uuid = require('uuid').v4();
|
||||||
export default class Ics {
|
export default class Ics {
|
||||||
|
|
||||||
generateIcsOutputFromGames = (games: GoogleCalendarEvent[]) => {
|
generateIcsOutputFromGames = (games: GoogleCalendarEvent[]) => {
|
||||||
// let icsOutput = '';
|
let output = [];
|
||||||
// for (let game of games) {
|
games.forEach((game) => {
|
||||||
// icsOutput += this.generateIcsOutputFromGame(game);
|
output.push(this.generateIcsOutputFromGame(game));
|
||||||
// }
|
});
|
||||||
// console.log(icsOutput)
|
|
||||||
// return icsOutput;
|
|
||||||
return this.generateIcsOutputFromGame(games[0])
|
|
||||||
|
|
||||||
|
const { error, value } = ics.createEvents(output);
|
||||||
|
if (error) {
|
||||||
|
console.log(error);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
|
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
|
||||||
|
@ -36,12 +39,6 @@ export default class Ics {
|
||||||
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
|
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
|
||||||
uid: uuid.toString(),
|
uid: uuid.toString(),
|
||||||
};
|
};
|
||||||
|
return icsEvent;
|
||||||
const { error, value } = ics.createEvent(icsEvent);
|
|
||||||
if (error) {
|
|
||||||
console.log(error);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
import GoogleCalendar from './GoogleCalendar';
|
import GoogleCalendar from './GoogleCalendar';
|
||||||
import GameSource from './GameSource';
|
import GameSource from './GameSource';
|
||||||
// import ics from 'ics';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { GoogleCalendarEvent } from './types';
|
|
||||||
import Ics from './Ics';
|
import Ics from './Ics';
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,8 +42,4 @@ const start = async () => {
|
||||||
console.log("ICS FILE GENERATED In: " + outputFileLocation)
|
console.log("ICS FILE GENERATED In: " + outputFileLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
start();
|
start();
|
Loading…
Reference in a new issue