fixed build error caused by a mistake in route.ts and ContributionHeatmap.tsx
This commit is contained in:
parent
ab18ff319e
commit
559971f8a8
2 changed files with 26 additions and 8 deletions
|
|
@ -3,7 +3,7 @@ export async function GET() {
|
|||
const res = await fetch("https://git.dvorakmortonxd.dev/api/v1/users/dvorakmortonxd/activities/feeds?limit=20");
|
||||
const data = await res.json();
|
||||
return Response.json(data);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return Response.json({ error: "failed to load" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,30 @@ interface HeatmapData {
|
|||
contributions: number;
|
||||
}
|
||||
|
||||
interface Activity {
|
||||
op_type: string;
|
||||
content?: string | null;
|
||||
created: string;
|
||||
repo?: {
|
||||
full_name?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface ActivityPayload {
|
||||
Commits?: Array<{
|
||||
Message?: string;
|
||||
}>;
|
||||
HeadCommit?: {
|
||||
Message?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ContributionHeatmap() {
|
||||
const [weeks, setWeeks] = useState<{ date: string; contribs: number; level: number }[][]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(false);
|
||||
const [totalContribs, setTotalContribs] = useState(0);
|
||||
const [activities, setActivities] = useState<any[]>([]);
|
||||
const [activities, setActivities] = useState<Activity[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchHeatmap() {
|
||||
|
|
@ -78,9 +96,9 @@ export default function ContributionHeatmap() {
|
|||
try {
|
||||
const res = await fetch("/api/activities");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
const data: Activity[] = await res.json();
|
||||
// Filter to just standard push/commit events
|
||||
const valid = data.filter((d: any) => d.op_type === "commit_repo" || d.op_type === "push_repo").slice(0, 3);
|
||||
const valid = data.filter((d) => d.op_type === "commit_repo" || d.op_type === "push_repo").slice(0, 3);
|
||||
setActivities(valid);
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
@ -142,14 +160,14 @@ export default function ContributionHeatmap() {
|
|||
let msg = "No message";
|
||||
try {
|
||||
if (act.content) {
|
||||
const parsed = JSON.parse(act.content);
|
||||
const parsed = JSON.parse(act.content) as ActivityPayload;
|
||||
if (parsed.Commits && parsed.Commits.length > 0) {
|
||||
msg = parsed.Commits[0].Message.split("\n")[0];
|
||||
} else if (parsed.HeadCommit) {
|
||||
msg = parsed.Commits[0].Message?.split("\n")[0] ?? msg;
|
||||
} else if (parsed.HeadCommit?.Message) {
|
||||
msg = parsed.HeadCommit.Message.split("\n")[0];
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
return (
|
||||
<div key={idx} style={{ display: "flex", flexDirection: "column", fontSize: "0.8rem", color: "var(--fg)" }}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue