1- import React , { useState } from 'react'
2- import { useDispatch , useSelector } from 'react-redux'
3- // import { push } from 'connected-react-router'
4- import { Box , ListItem , ListItemText , Grid } from '@mui/material'
1+ import React from 'react'
2+ import { useSelector } from 'react-redux'
53import * as AuthSelectors from 'reducers/auth/selectors'
6- import JunctionTheme from 'junctionTheme.js'
4+ import { useNavigate } from 'react-router-dom'
5+
6+ import Box from '@mui/material/Box'
7+ import { styled } from '@mui/material/styles'
78import Button from 'components/generic/Button'
89import UserAvatar from 'components/UserAvatar'
9- import { useMyProfilePreview } from 'graphql/queries/userProfile'
10- import { styled } from '@mui/system'
11- import { useLocation , useNavigate } from 'react-router-dom'
10+ import LanguageMenu from 'components/LanguageMenu'
1211
1312import { useTranslation } from 'react-i18next'
14- import LanguageMenu from 'components/LanguageMenu'
1513
1614export default ( ) => {
1715 const { t } = useTranslation ( )
1816 const navigate = useNavigate ( )
19- const location = useLocation ( )
2017 const idTokenPayload = useSelector ( AuthSelectors . getIdTokenPayload )
2118 const userId = idTokenPayload ?. sub
22- const dispatch = useDispatch ( )
23- // const classes = useStyles()
2419
25- if ( ! userId ) {
26- return (
27- < Box display = "flex" flexDirection = "row" alignItems = "center" >
28- < Grid container spacing = { 0 } >
29- < Grid item xs = { 12 } >
30- < Button
31- onClick = { ( ) =>
32- navigate ( '/login' , {
33- state : { nextRoute : location . pathname } ,
34- } )
35- }
36- strong = { true }
37- >
38- { t ( 'Sign_in_' ) }
39- </ Button >
40- </ Grid >
41- </ Grid >
42- </ Box >
43- )
44- }
20+ const UserMenu = styled ( Box ) ( ( { theme } ) => ( {
21+ display : 'flex' ,
22+ alignItems : 'center' ,
23+ flexDirection : 'column' ,
24+ [ theme . breakpoints . up ( 'sm' ) ] : {
25+ flexDirection : 'row' ,
26+ } ,
27+ gap : '0.5em' ,
28+ } ) )
4529
4630 return (
47- < Box className = "tw-gap-2 tw-flex tw-flex-col md:tw-flex-row tw-items-center" >
31+ < UserMenu >
4832 < LanguageMenu />
4933 { userId ? (
5034 < >
5135 < Button
5236 onClick = { ( ) => navigate ( '/dashboard/default/' ) }
5337 strong = { true }
5438 variant = "contained"
55- // className={classes.menuBox}
5639 >
5740 { t ( 'Dashboard_' ) }
5841 </ Button >
5942 < Button
6043 onClick = { ( ) => navigate ( '/logout' ) }
6144 strong = { true }
6245 variant = "outlined"
63- className = { 'tw-bg-white tw-text-black' }
64- // className={classes.menuBox}
6546 >
6647 { t ( 'Log_out_' ) }
6748 </ Button >
@@ -76,6 +57,6 @@ export default () => {
7657 { t ( 'Sign_in_' ) }
7758 </ Button >
7859 ) }
79- </ Box >
60+ </ UserMenu >
8061 )
8162}
0 commit comments