1- import { Box , Paper , Table , TableBody , TableCell , TableHead , TableRow , Typography } from '@mui/material' ;
1+ import { useState } from 'react' ;
2+ import {
3+ Box ,
4+ Collapse ,
5+ IconButton ,
6+ Paper ,
7+ Table ,
8+ TableBody ,
9+ TableCell ,
10+ TableHead ,
11+ TableRow ,
12+ Typography
13+ } from '@mui/material' ;
14+ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' ;
15+ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp' ;
216import LoadingIndicator from '../../components/LoadingIndicator' ;
317import ErrorPage from '../ErrorPage' ;
4- import { useAllAttendances } from '../../hooks/attendance.hooks' ;
18+ import { useAllAttendances , useAttendanceById } from '../../hooks/attendance.hooks' ;
519import { fullNamePipe } from '../../utils/pipes' ;
20+ import { MeetingAttendance } from 'shared' ;
21+
22+ interface AttendanceRowProps {
23+ attendance : MeetingAttendance ;
24+ }
25+
26+ const AttendanceRow : React . FC < AttendanceRowProps > = ( { attendance } ) => {
27+ const [ open , setOpen ] = useState ( false ) ;
28+ const { data : attendanceWithAttendees , isLoading } = useAttendanceById ( attendance . meetingAttendanceId , open ) ;
29+
30+ return (
31+ < >
32+ < TableRow hover sx = { { cursor : 'pointer' } } onClick = { ( ) => setOpen ( ( prev ) => ! prev ) } >
33+ < TableCell padding = "checkbox" >
34+ < IconButton
35+ size = "small"
36+ onClick = { ( e ) => {
37+ e . stopPropagation ( ) ;
38+ setOpen ( ( prev ) => ! prev ) ;
39+ } }
40+ >
41+ { open ? < KeyboardArrowUpIcon /> : < KeyboardArrowDownIcon /> }
42+ </ IconButton >
43+ </ TableCell >
44+ < TableCell > { attendance . teamName } </ TableCell >
45+ < TableCell > { fullNamePipe ( attendance . userCreated ) } </ TableCell >
46+ < TableCell > { new Date ( attendance . openedAt ) . toLocaleString ( ) } </ TableCell >
47+ < TableCell > { attendance . attendeesCount } </ TableCell >
48+ < TableCell > { attendance . teamMemberAttendancePercent . toFixed ( 1 ) } %</ TableCell >
49+ </ TableRow >
50+ < TableRow >
51+ < TableCell colSpan = { 6 } sx = { { py : 0 } } >
52+ < Collapse in = { open } timeout = "auto" unmountOnExit >
53+ < Box sx = { { py : 1 , px : 2 } } >
54+ < Typography variant = "subtitle2" gutterBottom >
55+ Attendees
56+ </ Typography >
57+ { isLoading ? (
58+ < LoadingIndicator />
59+ ) : ! attendanceWithAttendees || attendanceWithAttendees . attendees . length === 0 ? (
60+ < Typography variant = "body2" color = "text.secondary" >
61+ No attendees recorded.
62+ </ Typography >
63+ ) : (
64+ < Box sx = { { display : 'flex' , flexWrap : 'wrap' , gap : 1 } } >
65+ { attendanceWithAttendees . attendees . map ( ( user ) => (
66+ < Typography key = { user . userId } variant = "body2" >
67+ { fullNamePipe ( user ) }
68+ </ Typography >
69+ ) ) }
70+ </ Box >
71+ ) }
72+ </ Box >
73+ </ Collapse >
74+ </ TableCell >
75+ </ TableRow >
76+ </ >
77+ ) ;
78+ } ;
679
780const AdminToolsAttendanceConfig : React . FC = ( ) => {
881 const { data : attendances , isLoading, isError, error } = useAllAttendances ( ) ;
@@ -19,6 +92,7 @@ const AdminToolsAttendanceConfig: React.FC = () => {
1992 < Table size = "small" >
2093 < TableHead >
2194 < TableRow >
95+ < TableCell />
2296 < TableCell sx = { { fontWeight : 600 } } > Team Name</ TableCell >
2397 < TableCell sx = { { fontWeight : 600 } } > Initiated By</ TableCell >
2498 < TableCell sx = { { fontWeight : 600 } } > Date/Time</ TableCell >
@@ -29,20 +103,12 @@ const AdminToolsAttendanceConfig: React.FC = () => {
29103 < TableBody >
30104 { ! attendances || attendances . length === 0 ? (
31105 < TableRow >
32- < TableCell colSpan = { 5 } align = "center" >
106+ < TableCell colSpan = { 6 } align = "center" >
33107 No attendance records yet.
34108 </ TableCell >
35109 </ TableRow >
36110 ) : (
37- attendances . map ( ( attendance ) => (
38- < TableRow key = { attendance . meetingAttendanceId } hover >
39- < TableCell > { attendance . teamName } </ TableCell >
40- < TableCell > { fullNamePipe ( attendance . userCreated ) } </ TableCell >
41- < TableCell > { new Date ( attendance . openedAt ) . toLocaleString ( ) } </ TableCell >
42- < TableCell > { attendance . attendeesCount } </ TableCell >
43- < TableCell > { attendance . teamMemberAttendancePercent . toFixed ( 1 ) } %</ TableCell >
44- </ TableRow >
45- ) )
111+ attendances . map ( ( attendance ) => < AttendanceRow key = { attendance . meetingAttendanceId } attendance = { attendance } /> )
46112 ) }
47113 </ TableBody >
48114 </ Table >
0 commit comments