import { Metadata } from "next"; import { redirect } from "next/navigation"; import Image from "next/image"; import Link from "next/link"; import dayjs from "dayjs"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import ReturnToIsland from "@/components/admin/return-to-island"; export const metadata: Metadata = { title: "Exiled - TomodachiShare", description: "You have been exiled from the TomodachiShare island...", robots: { index: false, follow: false, }, }; export default async function ExiledPage() { const session = await auth(); if (!session?.user) redirect("/"); const activePunishment = await prisma.punishment.findFirst({ where: { userId: Number(session?.user.id), returned: false, }, include: { violatingMiis: { include: { mii: { select: { name: true, }, }, }, }, }, }); if (!activePunishment) redirect("/"); const expiresAt = dayjs(activePunishment.expiresAt); const createdAt = dayjs(activePunishment.createdAt); const hasExpired = activePunishment.type === "TEMP_EXILE" && activePunishment.expiresAt! > new Date(); const duration = activePunishment.type === "TEMP_EXILE" && Math.ceil(expiresAt.diff(createdAt, "days", true)); return (

{activePunishment.type === "PERM_EXILE" ? "Exiled permanently" : activePunishment.type === "TEMP_EXILE" ? `Exiled for ${duration} ${duration === 1 ? "day" : "days"}` : "Warning"}

You have been exiled from the TomodachiShare island because you violated the{" "} Terms of Service .

Reviewed: {activePunishment.createdAt.toLocaleDateString("en-GB")} at{" "} {activePunishment.createdAt.toLocaleString("en-GB")}

Note: {activePunishment.notes}


Violating Items
{activePunishment.reasons.map((index, reason) => (

Reason: {reason}

))} {activePunishment.violatingMiis.map((mii) => (
mii image

{mii.mii.name}

Reason: {mii.reason}

))}

{activePunishment.type !== "PERM_EXILE" ? ( <>

Once your punishment ends, you can return by checking the box below.

) : ( <>

Your punishment is permanent, therefore you cannot return.

)}
); }