currency for market
This commit is contained in:
@@ -17,6 +17,7 @@ import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
})
|
||||
export class HeaderComponent {
|
||||
cartItemCount;
|
||||
cartTotal;
|
||||
menuOpen = false;
|
||||
brandName = environment.brandFullName;
|
||||
logo = environment.logo;
|
||||
@@ -28,6 +29,7 @@ export class HeaderComponent {
|
||||
|
||||
constructor(private cartService: CartService, private router: Router) {
|
||||
this.cartItemCount = this.cartService.itemCount;
|
||||
this.cartTotal = this.cartService.totalPrice;
|
||||
}
|
||||
|
||||
get homeUrl(): string {
|
||||
@@ -79,4 +81,20 @@ export class HeaderComponent {
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
formatCartTotal(total: number): string {
|
||||
const locale = this.langService.currentLanguage() === 'en'
|
||||
? 'en-US'
|
||||
: this.langService.currentLanguage() === 'hy'
|
||||
? 'hy-AM'
|
||||
: 'ru-RU';
|
||||
const fractionDigits = Number.isInteger(total) ? 0 : 2;
|
||||
const amount = new Intl.NumberFormat(locale, {
|
||||
minimumFractionDigits: fractionDigits,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(total);
|
||||
const currencySymbol = this.langService.getCurrentCurrency()?.symbol ?? this.langService.currentCurrency();
|
||||
|
||||
return `${amount} ${currencySymbol}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user