-
-
Notifications
You must be signed in to change notification settings - Fork 199
Improve chapters/project leaders presentation #1729
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,71 @@ | ||||||||||||||
'use client' | ||||||||||||||
import { useQuery } from '@apollo/client' | ||||||||||||||
import { IconProp } from '@fortawesome/fontawesome-svg-core' | ||||||||||||||
import { User } from '@sentry/nextjs' | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect import for User type. The -import { User } from '@sentry/nextjs'
+import { User } from 'types/user' If the User type doesn't exist in 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
import { useRouter } from 'next/navigation' | ||||||||||||||
import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' | ||||||||||||||
import { GET_LEADER_DATA } from 'server/queries/userQueries' | ||||||||||||||
import { LeadersListBlockProps } from 'types/leaders' | ||||||||||||||
import AnchorTitle from 'components/AnchorTitle' | ||||||||||||||
import SecondaryCard from 'components/SecondaryCard' | ||||||||||||||
import UserCard from 'components/UserCard' | ||||||||||||||
|
||||||||||||||
const LeadersListBlock = ({ | ||||||||||||||
leaders, | ||||||||||||||
label = 'Leaders', | ||||||||||||||
icon, | ||||||||||||||
}: { | ||||||||||||||
leaders: LeadersListBlockProps | ||||||||||||||
label?: string | ||||||||||||||
icon?: IconProp | ||||||||||||||
}) => { | ||||||||||||||
const LeaderData = ({ username }: { username: string }) => { | ||||||||||||||
const { data, loading, error } = useQuery(GET_LEADER_DATA, { | ||||||||||||||
variables: { key: username }, | ||||||||||||||
}) | ||||||||||||||
const router = useRouter() | ||||||||||||||
|
||||||||||||||
if (loading) return <p>Loading {username}...</p> | ||||||||||||||
if (error) return <p>Error loading {username}'s data</p> | ||||||||||||||
|
||||||||||||||
const user = data?.user | ||||||||||||||
|
||||||||||||||
if (!user) { | ||||||||||||||
return <p>No data available for {username}</p> | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
const handleButtonClick = (user: User) => { | ||||||||||||||
router.push(`/members/${user.login}`) | ||||||||||||||
} | ||||||||||||||
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix type annotation for handleButtonClick parameter. The parameter type should match the actual user object structure from the GraphQL response, not the Sentry User type. - const handleButtonClick = (user: User) => {
+ const handleButtonClick = (user: any) => {
router.push(`/members/${user.login}`)
} Or better yet, define a proper User type and use it consistently throughout the application. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<UserCard | ||||||||||||||
avatar={user.avatarUrl} | ||||||||||||||
button={{ | ||||||||||||||
icon: <FontAwesomeIconWrapper icon="fa-solid fa-right-to-bracket" />, | ||||||||||||||
label: 'View Profile', | ||||||||||||||
onclick: () => handleButtonClick(user), | ||||||||||||||
}} | ||||||||||||||
className="h-64 w-40 bg-inherit" | ||||||||||||||
company={user.company} | ||||||||||||||
description={leaders[user.login]} | ||||||||||||||
location={user.location} | ||||||||||||||
name={user.name || username} | ||||||||||||||
/> | ||||||||||||||
) | ||||||||||||||
} | ||||||||||||||
Comment on lines
+22
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider potential performance implications and error handling improvements. The nested
For better performance, consider fetching all leader data in a single query or using GraphQL batching: // Alternative approach - single query for all leaders
const { data, loading, error } = useQuery(GET_MULTIPLE_LEADERS_DATA, {
variables: { usernames: Object.keys(leaders) },
}) 🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<SecondaryCard icon={icon} title={<AnchorTitle title={label} />}> | ||||||||||||||
<div className="flex w-full flex-col items-center justify-around overflow-hidden md:flex-row"> | ||||||||||||||
{Object.keys(leaders).map((username) => ( | ||||||||||||||
<div key={username}> | ||||||||||||||
<LeaderData username={username} /> | ||||||||||||||
</div> | ||||||||||||||
))} | ||||||||||||||
</div> | ||||||||||||||
</SecondaryCard> | ||||||||||||||
) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export default LeadersListBlock |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,9 @@ export const GET_PROJECT_DATA = gql` | |||||||||||||||||||||||||
key | ||||||||||||||||||||||||||
languages | ||||||||||||||||||||||||||
leaders | ||||||||||||||||||||||||||
leadersTemp { | ||||||||||||||||||||||||||
login | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider fetching additional User fields for complete leader display. Currently, only the
leadersTemp {
login
+ avatarUrl
+ name
+ company
+ location
+ bio
+ url
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
level | ||||||||||||||||||||||||||
name | ||||||||||||||||||||||||||
healthMetrics(limit: 30) { | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,7 @@ | ||||||||||||||||
export type LeadersListProps = { | ||||||||||||||||
leaders: string | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
export type LeadersListBlockProps = { | ||||||||||||||||
[key: string]: string | ||||||||||||||||
} | ||||||||||||||||
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) LGTM! Type definition follows requirements. The Consider adding a comment to clarify the structure: +// Maps username to certification strings (e.g., { arkid15r: 'CCSP, CISSP, CSSLP' })
export type LeadersListBlockProps = {
[key: string]: string
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
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.
🧹 Nitpick (assertive)
Consider improving method naming and documentation.
The implementation correctly exposes User objects via GraphQL, but consider the following improvements:
leaders_temp
suggests this is temporary. Based on the PR objectives, consider planning for the eventual rename.📝 Committable suggestion
🤖 Prompt for AI Agents