added clear lamps and fixed score grid size problems

This commit is contained in:
Polaris 2024-08-23 10:51:47 -04:00
parent 620874905e
commit d13fa0f2da
10 changed files with 312 additions and 131 deletions

View File

@ -41,72 +41,80 @@ export default async function Share({
const chunithm: chunithm[] = songsData.filter((song) =>
playlogIds.includes(song.id),
);
return (
<div className="min-h-screen bg-primary">
<div className="flex flex-col items-center justify-center space-y-4 p-4 dark:text-black">
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-4 dark:text-black">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="text-center text-xl font-bold text-black">
<span className="text-center text-xl font-bold text-primary">
Song: {song.title}
</span>
</div>
))}
</div>
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-4">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="text-center text-xl font-bold text-black">
<span className="text-center text-xl font-bold text-primary">
Artist: {song.artist}
</span>
</div>
))}
</div>
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-4">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="text-center text-xl font-bold text-black">
<span className="text-center text-xl font-bold text-primary">
Score: {song.score?.toLocaleString()}
</span>
</div>
))}
</div>
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-4">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="text-center text-xl font-bold text-black">
<span className="text-center text-xl font-bold text-primary">
Rank: {getGrade(song.score ?? 0)}
</span>
</div>
))}
</div>
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-4">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="pr-2 text-center text-xl font-bold text-black">
<span className="pr-2 text-center text-xl font-bold text-primary">
{song.isFullCombo && "FULL COMBO!"}
</span>
<span className="text-center text-xl font-bold text-black">
<div className="pt-2">
<span className="text-center text-xl font-bold text-primary">
Max combo: {song.maxCombo}
</span>
</div>
</div>
))}
</div>
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
<div className="w-full rounded-sm bg-primary-foreground p-2">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<div className="flex flex-col items-center justify-center">
<span className="text-md w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
Judge Justice: {song.judgeJustice}
<span className="text-md w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-primary shadow-[inset_0px_3px_6px_0px_#1a202c]">
Justice Critcal: {song.judgeCritical! + song.judgeHeaven!}
</span>
<span className="text-md m-5 w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
Judge Attack: {song.judgeAttack}
<span className="text-md mt-5 w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-primary shadow-[inset_0px_3px_6px_0px_#1a202c]">
Justice: {song.judgeJustice}
</span>
<span className="text-md w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
<span className="text-md mt-5 w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-primary shadow-[inset_0px_3px_6px_0px_#1a202c]">
Attack: {song.judgeAttack}
</span>
<span className="text-md mt-5 w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-primary shadow-[inset_0px_3px_6px_0px_#1a202c]">
Miss: {song.judgeGuilty}
</span>
</div>
@ -114,5 +122,6 @@ export default async function Share({
))}
</div>
</div>
</div>
);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -15,6 +15,12 @@ export default function RootLayout({
}>) {
return (
<html lang="en" className={GeistSans.className}>
<head>
<link rel="shortcut icon" href="/icon.png" />
<link rel="apple-touch-icon" sizes="any" href="/icon.png" />
<link rel="icon" type="image/png" sizes="any" href="/icon.png" />
<link rel="icon" type="image/png" sizes="any" href="/icon.png" />{" "}
</head>
<body className={GeistSans.className}>
<CustomThemeProvider>
<main className="">{children} </main>

View File

@ -1,11 +1,150 @@
"use server";
import { artemis } from "@/lib/prisma";
import { chuni_score_best } from "@/prisma/schemas/artemis/generated/artemis";
import type * as Prisma from "@prisma/client";
type ChuniScorePlaylog = Prisma.PrismaClient;
type ChuniStaticMusic = Prisma.PrismaClient;
export async function getSongsWithTitles(userId: number) {
try {
const songs: ChuniScorePlaylog[] =
await artemis.chuni_score_playlog.findMany({
where: {
user: userId,
},
orderBy: {
userPlayDate: "desc",
},
select: {
id: true,
maxCombo: true,
userPlayDate: true,
isFullCombo: true,
playerRating: true,
isAllJustice: true,
score: true,
judgeHeaven: true,
judgeGuilty: true,
judgeJustice: true,
judgeAttack: true,
judgeCritical: true,
isClear: true,
skillId: true,
skillEffect: true,
skillLevel: true,
isNewRecord: true,
musicId: true,
level: true,
rateAir: true,
rateHold: true,
rateFlick: true,
rateSlide: true,
rateTap: true,
romVersion: true,
eventId: true,
characterId: true,
charaIllustId: true,
track: true,
isContinue: true,
isFreeToPlay: true,
playKind: true,
playDate: true,
orderId: true,
sortNumber: true,
user: true,
placeId: true,
ticketId: true,
},
});
const chuniScorePlaylogMusicId = songs
.map((song) => song.musicId)
.filter((id): id is number => id !== null);
const staticMusicInfo: ChuniStaticMusic[] =
await artemis.chuni_static_music.findMany({
where: {
songId: {
in: chuniScorePlaylogMusicId,
},
},
select: {
songId: true,
title: true,
artist: true,
chartId: true,
level: true,
genre: true,
worldsEndTag: true,
jacketPath: true,
},
});
const chuniScoreBest: chuni_score_best[] =
await artemis.chuni_score_best.findMany({
where: {
musicId: {
in: chuniScorePlaylogMusicId,
},
},
select: {
id: true,
user: true,
musicId: true,
level: true,
playCount: true,
scoreMax: true,
resRequestCount: true,
resAcceptCount: true,
resSuccessCount: true,
missCount: true,
maxComboCount: true,
isFullCombo: true,
isAllJustice: true,
isSuccess: true,
fullChain: true,
maxChain: true,
scoreRank: true,
isLock: true,
ext1: true,
theoryCount: true,
},
});
const songsWithTitles = songs.map((song) => {
const staticInfo = staticMusicInfo.find(
(chuniStaticMusic) =>
chuniStaticMusic.songId === song.musicId &&
chuniStaticMusic.chartId === song.level,
);
const bestScore = chuniScoreBest.find(
(score) => score.musicId === song.musicId,
);
return {
...song,
title: staticInfo?.title || "Unknown Title",
artist: staticInfo?.artist || "Unknown Artist",
genre: staticInfo?.genre || "Unknown Genre",
chartId: staticInfo?.chartId || "Unknown chartId",
level: staticInfo?.level || "Unknown Level",
chartlevel: song.level || "Unknown Level",
playCount: bestScore?.playCount || 0,
isSuccess: bestScore?.isSuccess || 0,
jacketPath: staticInfo?.jacketPath || "",
};
});
return songsWithTitles;
} catch (error) {
console.error("Error fetching songs with titles:", error);
throw error;
}
}
export async function searchSongWithTitle(
userId: number,
searchQuery: string = "",
@ -39,32 +178,41 @@ export async function searchSongWithTitle(
},
},
select: {
songId: true,
title: true,
},
});
const playCounts = await artemis.chuni_score_playlog.groupBy({
by: ["musicId"],
_count: {
musicId: true,
},
const chuniScoreBest: chuni_score_best[] =
await artemis.chuni_score_best.findMany({
where: {
user: userId,
musicId: {
in: chuniScorePlaylogMusicId,
},
},
});
const playCountMap = playCounts.reduce(
(map, item) => {
if (item.musicId !== null) {
map[item.musicId] = item._count.musicId;
}
return map;
select: {
id: true,
user: true,
musicId: true,
level: true,
playCount: true,
scoreMax: true,
resRequestCount: true,
resAcceptCount: true,
resSuccessCount: true,
missCount: true,
maxComboCount: true,
isFullCombo: true,
isAllJustice: true,
isSuccess: true,
fullChain: true,
maxChain: true,
scoreRank: true,
isLock: true,
ext1: true,
theoryCount: true,
},
{} as Record<number, number>,
);
});
const songsWithTitles = songs.map((song) => {
const staticInfo = staticMusicInfo.find(
@ -73,9 +221,14 @@ export async function searchSongWithTitle(
chuniStaticMusic.chartId === song.level,
);
const bestScore = chuniScoreBest.find(
(score) => score.musicId === song.musicId,
);
return {
...song,
title: staticInfo?.title || "Unknown Title",
playCount: bestScore?.playCount || 0,
};
});

View File

@ -18,11 +18,11 @@ import { generateShareToken } from "@/app/(sharing)/[token]/token";
import { ArrowUpDown, MoreHorizontalIcon } from "lucide-react";
import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis";
import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis";
import { chuni_score_best } from "@/prisma/schemas/artemis/generated/artemis";
import { getDifficultyText, getGrade } from "@/lib/helpers";
import { Skeleton } from "../ui/skeleton";
type chunithm = chuni_score_playlog &
chuni_static_music & { playCount: number };
type chunithm = chuni_score_playlog & chuni_static_music & chuni_score_best;
export const columns: ColumnDef<chunithm>[] = [
{
@ -31,7 +31,7 @@ export const columns: ColumnDef<chunithm>[] = [
cell: ({ row }) => {
const jacketPath = row.original.jacketPath?.replace(".dds", ".png");
const [isLoading, setIsLoading] = useState(true);
return (
<div className="flex w-[300px] items-center truncate font-medium">
{!jacketPath ? (
@ -40,7 +40,7 @@ export const columns: ColumnDef<chunithm>[] = [
<img
src={`/jacketArts/${jacketPath}`}
alt="Jacket"
className="mr-2 inline-block h-[40px] w-[40px]"
className="mr-2 inline-block h-[70px] w-[70px]"
/>
)}
<span className="truncate">{row.original.title}</span>
@ -53,32 +53,61 @@ export const columns: ColumnDef<chunithm>[] = [
accessorKey: "score",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
<Button variant="ghost">
Score
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
cell: ({ row }) => <div>{row.original.score?.toLocaleString()}</div>,
sortingFn: (a, b) => {
const highScore = a.original.score ?? 0;
const lowScore = b.original.score ?? 0;
cell: ({ row }) => {
const isSuccess = row.original.isSuccess;
const skillId = row.original.skillId;
let isSuccessText = "";
return lowScore - highScore;
},
},
{
accessorKey: "isNew",
header: "New",
cell: ({ row }) => (
<div className="font-medium">
{row.original.isNewRecord && <span>New!!</span>}
switch (isSuccess) {
case 0:
isSuccessText = "Not Clear";
break;
case 1:
isSuccessText = "Clear";
break;
case 2:
isSuccessText = "Hard";
break;
case 3:
isSuccessText = "Absolute";
break;
case 4:
isSuccessText = "Absolute+";
break;
case 6:
isSuccessText = "Catastrophe";
break;
default:
isSuccessText = isSuccess?.toString() ?? "";
break;
}
return (
<div>
{row.original.score?.toLocaleString()}
<div className="mt-2 w-24 rounded-sm bg-primary pl-2 text-primary-foreground">
{isSuccessText}
</div>
),
<div
className={`mt-2 w-24 rounded-sm pl-2 ${
row.original.isNewRecord
? "bg-primary text-primary-foreground"
: "invisible"
}`}
>
<span>New!!</span>
</div>
</div>
);
},
},
{
accessorKey: "grade",
header: "Grade",
@ -122,14 +151,6 @@ export const columns: ColumnDef<chunithm>[] = [
{row.original.isAllJustice && <span>All Justice</span>}
</div>
),
// sortingFn: (a, b) => {
// const isAllJustice = a.original.isAllJustice;
// const defaultSort = b.original.isAllJustice;
// if (isAllJustice && !defaultSort) return -1;
// if (!isAllJustice && defaultSort) return 1;
// return 0;
// },
},
{
@ -173,13 +194,7 @@ export const columns: ColumnDef<chunithm>[] = [
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
{/* <DropdownMenuItem
onClick={() =>
song.title && navigator.clipboard.writeText(song.title)
}
>
Copy song title
</DropdownMenuItem> */}
<DropdownMenuSeparator />
<DropdownMenuItem onClick={handleGenerateShareToken}>
Share Song

View File

@ -84,7 +84,7 @@ export function DataTable<TData, TValue>({
data-state={row.getIsSelected() && "selected"}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id} className="p-5">
<TableCell key={cell.id} className="pb-2 pl-4 pt-2">
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
@ -99,7 +99,7 @@ export function DataTable<TData, TValue>({
)}
</TableBody>
</Table>
<div className="py- flex items-center justify-end space-x-2 p-4">
<div className="flex items-center justify-end space-x-2 p-4">
<Button
variant="outline"
size="sm"

View File

@ -2,7 +2,7 @@ import { DataTable } from "./data-table";
import { getAuth } from "@/auth/queries/getauth";
import { z } from "zod";
import { columns } from "./colums";
import { getSongsWithTitles } from "@/app/(sharing)/[token]/[id]/actions";
import { getSongsWithTitles } from "./action";
const userSchema = z.object({
UserId: z.number(),

BIN
public/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>

Before

Width:  |  Height:  |  Size: 629 B