currency for market

This commit is contained in:
sdarbinyan
2026-06-20 14:00:28 +04:00
parent a06b654103
commit 9386fbc2f8
3 changed files with 102 additions and 38 deletions

View File

@@ -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}`;
}
}