feat: Enhance specialty handling and navigation across doctor and specialty pages
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user