First commit
This commit is contained in:
61
src/app/pages/contracts/review/review.page.ts
Normal file
61
src/app/pages/contracts/review/review.page.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { NavController, LoadingController } from '@ionic/angular';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { EnvService } from 'src/app/services/env.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { IchambaService } from 'src/app/services/ichamba.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-review',
|
||||
templateUrl: './review.page.html',
|
||||
styleUrls: ['./review.page.scss'],
|
||||
})
|
||||
export class ReviewPage implements OnInit {
|
||||
|
||||
private loading;
|
||||
rate: any;
|
||||
contract_id: number = null;
|
||||
comment: any;
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private navCtrl: NavController,
|
||||
private alertService: AlertService,
|
||||
private ichambaService: IchambaService,
|
||||
private translateService: TranslateService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private loadingCtrl: LoadingController,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.contract_id = Number(this.activatedRoute.snapshot.paramMap.get('contract_id'));
|
||||
}
|
||||
|
||||
onRateChange(rating){
|
||||
console.log("changed rating: " + rating);
|
||||
// do your stuff
|
||||
}
|
||||
|
||||
reviewservice() {
|
||||
if (this.rate) {
|
||||
this.loadingCtrl.create().then((overlay) => {
|
||||
this.loading = overlay;
|
||||
this.loading.present();
|
||||
});
|
||||
this.ichambaService.reviewContract(this.contract_id, this.rate, this.comment).subscribe(
|
||||
data => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(data['message']);
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
}, error => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
|
||||
});
|
||||
} else {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.rate'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user