🐛 fix undefined choice

This commit is contained in:
Baptiste Lemoine 2019-10-03 11:27:25 +02:00
parent 49494236cf
commit 1074d219dd

View File

@ -1,5 +1,4 @@
import {Component, Input} from '@angular/core';
import {environment} from "../../environments/environment";
interface VoteChoice {
votesCount: {
@ -8,8 +7,8 @@ interface VoteChoice {
maybe: number
notAnswered: number
};
text: string;
date: Date;
text?: string;
date?: Date;
answer: 'yes' | 'no' | 'maybe' | null;
simpleAnswer: boolean; // enable if we display only a togglable "yes"
}
@ -25,17 +24,21 @@ interface VoteChoice {
})
export class VoteChoiceComponent {
@Input() choice: VoteChoice;
@Input() choice: VoteChoice = {
date: new Date(),
text: 'description ',
votesCount: {
yes: 0,
no: 0,
maybe: 0,
notAnswered: 0
},
simpleAnswer: false,
answer: null
};
constructor() {
if (!environment.production) {
// demo content for dev env
this.choice = {
date: new Date(),
text: 'description ',
simpleAnswer: false
}
}
}
setAnswserTo(newAnswer: 'yes' | 'no' | 'maybe' | null) {