Skip to content

Commit 1d03d97

Browse files
fix: RepositoryCard days in review fixed not to include Draft PRs (#23)
* fix: RepositoryCard days in review fixed not to include Draft PRs * Update src/components/Cards/RepositoryCard.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8e960eb commit 1d03d97

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/components/Cards/RepositoryCard.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({ name }) => {
2828
const ref = React.useRef<HTMLDivElement>(null);
2929
const isOnScreen = useOnScreen(ref);
3030
const [isVulnerabilityExpanded, setIsVulnerabilityExpanded] = useState(false);
31-
31+
3232
const enabled = useMemo(
3333
() => isOnScreen && octokit !== undefined && name !== undefined,
3434
[isOnScreen, octokit, name]
@@ -65,9 +65,11 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({ name }) => {
6565
});
6666

6767
const oldestPr = useMemo(() => {
68-
return pulls?.sort(
69-
(prA, prB) => prA.created_at.getTime() - prB.created_at.getTime()
70-
)[0];
68+
return (pulls ?? [])
69+
.filter(({ draft }) => !draft)
70+
.sort(
71+
(prA, prB) => prA.created_at.getTime() - prB.created_at.getTime()
72+
)[0];
7173
}, [pulls]);
7274

7375
const badgeColor = useMemo(
@@ -120,21 +122,23 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({ name }) => {
120122

121123
<Box sx={{ marginLeft: "auto" }}>
122124
{repoData ? (
123-
<VulnerabilityIndicator
124-
repositoryFullName={repoData.full_name}
125+
<VulnerabilityIndicator
126+
repositoryFullName={repoData.full_name}
125127
compact={true}
126128
expanded={false}
127-
onToggleExpanded={() => setIsVulnerabilityExpanded(!isVulnerabilityExpanded)}
129+
onToggleExpanded={() =>
130+
setIsVulnerabilityExpanded(!isVulnerabilityExpanded)
131+
}
128132
showExpandButton={true}
129133
/>
130134
) : null}
131135
</Box>
132136
</Box>
133-
137+
134138
{/* Expanded vulnerability details */}
135139
{isVulnerabilityExpanded && repoData && (
136-
<VulnerabilityIndicator
137-
repositoryFullName={repoData.full_name}
140+
<VulnerabilityIndicator
141+
repositoryFullName={repoData.full_name}
138142
compact={false}
139143
expanded={true}
140144
/>

0 commit comments

Comments
 (0)