-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
152 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import {User} from "../lib/auth"; | ||
import {Link} from "react-router-dom"; | ||
|
||
export default function UserInfo(props: User) { | ||
const {name, profilePic, username, designation, teamName} = props; | ||
return ( | ||
<div className="box block"> | ||
<div className="header pb-0 p-4 has-text-centered"> | ||
<figure className="avatar m-auto image mb-3 is-128x128"> | ||
<img alt={name} | ||
title={name} className="is-rounded" src={profilePic}/> | ||
</figure> | ||
<h1 className="is-size-4"> | ||
<Link to={`/profile/${username}`}> | ||
{name} | ||
</Link> | ||
</h1> | ||
<p> | ||
{designation} @ {teamName} | ||
</p> | ||
</div> | ||
<hr/> | ||
<div className="block summary pt-0 p-4 is-flex is-justify-content-space-around"> | ||
<div className="is-flex is-flex-direction-column is-align-items-center"> | ||
<span className="given-count has-text-weight-bold is-size-4"> | ||
{/*{{appreciations_given}}*/} | ||
</span> | ||
<span className="is-uppercase">Given</span> | ||
</div> | ||
<div className="is-flex is-flex-direction-column is-align-items-center"> | ||
<span className="received-count has-text-weight-bold is-size-4"> | ||
{/*{{appreciations_received}}*/} | ||
</span> | ||
<span className="is-uppercase">Received</span> | ||
</div> | ||
</div> | ||
</div>); | ||
} |
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 |
---|---|---|
@@ -1,41 +1,8 @@ | ||
import {useAuth} from "../../hooks/use-auth"; | ||
import {Link} from "react-router-dom"; | ||
import React from "react"; | ||
import UserInfo from "../UserInfo"; | ||
|
||
export default function CurrentUserInfo() { | ||
const auth = useAuth(); | ||
const {name, profilePic: avatar, username, designation, teamName} = auth.user!; | ||
|
||
return ( | ||
<div className="box block"> | ||
<div className="header pb-0 p-4 has-text-centered"> | ||
<figure className="avatar m-auto image mb-3 is-128x128"> | ||
<img alt={name} | ||
title={name} className="is-rounded" src={avatar}/> | ||
</figure> | ||
<h1 className="is-size-4"> | ||
<Link to={`/profile/${username}`}> | ||
{name} | ||
</Link> | ||
</h1> | ||
<p> | ||
{designation} @ {teamName} | ||
</p> | ||
</div> | ||
<hr/> | ||
<div className="block summary pt-0 p-4 is-flex is-justify-content-space-around"> | ||
<div className="is-flex is-flex-direction-column is-align-items-center"> | ||
<span className="given-count has-text-weight-bold is-size-4"> | ||
{/*{{appreciations_given}}*/} | ||
</span> | ||
<span className="is-uppercase">Given</span> | ||
</div> | ||
<div className="is-flex is-flex-direction-column is-align-items-center"> | ||
<span className="received-count has-text-weight-bold is-size-4"> | ||
{/*{{appreciations_received}}*/} | ||
</span> | ||
<span className="is-uppercase">Received</span> | ||
</div> | ||
</div> | ||
</div>); | ||
const {user} = useAuth(); | ||
return user ? <UserInfo {...user} /> : <span>Logged out</span>; | ||
} |
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,3 @@ | ||
.container { | ||
width: 50rem; | ||
} |
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,81 @@ | ||
import React, {useCallback} from "react"; | ||
import {Link, Route, Switch, useParams, useRouteMatch} from "react-router-dom"; | ||
import UserInfo from "../UserInfo"; | ||
import {useAsync} from "../../hooks/use-async"; | ||
import {userByUsername} from "../../lib/api"; | ||
import Loading from "../Loading"; | ||
import styles from './ProfilePage.module.css'; | ||
|
||
type ProfilePageRouteParams = { | ||
username: string | ||
} | ||
|
||
type TabItemProps = React.ComponentPropsWithoutRef<any> & { | ||
path: string | ||
} | ||
|
||
function TabItem({path, children}: TabItemProps) { | ||
const match = useRouteMatch(path); | ||
|
||
const classes = []; | ||
|
||
if (match && match.path === path && match.isExact) { | ||
classes.push('is-active') | ||
} | ||
|
||
return ( | ||
<li className={classes.join(' ')}>{children}</li> | ||
) | ||
} | ||
|
||
export default function ProfilePage() { | ||
const {username} = useParams<ProfilePageRouteParams>(); | ||
|
||
const loadUserInfo = useCallback(() => userByUsername(username), [username]); | ||
const {value: user, status} = useAsync(loadUserInfo); | ||
|
||
const {path, url} = useRouteMatch(); | ||
|
||
return ( | ||
<div className={`container ${styles.container}`}> | ||
{status === "pending" && <Loading/>} | ||
{user && <UserInfo {...user} />} | ||
{status === "success" && ( | ||
<div className="box"> | ||
<Switch> | ||
<div className="tabs is-fullwidth is-medium"> | ||
<ul> | ||
<TabItem path={path}> | ||
<Link to={url}> | ||
<span className="icon"> | ||
<ion-icon name="information-circle-outline"/> | ||
</span> | ||
<span>About</span> | ||
</Link> | ||
</TabItem> | ||
<TabItem path={`${path}/mentions`}> | ||
<Link to={`${url}/mentions`}> | ||
<span className="icon is-medium"> | ||
<ion-icon name="at-outline"/> | ||
</span> | ||
<span>Mentions</span> | ||
</Link> | ||
</TabItem> | ||
<TabItem path={`${path}/personal-objectives`}> | ||
<Link to={`${url}/personal-objectives`}> | ||
<span className="icon is-medium"> | ||
<ion-icon name="rocket-outline"/> | ||
</span> | ||
<span>Personal Objectives</span> | ||
</Link> | ||
</TabItem> | ||
</ul> | ||
</div> | ||
<Route path={path}/> | ||
<Route path={`${path}/mentions`}/> | ||
<Route path={`${path}/personal-objectives`}/> | ||
</Switch> | ||
</div>)} | ||
</div> | ||
); | ||
} |
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