Files
var-monorepo/apps/hub/app/(app)/_components/Penalty.tsx
2025-06-23 14:30:20 +02:00

52 lines
1.6 KiB
TypeScript

import { prisma } from "@repo/db";
import { TriangleAlert } from "lucide-react";
import { getServerSession } from "next-auth";
import { PenaltyCountdown } from "./PenaltyCountdown";
export const Penalty = async () => {
const session = await getServerSession();
const openPenaltys = await prisma.penalty.findMany({
where: {
userId: session?.user.id,
until: {
gte: new Date(),
},
type: { in: ["TIME_BAN", "BAN"] },
},
});
if (!openPenaltys[0]) {
return null;
}
return (
<div className="card bg-error shadow-xl mb-4 col-span-6 xl:col-span-3">
{openPenaltys[0].type === "TIME_BAN" && (
<div className="card-body text-base-300">
<h2 className="card-title text-3xl">
<TriangleAlert />
Aktive Strafe - <PenaltyCountdown until={openPenaltys[0].until ?? new Date()} />{" "}
verbleibend
</h2>
<p className="text-left font-bold">
Du hast eine aktive Strafe und kannst dich deshalb nicht mit dem Netzwerk verbinden.
</p>
<p className="text-left font-bold">Grund: {openPenaltys[0].reason}</p>
</div>
)}
{openPenaltys[0].type === "BAN" && (
<div className="card-body text-base-300">
<h2 className="card-title text-3xl">
<TriangleAlert />
Du wurdest permanent von VirtualAirRescue ausgeschlossen.
</h2>
<p className="text-left font-bold">
Dein Fehlverhalten war so schwerwiegend, dass du dauerhaft von VirtualAirRescue
ausgeschlossen wurdest. Du kannst dich nicht mehr mit dem Netzwerk verbinden.
</p>
<p className="text-left font-bold">Grund: {openPenaltys[0].reason}</p>
</div>
)}
</div>
);
};