fix type persian numbers && change design loading && fix warnings && handle icons size in device mobile

This commit is contained in:
Ehsan
2025-05-19 02:41:31 +03:30
parent 254d5d4ebd
commit c8c217e286
3 changed files with 34 additions and 5 deletions
+27 -2
View File
@@ -92,7 +92,7 @@ export const alert = (type, text, prop) => {
</p>
<p className="text-[14px] font-normal">{text}</p>
</div>,
{ prop },
{ prop }
);
};
@@ -105,10 +105,19 @@ export const addLabelToList = (list) =>
});
export const formatPhoneNumber = (input) => {
const digits = input.replace(/\D/g, "");
if (typeof input !== 'string') input = String(input);
const normalized = input
.replace(/[\u06F0-\u06F9]/g, d => String(d.charCodeAt(0) - 0x06F0))
.replace(/[\u0660-\u0669]/g, d => String(d.charCodeAt(0) - 0x0660));
const digits = normalized.replace(/\D/g, "");
const trimmed = digits.substring(0, 9);
const match = trimmed.match(/^(\d{0,2})(\d{0,3})(\d{0,4})$/);
if (!match) return trimmed;
return [match[1], match[2], match[3]].filter(Boolean).join(" ");
};
@@ -175,3 +184,19 @@ export const filterList = (data) => {
childrenList: filteredChildrenList,
};
};
export function getCleanNumberValue(value, defaultValue = 0) {
if (typeof value !== 'string') value = String(value);
// Convert Persian and Arabic digits to English digits
const persianArabicToEnglish = value
.replace(/[\u06F0-\u06F9]/g, d => String(d.charCodeAt(0) - 0x06F0))
.replace(/[\u0660-\u0669]/g, d => String(d.charCodeAt(0) - 0x0660));
// Remove non-numeric characters except dots (for decimal support)
const cleaned = persianArabicToEnglish.replace(/[^0-9.]/g, '');
// Return number or default if invalid
const number = parseFloat(cleaned);
return isNaN(number) ? defaultValue : number;
}