feat: add activity view

This commit is contained in:
2024-08-24 22:12:16 -07:00
parent a137511c99
commit 4cba941389
6 changed files with 1041 additions and 1 deletions

49
src/app/activity/page.tsx Normal file
View File

@ -0,0 +1,49 @@
"use client";
import { Activity } from "@/components/activity";
import { Review } from "@/components/review";
import { Rule } from "@/components/rule";
import { Testimonials } from "@/config/Testimonials";
import { useEffect, useState } from "react";
const Reviews = (): JSX.Element => {
const [activity, setActivity] = useState<
{
type: string;
date: Date;
repo: string;
repoName: string;
}[]
>([]);
useEffect(() => {
fetch("/api/activity")
.then((data) => data.json())
.then((data) => setActivity(data));
}, []);
return (
<>
<main className="w-[95%] text-center max-w-4xl m-auto mt-16 mb-16 rounded-lg">
<h1 className="text-5xl">Recent Activity</h1>
<section>
<p className="mb-2">See what Naomi has been up to lately.</p>
<Rule />
<ol className="relative border-s border-[--primary] w-4/5 m-auto">
{activity.map((act, i) => (
<Activity
key={act.date.toString()}
type={act.type}
date={act.date}
repo={act.repo}
repoName={act.repoName}
heart={i % 2 ? "🩷" : "🩵"}
/>
))}
</ol>
</section>
</main>
</>
);
};
export default Reviews;

View File

@ -0,0 +1,17 @@
import { getCodebergData } from "@/lib/codeberg";
import { getGithubData } from "@/lib/github";
import { NextResponse } from "next/server";
export async function GET() {
const codeberg = await getCodebergData();
const github = await getGithubData();
const normalised: {
type: string;
date: Date;
repo: string;
repoName: string;
}[] = [...codeberg.map(i => ({ type: i.op_type, date: new Date(i.created), repo: i.repo.html_url, repoName: i.repo.full_name })), ...github.map(i => ({ type: i.type, date: new Date(i.created_at), repo: i.repo.url.replace("api.github.com/repos", "github.com"), repoName: i.repo.name }))]
return NextResponse.json(normalised.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()).slice(0, 100))
}