Skip to content

Commit cc53559

Browse files
committed
fix(types): resolve lint warnings and type-check errors in RepositoryGraph
1 parent 1dc1430 commit cc53559

4 files changed

Lines changed: 42 additions & 32 deletions

File tree

components/dashboard/DashboardClient.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { X, RefreshCw } from 'lucide-react';
66
import Link from 'next/link';
77
import { toast } from 'sonner';
88
import type { Achievement } from '@/types/dashboard';
9+
import type { GraphNode, GraphLink } from '@/types';
910

1011
import RefreshButton from './RefreshButton';
1112
import ProfileCard from './ProfileCard';
@@ -65,8 +66,8 @@ interface DashboardData {
6566
commits: number;
6667
}>;
6768
graphData: {
68-
nodes: Record<string, unknown>[];
69-
links: Record<string, unknown>[];
69+
nodes: GraphNode[];
70+
links: GraphLink[];
7071
};
7172
}
7273

@@ -568,7 +569,7 @@ export default function DashboardClient({ initialData, username }: DashboardClie
568569
<AIInsights insights={initialData.insights} />
569570
</aside>
570571

571-
{/* Full Width Bottom Section */}
572+
{/* Repository Graph Section */}
572573
<div className="col-span-1 lg:col-span-2 lg:col-start-2">
573574
<RepositoryGraph data={initialData.graphData} />
574575
</div>

components/dashboard/RepositoryGraph.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dynamic from 'next/dynamic';
44
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
5-
import { X, Star, GitFork, Clock, Box } from 'lucide-react';
5+
import { Star, GitFork, Clock, Box } from 'lucide-react';
66

77
const ForceGraph2D = dynamic(() => import('react-force-graph-2d'), { ssr: false });
88

@@ -12,27 +12,7 @@ const FILTER_COLORS = {
1212
Forks: '#F97316', // Orange
1313
};
1414

15-
interface GraphNode {
16-
id: string;
17-
name: string;
18-
type: 'User' | 'Repo' | 'Contribution' | 'Fork';
19-
val: number;
20-
color: string;
21-
stats?: {
22-
stars?: number;
23-
forks?: number;
24-
language?: string | null;
25-
updatedAt?: string;
26-
description?: string | null;
27-
};
28-
x?: number;
29-
y?: number;
30-
}
31-
32-
interface GraphLink {
33-
source: string | GraphNode;
34-
target: string | GraphNode;
35-
}
15+
import { GraphNode, GraphLink } from '@/types';
3616

3717
interface RepositoryGraphProps {
3818
data: {

lib/github.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// lib/github.ts
22

3-
import type { ContributionCalendar, ContributionDay } from '@/types';
3+
import type { ContributionCalendar, ContributionDay, GraphNode, GraphLink } from '@/types';
44
import { calculateStreak, aggregateCalendars } from '@/lib/calculate';
55
import { DistributedCache } from '@/lib/cache';
66
import { LANGUAGE_COLORS } from '@/lib/svg/languageColors';
@@ -782,12 +782,11 @@ export async function fetchContributedRepos(
782782
}
783783

784784
export async function getFullDashboardData(username: string, options: FetchOptions = {}) {
785-
const [profileResult, reposResult, calendarResult, orgsResult, contributedReposResult] =
785+
const [profileResult, reposResult, calendarResult, contributedReposResult] =
786786
await Promise.allSettled([
787787
fetchUserProfile(username, options),
788788
fetchUserRepos(username, options),
789789
fetchGitHubContributions(username, options),
790-
fetchUserOrganizations(username, options),
791790
fetchContributedRepos(username, options),
792791
]);
793792

@@ -803,7 +802,6 @@ export async function getFullDashboardData(username: string, options: FetchOptio
803802
calendarResult.status === 'fulfilled'
804803
? calendarResult.value
805804
: ({ totalContributions: 0, weeks: [] } as ContributionCalendar);
806-
const orgsData = orgsResult.status === 'fulfilled' ? orgsResult.value : [];
807805
const contributedReposData =
808806
contributedReposResult.status === 'fulfilled' ? contributedReposResult.value : [];
809807

@@ -890,8 +888,8 @@ export async function getFullDashboardData(username: string, options: FetchOptio
890888
const insights = buildInsights(streakStats, languages);
891889

892890
// Building Graph Data
893-
const nodes: Record<string, unknown>[] = [];
894-
const links: Record<string, unknown>[] = [];
891+
const nodes: GraphNode[] = [];
892+
const links: GraphLink[] = [];
895893

896894
// Central User Node
897895
nodes.push({
@@ -925,7 +923,16 @@ export async function getFullDashboardData(username: string, options: FetchOptio
925923
});
926924

927925
// Open Source Contributions
928-
contributedReposData.forEach((repo) => {
926+
contributedReposData.forEach((repoItem) => {
927+
const repo = repoItem as {
928+
name: string;
929+
nameWithOwner: string;
930+
owner?: { login: string };
931+
stargazerCount?: number;
932+
forkCount?: number;
933+
primaryLanguage?: { name: string } | null;
934+
updatedAt?: string;
935+
};
929936
nodes.push({
930937
id: repo.nameWithOwner,
931938
name: repo.name,

types/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,25 @@ export interface BadgeParams {
185185
/** Opt-in to show volumetric gradients on the monolith floor. */
186186
gradient?: boolean;
187187
}
188+
189+
export interface GraphNode {
190+
id: string;
191+
name: string;
192+
type: 'User' | 'Repo' | 'Contribution' | 'Fork';
193+
val: number;
194+
color: string;
195+
stats?: {
196+
stars?: number;
197+
forks?: number;
198+
language?: string | null;
199+
updatedAt?: string;
200+
description?: string | null;
201+
};
202+
x?: number;
203+
y?: number;
204+
}
205+
206+
export interface GraphLink {
207+
source: string | GraphNode;
208+
target: string | GraphNode;
209+
}

0 commit comments

Comments
 (0)