| 1 | import { notFound, redirect } from "next/navigation"; |
| 2 | |
| 3 | import { CreateIssueForm } |
| 4 | import { createServerClient, getServerSession |
| 5 | |
| 6 | export default async function |
| 7 | params, |
| 8 | }: PageProps< |
| 9 | const { username, |
| 10 | |
| 11 | const [session, |
| 12 | getServerSession(), |
| 13 | createServerClient(), |
| 14 | ]); |
| 15 | |
| 16 | if (!session?.user |
| 17 | redirect( |
| 18 | `/auth/sign-in?redirectTo=${encodeURIComponent(`/ |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | const [repository, |
| 23 | client.GET("/api/repositories/{username}/{slug} |
| 24 | params: { path: { |
| 25 | }), |
| 26 | client.GET("/api/repositories/{username}/{repo}/labels |
| 27 | params: { path: { |
| 28 | }), |
| 29 | ]); |
| 30 | |
| 31 | if (repository.response |
| 32 | if (!repository.data |
| 33 | |
| 34 | return ( |
| 35 | <div className="flex flex-col gap-4 |
| 36 | <div> |
| 37 | <h1 className="text-lg font-semibold |
| 38 | <p className="text-sm text-muted-foreground |
| 39 | Describe a bug, a task, or an idea for {username}/{repo |
| 40 | </p> |
| 41 | </div> |
| 42 | |
| 43 | <CreateIssueForm |
| 44 | username={username} |
| 45 | repo={repo} |
| 46 | labels={labels.data |
| 47 | /> |
| 48 | </div> |
| 49 | ); |
| 50 | } |