This commit is contained in:
Samandar Turgunboyev
2025-10-14 16:11:32 +05:00
parent 1f1aae0ab7
commit dc478c57bb
11 changed files with 47 additions and 75 deletions

View File

@@ -1,5 +1,5 @@
import { LanguageRoutes } from '../config/i18n/types';
import { getLocale } from 'next-intl/server';
import { LanguageRoutes } from '../config/i18n/types';
/**
* Format price. With label.
@@ -10,9 +10,9 @@ import { getLocale } from 'next-intl/server';
const formatPrice = async (amount: number | string, withLabel?: boolean) => {
const locale = (await getLocale()) as LanguageRoutes;
const label = withLabel
? locale == LanguageRoutes.RU
? locale === LanguageRoutes.RU
? ' сум'
: locale == LanguageRoutes.KI
: locale === LanguageRoutes.KI
? ' сўм'
: ' som'
: '';
@@ -22,7 +22,7 @@ const formatPrice = async (amount: number | string, withLabel?: boolean) => {
const formattedDollars = dollars.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
if (String(amount).length == 0) {
if (String(amount).length === 0) {
return formattedDollars + '.' + cents + label;
} else {
return formattedDollars + label;