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>
|
||||
);
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import Events from "./_components/FeaturedEvents";
|
||||
import { Stats } from "./_components/Stats";
|
||||
import { Badges } from "./_components/Badges";
|
||||
import { RecentFlights } from "(app)/_components/RecentFlights";
|
||||
import { Penalty } from "(app)/_components/Penalty";
|
||||
|
||||
export default async function Home({
|
||||
searchParams,
|
||||
@@ -12,6 +13,7 @@ export default async function Home({
|
||||
const view = stats || "pilot";
|
||||
return (
|
||||
<div>
|
||||
<Penalty />
|
||||
<Stats stats={view} />
|
||||
<div className="grid grid-cols-6 gap-4">
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
|
||||
|
||||
Reference in New Issue
Block a user