added tour
This commit is contained in:
@@ -17,18 +17,15 @@ const formatPrice = (amount: number | string, withLabel = false): string => {
|
||||
: " so‘m"
|
||||
: "";
|
||||
|
||||
// Agar qiymat bo‘sh yoki 0 bo‘lsa — hech narsa ko‘rsatmaymiz
|
||||
if (
|
||||
amount === "" ||
|
||||
amount === null ||
|
||||
amount === undefined ||
|
||||
Number(amount) === 0
|
||||
)
|
||||
return "";
|
||||
// Agar qiymat bo‘sh yoki null/undefined bo‘lsa — hech narsa ko‘rsatmaymiz
|
||||
if (amount === "" || amount === null || amount === undefined) return "";
|
||||
|
||||
// Faqat raqamlarni qoldiramiz
|
||||
const numeric = String(amount).replace(/\D/g, "");
|
||||
|
||||
// Agar hech qanday raqam kiritilmagan bo‘lsa, bo‘sh qaytaramiz
|
||||
if (numeric === "") return "";
|
||||
|
||||
// Raqamni 3 xonadan ajratamiz
|
||||
const formatted = numeric.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user