1
Fork 0

Add logout button

This commit is contained in:
viktorstrate 2020-02-21 12:22:04 +01:00
parent f57388e276
commit b3f4264b3d
2 changed files with 33 additions and 23 deletions

View File

@ -39,8 +39,7 @@ const Content = styled.div`
overflow-y: scroll; overflow-y: scroll;
` `
const SideButton = props => { const SideButtonLink = styled(NavLink)`
const StyledLink = styled(NavLink)`
text-align: center; text-align: center;
padding-top: 8px; padding-top: 8px;
padding-left: 2px; padding-left: 2px;
@ -59,12 +58,13 @@ const SideButton = props => {
:hover { :hover {
transform: scale(1.02); transform: scale(1.02);
} }
` `
const SideButton = props => {
return ( return (
<StyledLink {...props} activeStyle={{ color: '#4183c4' }}> <SideButtonLink {...props} activeStyle={{ color: '#4183c4' }}>
{props.children} {props.children}
</StyledLink> </SideButtonLink>
) )
} }
@ -120,6 +120,10 @@ const Layout = ({ children, title }) => (
return null return null
}} }}
</Query> </Query>
<SideButton to="/logout">
<Icon name="lock" />
<SideButtonLabel>Log out</SideButtonLabel>
</SideButton>
</SideMenu> </SideMenu>
</Authorized> </Authorized>
<Sidebar> <Sidebar>

View File

@ -31,6 +31,12 @@ class Routes extends React.Component {
> >
<Switch> <Switch>
<Route path="/login" component={LoginPage} /> <Route path="/login" component={LoginPage} />
<Route path="/logout">
{() => {
localStorage.removeItem('token')
location.href = '/'
}}
</Route>
<Route path="/initialSetup" component={InitialSetupPage} /> <Route path="/initialSetup" component={InitialSetupPage} />
<Route path="/share" component={SharePage} /> <Route path="/share" component={SharePage} />
<AuthorizedRoute exact path="/albums" component={AlbumsPage} /> <AuthorizedRoute exact path="/albums" component={AlbumsPage} />