shared library hinzugefügt
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Award } from "lucide-react";
|
||||
import { getServerSession } from "../../api/auth/[...nextauth]/auth";
|
||||
import { Badge } from "../../_components/Badge/Badge";
|
||||
import { Badge } from "@repo/shared-components";
|
||||
import { JSX } from "react";
|
||||
|
||||
export const Badges: () => Promise<JSX.Element> = async () => {
|
||||
@@ -16,8 +16,14 @@ export const Badges: () => Promise<JSX.Element> = async () => {
|
||||
</span>
|
||||
</h2>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{session.user.badges.length === 0 && (
|
||||
<span className="text-sm text-gray-500">
|
||||
Noch ziemlich leer hier. Du kannst dir Abzeichen erarbeiten indem du an Events
|
||||
teilnimmst.
|
||||
</span>
|
||||
)}
|
||||
{session.user.badges.map((badge, i) => {
|
||||
return <Badge name={badge} key={`${badge} - ${i}`} />;
|
||||
return <Badge badge={badge} key={`${badge} - ${i}`} />;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import { getPublicUser, prisma } from "@repo/db";
|
||||
import { TriangleAlert } from "lucide-react";
|
||||
import { PenaltyCountdown } from "./PenaltyCountdown";
|
||||
import { getServerSession } from "api/auth/[...nextauth]/auth";
|
||||
|
||||
export const Penalty = async () => {
|
||||
const session = await getServerSession();
|
||||
const openTimeban = await prisma.penalty.findMany({
|
||||
where: {
|
||||
userId: session?.user.id,
|
||||
until: {
|
||||
gte: new Date(),
|
||||
},
|
||||
suspended: false,
|
||||
type: { in: ["TIME_BAN"] },
|
||||
},
|
||||
include: {
|
||||
CreatedUser: true,
|
||||
},
|
||||
});
|
||||
|
||||
const openBans = await prisma.penalty.findMany({
|
||||
where: {
|
||||
userId: session?.user.id,
|
||||
suspended: false,
|
||||
type: { in: ["BAN"] },
|
||||
},
|
||||
include: {
|
||||
CreatedUser: true,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card bg-error shadow-xl mb-4 col-span-6 xl:col-span-3">
|
||||
{openTimeban[0] && openTimeban[0].type === "TIME_BAN" && (
|
||||
<div className="card-body text-base-300">
|
||||
<h2 className="card-title text-3xl">
|
||||
<TriangleAlert />
|
||||
Aktive Strafe - <PenaltyCountdown until={openTimeban[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">
|
||||
<span className="font-bold">Grund:</span> {openTimeban[0].reason}
|
||||
</p>
|
||||
{openTimeban[0].CreatedUser && (
|
||||
<p className="text-left">
|
||||
<span className="font-bold">Admin:</span>{" "}
|
||||
{getPublicUser(openTimeban[0].CreatedUser).fullName}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{session?.user.isBanned && (
|
||||
<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>
|
||||
{openBans[0] && (
|
||||
<>
|
||||
<p className="text-left font-bold">
|
||||
Grund: {openBans[0].reason || "Keine Begründung gefunden"}
|
||||
</p>
|
||||
{openBans[0].CreatedUser && (
|
||||
<p className="text-left">
|
||||
<span className="font-bold">Admin:</span>{" "}
|
||||
{getPublicUser(openBans[0].CreatedUser).fullName}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -83,6 +83,8 @@ export const PilotStats = async () => {
|
||||
const hours = Math.floor(totalPilotTime / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((totalPilotTime % (1000 * 60 * 60)) / (1000 * 60));
|
||||
|
||||
const totalFlownMissionsPercent = ((ownRankMissionsFlown * 100) / totalUserCount).toFixed(0);
|
||||
|
||||
return (
|
||||
<div className="stats shadow">
|
||||
<div className="stat">
|
||||
@@ -104,7 +106,8 @@ export const PilotStats = async () => {
|
||||
<div className="stat-title">Einsätze geflogen</div>
|
||||
<div className="stat-value text-primary">{totalFlownMissions}</div>
|
||||
<div className="stat-desc">
|
||||
Du bist damit unter den top {((ownRankMissionsFlown * 100) / totalUserCount).toFixed(0)}%!
|
||||
Du bist damit unter den top{" "}
|
||||
{!isNaN(Number(totalFlownMissionsPercent)) ? totalFlownMissionsPercent : 0}%!
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -233,7 +236,6 @@ export const DispoStats = async () => {
|
||||
</div>
|
||||
<div className="stat-title">Einsätze disponiert</div>
|
||||
<div className="stat-value text-primary">{totalDispatchedMissions}</div>
|
||||
<div className="stat-desc">Du bist damit unter den top 9%!</div>
|
||||
</div>
|
||||
|
||||
<div className="stat">
|
||||
|
||||
Reference in New Issue
Block a user