wip: first draft for eventManager and interfaces

This commit is contained in:
Frieder Schlesier 2023-02-12 13:55:36 +01:00
parent 24cdde85d8
commit 56443f2b71
2 changed files with 83 additions and 0 deletions

56
src/api/EventManager.ts Normal file
View File

@ -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 <CommuniEvent>{
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: <EventState>{
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<CommuniEvent> - list of communi events
*/
listEvents = async () => {
let events = Array<CommuniEvent>()
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) => {
//
}
}

View File

@ -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