Updated typescript types for Event
This commit is contained in:
parent
97d8429f22
commit
51dfb8cd7f
@ -1,13 +1,13 @@
|
|||||||
import { Event as _Event } from "../types";
|
import { Event as EventType } from "../types";
|
||||||
|
|
||||||
export default class Event implements _Event {
|
export default class Event implements EventType {
|
||||||
date: Date;
|
date: Date;
|
||||||
title: string;
|
title: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
bgColor?: string;
|
bgColor?: string;
|
||||||
|
|
||||||
constructor({ date, title, text, icon, bgColor }) {
|
constructor({ date, title, text, icon, bgColor }: EventType) {
|
||||||
this.date = new Date(date);
|
this.date = new Date(date);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default class Events {
|
|||||||
this.sortedEvents = this.processEvents(events);
|
this.sortedEvents = this.processEvents(events);
|
||||||
}
|
}
|
||||||
|
|
||||||
private processEvents(events): Event[] {
|
private processEvents(events: Event[]): Event[] {
|
||||||
const _events = events.reduce((collection, event) => {
|
const _events = events.reduce((collection, event) => {
|
||||||
// only include valid events
|
// only include valid events
|
||||||
if (event.title && event.date && isValid(new Date(event.date))) {
|
if (event.title && event.date && isValid(new Date(event.date))) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user