@@ -11,31 +11,16 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
1111import { useToast } from "@/hooks/use-toast" ;
1212import { useUser } from "@/context/UserContext" ;
1313import { apiRequest , queryClient } from "@/lib/queryClient" ;
14- import { isEmailInList , isSpeaker } from "@/lib/email-utils" ;
14+ import { isEmailInAttendees , isSpeaker } from "@/lib/email-utils" ;
1515import { findOverlapsWithSession } from "@/lib/session-utils" ;
1616import { formatDisplayName } from "@/lib/name-utils" ;
1717import { getInitials } from "@/lib/utils" ;
18- import type { Session , ForumData } from "@shared/schema" ;
18+ import type { Session , ForumData , Attendee } from "@shared/schema" ;
1919
20- interface UserInfo {
21- displayName : string ;
22- email : string ;
23- }
24-
25- function AttendeeItem ( { email, index } : { email : string ; index : number } ) {
26- const { data : userInfo , isLoading } = useQuery < UserInfo > ( {
27- queryKey : [ "/api/users" , email ] ,
28- queryFn : async ( ) => {
29- const res = await fetch ( `/api/users/${ encodeURIComponent ( email ) } ` ) ;
30- if ( ! res . ok ) throw new Error ( "User not found" ) ;
31- return res . json ( ) ;
32- } ,
33- staleTime : 1000 * 60 * 60 ,
34- } ) ;
35-
36- const displayName = formatDisplayName ( userInfo ?. displayName || email . split ( "@" ) [ 0 ] ) ;
37- const initials = displayName . split ( / [ \s ] + / ) . filter ( Boolean ) . slice ( 0 , 2 ) . map ( ( w : string ) => w [ 0 ] ) . join ( "" ) . toUpperCase ( ) || email . slice ( 0 , 2 ) . toUpperCase ( ) ;
38- const photoUrl = `/api/users/${ encodeURIComponent ( email ) } /photo` ;
20+ function AttendeeItem ( { attendee, index } : { attendee : Attendee ; index : number } ) {
21+ const displayName = formatDisplayName ( attendee . name ) ;
22+ const initials = displayName . split ( / [ \s ] + / ) . filter ( Boolean ) . slice ( 0 , 2 ) . map ( ( w : string ) => w [ 0 ] ) . join ( "" ) . toUpperCase ( ) || attendee . email . slice ( 0 , 2 ) . toUpperCase ( ) ;
23+ const photoUrl = attendee . photoUrl || `/api/users/${ encodeURIComponent ( attendee . email ) } /photo` ;
3924
4025 return (
4126 < div className = "flex items-center gap-3" data-testid = { `attendee-${ index } ` } >
@@ -45,13 +30,9 @@ function AttendeeItem({ email, index }: { email: string; index: number }) {
4530 { initials }
4631 </ AvatarFallback >
4732 </ Avatar >
48- { isLoading ? (
49- < Skeleton className = "h-4 w-32" />
50- ) : (
51- < span className = "text-sm truncate" data-testid = { `text-attendee-name-${ index } ` } >
52- { displayName }
53- </ span >
54- ) }
33+ < span className = "text-sm truncate" data-testid = { `text-attendee-name-${ index } ` } >
34+ { displayName }
35+ </ span >
5536 </ div >
5637 ) ;
5738}
@@ -109,7 +90,7 @@ export default function SessionDetail() {
10990
11091 const registeredSessions = useMemo ( ( ) => {
11192 if ( ! forumData ?. sessions || ! user ?. email ) return [ ] ;
112- return forumData . sessions . filter ( ( s ) => isEmailInList ( user . email , s . attendees ) ) ;
93+ return forumData . sessions . filter ( ( s ) => isEmailInAttendees ( user . email , s . attendees ) ) ;
11394 } , [ forumData ?. sessions , user ?. email ] ) ;
11495
11596 const overlappingSessions = useMemo ( ( ) => {
@@ -222,7 +203,7 @@ export default function SessionDetail() {
222203 ) ;
223204 }
224205
225- const isRegistered = user ?. email ? isEmailInList ( user . email , session . attendees ) : false ;
206+ const isRegistered = user ?. email ? isEmailInAttendees ( user . email , session . attendees ) : false ;
226207 const isUserSpeaker = user ?. email ? isSpeaker ( user . email , session . speakers ) : false ;
227208 const isPending = registerMutation . isPending || unregisterMutation . isPending ;
228209
@@ -416,8 +397,8 @@ export default function SessionDetail() {
416397 Deelnemers ({ session . capacity ? `${ session . attendees . length } /${ session . capacity } ` : session . attendees . length } )
417398 </ h3 >
418399 < div className = "space-y-3" >
419- { session . attendees . map ( ( email , index ) => (
420- < AttendeeItem key = { email } email = { email } index = { index } />
400+ { session . attendees . map ( ( attendee , index ) => (
401+ < AttendeeItem key = { attendee . email } attendee = { attendee } index = { index } />
421402 ) ) }
422403 </ div >
423404 </ CardContent >
0 commit comments