Skip to content
Snippets Groups Projects
Commit 11c063fc authored by Albin Henriksson's avatar Albin Henriksson
Browse files

Resolve "Use duplicate api"

parent ba129d7c
No related branches found
No related tags found
1 merge request!81Resolve "Use duplicate api"
Pipeline #41613 passed with warnings
......@@ -83,6 +83,20 @@ const CompetitionManager: React.FC = (props: any) => {
}
}
const handleDuplicateCompetition = async () => {
if (activeId) {
await axios
.post(`/competitions/${activeId}/copy`)
.then(() => {
setAnchorEl(null)
dispatch(getCompetitions())
})
.catch(({ response }) => {
console.warn(response.data)
})
}
}
const handleFilterChange = (newParams: CompetitionFilterParams) => {
dispatch(setFilterParams(newParams))
dispatch(getCompetitions())
......@@ -177,7 +191,7 @@ const CompetitionManager: React.FC = (props: any) => {
/>
<Menu id="simple-menu" anchorEl={anchorEl} keepMounted open={Boolean(anchorEl)} onClose={handleClose}>
<MenuItem onClick={() => history.push(`/presenter/id=${activeId}&code=123123`)}>Starta</MenuItem>
<MenuItem onClick={handleClose}>Duplicera</MenuItem>
<MenuItem onClick={handleDuplicateCompetition}>Duplicera</MenuItem>
<RemoveMenuItem onClick={handleDeleteCompetition}>Ta bort</RemoveMenuItem>
</Menu>
</div>
......
......@@ -76,9 +76,7 @@ const AdminLogin: React.FC = () => {
fullWidth
variant="contained"
color="secondary"
disabled={
!formik.isValid || formik.values.model?.email === '' || formik.values.model?.email === '' || loading
}
disabled={!!formik.errors.model?.password || !!formik.errors.model?.email || loading}
>
Logga in
</Button>
......
......@@ -128,16 +128,13 @@ const PresentationEditorPage: React.FC = () => {
}
const handleDuplicateSlide = async () => {
const response = await axios.post(`/competitions/${id}/slides`)
const newOrder = response.data.items[response.data.total_count - 1].order
const oldSlide = competition.slides.find((slide) => slide.order === contextState.slideOrder)
await axios.put(`/competitions/${id}/slides/${newOrder}`, { timer: oldSlide?.timer, title: oldSlide?.title })
await axios.post(`/competitions/${id}/slides/${contextState.slideOrder}/copy`)
dispatch(getEditorCompetition(id))
setContextState(initialState)
}
const renderSlideIcon = (slide: RichSlide) => {
switch (slide.questions[0].type_id) {
switch (slide.questions && slide.questions[0].type_id) {
case 0:
return <InfoOutlinedIcon></InfoOutlinedIcon> // information slide
case 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment