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
baa9a15a
Commit
baa9a15a
authored
3 years ago
by
Björn Modée
Browse files
Options
Downloads
Patches
Plain Diff
Fix dashboard to display correct information
parent
0604b1cb
No related branches found
Branches containing commit
No related tags found
1 merge request
!139
Fix dashboard to display correct information
Pipeline
#44887
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/dashboard/components/CurrentUser.tsx
+31
-2
31 additions, 2 deletions
client/src/pages/admin/dashboard/components/CurrentUser.tsx
with
31 additions
and
2 deletions
client/src/pages/admin/dashboard/components/CurrentUser.tsx
+
31
−
2
View file @
baa9a15a
...
...
@@ -6,6 +6,35 @@ import { useAppSelector } from '../../../../hooks'
const
CurrentUser
:
React
.
FC
=
()
=>
{
const
currentUser
=
useAppSelector
((
state
:
{
user
:
{
userInfo
:
any
}
})
=>
state
.
user
.
userInfo
)
const
regions
=
useAppSelector
((
state
)
=>
state
.
cities
.
cities
)
//const regionlist = regions.map((index) => index.name)
const
regionlist
=
regions
.
map
((
index
)
=>
index
)
const
roles
=
useAppSelector
((
state
)
=>
state
.
roles
.
roles
)
const
rolelist
=
roles
.
map
((
index
)
=>
index
)
/** This is a temporary fix, these values "should" be stored in the state along with all the othe userinfo */
const
getRegionName
=
()
=>
{
if
(
currentUser
&&
regions
)
{
for
(
let
i
=
0
;
i
<
regionlist
.
length
;
i
++
)
{
if
(
regionlist
[
i
].
id
===
currentUser
.
city_id
)
{
return
regionlist
[
i
].
name
}
}
}
return
'
N/A
'
}
/** This is a temporary fix, these values "should" be stored in the state along with all the othe userinfo */
const
getRoleName
=
()
=>
{
if
(
currentUser
&&
roles
)
{
for
(
let
i
=
0
;
i
<
rolelist
.
length
;
i
++
)
{
if
(
rolelist
[
i
].
id
===
currentUser
.
role_id
)
{
return
rolelist
[
i
].
name
}
}
}
return
'
N/A
'
}
return
(
<
div
>
...
...
@@ -21,10 +50,10 @@ const CurrentUser: React.FC = () => {
</
Typography
>
</
div
>
<
div
>
<
Typography
variant
=
"h6"
>
Region:
</
Typography
>
<
Typography
variant
=
"h6"
>
Region:
{
getRegionName
()
}
</
Typography
>
</
div
>
<
div
>
<
Typography
variant
=
"h6"
>
Roll:
</
Typography
>
<
Typography
variant
=
"h6"
>
Roll:
{
getRoleName
()
}
</
Typography
>
</
div
>
</
Box
>
</
div
>
...
...
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