import { Component, OnInit } from '@angular/core'; import { StorageService } from 'src/app/services/storage.service'; import { LoadAlertsService } from 'src/app/services/load-alerts.service'; import { UserService } from 'src/app/services/user.service'; import { RouterService } from 'src/app/services/router.service'; import { PopoverController } from '@ionic/angular'; @Component({ selector: 'app-spot-gopro', templateUrl: './spot-gopro.component.html', styleUrls: ['./spot-gopro.component.scss'], }) export class SpotGoproComponent implements OnInit { lang; goprocode: any; constructor(private storage:StorageService, private loadalert:LoadAlertsService, private userService:UserService, private router:RouterService, public popoverController: PopoverController) { } ngOnInit() { this.storage.get("lang").then(data=>{console.log(data,'lang'); this.lang=data; if(data==2) { document.dir='rtl' } else { document.dir='ltr' } }, error=>{console.log(error,'langError');}); } gopro() { this.loadalert.presentLoading(this.lang==1?"Please Wait.":"Please Wait."); this.userService.GoPro(this.lang,this.goprocode).subscribe(data=>{ if(data.response_message ==="success"){ this.loadalert.dismissLoading(); this.popoverController.dismiss(); setTimeout(() => { this.router.navByUrl("layout/speed"); this.loadalert.PresentAlert("","Success",'Go Pro Activated.'); }, 1000); } else { this.loadalert.PresentAlert("","Failed",'Go Pro subscription Failed.'); } this.loadalert.dismissLoading(); },error=>{ this.loadalert.PresentAlert("","Attention",'Error in connection.'); //this.loadalert.PresentAlert("","Attention",'This user does not have subscription yet.'); this.loadalert.dismissLoading(); console.log(error,"error"); }); } get Lang(){ return this.lang; } }