+
+
+ {data.totalCount}
+ {data.totalCount === 1 ? "Mii" : "Miis"}
+
-// const where: Prisma.MiiWhereInput = {
-// // In queue logic
-// ...(parentPage === "admin"
-// ? { in_queue: true } // Only show queued Miis
-// : userId
-// ? {
-// // Include queued Miis if user is on their profile
-// ...(Number(session?.user?.id) === userId ? {} : { in_queue: false }),
-// userId,
-// }
-// : {
-// // Don't show queued Miis on main page
-// in_queue: false,
-// }),
-// // Only show liked miis on likes page
-// ...(parentPage === "likes" && miiIdsLiked && { id: { in: miiIdsLiked } }),
-// // Searching
-// ...(query && {
-// OR: [{ name: { contains: query, mode: "insensitive" } }, { tags: { has: query } }, { description: { contains: query, mode: "insensitive" } }],
-// }),
-// // Tag filtering
-// ...(tags && tags.length > 0 && { tags: { hasEvery: tags } }),
-// ...(exclude && exclude.length > 0 && { NOT: { tags: { hasSome: exclude } } }),
-// // Platform
-// ...(platform && { platform: { equals: platform } }),
-// // Gender
-// ...(gender && { gender: { equals: gender } }),
-// // Allow Copying
-// ...(allowCopying && { allowedCopying: true }),
-// // Makeup
-// ...(makeup && { makeup: { equals: makeup } }),
-// // Quarantined
-// ...(!quarantined && !userId && { quarantined: false }),
-// };
+
+
+
+
+
-// const select: Prisma.MiiSelect = {
-// id: true,
-// // Don't show when userId is specified
-// ...(!userId && {
-// user: {
-// select: {
-// id: true,
-// name: true,
-// },
-// },
-// }),
-// platform: true,
-// name: true,
-// imageCount: true,
-// tags: true,
-// createdAt: true,
-// gender: true,
-// makeup: true,
-// allowedCopying: true,
-// quarantined: true,
-// in_queue: true,
-// // Mii liked check
-// ...(session?.user?.id && {
-// likedBy: {
-// where: { userId: Number(session.user.id) },
-// select: { userId: true },
-// },
-// }),
-// // Like count
-// _count: {
-// select: { likedBy: true },
-// },
-// };
+
+ {data.miis.map((mii) => (
+
+ {mii.in_queue && (
+
+
+ In Queue
+
+ )}
-// const skip = (page - 1) * limit;
+
+
+
-// let totalCount: number;
-// let miis: Prisma.MiiGetPayload<{ select: typeof select }>[];
+
+
+
+ {mii.name}
+
+
+ {mii.platform === "SWITCH" ? (
+
+ ) : (
+
+ )}
+
+
+
+ {mii.tags.map((tag: string) => (
+
+ {tag}
+
+ ))}
+
-// if (sort === "random") {
-// // Get all IDs that match the where conditions
-// const matchingIds = await prisma.mii.findMany({
-// where,
-// select: { id: true },
-// });
+
+
-// totalCount = matchingIds.length;
+ {!userId && (
+
+ @{mii.user?.name}
+
+ )}
-// if (matchingIds.length === 0) return;
+ {userId && Number($session?.user?.id) == userId && (
+
+
+
+
+
+
+ )}
-// // Use seed for consistent random results
-// const randomSeed = seed || crypto.randomInt(0, 1_000_000_000);
-// const rng = seedrandom(randomSeed.toString());
+ {/* Admin Controls */}
+ {parentPage === "admin" && (
+
+
+
{
+ await fetch(`/api/admin/accept-mii?id=${mii.id}`, { method: "PATCH" });
+ }}
+ className="cursor-pointer text-zinc-400 hover:text-green-500 transition-colors p-1 bg-white rounded-md shadow-sm border border-zinc-200 hover:border-green-500"
+ title="Accept Mii"
+ >
+
+
+
+
+
+
-// // Randomize all IDs using the Durstenfeld algorithm
-// for (let i = matchingIds.length - 1; i > 0; i--) {
-// const j = Math.floor(rng() * (i + 1));
-// [matchingIds[i], matchingIds[j]] = [matchingIds[j], matchingIds[i]];
-// }
-
-// // Convert to number[] array
-// const selectedIds = matchingIds.slice(skip, skip + limit).map((i) => i.id);
-
-// miis = await prisma.mii.findMany({
-// where: {
-// id: { in: selectedIds },
-// },
-// select,
-// });
-// } else {
-// // Sorting by likes, newest, or oldest
-// let orderBy: Prisma.MiiOrderByWithRelationInput[];
-
-// if (sort === "likes") {
-// orderBy = [{ likedBy: { _count: "desc" } }, { name: "asc" }];
-// } else if (sort === "oldest") {
-// orderBy = [{ createdAt: "asc" }, { name: "asc" }];
-// } else {
-// // default to newest
-// orderBy = [{ createdAt: "desc" }, { name: "asc" }];
-// }
-
-// [totalCount, miis] = await Promise.all([
-// prisma.mii.count({ where: { ...where, userId } }),
-// prisma.mii.findMany({
-// where,
-// orderBy,
-// select,
-// skip,
-// take: limit,
-// }),
-// ]);
-// }
-
-// const lastPage = Math.ceil(totalCount / limit);
-
-// return (
-//
-//
-//
-// {totalCount}
-// {totalCount === 1 ? "Mii" : "Miis"}
-//
-
-//
-//
-//
-//
-//
-
-//
-//
-//
-// );
-// }
+
{new Date(mii.createdAt).toLocaleString("en-GB", { timeZone: "UTC" })}
+
+ )}
+
+
+
+ ))}
+
+
+
+ ) : (
+