cedarstalking with keyboard shortcuts
0
fork

Configure Feed

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

feat: format email and phone nicer

+31 -3
+3
src/api.ts
··· 83 83 person: { 84 84 box: string | null; 85 85 }; 86 + address: { 87 + addresslines: string[]; 88 + } | null; 86 89 } 87 90 88 91 export interface Department {
+28 -3
src/search-directory.tsx
··· 85 85 } 86 86 87 87 function formatPhone(phone: string): string { 88 - // 4-digit campus extensions → "ext. XXXX" 89 - return /^\d{4}$/.test(phone.trim()) ? `ext. ${phone.trim()}` : phone; 88 + const digits = phone.replace(/\D/g, ""); 89 + if (digits.length === 4) return `ext. ${digits}`; 90 + if (digits.length === 7) return `${digits.slice(0, 3)}-${digits.slice(3)}`; 91 + if (digits.length === 10) return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}`; 92 + if (digits.length === 11 && digits[0] === "1") 93 + return `+1 (${digits.slice(1, 4)}) ${digits.slice(4, 7)}-${digits.slice(7)}`; 94 + return phone.trim(); 90 95 } 91 96 92 97 const FACULTY_TITLE_KEYWORDS = /professor|instructor|lecturer|faculty/i; ··· 385 390 text={demo ? "ext. ****" : formatPhone(person.OfficePhone)} 386 391 /> 387 392 )} 388 - {!!(person.AddressCity || person.AddressState) && ( 393 + {!!(person.AddressCity || person.AddressState || info?.address?.addresslines?.length) && ( 389 394 <Detail.Metadata.Separator /> 390 395 )} 391 396 {!!(person.AddressCity || person.AddressState) && ( ··· 394 399 text={demo ? "City, OH" : [person.AddressCity, person.AddressState].filter(Boolean).join(", ")} 395 400 /> 396 401 )} 402 + {info?.address?.addresslines?.filter(Boolean).length ? ( 403 + <Detail.Metadata.Label 404 + title="Address" 405 + text={demo ? "123 Example St, City, OH 00000" : info.address.addresslines.filter(Boolean).join(", ")} 406 + /> 407 + ) : null} 397 408 {info?.student?.isStudent && (() => { 398 409 const majors = info.student.majors.filter(m => m.desc?.trim()); 399 410 const minors = info.student.minors.filter(m => m.desc?.trim()); ··· 440 451 <Action.CopyToClipboard 441 452 title="Copy Email" 442 453 content={demo ? "username@cedarville.edu" : email(person.Username)} 454 + /> 455 + )} 456 + {!demo && person.Username && ( 457 + <Action.OpenInBrowser 458 + title="Send Email" 459 + url={`mailto:${email(person.Username)}`} 460 + icon={Icon.Envelope} 443 461 /> 444 462 )} 445 463 {person.OfficePhone && ( ··· 582 600 <Action.CopyToClipboard 583 601 title="Copy Email" 584 602 content={demo ? "username@cedarville.edu" : email(person.Username)} 603 + /> 604 + )} 605 + {!demo && person.Username && ( 606 + <Action.OpenInBrowser 607 + title="Send Email" 608 + url={`mailto:${email(person.Username)}`} 609 + icon={Icon.Envelope} 585 610 /> 586 611 )} 587 612 {person.OfficePhone && (