diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 0d40e11c..82f9751f 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -733,18 +733,21 @@ export class PollService implements Resolve { */ convertCalendarToText() { console.log('this.dateChoiceList', this.dateChoiceList); - // if(!this.dateChoiceList.length){ - // return []; - // } - let converted = []; - for (let someDate of this.calendar) { - converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); - } - this.dateChoiceList = converted.sort((first: any, second: any) => { - return first.date_object - second.date_object; - }); - return converted; + if (this.calendar && this.calendar.length) { + let converted = []; + for (let someDate of this.calendar) { + converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); + } + + this.dateChoiceList = converted.sort((first: any, second: any) => { + return first.date_object - second.date_object; + }); + return converted; + } else { + this.dateChoiceList = []; + } + return this.dateChoiceList; } /**