feat: Enhance specialty handling and navigation across doctor and specialty pages

This commit is contained in:
hamed
2026-08-08 17:33:13 +03:30
parent 56e264e44c
commit 79747c443c
12 changed files with 435 additions and 27 deletions
+24
View File
@@ -25,3 +25,27 @@ export function isCategorySpecialty(specialty) {
export function isIndexableSpecialty(specialty) {
return Boolean(specialty) && !isCategorySpecialty(specialty);
}
/** زیرشاخه‌های فعالِ یک تخصص، به ترتیب weight سپس نام. */
export function childSpecialties(specialty) {
if (!specialty) return [];
return specialtiesData
.filter(
(item) =>
item?.status === 1 &&
String(item.parent_id ?? "") === String(specialty.id)
)
.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0) || a.name.localeCompare(b.name, "fa"));
}
/** والدِ فعالِ یک زیرتخصص، یا null اگر ریشه باشد. */
export function parentSpecialty(specialty) {
if (!specialty?.parent_id) return null;
return (
specialtiesData.find(
(item) => item?.status === 1 && String(item.id) === String(specialty.parent_id)
) ?? null
);
}