diff --git a/src/api/EventManager.ts b/src/api/EventManager.ts new file mode 100644 index 0000000..e455457 --- /dev/null +++ b/src/api/EventManager.ts @@ -0,0 +1,56 @@ +import { EventState } from "@prisma/client" +import { CommuniEvent } from "../interfaces/CommuniEvents" + +export class EventManager { + static + /** + * + * @returns CommuniEvent - list of communi events + */ + eventFromDefault() { + return { + titleFormatted: "Godi am 01.01.1970", + descriptionDescriptionFormatted: "Einfache Beschreibung für Godi\n Beschreibung der Predigtreihe\n\n Predigt: \n Moderation:", + dateTime: "2022-09-25 10:00:00", + endDateTime: "2022-09-25 11:15:00", + isOfficial: true, + state: { + publishYoutube: true, + publishFacebook: false, + publishInstagram: false + } + } + } + // TODO: how to create a simple route? with express? + // this is the point to think about switching to Nest framework + + // TODO: fetch from DB or from App interface? + // ptobably both... add a sync function + + /** + * + * @returns Array - list of communi events + */ + listEvents = async () => { + let events = Array() + + return events + } + + syncFromApp = async () => { + // fetch list from App + // fetch list from DB + // for (event in Events) { + // update info in DB with latest info from App + // } + } + + /** + * adds a new Event to our database + * + * @param newEvent - event to add, from Form + */ + addEventFromForm = async (newEvent: CommuniEvent) => { + // + } +} \ No newline at end of file diff --git a/src/interfaces/CommuniEvents.ts b/src/interfaces/CommuniEvents.ts new file mode 100644 index 0000000..9d62bf4 --- /dev/null +++ b/src/interfaces/CommuniEvents.ts @@ -0,0 +1,27 @@ +// similar to return types of CommuniApp REST API +export interface IEvent { + id?: number + titleFormatted: string + locationFormatted: string + descriptionDescriptionFormatted: string + dateTime: string + endDateTime: string + isOfficial: boolean + videoUrl?: string + group?: number + createdBy?: number + state: EventState +} + +export interface EventState { + id?: number + event?: IEvent + publishYoutube: boolean + publishFacebook: boolean + publishInstagram: boolean + + // FIXME: + eventId?: number +} + +export type CommuniEvent = IEvent \ No newline at end of file