diff --git a/src/models/profile.model.ts b/src/models/profile.model.ts index 8950b1d2292130b18ae1a21ed4d42b31524a0c50..c041fb23a5f8acd5a20d4cf83dc48a518374bad1 100644 --- a/src/models/profile.model.ts +++ b/src/models/profile.model.ts @@ -23,9 +23,9 @@ export interface ProfileEntity { onboarding: Onboarding mailToken: string partnersIssueSeenDate: { - enedis: string - egl: string - grdf: string + enedis?: string + egl?: string + grdf?: string } haveSeenEcogestureModal: boolean activateHalfHourDate: string diff --git a/src/services/profile.service.ts b/src/services/profile.service.ts index 06f7d644e8277baba9382c98aeb1508902187241..64bf5dc792d3d18564472b50773c10ee527240d3 100644 --- a/src/services/profile.service.ts +++ b/src/services/profile.service.ts @@ -10,7 +10,10 @@ export default class ProfileService { this._client = _client } - private getDate(date: string): DateTime { + private getDate(date: string | undefined): DateTime { + if (!date) { + return DateTime.local().minus({ day: 1 }).startOf('day') + } return DateTime.fromISO(date, { zone: 'utc', }) @@ -30,9 +33,9 @@ export default class ProfileService { : profileEntity.monthlyAnalysisDate, lastConnectionDate: this.getDate(profileEntity.lastConnectionDate), partnersIssueSeenDate: { - enedis: this.getDate(profileEntity.partnersIssueSeenDate.enedis), - egl: this.getDate(profileEntity.partnersIssueSeenDate.egl), - grdf: this.getDate(profileEntity.partnersIssueSeenDate.grdf), + enedis: this.getDate(profileEntity.partnersIssueSeenDate?.enedis), + egl: this.getDate(profileEntity.partnersIssueSeenDate?.egl), + grdf: this.getDate(profileEntity.partnersIssueSeenDate?.grdf), }, activateHalfHourDate: this.getDate(profileEntity.activateHalfHourDate), customPopupDate: this.getDate(profileEntity.customPopupDate),