-
Notifications
You must be signed in to change notification settings - Fork 30
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
app-root, lib-user: Add ProfileHeader to UserStats, refactor related API requests #5898
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a9b36dc
Pass authClient to UserStats
mcbouslog f9005b0
Init UserStats add ProfileHeader
mcbouslog 661e8e8
Refactor lib-user auth and user request
mcbouslog fc0c22d
Refactor useUserStats
mcbouslog ba8dbcb
Refactor hooks for auth and oauth
mcbouslog 9cb1c5d
Add stats hosts
mcbouslog 3395dbd
Merge branch 'master' into app-root-user-stats-profile
mcbouslog bcf7394
Fix ProfileHeader test
mcbouslog eae9fe2
Refactor ProfileHeader titled stats
mcbouslog 2de48ce
Move dateRanges
mcbouslog 2b4cf19
Add statsQuery to UserStats
mcbouslog 5ebea83
Remove withResponsiveContext, replace with Grommet ResponsiveContext
mcbouslog 41a4e87
Refactor user login usage
mcbouslog 99a8468
Merge branch 'master' into app-root-user-stats-profile
mcbouslog 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
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.
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.
In what scenario could this be
NaN
? I ask because thevalue
prop passed to TitledStat is a requirednumber
, so without an inline code comment here I'm confused why these additional lines are needed.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.
Yes, great question, the reason these lines I think are necessary surprised me.
typeof NaN
is actually'number'
(which made me lol, I had forgotten that JavaScript quirk).NaN
can result from invalid arithmetic operations (as well as other reasons), and I think while loading stats or if there are no hours then the result of the equation that converts the seconds can result inNaN
.