| 1 | import { GitFork } from "lucide-react"; |
| 2 | import Link from "next/link |
| 3 | import { notFound } |
| 4 | |
| 5 | import { FromNowHoverCard } |
| 6 | import { buttonVariants } |
| 7 | import { createServerClient } |
| 8 | import { cn } |
| 9 | |
| 10 | export default async function |
| 11 | params, |
| 12 | searchParams, |
| 13 | }: PageProps< |
| 14 | const { username, |
| 15 | const { cursor |
| 16 | |
| 17 | const client = |
| 18 | const { data |
| 19 | "/api/repositories/{username}/{slug}/forks", |
| 20 | { |
| 21 | params: { |
| 22 | path: { username, |
| 23 | query: { cursor: typeof |
| 24 | }, |
| 25 | }, |
| 26 | ); |
| 27 | |
| 28 | if (!data) |
| 29 | |
| 30 | return ( |
| 31 | <div className="flex flex-col gap-4 |
| 32 | <h1 className="flex items-center gap-2 text-lg font-semibold |
| 33 | <GitFork className=" |
| 34 | Forks |
| 35 | </h1> |
| 36 | |
| 37 | {data.forks.length |
| 38 | <div className="flex flex-col items-center gap-3 rounded-lg border border-dashed py-16 text-center |
| 39 | <p className="text-sm font-medium |
| 40 | <Link |
| 41 | href={`/${username |
| 42 | className={cn(buttonVariants |
| 43 | > |
| 44 | Fork this repository |
| 45 | </Link> |
| 46 | </div> |
| 47 | ) : ( |
| 48 | <ul className="divide-y rounded-lg border |
| 49 | {data.forks.map |
| 50 | <li |
| 51 | key={`${fork |
| 52 | className="flex flex-col gap-1 px-4 py-3" |
| 53 | > |
| 54 | <div className="flex items-center gap-2 |
| 55 | <Link |
| 56 | href={`/${fork |
| 57 | className="text-sm font-medium text-primary hover:underline" |
| 58 | > |
| 59 | {fork.username}/ |
| 60 | </Link> |
| 61 | <span className="ml-auto text-xs text-muted-foreground |
| 62 | pushed <FromNowHoverCard date={ |
| 63 | </span> |
| 64 | </div> |
| 65 | |
| 66 | {fork.description && |
| 67 | <p className="text-sm text-muted-foreground |
| 68 | {fork.description} |
| 69 | </p> |
| 70 | )} |
| 71 | </li> |
| 72 | ))} |
| 73 | </ul> |
| 74 | )} |
| 75 | |
| 76 | {data.nextCursor && |
| 77 | <Link |
| 78 | href={`/${username |
| 79 | className={cn(buttonVariants |
| 80 | > |
| 81 | Next page |
| 82 | </Link> |
| 83 | )} |
| 84 | </div> |
| 85 | ); |
| 86 | } |