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

@ -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;
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: "isNew",
header: "New",
cell: ({ row }) => (
<div className="font-medium">
{row.original.isNewRecord && <span>New!!</span>}
</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