File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,16 @@ import IconAccount from '@material-ui/icons/AccountBalance'
18
18
import IconSettings from '@material-ui/icons/Settings'
19
19
import IconLogout from '@material-ui/icons/ExitToApp'
20
20
21
+ import { useDashboardData } from '../../_state'
22
+
21
23
const HeaderProfile = ( ) => {
22
24
const classes = useStyles ( )
23
25
const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null )
26
+ const { user } = useDashboardData ( )
27
+
28
+ if ( ! user ) {
29
+ return < div className = { clsx ( 'headerProfile' , classes . headerProfile ) } />
30
+ }
24
31
25
32
function handleClick ( event : React . MouseEvent < HTMLButtonElement > ) {
26
33
setAnchorEl ( event . currentTarget )
@@ -43,10 +50,10 @@ const HeaderProfile = () => {
43
50
>
44
51
< Avatar
45
52
className = { classes . profileAvatar }
46
- alt = "John Doe"
53
+ alt = { user . firstName }
47
54
src = "https://avatars3.githubusercontent.com/u/3959008?v=3& s = 40 "
48
55
/>
49
- < span className = { classes . profileName } > Gevorg </ span >
56
+ < span className = { classes . profileName } > { user . firstName } </ span >
50
57
< IconArrowDropDown />
51
58
</ IconButton >
52
59
< Menu
Original file line number Diff line number Diff line change @@ -11,15 +11,17 @@ export interface DashboardStateData {
11
11
user ?: User
12
12
}
13
13
export interface DashboardState extends DashboardStateStatus {
14
- data ?: DashboardStateData
14
+ data : DashboardStateData
15
+ }
16
+
17
+ const initialState : DashboardState = {
18
+ loading : false ,
19
+ error : undefined ,
20
+ data : { } ,
15
21
}
16
22
17
23
const model = createModel ( {
18
- state : {
19
- loading : false ,
20
- error : null ,
21
- data : null ,
22
- } ,
24
+ state : initialState ,
23
25
reducers : {
24
26
setStatus : (
25
27
state : DashboardState ,
Original file line number Diff line number Diff line change 1
1
import { useDispatch , useSelector } from 'react-redux'
2
2
import { RootState , RootDispatch } from '_store'
3
3
4
- import dashboard from './dashboard'
4
+ import dashboard , { DashboardState , DashboardStateData } from './dashboard'
5
5
6
6
export function useDashboardState ( ) {
7
7
return useSelector ( ( state : RootState ) => state . dashboard )
8
8
}
9
9
10
+ export function useDashboardData ( ) : DashboardStateData {
11
+ const { data } = useDashboardState ( )
12
+
13
+ return data
14
+ }
15
+
10
16
export function useDashboardEffects ( ) {
11
17
const dispatch = useDispatch < RootDispatch > ( )
12
18
return dispatch . dashboard
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ import organizationsToUsersData from './organizationsToUsersData'
5
5
const list : User [ ] = [
6
6
{
7
7
id : 1 ,
8
- firstName : 'John ' ,
9
- lastName : 'Doe ' ,
8
+ firstName : 'Gevorg ' ,
9
+ lastName : 'H ' ,
10
10
username : 'johndoe1' ,
11
11
email : 'john@doe.com' ,
12
12
avatarUrl : 'https://avatars3.githubusercontent.com/u/3959008?v=3&s=40' ,
You can’t perform that action at this time.
0 commit comments