import ngModule from '../module'; import './style.scss'; class Controller { constructor($http) { this.$http = $http; } $onChanges() { if (!this.client) return; this.$http.get(`/client/api/Clients/${this.client.id}/summary`).then(res => { if (res && res.data) { this.summary = res.data; if (res.data.classifications.length) this.grade = res.data.classifications[0].insurances[0].grade; this.summary.sumRisk = this.sumRisk(); } }); } sumRisk() { let total = 0; this.summary.clientRisks.forEach(risk => { total += risk.amount; }); return total; } claimRate(priceIncreasing) { if (priceIncreasing) return priceIncreasing * 100; } claimingRate(rate) { if (rate) return rate * 100; } } Controller.$inject = ['$http']; ngModule.component('vnClientSummary', { template: require('./index.html'), controller: Controller, bindings: { client: '<' } });