({univProgram, selectProgram, setSelectProgram, ButtonComponent})
| 94 | } |
| 95 | |
| 96 | export function ProgramList({univProgram, selectProgram, setSelectProgram, ButtonComponent}) { |
| 97 | const univName = univProgram[0]; |
| 98 | const programList = univProgram[1]; |
| 99 | const hasPrograms = programList.length > 0; |
| 100 | const [isFolded, setIsFolded] = React.useState(!hasPrograms); |
| 101 | const region = programList[0]?.Region ?? univRegionMapping[univName] ?? []; |
| 102 | const flags = region.map((r) => regionFlagMapping[r]).filter(Boolean).join(' '); |
| 103 | return ( |
| 104 | <> |
| 105 | <ListItemButton |
| 106 | onClick={() => setIsFolded(!isFolded)} |
| 107 | > |
| 108 | {isFolded ? <ExpandMore fontSize="0.9em"/> : <NavigateNext fontSize="0.9em"/>} |
| 109 | <ListItemText |
| 110 | primary={ |
| 111 | <Box sx={{display: 'flex', justifyContent: 'space-between'}}> |
| 112 | <Typography>{univName}</Typography> |
| 113 | <Typography>{flags}</Typography> |
| 114 | </Box> |
| 115 | } |
| 116 | secondary={ |
| 117 | <Typography variant='subtitle1' sx={{fontSize: 'clamp(11px, 1.5vw, 13px)', color: 'text.secondary'}}> |
| 118 | {univAbbrFullNameMapping[univName]} |
| 119 | </Typography> |
| 120 | }/> |
| 121 | |
| 122 | </ListItemButton> |
| 123 | <Divider component="li" light/> |
| 124 | <Collapse in={isFolded} timeout='auto' unmountOnExit> |
| 125 | <List component="div" disablePadding> |
| 126 | { |
| 127 | hasPrograms ? programList.map((program) => ( |
| 128 | <ButtonComponent |
| 129 | program={program} |
| 130 | selectProgram={selectProgram} |
| 131 | setSelectProgram={setSelectProgram} |
| 132 | key={program.ProgramID} |
| 133 | /> |
| 134 | )) : <EmptyProgramButton univName={univName}/> |
| 135 | } |
| 136 | </List> |
| 137 | </Collapse> |
| 138 | </> |
| 139 | ) |
| 140 | } |
| 141 | |
| 142 | function EmptyProgramButton({univName}) { |
| 143 | return ( |
nothing calls this directly
no outgoing calls
no test coverage detected