added reports stats for admins
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { PersonIcon } from "@radix-ui/react-icons";
|
||||
import { prisma, User } from "@repo/db";
|
||||
import { AdminForm, ConnectionHistory, ProfileForm } from "./_components/forms";
|
||||
import {
|
||||
AdminForm,
|
||||
ConnectionHistory,
|
||||
ProfileForm,
|
||||
UserReports,
|
||||
} from "./_components/forms";
|
||||
import { Error } from "../../../../_components/Error";
|
||||
|
||||
const Page = async ({ params }: { params: { id: string } }) => {
|
||||
@@ -62,6 +67,33 @@ const Page = async ({ params }: { params: { id: string } }) => {
|
||||
lastLogin: pilotSessions[pilotSessions.length - 1]?.loginTime,
|
||||
};
|
||||
|
||||
const totalReportsReports = await prisma.report.count({
|
||||
where: {
|
||||
reportedUserId: user?.id,
|
||||
},
|
||||
});
|
||||
const totalReports60Days = await prisma.report.count({
|
||||
where: {
|
||||
reportedUserId: user?.id,
|
||||
timestamp: {
|
||||
gte: new Date(Date.now() - 60 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalReportsOpen = await prisma.report.count({
|
||||
where: {
|
||||
reportedUserId: user?.id,
|
||||
reviewed: false,
|
||||
},
|
||||
});
|
||||
|
||||
const reports = {
|
||||
total: totalReportsReports,
|
||||
open: totalReportsOpen,
|
||||
total60Days: totalReports60Days,
|
||||
};
|
||||
|
||||
if (!user) return <Error statusCode={404} title="User not found" />;
|
||||
return (
|
||||
<div className="grid grid-cols-6 gap-4">
|
||||
@@ -75,7 +107,15 @@ const Page = async ({ params }: { params: { id: string } }) => {
|
||||
<ProfileForm user={user} />
|
||||
</div>
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
|
||||
<AdminForm user={user} dispoTime={dispoTime} pilotTime={pilotTime} />
|
||||
<AdminForm
|
||||
user={user}
|
||||
dispoTime={dispoTime}
|
||||
pilotTime={pilotTime}
|
||||
reports={reports}
|
||||
/>
|
||||
</div>
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-6">
|
||||
<UserReports user={user} />
|
||||
</div>
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-6">
|
||||
<ConnectionHistory user={user} />
|
||||
|
||||
Reference in New Issue
Block a user