Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UniSport_frontEnd
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
swp-unisport
team-nodejs
UniSport_frontEnd
Commits
dc839e21
Commit
dc839e21
authored
4 years ago
by
philippkb
Browse files
Options
Downloads
Patches
Plain Diff
sportsView has a working state
parent
6fe82bde
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/admin/sports/SportartenTable.tsx
+15
-4
15 additions, 4 deletions
src/components/admin/sports/SportartenTable.tsx
src/components/admin/sports/SportartenView.tsx
+5
-21
5 additions, 21 deletions
src/components/admin/sports/SportartenView.tsx
with
20 additions
and
25 deletions
src/components/admin/sports/SportartenTable.tsx
+
15
−
4
View file @
dc839e21
...
...
@@ -16,13 +16,15 @@ import {ICategorie, ISport} from "./sportsMockData";
interface
SportartenTableProps
{
categories
:
ICategorie
[]
sportarten
:
ISport
[]
activ
:
boolean
activ
:
boolean
,
handler
:
any
,
}
export
const
SportartenTable
:
React
.
FC
<
SportartenTableProps
>
=
({
sportarten
,
categories
,
activ
activ
,
handler
,
}:
SportartenTableProps
)
=>
{
return
(
<
Table
>
...
...
@@ -42,7 +44,7 @@ export const SportartenTable: React.FC<SportartenTableProps> = ({
</
TableRow
>
</
TableHead
>
<
TableBody
>
{
sportarten
.
map
((
elem
)
=>
{
{
sportarten
.
map
((
elem
,
tx
)
=>
{
return
(
<
TableRow
key
=
{
elem
.
name
}
>
<
TableCell
>
{
elem
.
name
}
</
TableCell
>
...
...
@@ -52,9 +54,18 @@ export const SportartenTable: React.FC<SportartenTableProps> = ({
<
TableCell
key
=
{
key
}
>
<
TextField
id
=
"outlined-basic"
label
=
"
"
type
=
"number
"
variant
=
"outlined"
value
=
{
elem
.
categoryWeights
[
key
]
}
onChange
=
{
(
e
)
=>
{
console
.
log
(
e
.
currentTarget
.
value
)
console
.
log
(
parseInt
(
e
.
currentTarget
.
value
,
10
))
let
copy
=
[...
sportarten
]
copy
[
tx
].
categoryWeights
[
key
]
=
parseInt
(
e
.
currentTarget
.
value
,
10
)
console
.
log
(
sportarten
[
3
].
categoryWeights
)
handler
(
copy
)
}
}
/>
</
TableCell
>
)
...
...
This diff is collapsed.
Click to expand it.
src/components/admin/sports/SportartenView.tsx
+
5
−
21
View file @
dc839e21
import
React
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
Fab
,
makeStyles
}
from
'
@material-ui/core
'
import
AddIcon
from
'
@material-ui/icons/Add
'
import
{
SportartenTable
}
from
'
./SportartenTable
'
...
...
@@ -14,37 +14,21 @@ const useStyles = makeStyles((theme) => ({
export
const
SportartenView
:
React
.
FC
=
()
=>
{
const
classes
=
useStyles
()
/*
const categories = [
'Teamsport',
'Ballsport',
'Wassersport',
'Solo',
'Wettkampf',
'Fitness',
]
const sportarten = [
{ name: 'Kungfu', werte: [1, 3, 5, 2, 2, 2] },
{ name: 'Volleyball', werte: [1, 3, 5, 2, 2, 2] },
{ name: 'Tischtennis', werte: [1, 3, 5, 2, 2, 2] },
{ name: 'Tischtennis', werte: [1, 3, 5, 2, 2, 2] },
{ name: 'Tischtennis', werte: [1, 3, 5, 2, 2, 2] },
{ name: 'Tischtennis', werte: [1, 3, 5, 2, 2, 2] }
]
*/
const
categories
=
mockCategorieData
const
sportarten
=
mockSportsData
const
[
categories
,
setCategories
]
=
useState
(
mockCategorieData
)
const
[
sportarten
,
setSportarten
]
=
useState
(
mockSportsData
)
return
(
<
div
>
<
h2
>
Aktive Sportarten
</
h2
>
<
SportartenTable
handler
=
{
setSportarten
}
categories
=
{
categories
}
sportarten
=
{
sportarten
}
activ
=
{
true
}
/>
<
h2
>
Inaktive Sportarten
</
h2
>
<
SportartenTable
handler
=
{
setSportarten
}
categories
=
{
categories
}
sportarten
=
{
sportarten
}
activ
=
{
false
}
...
...
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