diff --git a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx index c645724e3c7fabda69a2ad2434f4bd7b587c8c2e..5426152ff33783745f8dc1181237cd2926b0a16a 100644 --- a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx +++ b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx @@ -27,8 +27,19 @@ it('renders presentation editor', () => { ], }, } + const typesRes: any = { + data: { + view_types: [ + { + name: '', + id: 0, + }, + ], + }, + } ;(mockedAxios.get as jest.Mock).mockImplementation((path: string, params?: any) => { if (path.startsWith('/api/competitions')) return Promise.resolve(competitionRes) + if (path.startsWith('/api/misc/types')) return Promise.resolve(typesRes) return Promise.resolve(citiesRes) }) render( diff --git a/client/src/pages/presentationEditor/PresentationEditorPage.tsx b/client/src/pages/presentationEditor/PresentationEditorPage.tsx index 65720dc9a416264e58938a03fc96246e5a0975ab..80d35c5f38c8b879976b91204f9572ac9cf5735a 100644 --- a/client/src/pages/presentationEditor/PresentationEditorPage.tsx +++ b/client/src/pages/presentationEditor/PresentationEditorPage.tsx @@ -93,9 +93,9 @@ const PresentationEditorPage: React.FC = () => { const competition = useAppSelector((state) => state.editor.competition) const competitionLoading = useAppSelector((state) => state.editor.loading) useEffect(() => { + dispatch(getTypes()) dispatch(getEditorCompetition(competitionId)) dispatch(getCities()) - dispatch(getTypes()) }, []) const setActiveSlideId = (id: number) => { @@ -177,7 +177,7 @@ const PresentationEditorPage: React.FC = () => { Applicera ändringar på samtliga vyer </Typography> <ViewButton - activeView={activeViewTypeName === 'Audience'} + $activeView={activeViewTypeName === 'Audience'} variant="contained" color="secondary" onClick={() => changeView('Audience')} @@ -185,7 +185,7 @@ const PresentationEditorPage: React.FC = () => { Åskådarvy </ViewButton> <ViewButton - activeView={activeViewTypeName === 'Team'} + $activeView={activeViewTypeName === 'Team'} variant="contained" color="secondary" onClick={() => changeView('Team')} diff --git a/client/src/pages/presentationEditor/styled.tsx b/client/src/pages/presentationEditor/styled.tsx index ea266c5e03b1517d522674136182fb22f2e3c8f2..f68eb166043c970cb5f6e69bc57b090790b1d607 100644 --- a/client/src/pages/presentationEditor/styled.tsx +++ b/client/src/pages/presentationEditor/styled.tsx @@ -8,12 +8,12 @@ export const ToolBarContainer = styled(Toolbar)` ` interface ViewButtonProps { - activeView: boolean + $activeView: boolean } export const ViewButton = styled(Button)<ViewButtonProps>` margin-right: 8px; - background: ${(props) => (props.activeView ? '#5a0017' : undefined)}; + background: ${(props) => (props.$activeView ? '#5a0017' : undefined)}; ` export const ViewButtonClicked = styled(Button)` diff --git a/client/src/pages/views/OperatorViewPage.tsx b/client/src/pages/views/OperatorViewPage.tsx index 29f2091768483e7989cecc877ae1372b389f014c..e965a3ec9f60b77b1919525f75ba2a925a81e84b 100644 --- a/client/src/pages/views/OperatorViewPage.tsx +++ b/client/src/pages/views/OperatorViewPage.tsx @@ -143,44 +143,42 @@ const OperatorViewPage: React.FC = () => { > <DialogTitle id="responsive-dialog-title">{'Koder för tävlingen'}</DialogTitle> <DialogContent> - <DialogContentText> - <ListItem> - <ListItemText primary={`Domare: ${presentation.code}`} /> - <Tooltip title="Kopiera kod" arrow> - <Button - onClick={() => { - navigator.clipboard.writeText(presentation.code) - }} - > - <FileCopyIcon fontSize="small" /> - </Button> - </Tooltip> - </ListItem> - <ListItem> - <ListItemText primary={`Tävlande: ${presentation.code}`} /> - <Tooltip title="Kopiera kod" arrow> - <Button - onClick={() => { - navigator.clipboard.writeText(presentation.code) - }} - > - <FileCopyIcon fontSize="small" /> - </Button> - </Tooltip> - </ListItem> - <ListItem> - <ListItemText primary={`Publik: ${presentation.code}`} /> - <Tooltip title="Kopiera kod" arrow> - <Button - onClick={() => { - navigator.clipboard.writeText(presentation.code) - }} - > - <FileCopyIcon fontSize="small" /> - </Button> - </Tooltip> - </ListItem> - </DialogContentText> + <ListItem> + <ListItemText primary={`Domare: ${presentation.code}`} /> + <Tooltip title="Kopiera kod" arrow> + <Button + onClick={() => { + navigator.clipboard.writeText(presentation.code) + }} + > + <FileCopyIcon fontSize="small" /> + </Button> + </Tooltip> + </ListItem> + <ListItem> + <ListItemText primary={`Tävlande: ${presentation.code}`} /> + <Tooltip title="Kopiera kod" arrow> + <Button + onClick={() => { + navigator.clipboard.writeText(presentation.code) + }} + > + <FileCopyIcon fontSize="small" /> + </Button> + </Tooltip> + </ListItem> + <ListItem> + <ListItemText primary={`Publik: ${presentation.code}`} /> + <Tooltip title="Kopiera kod" arrow> + <Button + onClick={() => { + navigator.clipboard.writeText(presentation.code) + }} + > + <FileCopyIcon fontSize="small" /> + </Button> + </Tooltip> + </ListItem> </DialogContent> <DialogActions> <Button autoFocus onClick={handleClose} color="primary"> @@ -304,11 +302,12 @@ const OperatorViewPage: React.FC = () => { }} > <List> - {teams.map((team) => ( - <ListItem key={team.id}> - {team.name} score: {team.question_answers}{' '} - </ListItem> - ))} + {teams && + teams.map((team) => ( + <ListItem key={team.id}> + {team.name} score: {team.question_answers}{' '} + </ListItem> + ))} </List> </Popover> </OperatorContainer>