-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View user profiles #582
Merged
Merged
View user profiles #582
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5801eab
created UserProfile component and linking in progress
1679353
fixed missing .js format and commiting before fetch
0b7c3b0
/users/:id now returns a page with raw data
4117c7a
more or less done user page + links from entryoverview and review
6e0077d
Merge branch 'main' into view-user-profiles
38b8e67
/users/:id route is now part of authroutes
aae402f
updated styling of user page and links to it
a52a3cd
Merge branch 'main' of https://github.com/falling-fruit/falling-fruit…
994e790
changed link styles / time formatting / synced styles of import and u…
e07a2a6
Merge branch 'main' into view-user-profiles
3d26a1e
user icon moved to bio
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { ArrowBack, Calendar, User } from '@styled-icons/boxicons-regular' | ||
import { useEffect, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useParams } from 'react-router-dom' | ||
import styled from 'styled-components/macro' | ||
|
||
import { getUserById } from '../../utils/api' | ||
import { useAppHistory } from '../../utils/useAppHistory' | ||
import { PageScrollWrapper, PageTemplate } from '../about/PageTemplate' | ||
import { formatISOString } from '../entry/textFormatters' | ||
import BackButton from '../ui/BackButton' | ||
import { theme } from '../ui/GlobalStyle' | ||
import IconBesideText from '../ui/IconBesideText' | ||
import { LoadingOverlay } from '../ui/LoadingIndicator' | ||
|
||
const StyledNavBack = styled.div` | ||
svg { | ||
height: 20px; | ||
margin-right: 5px; | ||
} | ||
` | ||
const UserProfile = () => { | ||
const { id } = useParams() | ||
const history = useAppHistory() | ||
const { t, i18n } = useTranslation() | ||
const [userData, setUserData] = useState({}) | ||
const [isLoading, setIsLoading] = useState(true) | ||
|
||
useEffect(() => { | ||
async function fetchUserData() { | ||
setIsLoading(true) | ||
|
||
const data = await getUserById(id) | ||
setUserData(data) | ||
|
||
setIsLoading(false) | ||
} | ||
|
||
fetchUserData() | ||
}, [id]) | ||
|
||
if (isLoading) { | ||
return <LoadingOverlay /> | ||
} | ||
|
||
const { created_at, name, bio } = userData | ||
|
||
return ( | ||
<PageScrollWrapper> | ||
<PageTemplate> | ||
<StyledNavBack> | ||
<BackButton | ||
onClick={(event) => { | ||
event.stopPropagation() | ||
history.goBack() | ||
}} | ||
> | ||
<ArrowBack /> | ||
{t('back')} | ||
</BackButton> | ||
</StyledNavBack> | ||
<IconBesideText> | ||
<User size={40} /> | ||
<h3>User: {name}</h3> | ||
</IconBesideText> | ||
<p> | ||
<i>{bio}</i> | ||
</p> | ||
<IconBesideText> | ||
<Calendar color={theme.secondaryText} size={20} /> | ||
<p> | ||
<time dateTime={created_at}> | ||
{`Joined on ${formatISOString(created_at, i18n.language)}`} | ||
</time> | ||
</p> | ||
</IconBesideText> | ||
</PageTemplate> | ||
</PageScrollWrapper> | ||
) | ||
} | ||
|
||
export default UserProfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to style this - maybe text-decoration: none (undoing the underline styling) and theme.orange for color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even undoing all the link styling is an option - then the feature won't be discoverable on mobile for now, and will only be known to be a link on desktop because of pointer cursor, but that's fine, since we don't have much content for the pages yet.