Changed error boundary to cover both full hub and disaptch app
This commit is contained in:
@@ -7,10 +7,7 @@ import { PlaneIcon } from "lucide-react";
|
||||
export const PilotStats = async () => {
|
||||
const session = await getServerSession();
|
||||
if (!session) return null;
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
});
|
||||
|
||||
const user = session.user;
|
||||
const mostFlownStationsIds = await prisma.missionOnStationUsers.groupBy({
|
||||
where: {
|
||||
userId: user?.id,
|
||||
@@ -63,8 +60,7 @@ export const PilotStats = async () => {
|
||||
orderBy: { _count: { userId: "desc" } },
|
||||
});
|
||||
|
||||
const ownRankMissionsFlown =
|
||||
missionsFlownRanks.findIndex((rank) => rank.userId === user?.id) + 1;
|
||||
const ownRankMissionsFlown = missionsFlownRanks.findIndex((rank) => rank.userId === user?.id) + 1;
|
||||
|
||||
const totalUserCount = await prisma.user.count({
|
||||
where: {
|
||||
@@ -108,8 +104,7 @@ 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 {((ownRankMissionsFlown * 100) / totalUserCount).toFixed(0)}%!
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -140,17 +135,12 @@ export const PilotStats = async () => {
|
||||
<div className="stat-figure text-info">
|
||||
<PlaneIcon className="w-8 h-8" />
|
||||
</div>
|
||||
<div className="stat-value text-info">
|
||||
{mostFlownStation?.bosCallsign}
|
||||
</div>
|
||||
<div className="stat-title">
|
||||
War bisher dein Rettungsmittel der Wahl
|
||||
</div>
|
||||
<div className="stat-value text-info">{mostFlownStation?.bosCallsign}</div>
|
||||
<div className="stat-title">War bisher dein Rettungsmittel der Wahl</div>
|
||||
{unflownStationsCount > 0 && (
|
||||
<div className="stat-desc text-secondary">
|
||||
{unflownStationsCount}{" "}
|
||||
{unflownStationsCount > 1 ? "Stationen" : "Station"} warten noch
|
||||
auf dich!
|
||||
{unflownStationsCount} {unflownStationsCount > 1 ? "Stationen" : "Station"} warten
|
||||
noch auf dich!
|
||||
</div>
|
||||
)}
|
||||
{unflownStationsCount === 0 && (
|
||||
@@ -167,9 +157,7 @@ export const PilotStats = async () => {
|
||||
export const DispoStats = async () => {
|
||||
const session = await getServerSession();
|
||||
if (!session) return null;
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
});
|
||||
const user = session.user;
|
||||
|
||||
const dispoSessions = await prisma.connectedDispatcher.findMany({
|
||||
where: {
|
||||
@@ -275,9 +263,7 @@ export const DispoStats = async () => {
|
||||
<div className="stat-figure text-info">
|
||||
<PlaneIcon className="w-8 h-8" />
|
||||
</div>
|
||||
<div className="stat-value text-info">
|
||||
{mostDispatchedStation?.bosCallsign}
|
||||
</div>
|
||||
<div className="stat-value text-info">{mostDispatchedStation?.bosCallsign}</div>
|
||||
<div className="stat-title">Wurde von dir am meisten Disponiert</div>
|
||||
<div className="stat-desc text-secondary">
|
||||
{mostDispatchedStationIds[0]?._count.missionStationIds} Einsätze
|
||||
|
||||
Reference in New Issue
Block a user