Added time Ban and penalty
This commit is contained in:
36
apps/hub/app/(app)/_components/Penalty.tsx
Normal file
36
apps/hub/app/(app)/_components/Penalty.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { prisma } from "@repo/db";
|
||||
import { TriangleAlert } from "lucide-react";
|
||||
import { getServerSession } from "next-auth";
|
||||
|
||||
export const Penalty = async () => {
|
||||
const session = await getServerSession();
|
||||
const openPenaltys = await prisma.penalty.findMany({
|
||||
where: {
|
||||
userId: session?.user.id,
|
||||
until: {
|
||||
gte: new Date(),
|
||||
},
|
||||
type: "TIME_BAN",
|
||||
},
|
||||
});
|
||||
console.log("Open Penaltys:", openPenaltys);
|
||||
if (!openPenaltys[0]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
|
||||
<div className="card-body">
|
||||
<h2 className="card-title text-3xl text-center text-error">
|
||||
<TriangleAlert />
|
||||
Aktive Strafe
|
||||
</h2>
|
||||
<p>Du hast eine aktive Strafe, die dich daran hindert, an Flügen teilzunehmen.</p>
|
||||
<p>Strafe: {openPenaltys[0].reason}</p>
|
||||
{openPenaltys[0].until && (
|
||||
<p>Bis: {new Date(openPenaltys[0].until).toLocaleDateString()}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user