import * as Moment from 'moment'; import { Component, OnInit, ViewChild } from '@angular/core'; import { UserProfileService } from '../../services/user.profile.service'; import { AuthService } from '../../services/auth.service'; import { FeedbackPanelComponent } from '../feedback-panel/feedback-panel.component'; @Component({ selector: 'app-gdpr-prompt', templateUrl: './gdpr-prompt.component.html', styleUrls: ['./gdpr-prompt.component.css'], providers: [ UserProfileService ] }) export class GdprPromptComponent implements OnInit { @ViewChild('FeedbackPanel') FeedbackPanel:FeedbackPanelComponent; isWorking: boolean = false; constructor(private _profile: UserProfileService, private _auth: AuthService) { } ngOnInit() { } renew_gdpr() { if (this.isWorking) { return; } this.isWorking = true; this._profile.renew_gdpr() .then(() => { this._auth.User.gdpr_date = Moment(); this._auth.restashUser(); this.isWorking = false; }) .catch((err) => { this.FeedbackPanel.triggerError(err); this.isWorking = false; }) } }