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
7ec5112f
Commit
7ec5112f
authored
3 years ago
by
Albin Henriksson
Browse files
Options
Downloads
Patches
Plain Diff
Add snackbar when duplicate team names and pre-select edited team's name
parent
6afcf518
No related branches found
Branches containing commit
No related tags found
1 merge request
!151
Add snackbar when duplicate team names and pre-select edited team's name
Pipeline
#45697
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/presentationEditor/components/Teams.tsx
+17
-2
17 additions, 2 deletions
client/src/pages/presentationEditor/components/Teams.tsx
with
17 additions
and
2 deletions
client/src/pages/presentationEditor/components/Teams.tsx
+
17
−
2
View file @
7ec5112f
...
@@ -8,10 +8,12 @@ import {
...
@@ -8,10 +8,12 @@ import {
IconButton
,
IconButton
,
ListItem
,
ListItem
,
ListItemText
,
ListItemText
,
Snackbar
,
TextField
,
TextField
,
}
from
'
@material-ui/core
'
}
from
'
@material-ui/core
'
import
CloseIcon
from
'
@material-ui/icons/Close
'
import
CloseIcon
from
'
@material-ui/icons/Close
'
import
EditIcon
from
'
@material-ui/icons/Edit
'
import
EditIcon
from
'
@material-ui/icons/Edit
'
import
{
Alert
}
from
'
@material-ui/lab
'
import
axios
from
'
axios
'
import
axios
from
'
axios
'
import
React
,
{
useState
}
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
getEditorCompetition
}
from
'
../../../actions/editor
'
import
{
getEditorCompetition
}
from
'
../../../actions/editor
'
...
@@ -32,6 +34,7 @@ type TeamsProps = {
...
@@ -32,6 +34,7 @@ type TeamsProps = {
const
Teams
=
({
competitionId
}:
TeamsProps
)
=>
{
const
Teams
=
({
competitionId
}:
TeamsProps
)
=>
{
const
dispatch
=
useAppDispatch
()
const
dispatch
=
useAppDispatch
()
const
competition
=
useAppSelector
((
state
)
=>
state
.
editor
.
competition
)
const
competition
=
useAppSelector
((
state
)
=>
state
.
editor
.
competition
)
const
[
errorActive
,
setErrorActive
]
=
React
.
useState
(
false
)
const
editTeam
=
async
()
=>
{
const
editTeam
=
async
()
=>
{
if
(
editTeamState
.
variant
===
'
Add
'
)
{
if
(
editTeamState
.
variant
===
'
Add
'
)
{
await
axios
await
axios
...
@@ -46,7 +49,9 @@ const Teams = ({ competitionId }: TeamsProps) => {
...
@@ -46,7 +49,9 @@ const Teams = ({ competitionId }: TeamsProps) => {
.
then
(()
=>
{
.
then
(()
=>
{
dispatch
(
getEditorCompetition
(
competitionId
))
dispatch
(
getEditorCompetition
(
competitionId
))
})
})
.
catch
(
console
.
log
)
.
catch
((
response
)
=>
{
if
(
response
?.
response
?.
status
===
409
)
setErrorActive
(
true
)
})
}
}
setEditTeamState
({
open
:
false
})
setEditTeamState
({
open
:
false
})
}
}
...
@@ -102,7 +107,14 @@ const Teams = ({ competitionId }: TeamsProps) => {
...
@@ -102,7 +107,14 @@ const Teams = ({ competitionId }: TeamsProps) => {
<
DialogContentText
>
<
DialogContentText
>
Skriv
{
editTeamState
.
variant
===
'
Edit
'
?
'
det nya
'
:
''
}
namnet på laget och klicka sedan på bekräfta.
Skriv
{
editTeamState
.
variant
===
'
Edit
'
?
'
det nya
'
:
''
}
namnet på laget och klicka sedan på bekräfta.
</
DialogContentText
>
</
DialogContentText
>
<
TextField
autoFocus
margin
=
"dense"
label
=
"Lagnamn"
fullWidth
onChange
=
{
updateSelectedTeamName
}
/>
<
TextField
autoFocus
margin
=
"dense"
label
=
"Lagnamn"
fullWidth
onChange
=
{
updateSelectedTeamName
}
defaultValue
=
{
editTeamState
.
variant
===
'
Edit
'
?
editTeamState
.
team
?.
name
:
''
}
/>
</
DialogContent
>
</
DialogContent
>
<
DialogActions
>
<
DialogActions
>
<
Button
onClick
=
{
()
=>
setEditTeamState
({
open
:
false
})
}
color
=
"secondary"
>
<
Button
onClick
=
{
()
=>
setEditTeamState
({
open
:
false
})
}
color
=
"secondary"
>
...
@@ -113,6 +125,9 @@ const Teams = ({ competitionId }: TeamsProps) => {
...
@@ -113,6 +125,9 @@ const Teams = ({ competitionId }: TeamsProps) => {
</
Button
>
</
Button
>
</
DialogActions
>
</
DialogActions
>
</
Dialog
>
</
Dialog
>
<
Snackbar
open
=
{
errorActive
}
autoHideDuration
=
{
4000
}
onClose
=
{
()
=>
setErrorActive
(
false
)
}
>
<
Alert
severity
=
"error"
>
{
`Du kan inte välja det namnet eftersom ett annat lag har samma namn, välj ett annat namn och försök igen.`
}
</
Alert
>
</
Snackbar
>
</
SettingsList
>
</
SettingsList
>
)
)
}
}
...
...
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