-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/#495-change-outdated-twitter-logo
- Loading branch information
Showing
8 changed files
with
152 additions
and
8 deletions.
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,84 @@ | ||
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> | ||
<h3>User: {name}</h3> | ||
{bio && ( | ||
<IconBesideText> | ||
<User size={20} /> | ||
<p> | ||
<i>{bio}</i> | ||
</p> | ||
</IconBesideText> | ||
)} | ||
<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