This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
1 parent
93482bb
commit 174bce1
Showing
6 changed files
with
139 additions
and
109 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
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,98 @@ | ||
import { | ||
ClockIcon, | ||
CodeBracketIcon, | ||
LanguageIcon, | ||
StarIcon, | ||
TicketIcon, | ||
} from "@heroicons/react/20/solid"; | ||
import { getServerSession } from "next-auth/next"; | ||
import { formatDistance } from "date-fns"; | ||
|
||
import { authOptions } from "@/app/api/auth/[...nextauth]/route"; | ||
import prisma from "@/models/db"; | ||
import Heading from "@/components/Heading"; | ||
import List from "@/components/List"; | ||
import Stats from "@/components/Stats"; | ||
import { checkSummary } from "@/utils/checks"; | ||
|
||
export default async function Page({ params }) { | ||
const id = params.id; | ||
const session = await getServerSession(authOptions); | ||
if (!session) { | ||
redirect("/"); | ||
} | ||
|
||
const check = await prisma.check.findUnique({ | ||
where: { id }, | ||
include: { | ||
repository: { | ||
include: { | ||
user: true, | ||
}, | ||
}, | ||
githubResponse: true, | ||
}, | ||
}); | ||
|
||
// TODO add to above query and redirect if no result | ||
if (session.user.id !== check.repository.user.id) { | ||
redirect("/"); | ||
} | ||
|
||
const summary = checkSummary(check.data); | ||
|
||
return ( | ||
<> | ||
<Heading | ||
title={`${check.repository.owner} / ${check.repository.repo}`} | ||
actions={[ | ||
{ | ||
text: "GitHub Repo", | ||
url: check.repository.url, | ||
icon: CodeBracketIcon, | ||
}, | ||
]} | ||
extras={[ | ||
{ icon: StarIcon, text: check.githubResponse.repo.stargazers_count }, | ||
{ icon: LanguageIcon, text: check.githubResponse.repo.language }, | ||
{ | ||
icon: ClockIcon, | ||
text: formatDistance( | ||
check.githubResponse.repo.updated_at, | ||
new Date(), | ||
{ | ||
addSuffix: true, | ||
} | ||
), | ||
}, | ||
{ icon: TicketIcon, text: check.githubResponse.repo.open_issues }, | ||
]} | ||
/> | ||
<Stats | ||
data={[ | ||
{ | ||
name: "Success", | ||
stat: summary.success?.length || 0, | ||
status: "success", | ||
}, | ||
{ | ||
name: "Warning", | ||
stat: summary.warning?.length || 0, | ||
status: "warning", | ||
}, | ||
{ name: "Error", stat: summary.error?.length || 0, status: "error" }, | ||
]} | ||
/> | ||
<List | ||
data={check.data.map((check) => ({ | ||
id: check.id, | ||
href: `/checks/${check.id}`, | ||
title: check.title, | ||
status: check.status, | ||
extra: check.extra, | ||
description: check.description, | ||
}))} | ||
/> | ||
</> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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