From 8cb1c5c88cb25350e6dfde59c57d76d4478fecd7 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sat, 25 Sep 2021 15:50:31 +0400 Subject: [PATCH] Fix for fee rounding not using locale fixes #796 --- .../shared/pipes/fee-rounding/fee-rounding.pipe.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/shared/pipes/fee-rounding/fee-rounding.pipe.ts b/frontend/src/app/shared/pipes/fee-rounding/fee-rounding.pipe.ts index 6a050a9f7..319698b23 100644 --- a/frontend/src/app/shared/pipes/fee-rounding/fee-rounding.pipe.ts +++ b/frontend/src/app/shared/pipes/fee-rounding/fee-rounding.pipe.ts @@ -1,15 +1,20 @@ -import { Pipe, PipeTransform } from "@angular/core"; +import { formatNumber } from "@angular/common"; +import { Inject, LOCALE_ID, Pipe, PipeTransform } from "@angular/core"; @Pipe({ name: "feeRounding", }) export class FeeRoundingPipe implements PipeTransform { + constructor( + @Inject(LOCALE_ID) private locale: string, + ) {} + transform(fee: number): string { if (fee >= 100) { - return fee.toFixed(0); + return formatNumber(fee, this.locale, '1.0-0') } else if (fee < 10) { - return fee.toFixed(2); + return formatNumber(fee, this.locale, '1.2-2') } - return fee.toFixed(1); + return formatNumber(fee, this.locale, '1.1-1') } }