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
+5 -1
View File
@@ -44,9 +44,13 @@ function SearchBar({ selected, setSelected, state, handleSearch }) {
<Button <Button
onClick={handleSearch} onClick={handleSearch}
className=" className="
!rounded-[4px] !gap-2.5 !p-2 md:!p-3 lg:!p-4 !min-w-fit !rounded-[4px] !gap-2.5 !p-2 md:!p-3 lg:!p-4
!w-[38px] sm:!w-[44px] md:!w-[50px] lg:!w-[56px] !w-[38px] sm:!w-[44px] md:!w-[50px] lg:!w-[56px]
!h-[38px] sm:!h-[44px] md:!h-[50px] lg:!h-[56px] !h-[38px] sm:!h-[44px] md:!h-[50px] lg:!h-[56px]
!min-w-[38px] sm:!min-w-[44px] md:!min-w-[50px] lg:!min-w-[56px]
!min-h-[38px] sm:!min-h-[44px] md:!min-h-[50px] lg:!min-h-[56px]
!max-w-[38px] sm:!max-w-[44px] md:!max-w-[50px] lg:!max-w-[56px]
!max-h-[38px] sm:!max-h-[44px] md:!max-h-[50px] lg:!max-h-[56px]
" "
> >
<SearchD /> <SearchD />
+27 -2
View File
@@ -92,7 +92,7 @@ export const alert = (type, text, prop) => {
</p> </p>
<p className="text-[14px] font-normal">{text}</p> <p className="text-[14px] font-normal">{text}</p>
</div>, </div>,
{ prop }, { prop }
); );
}; };
@@ -105,10 +105,19 @@ export const addLabelToList = (list) =>
}); });
export const formatPhoneNumber = (input) => { 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 trimmed = digits.substring(0, 9);
const match = trimmed.match(/^(\d{0,2})(\d{0,3})(\d{0,4})$/); const match = trimmed.match(/^(\d{0,2})(\d{0,3})(\d{0,4})$/);
if (!match) return trimmed; if (!match) return trimmed;
return [match[1], match[2], match[3]].filter(Boolean).join(" "); return [match[1], match[2], match[3]].filter(Boolean).join(" ");
}; };
@@ -175,3 +184,19 @@ export const filterList = (data) => {
childrenList: filteredChildrenList, 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;
}
+2 -2
View File
@@ -28,7 +28,7 @@ api.interceptors.request.use(
} }
return request; return request;
}, },
(err) => Promise.reject(err), (err) => Promise.reject(err)
); );
api.interceptors.response.use( api.interceptors.response.use(
@@ -41,7 +41,7 @@ api.interceptors.response.use(
window.location.pathname = "/login"; window.location.pathname = "/login";
} else { } else {
} }
}, }
); );
export default api; export default api;