Changed error boundary to cover both full hub and disaptch app

This commit is contained in:
PxlLoewe
2025-05-29 22:25:30 -07:00
parent d968507484
commit 0cebe2b97e
24 changed files with 226 additions and 194 deletions

View File

@@ -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