revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,14 +1,14 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { AvatarImage } from "@/components/shared/avatar-image";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import Link from 'next/link'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { AvatarImage } from '@/components/shared/avatar-image'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { canAccess, getAdminContext, PERMS } from '@/lib/permissions'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
export default async function ModTeamPage() {
|
||||
const { session, permissions } = await getAdminContext();
|
||||
if (!canAccess(permissions, PERMS.MODERATION_VIEW, session.user.rank)) redirect("/admin");
|
||||
const { session, permissions } = await getAdminContext()
|
||||
if (!canAccess(permissions, PERMS.MODERATION_VIEW, session.user.rank)) redirect('/admin')
|
||||
|
||||
// Get all staff (rank >= 4)
|
||||
const staff = await prisma.user.findMany({
|
||||
@@ -22,34 +22,34 @@ export default async function ModTeamPage() {
|
||||
lastLogin: true,
|
||||
lastOnline: true,
|
||||
},
|
||||
orderBy: [{ online: "desc" }, { rank: "desc" }],
|
||||
});
|
||||
orderBy: [{ online: 'desc' }, { rank: 'desc' }],
|
||||
})
|
||||
|
||||
// Get CFH ticket counts per mod and web ticket counts
|
||||
const [cfhCounts, webTicketCounts, modActionCounts] = await Promise.all([
|
||||
prisma.supportTickets.groupBy({
|
||||
by: ["modId"],
|
||||
by: ['modId'],
|
||||
where: { modId: { in: staff.map((s) => s.id) } },
|
||||
_count: { _all: true },
|
||||
}),
|
||||
prisma.websiteTicket.groupBy({
|
||||
by: ["assigneeId"],
|
||||
by: ['assigneeId'],
|
||||
where: { assigneeId: { in: staff.map((s) => s.id) } },
|
||||
_count: { _all: true },
|
||||
}),
|
||||
prisma.adminAuditLog.groupBy({
|
||||
by: ["userId"],
|
||||
by: ['userId'],
|
||||
where: {
|
||||
userId: { in: staff.map((s) => s.id) },
|
||||
action: { startsWith: "mod_" },
|
||||
action: { startsWith: 'mod_' },
|
||||
},
|
||||
_count: { _all: true },
|
||||
}),
|
||||
]);
|
||||
])
|
||||
|
||||
const cfhMap = new Map(cfhCounts.map((c) => [c.modId, c._count._all]));
|
||||
const webMap = new Map(webTicketCounts.map((c) => [c.assigneeId, c._count._all]));
|
||||
const actionMap = new Map(modActionCounts.map((c) => [c.userId, c._count._all]));
|
||||
const cfhMap = new Map(cfhCounts.map((c) => [c.modId, c._count._all]))
|
||||
const webMap = new Map(webTicketCounts.map((c) => [c.assigneeId, c._count._all]))
|
||||
const actionMap = new Map(modActionCounts.map((c) => [c.userId, c._count._all]))
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -63,7 +63,7 @@ export default async function ModTeamPage() {
|
||||
<Card>
|
||||
<CardContent className="pt-4 text-center">
|
||||
<p className="text-2xl font-bold text-[var(--admin-success)]">
|
||||
{staff.filter((s) => s.online === "1").length}
|
||||
{staff.filter((s) => s.online === '1').length}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">Online Now</p>
|
||||
</CardContent>
|
||||
@@ -76,7 +76,9 @@ export default async function ModTeamPage() {
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="pt-4 text-center">
|
||||
<p className="text-2xl font-bold text-primary">{staff.filter((s) => s.rank >= 7).length}</p>
|
||||
<p className="text-2xl font-bold text-primary">
|
||||
{staff.filter((s) => s.rank >= 7).length}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">Super Admins</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -103,14 +105,14 @@ export default async function ModTeamPage() {
|
||||
<div className="relative">
|
||||
<AvatarImage
|
||||
figure={member.look}
|
||||
options={{ headOnly: true, size: "l" }}
|
||||
options={{ headOnly: true, size: 'l' }}
|
||||
alt={member.username}
|
||||
width={32}
|
||||
height={32}
|
||||
/>
|
||||
<span
|
||||
className={`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-background ${
|
||||
member.online === "1" ? "bg-[var(--admin-success)]" : "bg-[var(--admin-text-muted)]"
|
||||
member.online === '1' ? 'bg-[var(--admin-success)]' : 'bg-[var(--admin-text-muted)]'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
@@ -133,15 +135,15 @@ export default async function ModTeamPage() {
|
||||
<p className="text-[9px] text-muted-foreground">Mod</p>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">
|
||||
{member.online === "1"
|
||||
? "Online"
|
||||
{member.online === '1'
|
||||
? 'Online'
|
||||
: member.lastOnline
|
||||
? new Date(member.lastOnline * 1000).toLocaleDateString()
|
||||
: "—"}
|
||||
: '—'}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user