Skip to content

Commit

Permalink
Tidy up profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
mrseanbaines committed Jul 5, 2020
1 parent 14bad4d commit ef89cb2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/components/profile/profile.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled, { css } from 'styled-components'

export const UpperSection = styled.div(({ theme }) => {
return css`
padding: ${theme.space[3]} ${theme.space[4]};
display: grid;
gap: ${theme.space[3]};
background: ${theme.colors.background.default};
`
})

export const Details = styled.p(({ theme }) => {
return css`
text-align: center;
font-size: ${theme.fontSizes[1]};
`
})

export const Meta = styled.p(({ theme }) => {
return css`
text-align: center;
font-size: ${theme.fontSizes[1]};
color: ${theme.colors.text.muted};
`
})
17 changes: 15 additions & 2 deletions src/components/profile/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react'
import { useDispatch } from 'react-redux'
import { useDispatch, useSelector } from 'react-redux'

import Layout from 'components/layout'
import Header from 'components/header'
import { logout } from 'store/auth/actions'
import { getUser } from 'store/auth/selectors'
import * as sc from 'styles/common'
import * as s from './profile.styles'

const Profile: React.FC = () => {
const dispatch = useDispatch()
const user = useSelector(getUser)

const handleLogout = () => {
dispatch(logout())
Expand All @@ -19,8 +22,18 @@ const Profile: React.FC = () => {
<Header title='Profile' />
</sc.HeaderWrapper>

<sc.UpperSection>
<s.Details>{user?.name}</s.Details>
<s.Details>{user?.email}</s.Details>

<hr />
<s.Meta>Budgie v0.0.0</s.Meta>
</sc.UpperSection>

<Layout>
<button onClick={handleLogout}>Log out</button>
<hr />

<sc.TextButton onClick={handleLogout}>Log out</sc.TextButton>
</Layout>
</sc.Wrapper>
)
Expand Down
4 changes: 2 additions & 2 deletions src/store/auth/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const userLoading = () => ({
type: USER_LOADING,
})

const userLoaded = (user: User) => ({
const userLoaded = (payload: User) => ({
type: USER_LOADED,
user,
payload,
})

const authError = () => ({
Expand Down
2 changes: 2 additions & 0 deletions src/store/auth/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { State } from 'store'

export const getIsAuthenticated = (state: State) => state.auth.isAuthenticated

export const getUser = (state: State) => state.auth.user
2 changes: 1 addition & 1 deletion src/styles/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const HeaderWrapper = styled.div(({ theme }) => {

export const UpperSection = styled.div(({ theme }) => {
return css`
padding: ${theme.space[3]} ${theme.space[4]};
padding: ${theme.space[3]} ${theme.space[2]};
display: grid;
gap: ${theme.space[3]};
background: ${theme.colors.background.default};
Expand Down
1 change: 1 addition & 0 deletions src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const GlobalStyles = createGlobalStyle(({ theme }) => {
}
hr {
width: 100%;
border: none;
border-top: ${theme.borders.default};
}
Expand Down

0 comments on commit ef89cb2

Please sign in to comment.