-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { title } from "@/components/primitives" | ||
import { Show } from "./show" | ||
|
||
export const metadata = { | ||
title: "Used by", | ||
} | ||
export default function Page() { | ||
return ( | ||
<section className="flex flex-col items-center justify-center gap-4 py-4"> | ||
<div className="inline-block max-w-lg text-center justify-center"> | ||
<h2 className={title({ color: "indigo", size: "sm" })}>Used </h2> | ||
<h2 className={title({ size: "sm" })}>By</h2> | ||
</div> | ||
<Show /> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use client" | ||
import { UsedRepoInfo } from "@/types" | ||
import { | ||
Card, | ||
CardBody, | ||
CardHeader, | ||
Image, | ||
Link, | ||
Pagination, | ||
} from "@nextui-org/react" | ||
import { useSearchParams } from "next/navigation" | ||
import { useEffect, useState } from "react" | ||
|
||
export function Show() { | ||
const searchParams = useSearchParams() | ||
const [data, setData] = useState<UsedRepoInfo[]>([]) | ||
const [total, setTotal] = useState(0) | ||
async function refetch() { | ||
const resp = await fetch("/api/used_by?" + searchParams.toString()) | ||
const { data, total } = await resp.json() | ||
setData(data) | ||
setTotal(total) | ||
} | ||
useEffect(() => { | ||
refetch() | ||
}, [searchParams]) | ||
return ( | ||
<div className="w-full pt-4 md:px-10 lg:px-[14%] flex gap-2 flex-col"> | ||
<div className="grid grid-cols-1 md:grid-cols-[repeat(auto-fill,minmax(400px,1fr))]"> | ||
{data.map((repo) => ( | ||
<Card isPressable key={repo.name}> | ||
<CardHeader className="pb-0">{repo.name}</CardHeader> | ||
<CardBody className="p-3"> | ||
<Link href={`/api?repo=${repo.name}`}> | ||
<Image src={`/api?repo=${repo.name}`} /> | ||
</Link> | ||
</CardBody> | ||
</Card> | ||
))} | ||
</div> | ||
<div className="flex justify-center"> | ||
<Pagination | ||
total={total} | ||
page={parseInt(searchParams.get("page") ?? "1")} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NextRequest, NextResponse } from "next/server" | ||
import { usedBy } from "../github" | ||
|
||
export async function GET(req: NextRequest) { | ||
try { | ||
const searchParams = req.nextUrl.searchParams | ||
const per_page = parseInt(searchParams.get("per_page") || "20") | ||
const page = parseInt(searchParams.get("page") || "1") | ||
const users = usedBy(per_page, page) | ||
return NextResponse.json(users) | ||
} catch (e: any) { | ||
return NextResponse.json({ error: e.message }, { status: 500 }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import {SVGProps} from "react"; | ||
import { SVGProps } from "react" | ||
|
||
export type IconSvgProps = SVGProps<SVGSVGElement> & { | ||
size?: number; | ||
}; | ||
size?: number | ||
} | ||
|
||
export type UsedRepoInfo = { | ||
name: string | ||
count: number | ||
} |