-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app-root, lib-user: Add ProfileHeader to UserStats, refactor related …
…API requests (#5898) * Pass authClient to UserStats * Init UserStats add ProfileHeader * Refactor lib-user auth and user request * Refactor useUserStats * Refactor hooks for auth and oauth * Add stats hosts * Fix ProfileHeader test * Refactor ProfileHeader titled stats * Move dateRanges * Add statsQuery to UserStats * Remove withResponsiveContext, replace with Grommet ResponsiveContext * Refactor user login usage
- Loading branch information
Showing
20 changed files
with
137 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
'use client' | ||
|
||
import { UserStats } from '@zooniverse/user' | ||
import auth from 'panoptes-client/lib/auth' | ||
|
||
export default function UserPage() { | ||
return ( | ||
<UserStats /> | ||
<UserStats | ||
authClient={auth} | ||
/> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,44 +1,49 @@ | ||
'use client' | ||
|
||
// This component is a work in progress. It is not intended to be imported as-is, but is currently being used for initial UserStats local development. | ||
import { object } from 'prop-types' | ||
|
||
import { node } from 'prop-types' | ||
import { | ||
usePanoptesUser, | ||
useUserStats | ||
} from '@hooks' | ||
|
||
import Layout from '../shared/Layout/Layout' | ||
import ContentBox from '../shared/ContentBox/ContentBox' | ||
import ProfileHeader from '../shared/ProfileHeader/ProfileHeader' | ||
|
||
function UserStats ({ | ||
children | ||
authClient | ||
}) { | ||
const { data: user, error, isLoading } = usePanoptesUser(authClient) | ||
|
||
const statsQuery = { | ||
period: 'year', | ||
project_contributions: true, | ||
time_spent: true | ||
} | ||
const { data: userStats, error: statsError, isLoading: statsLoading } = useUserStats({ authClient, query: statsQuery, userID: user?.id }) | ||
|
||
return ( | ||
<Layout> | ||
<div> | ||
<div style={{ | ||
borderRadius: '8px', | ||
border: '0.5px solid #A6A7A9', | ||
boxShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.25)', | ||
color: 'black', | ||
height: '472px', | ||
marginBottom: '30px' | ||
}}> | ||
<p>User profile header goes here.</p> | ||
<p>Bar chart goes here.</p> | ||
</div> | ||
<div style={{ | ||
borderRadius: '8px', | ||
border: '0.5px solid #A6A7A9', | ||
boxShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.25)', | ||
color: 'black', | ||
height: '300px' | ||
}}> | ||
<p>Top projects goes here.</p> | ||
</div> | ||
</div> | ||
<ContentBox | ||
direction='column' | ||
gap='32px' | ||
height='400px' | ||
> | ||
<ProfileHeader | ||
avatar={user?.avatar_src} | ||
classifications={userStats?.total_count} | ||
displayName={user?.display_name} | ||
login={user?.login} | ||
projects={userStats?.project_contributions?.length} | ||
/> | ||
</ContentBox> | ||
</Layout> | ||
) | ||
} | ||
|
||
UserStats.propTypes = { | ||
children: node | ||
authClient: object | ||
} | ||
|
||
export default UserStats |
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
5 changes: 4 additions & 1 deletion
5
packages/lib-user/src/components/shared/BarChart/BarChart.stories.js
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 @@ | ||
export { default as Layout } from './Layout.js' |
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
5 changes: 4 additions & 1 deletion
5
packages/lib-user/src/components/shared/Select/Select.stories.js
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
Oops, something went wrong.