-
-
Notifications
You must be signed in to change notification settings - Fork 596
refactor the cardDetailsPage #2440
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,56 @@ | ||
| import RecentIssues from 'components/RecentIssues' | ||
| import RecentPullRequests from 'components/RecentPullRequests' | ||
| import RecentReleases from 'components/RecentReleases' | ||
| import Milestones from 'components/Milestones' | ||
| import type { Issue } from 'types/issue' | ||
| import type { PullRequest } from 'types/pullRequest' | ||
| import type { Milestone } from 'types/milestone' | ||
| import type { Release } from 'types/release' | ||
|
|
||
| interface ActivitySectionProps { | ||
| type: string | ||
| recentIssues?: Issue[] | ||
| pullRequests?: PullRequest[] | ||
| recentMilestones?: Milestone[] | ||
| recentReleases?: Release[] | ||
| showAvatar?: boolean | ||
| } | ||
|
|
||
| const ActivitySection = ({ | ||
| type, | ||
| recentIssues, | ||
| pullRequests, | ||
| recentMilestones, | ||
| recentReleases, | ||
| showAvatar, | ||
| }: ActivitySectionProps) => ( | ||
| <> | ||
| {(type === 'project' || | ||
| type === 'repository' || | ||
| type === 'user' || | ||
| type === 'organization') && ( | ||
| <div className="grid-cols-2 gap-4 lg:grid"> | ||
| <RecentIssues data={recentIssues} showAvatar={showAvatar} /> | ||
| {type === 'user' || | ||
| type === 'organization' || | ||
| type === 'repository' || | ||
| type === 'project' ? ( | ||
| <Milestones data={recentMilestones} showAvatar={showAvatar} /> | ||
| ) : ( | ||
| <RecentReleases data={recentReleases} showAvatar={showAvatar} showSingleColumn={true} /> | ||
| )} | ||
| </div> | ||
| )} | ||
| {(type === 'project' || | ||
| type === 'repository' || | ||
| type === 'organization' || | ||
| type === 'user') && ( | ||
| <div className="grid-cols-2 gap-4 lg:grid"> | ||
| <RecentPullRequests data={pullRequests} showAvatar={showAvatar} /> | ||
| <RecentReleases data={recentReleases} showAvatar={showAvatar} showSingleColumn={true} /> | ||
| </div> | ||
| )} | ||
|
Comment on lines
+28
to
+52
Contributor
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 redundant conditional logic and unreachable code. The logic contains multiple critical issues:
This suggests the original intent was different conditional logic for different type combinations. Clarify the intended rendering logic. If both grids should always display together for these types, simplify to: - <>
- {(type === 'project' ||
- type === 'repository' ||
- type === 'user' ||
- type === 'organization') && (
+ <>
+ {(type === 'project' || type === 'repository' || type === 'user' || type === 'organization') && (
+ <>
<div className="grid-cols-2 gap-4 lg:grid">
<RecentIssues data={recentIssues} showAvatar={showAvatar} />
- {type === 'user' ||
- type === 'organization' ||
- type === 'repository' ||
- type === 'project' ? (
- <Milestones data={recentMilestones} showAvatar={showAvatar} />
- ) : (
- <RecentReleases data={recentReleases} showAvatar={showAvatar} showSingleColumn={true} />
- )}
+ <Milestones data={recentMilestones} showAvatar={showAvatar} />
</div>
- )}
- {(type === 'project' ||
- type === 'repository' ||
- type === 'organization' ||
- type === 'user') && (
<div className="grid-cols-2 gap-4 lg:grid">
<RecentPullRequests data={pullRequests} showAvatar={showAvatar} />
<RecentReleases data={recentReleases} showAvatar={showAvatar} showSingleColumn={true} />
</div>
+ </>
)}
</>If different types should show different content, please clarify the requirements.
🤖 Prompt for AI Agents |
||
| </> | ||
| ) | ||
|
|
||
| export default ActivitySection; | ||
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.
🛠️ Refactor suggestion | 🟠 Major
Remove duplicate type definition.
ActivitySectionPropsis defined locally but also exists intypes/components.ts(per relevant snippets). The two definitions differ: the local version marks arrays as optional, whiletypes/components.tsdefines them as required. This duplication creates maintenance overhead and type inconsistency risk.Remove the local interface and import from the shared types file:
📝 Committable suggestion
🤖 Prompt for AI Agents