change function and design page doctors & signin & signup & home & specialties & helper

This commit is contained in:
Ehsan
2025-05-21 16:44:34 +03:30
parent c8c217e286
commit 6c7709c342
13 changed files with 96 additions and 86 deletions
+9 -23
View File
@@ -105,11 +105,11 @@ export const addLabelToList = (list) =>
});
export const formatPhoneNumber = (input) => {
if (typeof input !== 'string') input = String(input);
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));
.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, "");
@@ -146,17 +146,6 @@ export const searchOnList = (list, value, name) => {
return newList;
};
export const addKeyToList = (list, nameKey, nameValue) => {
const newList = list.map((item) => {
return {
...item,
[nameKey]: item[nameValue],
};
});
return newList;
};
export function clearFilterParams(router, listRemove) {
const currentParams = new URLSearchParams(window.location.search);
const keysToRemove = listRemove;
@@ -171,30 +160,27 @@ export const filterList = (data) => {
const parentList = specialties.filter((item) => !item.parent);
const childrenList = specialties.filter((item) => item.parent);
const changedParentList = addKeyToList(parentList, "label", "name") || [];
const changedChildrenList = addKeyToList(childrenList, "label", "name") || [];
const filteredChildrenList =
data && data.category
? changedChildrenList.filter((item) => item.parent === data.category.id)
? childrenList.filter((item) => item.parent === data.category.id)
: [];
return {
parentList: changedParentList,
parentList: parentList,
childrenList: filteredChildrenList,
};
};
export function getCleanNumberValue(value, defaultValue = 0) {
if (typeof value !== 'string') value = String(value);
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));
.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, '');
const cleaned = persianArabicToEnglish.replace(/[^0-9.]/g, "");
// Return number or default if invalid
const number = parseFloat(cleaned);