Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
7d13d8e5
Commit
7d13d8e5
authored
3 years ago
by
Björn Modée
Browse files
Options
Downloads
Patches
Plain Diff
Add dialog when deleting a competition
parent
cd476058
No related branches found
No related tags found
1 merge request
!134
Add dialog when deleting a competition
Pipeline
#44635
passed with warnings
3 years ago
Stage: setup
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/src/pages/admin/competitions/CompetitionManager.tsx
+40
-2
40 additions, 2 deletions
client/src/pages/admin/competitions/CompetitionManager.tsx
with
40 additions
and
2 deletions
client/src/pages/admin/competitions/CompetitionManager.tsx
+
40
−
2
View file @
7d13d8e5
...
...
@@ -4,6 +4,7 @@ import {
Dialog
,
DialogActions
,
DialogContent
,
DialogContentText
,
DialogTitle
,
ListItem
,
ListItemText
,
...
...
@@ -12,13 +13,14 @@ import {
TextField
,
Tooltip
,
Typography
,
useMediaQuery
,
}
from
'
@material-ui/core
'
import
FormControl
from
'
@material-ui/core/FormControl
'
import
InputLabel
from
'
@material-ui/core/InputLabel
'
import
MenuItem
from
'
@material-ui/core/MenuItem
'
import
Paper
from
'
@material-ui/core/Paper
'
import
Select
from
'
@material-ui/core/Select
'
import
{
createStyles
,
makeStyles
,
Theme
}
from
'
@material-ui/core/styles
'
import
{
createStyles
,
makeStyles
,
Theme
,
useTheme
}
from
'
@material-ui/core/styles
'
import
Table
from
'
@material-ui/core/Table
'
import
TableBody
from
'
@material-ui/core/TableBody
'
import
TableCell
from
'
@material-ui/core/TableCell
'
...
...
@@ -72,6 +74,11 @@ interface Code {
}
const
CompetitionManager
:
React
.
FC
=
(
props
:
any
)
=>
{
// for dialog alert
const
[
openAlert
,
setOpen
]
=
React
.
useState
(
false
)
const
theme
=
useTheme
()
const
fullScreen
=
useMediaQuery
(
theme
.
breakpoints
.
down
(
'
sm
'
))
const
[
anchorEl
,
setAnchorEl
]
=
React
.
useState
<
null
|
HTMLElement
>
(
null
)
const
[
activeId
,
setActiveId
]
=
React
.
useState
<
number
|
undefined
>
(
undefined
)
const
[
timerHandle
,
setTimerHandle
]
=
React
.
useState
<
number
|
undefined
>
(
undefined
)
...
...
@@ -101,6 +108,10 @@ const CompetitionManager: React.FC = (props: any) => {
setActiveId
(
undefined
)
}
const
handleCloseVerify
=
()
=>
{
setOpen
(
false
)
}
useEffect
(()
=>
{
dispatch
(
getCompetitions
())
},
[])
...
...
@@ -116,8 +127,13 @@ const CompetitionManager: React.FC = (props: any) => {
dispatch
(
setFilterParams
({
...
filterParams
,
name
:
event
.
target
.
value
}))
}
const
handleVerifyDelete
=
()
=>
{
setOpen
(
true
)
}
// Function to remove a competition from the systems database
const
handleDeleteCompetition
=
async
()
=>
{
setOpen
(
false
)
if
(
activeId
)
{
await
axios
.
delete
(
`/api/competitions/
${
activeId
}
`
)
...
...
@@ -334,10 +350,32 @@ const CompetitionManager: React.FC = (props: any) => {
<
MenuItem
onClick
=
{
handleStartCompetition
}
>
Starta
</
MenuItem
>
<
MenuItem
onClick
=
{
handleOpenDialog
}
>
Visa koder
</
MenuItem
>
<
MenuItem
onClick
=
{
handleDuplicateCompetition
}
>
Duplicera
</
MenuItem
>
<
RemoveMenuItem
onClick
=
{
handleDelete
Competition
}
data-testid
=
"removeCompetitionButton"
>
<
RemoveMenuItem
onClick
=
{
handle
Verify
Delete
}
data-testid
=
"removeCompetitionButton"
>
Ta bort
</
RemoveMenuItem
>
</
Menu
>
<
Dialog
fullScreen
=
{
fullScreen
}
open
=
{
openAlert
}
onClose
=
{
handleCloseVerify
}
aria-labelledby
=
"responsive-dialog-title"
>
<
DialogTitle
id
=
"responsive-dialog-title"
>
{
'
Ta bort tävlingen?
'
}
</
DialogTitle
>
<
DialogContent
>
<
DialogContentText
>
Är du säker på att du vill ta bort tävlingen och all dess information från systemet?
</
DialogContentText
>
</
DialogContent
>
<
DialogActions
>
<
Button
autoFocus
onClick
=
{
handleCloseVerify
}
color
=
"primary"
>
Avbryt
</
Button
>
<
Button
data-testid
=
"acceptRemoveUser"
onClick
=
{
handleDeleteCompetition
}
color
=
"primary"
autoFocus
>
Ta bort
</
Button
>
</
DialogActions
>
</
Dialog
>
<
Dialog
open
=
{
dialogIsOpen
}
onClose
=
{
handleCloseDialog
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment