chore: fetch stargazers data from stargazers api

This commit is contained in:
Ephraim Atta-Duncan
2023-08-14 21:51:38 +00:00
committed by Mythie
parent a78ed42f6c
commit fdd3d7c6fe
2 changed files with 28 additions and 48 deletions

View File

@ -20,6 +20,17 @@ const ZMergedPullRequestsResponse = z.object({
total_count: z.number(),
});
const ZStargazersLiveResponse = z.record(
z.object({
stars: z.number(),
forks: z.number(),
mergedPRs: z.number(),
openIssues: z.number(),
}),
);
export type StargazersType = z.infer<typeof ZStargazersLiveResponse>;
// const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse;
export default async function OpenPage() {
@ -46,6 +57,14 @@ export default async function OpenPage() {
.then((res) => res.json())
.then((res) => ZMergedPullRequestsResponse.parse(res));
const STARGAZERS_DATA = await fetch('https://stargrazer-live.onrender.com/api/stats', {
headers: {
accept: 'application/json',
},
})
.then((res) => res.json())
.then((res) => ZStargazersLiveResponse.parse(res));
return (
<div className="mx-auto mt-12 max-w-screen-lg">
<div className="flex flex-col items-center justify-center">
@ -88,7 +107,7 @@ export default async function OpenPage() {
<FundingRaised className="col-span-12 lg:col-span-6" />
<CapTable className="col-span-12 lg:col-span-6" />
<GithubStars className="col-span-12 lg:col-span-6" />
<GithubStars className="col-span-12 lg:col-span-6" data={STARGAZERS_DATA} />
<div className="col-span-12 mt-12 flex flex-col items-center justify-center">
<h2 className="text-2xl font-bold">Where's the rest?</h2>