I have developed TypeScript code to compute the percentages of firms and insights and exhibit them using a progress bar. The following snippet contains the code:
export class InsightsComponent implements OnInit {
insights: any;
firm: Firm;
constructor(
private firmService: FirmService,
private provider: FirmProvider,
private http: HttpClient,
) {}
ngOnInit(): void {
this.provider.getInsights(this.firmService.getDomain())
.then(data => {
console.log(data);
this.insights = data;
});
this.provider.getCurrent(this.firmService.getDomain())
.then(data => {
this.firm = data;
});
}
calcInvoiced = (firm: Firm, insights: number) => {
((this.firm / this.insights) * 100).toFixed(2);
}
}
Would you be able to offer feedback on potential enhancements and optimizations for this piece of code?