cedarstalking with keyboard shortcuts
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: indentify facilty

+26 -7
+1
src/api.ts
··· 2 2 3 3 export interface DirectoryPerson { 4 4 Id: string; 5 + isFaculty?: boolean; // resolved from Info/Json; heuristic until confirmed 5 6 Username: string; 6 7 FirstName: string; 7 8 LastName: string;
+25 -7
src/search-directory.tsx
··· 85 85 return /^\d{4}$/.test(phone.trim()) ? `ext. ${phone.trim()}` : phone; 86 86 } 87 87 88 + const FACULTY_TITLE_KEYWORDS = /professor|instructor|lecturer|faculty/i; 89 + 90 + function isFacultyHeuristic(person: DirectoryPerson): boolean { 91 + if (person.isFaculty !== undefined) return person.isFaculty; 92 + return !!person.Title && FACULTY_TITLE_KEYWORDS.test(person.Title); 93 + } 94 + 88 95 function parseSearchQuery(query: string): { 89 96 firstName: string; 90 97 lastName: string; ··· 139 146 return now >= start && now <= end; 140 147 }) ?? terms[0]; 141 148 const result = await getPersonInfo(person.Id, current.code, cookie); 142 - if (result) setInfo(result); 149 + if (result) { 150 + setInfo(result); 151 + // Write confirmed isFaculty back to cache 152 + const confirmed = result.faculty.isFaculty; 153 + if (person.isFaculty !== confirmed) { 154 + await mergePeopleIntoCache([{ ...person, isFaculty: confirmed }]); 155 + } 156 + } 143 157 })(); 144 158 }, [person.Id, cookie]); 145 159 ··· 150 164 const isStaff = !person.StudentType || !!(person.Title?.trim() && person.OfficeBuildingCode); 151 165 const tags: string[] = []; 152 166 if (isStaff) { 153 - tags.push("Staff"); 167 + tags.push(isFacultyHeuristic(person) ? "Faculty" : "Staff"); 154 168 } else if (person.StudentType === "DE") { 155 169 tags.push("Dual Enrollment"); 156 170 } else { ··· 211 225 person.studentWorker) && <Detail.Metadata.Separator />} 212 226 {isStaff ? ( 213 227 <Detail.Metadata.TagList title="Role"> 214 - <Detail.Metadata.TagList.Item text="Staff" color={Color.Green} /> 228 + <Detail.Metadata.TagList.Item 229 + text={isFacultyHeuristic(person) ? "Faculty" : "Staff"} 230 + color={isFacultyHeuristic(person) ? Color.Orange : Color.Green} 231 + /> 215 232 </Detail.Metadata.TagList> 216 233 ) : person.StudentType === "DE" ? ( 217 234 <Detail.Metadata.TagList title="Program"> ··· 263 280 } 264 281 /> 265 282 )} 266 - {person.OfficeBuildingName && ( 283 + {person.OfficeBuildingCode && ( 267 284 <Detail.Metadata.Label 268 285 title="Office" 269 286 text={ 270 287 person.OfficeRoom 271 - ? `${person.OfficeBuildingName}, Room ${person.OfficeRoom}` 272 - : person.OfficeBuildingName 288 + ? `${person.OfficeBuildingCode} ${person.OfficeRoom}` 289 + : person.OfficeBuildingCode 273 290 } 274 291 /> 275 292 )} ··· 419 436 // Badge 420 437 let badge: List.Item.Accessory | null = null; 421 438 if (!isStudent) { 422 - badge = { tag: { value: "Staff", color: Color.Green } }; 439 + const faculty = isFacultyHeuristic(person); 440 + badge = { tag: { value: faculty ? "Faculty" : "Staff", color: faculty ? Color.Orange : Color.Green } }; 423 441 } else if (person.StudentType === "DE") { 424 442 badge = { tag: { value: "DE", color: Color.Orange } }; 425 443 } else if (person.StudentType === "GS" || person.StudentClass === "GS") {