mirror of
https://gitea.tendokyu.moe/pinapelz/Mirage.git
synced 2026-09-22 22:38:04 +03:00
implement dancearound custom score view
This commit is contained in:
+33
-21
@@ -375,13 +375,15 @@ export const handleGetScoresByChartId = async (
|
||||
) => {
|
||||
try {
|
||||
const { chartId } = req.params;
|
||||
const { sortKey, direction, pageNum, pbOnly } = req.query;
|
||||
const { sortKey, direction, pageNum, pbOnly, game } = req.query;
|
||||
const chartIdString = chartId as string;
|
||||
const pageNumber = parseInt(pageNum as string);
|
||||
const sortKeyString = (sortKey as string) || "timestamp";
|
||||
const directionString =
|
||||
(direction as string)?.toLowerCase() === "asc" ? "asc" : "desc";
|
||||
const pbOnlyFlag = pbOnly === "true";
|
||||
const gameInternalName = game as string;
|
||||
|
||||
if (
|
||||
directionString &&
|
||||
directionString !== "asc" &&
|
||||
@@ -400,20 +402,22 @@ export const handleGetScoresByChartId = async (
|
||||
SELECT DISTINCT ON (s."userId") s.*, u.username
|
||||
FROM "Score" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
WHERE s."chartId" = $1
|
||||
WHERE s."chartId" = $1 AND s."gameInternalName" = $2
|
||||
ORDER BY s."userId", s."timestamp" ${directionString.toUpperCase()}
|
||||
OFFSET $2
|
||||
LIMIT $3
|
||||
OFFSET $3
|
||||
LIMIT $4
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
(pageNumber - 1) * PAGE_SIZE,
|
||||
PAGE_SIZE,
|
||||
);
|
||||
} else {
|
||||
// Check if we need grade-based sorting by sampling one score
|
||||
const sampleScore = await prisma.$queryRawUnsafe<any[]>(
|
||||
`SELECT s.data->>'${sortKeyString}' as value FROM "Score" s WHERE s."chartId" = $1 AND s.data->>'${sortKeyString}' IS NOT NULL LIMIT 1`,
|
||||
chartIdString
|
||||
`SELECT s.data->>'${sortKeyString}' as value FROM "Score" s WHERE s."chartId" = $1 AND s."gameInternalName" = $2 AND s.data->>'${sortKeyString}' IS NOT NULL LIMIT 1`,
|
||||
chartIdString,
|
||||
gameInternalName
|
||||
);
|
||||
|
||||
const isGradeSort = sampleScore.length > 0 &&
|
||||
@@ -426,12 +430,13 @@ export const handleGetScoresByChartId = async (
|
||||
SELECT DISTINCT ON (s."userId") s.*, u.username
|
||||
FROM "Score" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
WHERE s."chartId" = $1
|
||||
WHERE s."chartId" = $1 AND s."gameInternalName" = $2
|
||||
ORDER BY s."userId", ${createGradeCaseStatement(sortKeyString, directionString)}
|
||||
OFFSET $2
|
||||
LIMIT $3
|
||||
OFFSET $3
|
||||
LIMIT $4
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
(pageNumber - 1) * PAGE_SIZE,
|
||||
PAGE_SIZE,
|
||||
);
|
||||
@@ -441,12 +446,13 @@ export const handleGetScoresByChartId = async (
|
||||
SELECT DISTINCT ON (s."userId") s.*, u.username
|
||||
FROM "Score" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
WHERE s."chartId" = $1
|
||||
WHERE s."chartId" = $1 AND s."gameInternalName" = $2
|
||||
ORDER BY s."userId", (s.data->>'${sortKeyString}')::numeric ${directionString.toUpperCase()}
|
||||
OFFSET $2
|
||||
LIMIT $3
|
||||
OFFSET $3
|
||||
LIMIT $4
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
(pageNumber - 1) * PAGE_SIZE,
|
||||
PAGE_SIZE,
|
||||
);
|
||||
@@ -458,15 +464,17 @@ export const handleGetScoresByChartId = async (
|
||||
`
|
||||
SELECT COUNT(DISTINCT "userId") as count
|
||||
FROM "Score"
|
||||
WHERE "chartId" = $1
|
||||
WHERE "chartId" = $1 AND "gameInternalName" = $2
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
);
|
||||
totalScores = Number(userCountResult[0]?.count || 0);
|
||||
} else {
|
||||
totalScores = await prisma.score.count({
|
||||
where: {
|
||||
chartId: chartIdString,
|
||||
gameInternalName: gameInternalName,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -474,6 +482,7 @@ export const handleGetScoresByChartId = async (
|
||||
scores = await prisma.score.findMany({
|
||||
where: {
|
||||
chartId: chartIdString,
|
||||
gameInternalName: gameInternalName,
|
||||
},
|
||||
include: {
|
||||
user: {
|
||||
@@ -491,8 +500,9 @@ export const handleGetScoresByChartId = async (
|
||||
} else {
|
||||
// Check if we need grade-based sorting by sampling one score
|
||||
const sampleScore = await prisma.$queryRawUnsafe<any[]>(
|
||||
`SELECT s.data->>'${sortKeyString}' as value FROM "Score" s WHERE s."chartId" = $1 AND s.data->>'${sortKeyString}' IS NOT NULL LIMIT 1`,
|
||||
chartIdString
|
||||
`SELECT s.data->>'${sortKeyString}' as value FROM "Score" s WHERE s."chartId" = $1 AND s."gameInternalName" = $2 AND s.data->>'${sortKeyString}' IS NOT NULL LIMIT 1`,
|
||||
chartIdString,
|
||||
gameInternalName
|
||||
);
|
||||
|
||||
const isGradeSort = sampleScore.length > 0 &&
|
||||
@@ -504,12 +514,13 @@ export const handleGetScoresByChartId = async (
|
||||
`
|
||||
SELECT s.*, u.username FROM "Score" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
WHERE s."chartId" = $1
|
||||
WHERE s."chartId" = $1 AND s."gameInternalName" = $2
|
||||
ORDER BY ${createGradeCaseStatement(sortKeyString, directionString)}
|
||||
OFFSET $2
|
||||
LIMIT $3
|
||||
OFFSET $3
|
||||
LIMIT $4
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
(pageNumber - 1) * PAGE_SIZE,
|
||||
PAGE_SIZE,
|
||||
);
|
||||
@@ -519,12 +530,13 @@ export const handleGetScoresByChartId = async (
|
||||
`
|
||||
SELECT s.*, u.username FROM "Score" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
WHERE s."chartId" = $1
|
||||
WHERE s."chartId" = $1 AND s."gameInternalName" = $2
|
||||
ORDER BY (s.data->>'${sortKeyString}')::numeric ${directionString.toUpperCase()}
|
||||
OFFSET $2
|
||||
LIMIT $3
|
||||
OFFSET $3
|
||||
LIMIT $4
|
||||
`,
|
||||
chartIdString,
|
||||
gameInternalName,
|
||||
(pageNumber - 1) * PAGE_SIZE,
|
||||
PAGE_SIZE,
|
||||
);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,473 @@
|
||||
import React from "react";
|
||||
import {Link} from "react-router";
|
||||
import { globalSkipKeys } from "../../types/constants";
|
||||
import lampExcellent from "../../assets/games/dancearound/grade_excellent.webp";
|
||||
import lampFullcombo from "../../assets/games/dancearound/grade_fullcombo.webp";
|
||||
import lampClear from "../../assets/games/dancearound/grade_clear.webp";
|
||||
import lampFailure from "../../assets/games/dancearound/grade_failed.webp";
|
||||
import SHA1 from "crypto-js/sha1";
|
||||
|
||||
interface Score {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[key: string]: any;
|
||||
timestamp: string | number;
|
||||
username?: string;
|
||||
}
|
||||
|
||||
interface ScoreDisplayProps {
|
||||
scores: Score[];
|
||||
viewMode: "cards" | "table";
|
||||
sortField: string;
|
||||
sortDirection: "asc" | "desc";
|
||||
onSort: (field: string) => void;
|
||||
onDelete?: (scoreId: number) => void;
|
||||
showUsername?: boolean;
|
||||
hideTitleArtist?: boolean;
|
||||
}
|
||||
|
||||
const DancearoundScoreDisplay: React.FC<ScoreDisplayProps> = ({
|
||||
scores,
|
||||
viewMode,
|
||||
sortField,
|
||||
sortDirection,
|
||||
onSort,
|
||||
onDelete,
|
||||
showUsername = false,
|
||||
hideTitleArtist = false,
|
||||
}) => {
|
||||
// Key mappings for better display names. Hit or miss
|
||||
const keyDisplayNames: Record<string, string> = {
|
||||
title: "Title",
|
||||
artist: "Artist",
|
||||
score: "Score",
|
||||
difficulty: "Difficulty Level",
|
||||
lamp: "Rank",
|
||||
diff_lamp: "Chart Difficulty",
|
||||
timestamp: "Date",
|
||||
judgements: "Judgements",
|
||||
maxCombo: "Max Combo",
|
||||
perfect: "Perfect",
|
||||
great: "Great",
|
||||
good: "Good",
|
||||
bad: "Bad",
|
||||
miss: "Miss",
|
||||
username: "Username",
|
||||
clear_status: "Status"
|
||||
};
|
||||
|
||||
const primaryKeys = ["title", "artist", "song"];
|
||||
const mainStatKeys = [
|
||||
"score",
|
||||
"difficulty",
|
||||
"lamp",
|
||||
"diff_lamp",
|
||||
];
|
||||
const expandableKeys = ["judgements", "optional"];
|
||||
const localSkipKeys = ["num_players"]
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const formatValue = (value: any, key: string): string => {
|
||||
if (value === null || value === undefined) return "N/A";
|
||||
|
||||
// Handle timestamps
|
||||
if (key === "timestamp" || key === "date") {
|
||||
const date = new Date(typeof value === "number" ? value : value);
|
||||
return date.toLocaleDateString();
|
||||
}
|
||||
|
||||
if (typeof value === "number") {
|
||||
if (key === "score" || key === "maxCombo" || key === "combo") {
|
||||
return value.toLocaleString();
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
return String(value);
|
||||
};
|
||||
|
||||
const getDisplayName = (key: string): string => {
|
||||
return keyDisplayNames[key] || key.charAt(0).toUpperCase() + key.slice(1);
|
||||
};
|
||||
|
||||
const renderValue = (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
key: string,
|
||||
compact: boolean = false,
|
||||
): React.ReactElement => {
|
||||
if (value === null || value === undefined)
|
||||
return <span className="text-slate-500">N/A</span>;
|
||||
|
||||
if (key === "clear_status") {
|
||||
let lampImg;
|
||||
if (value === "EXC") {
|
||||
lampImg = lampExcellent;
|
||||
} else if (value === "FULL COMBO" ) {
|
||||
lampImg = lampFullcombo;
|
||||
} else if (value === "PASSED") {
|
||||
lampImg = lampClear;
|
||||
} else if (value === "FAILURE") {
|
||||
lampImg = lampFailure;
|
||||
}
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{lampImg ? (
|
||||
<img
|
||||
src={lampImg}
|
||||
alt={`${value} lamp`}
|
||||
className="w-16 h-16 object-contain"
|
||||
/>
|
||||
) : (
|
||||
<span className="font-medium">
|
||||
{formatValue(value, key)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Handle judgements specially
|
||||
if (key === "judgements" && typeof value === "object") {
|
||||
const judgementEntries = Object.entries(value);
|
||||
|
||||
if (compact) {
|
||||
return (
|
||||
<div className="text-xs text-slate-300 space-y-1">
|
||||
{judgementEntries.map(([jKey, jValue]) => (
|
||||
<div key={jKey} className="flex justify-between">
|
||||
<span className="text-slate-400 capitalize">
|
||||
{getDisplayName(jKey)}:
|
||||
</span>
|
||||
<span className="font-medium">{formatValue(jValue, jKey)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="flex flex-wrap gap-1 text-xs">
|
||||
{judgementEntries.map(([jKey, jValue]) => (
|
||||
<span
|
||||
key={jKey}
|
||||
className="bg-slate-700/50 text-slate-200 px-2 py-1 rounded-full border border-slate-600"
|
||||
>
|
||||
<span className="capitalize">{getDisplayName(jKey)}</span>:{" "}
|
||||
{formatValue(jValue, jKey)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof value === "object" && !Array.isArray(value)) {
|
||||
return (
|
||||
<div className="space-y-1">
|
||||
{Object.entries(value).map(([subKey, subValue]) => (
|
||||
<div key={subKey} className="flex justify-between text-xs">
|
||||
<span className="text-slate-400">{getDisplayName(subKey)}:</span>
|
||||
<span className="font-medium">
|
||||
{formatValue(subValue, subKey)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return <span>{formatValue(value, key)}</span>;
|
||||
};
|
||||
|
||||
const getScoreEntries = (score: Score) => {
|
||||
const entries = Object.entries(score).filter(
|
||||
([key]) => !globalSkipKeys.includes(key) && !localSkipKeys.includes(key),
|
||||
);
|
||||
|
||||
const primary = entries.filter(([key]) => primaryKeys.includes(key));
|
||||
const mainStats = entries.filter(([key]) => mainStatKeys.includes(key));
|
||||
const expandable = entries.filter(([key]) => expandableKeys.includes(key));
|
||||
const others = entries.filter(
|
||||
([key]) =>
|
||||
!primaryKeys.includes(key) &&
|
||||
!mainStatKeys.includes(key) &&
|
||||
!expandableKeys.includes(key) &&
|
||||
key !== "timestamp",
|
||||
);
|
||||
|
||||
return {
|
||||
primary,
|
||||
mainStats,
|
||||
expandable,
|
||||
others,
|
||||
timestamp: score.timestamp,
|
||||
};
|
||||
};
|
||||
|
||||
const SortIcon = ({ field }: { field: string }) => {
|
||||
if (sortField !== field) {
|
||||
return <span className="text-slate-500">↕</span>;
|
||||
}
|
||||
return sortDirection === "asc" ? (
|
||||
<span className="text-violet-400">↑</span>
|
||||
) : (
|
||||
<span className="text-violet-400">↓</span>
|
||||
);
|
||||
};
|
||||
|
||||
const sortedScores = [...scores].sort((a, b) => {
|
||||
const aVal = a[sortField];
|
||||
const bVal = b[sortField];
|
||||
|
||||
if (aVal === undefined || aVal === null) return 1;
|
||||
if (bVal === undefined || bVal === null) return -1;
|
||||
|
||||
let comparison = 0;
|
||||
|
||||
if (typeof aVal === "string" && typeof bVal === "string") {
|
||||
comparison = aVal.localeCompare(bVal);
|
||||
} else if (typeof aVal === "number" && typeof bVal === "number") {
|
||||
comparison = aVal - bVal;
|
||||
} else if (aVal instanceof Date && bVal instanceof Date) {
|
||||
comparison = aVal.getTime() - bVal.getTime();
|
||||
} else {
|
||||
comparison = String(aVal).localeCompare(String(bVal));
|
||||
}
|
||||
|
||||
return sortDirection === "asc" ? comparison : -comparison;
|
||||
});
|
||||
|
||||
// Get all possible keys for table headers
|
||||
const allKeys = Array.from(
|
||||
new Set(scores.flatMap((score) => Object.keys(score))),
|
||||
).filter((key) => !globalSkipKeys.includes(key) && !localSkipKeys.includes(key));
|
||||
|
||||
// Prioritize important keys for table display
|
||||
const tableKeys = [
|
||||
...(hideTitleArtist ? [] : ["title", "song", "artist"]),
|
||||
...(showUsername ? ["username"] : []),
|
||||
"score",
|
||||
"difficulty",
|
||||
"lamp",
|
||||
"diff_lamp",
|
||||
"clear_status",
|
||||
"rating",
|
||||
"percent",
|
||||
"grade",
|
||||
"judgements",
|
||||
"maxCombo",
|
||||
"combo",
|
||||
"timestamp",
|
||||
].filter((key) => allKeys.includes(key));
|
||||
|
||||
// Add actions column if delete function is provided
|
||||
const showActions = onDelete && viewMode === "table";
|
||||
|
||||
if (scores.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-16">
|
||||
<div className="w-24 h-24 bg-slate-800 rounded-full flex items-center justify-center mx-auto mb-6">
|
||||
<span className="text-slate-400 text-2xl">🎵</span>
|
||||
</div>
|
||||
<h3 className="text-xl font-semibold text-slate-300 mb-2">
|
||||
No scores found
|
||||
</h3>
|
||||
<p className="text-slate-500">Import some score data to get started!</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (viewMode === "cards") {
|
||||
return (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6">
|
||||
{sortedScores.map((score, index) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { primary, mainStats, expandable, others, timestamp } =
|
||||
getScoreEntries(score);
|
||||
const chartIdHash = SHA1(`dancearound${score.title}${score.artist}`).toString();
|
||||
return (
|
||||
<div
|
||||
key={score.id || index}
|
||||
className="bg-slate-900/50 backdrop-blur-sm border border-slate-800/50 rounded-xl p-6 hover:border-violet-500/30 transition-all duration-300 hover:shadow-lg hover:shadow-violet-500/10"
|
||||
>
|
||||
{/* Primary Info */}
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex-1 min-w-0">
|
||||
{!hideTitleArtist && (
|
||||
<Link to={`/chart?chartId=${chartIdHash}&game=dancearound`}>
|
||||
<h3 className="text-lg font-semibold text-white mb-1 break-words leading-tight">
|
||||
{score.title || score.song || "Unknown Title"}
|
||||
</h3>
|
||||
{score.artist && (
|
||||
<p className="text-slate-400 text-sm break-words leading-tight">
|
||||
{score.artist}
|
||||
</p>
|
||||
)}
|
||||
</Link>
|
||||
)}
|
||||
{showUsername && score.username && (
|
||||
<p className="text-slate-500 text-xs break-words leading-tight">
|
||||
by {score.username}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Stats */}
|
||||
{mainStats.length > 0 && (
|
||||
<div className="grid grid-cols-2 gap-4 mb-4">
|
||||
{mainStats.slice(0, 5).map(([key, value]) => (
|
||||
<div key={key} className="bg-slate-800/50 rounded-lg p-3">
|
||||
<p className="text-slate-400 text-xs uppercase tracking-wide mb-1">
|
||||
{getDisplayName(key)}
|
||||
</p>
|
||||
<p className="text-white font-semibold text-lg">
|
||||
{renderValue(value, key)}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Expandable sections (judgements, optional) */}
|
||||
{expandable.map(([key, value]) => (
|
||||
<div key={key} className="mb-4">
|
||||
<p className="text-slate-400 text-xs uppercase tracking-wide mb-2">
|
||||
{getDisplayName(key)}
|
||||
</p>
|
||||
{renderValue(value, key)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Other fields */}
|
||||
{others.length > 0 && (
|
||||
<div className="mb-4">
|
||||
<div className="grid grid-cols-2 gap-2 text-sm">
|
||||
{others.map(([key, value]) => (
|
||||
<div key={key} className="flex justify-between">
|
||||
<span className="text-slate-400">
|
||||
{getDisplayName(key)}:
|
||||
</span>
|
||||
<span className="text-white font-medium">
|
||||
{renderValue(value, key)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Timestamp */}
|
||||
<div className="pt-4 border-t border-slate-800/50">
|
||||
<p className="text-slate-500 text-xs">
|
||||
{new Date(
|
||||
typeof timestamp === "number" ? timestamp : timestamp,
|
||||
).toLocaleDateString()}{" "}
|
||||
•{" "}
|
||||
{new Date(
|
||||
typeof timestamp === "number" ? timestamp : timestamp,
|
||||
).toLocaleTimeString([], {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Table
|
||||
return (
|
||||
<div className="bg-slate-900/50 backdrop-blur-sm border border-slate-800/50 rounded-xl overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm min-w-[1000px]">
|
||||
<thead className="bg-slate-800/50 border-b border-slate-700/50">
|
||||
<tr>
|
||||
{tableKeys.map((key) => (
|
||||
<th
|
||||
key={key}
|
||||
className="px-4 py-3 text-left text-slate-300 font-medium"
|
||||
>
|
||||
{key === "judgements" ? (
|
||||
<span>{getDisplayName(key)}</span>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => onSort(key)}
|
||||
className="flex items-center space-x-2 hover:text-white transition-colors"
|
||||
>
|
||||
<span>{getDisplayName(key)}</span>
|
||||
<SortIcon field={key} />
|
||||
</button>
|
||||
)}
|
||||
</th>
|
||||
))}
|
||||
{showActions && (
|
||||
<th className="px-4 py-3 text-left text-slate-300 font-medium w-16">
|
||||
Actions
|
||||
</th>
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-slate-800/50">
|
||||
{sortedScores.map((score, index) => (
|
||||
<tr
|
||||
key={score.id || index}
|
||||
className="hover:bg-slate-800/30 transition-colors group"
|
||||
>
|
||||
{tableKeys.map((key) => (
|
||||
<td key={key} className="px-4 py-3">
|
||||
{key === "lamp" || key === "diff_lamp" ? (
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="inline-block bg-slate-800/50 text-slate-200 px-2 py-1 rounded text-xs border border-slate-600">
|
||||
{score[key] || "No Clear"}
|
||||
</span>
|
||||
</div>
|
||||
) : key === "judgements" ? (
|
||||
<div className="w-32">
|
||||
{renderValue(score[key], key, true)}
|
||||
</div>
|
||||
) : key === "timestamp" ? (
|
||||
<span className="text-slate-400 text-xs">
|
||||
{new Date(
|
||||
typeof score[key] === "number"
|
||||
? score[key]
|
||||
: score[key],
|
||||
).toLocaleDateString()}
|
||||
</span>
|
||||
) : key === "username" ? (
|
||||
<span className="text-violet-400 text-sm font-medium">
|
||||
{score[key] || "Unknown"}
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className={`${(key === "title" || key === "song") && !hideTitleArtist ? "text-white font-medium" : key === "score" ? "text-white font-medium" : "text-slate-300"}`}
|
||||
>
|
||||
{renderValue(score[key], key)}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
))}
|
||||
{showActions && (
|
||||
<td className="px-4 py-3">
|
||||
<button
|
||||
onClick={() => onDelete(score.id)}
|
||||
className="text-red-400 hover:text-red-300 opacity-100 transition-opacity duration-200 p-1 rounded bg-red-500/10"
|
||||
title="Delete score"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DancearoundScoreDisplay;
|
||||
@@ -285,7 +285,7 @@ const ScoreDisplay: React.FC<ScoreDisplayProps> = ({
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex-1 min-w-0">
|
||||
{!hideTitleArtist && (
|
||||
<Link to={`/chart?chartId=${chartIdHash}`}>
|
||||
<Link to={`/chart?chartId=${chartIdHash}&game=${internalGameName}`}>
|
||||
<h3 className="text-base sm:text-lg font-semibold text-white mb-1 break-words leading-tight">
|
||||
{score.title || score.song || "Unknown Title"}
|
||||
</h3>
|
||||
|
||||
@@ -10,6 +10,7 @@ type SortField = string;
|
||||
type SortDirection = "asc" | "desc";
|
||||
|
||||
import { getFilterOptions } from "../types/constants";
|
||||
import DancearoundScoreDisplay from "../components/displays/DancearoundScoreDisplay";
|
||||
|
||||
const Chart = () => {
|
||||
const { user, isLoading, logout } = useAuth();
|
||||
@@ -82,6 +83,7 @@ const Chart = () => {
|
||||
url.searchParams.append("sortKey", requestOrder);
|
||||
url.searchParams.append("direction", "asc");
|
||||
url.searchParams.append("pbOnly", "true");
|
||||
url.searchParams.append("game", gameName);
|
||||
|
||||
const response = await fetch(url.toString(), {credentials: 'include'});
|
||||
if (!response.ok) throw new Error("Failed to fetch scores");
|
||||
@@ -97,7 +99,7 @@ const Chart = () => {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[user, requestOrder, chartIdHash],
|
||||
[user, requestOrder, chartIdHash, gameName],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -184,6 +186,18 @@ const Chart = () => {
|
||||
hideTitleArtist={true}
|
||||
/>
|
||||
);
|
||||
case "dancearound":
|
||||
return (
|
||||
<DancearoundScoreDisplay
|
||||
scores={scores}
|
||||
viewMode={viewMode}
|
||||
sortField={sortField}
|
||||
sortDirection={sortDirection}
|
||||
onSort={handleSort}
|
||||
showUsername={true}
|
||||
hideTitleArtist={true}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<ScoreDisplay
|
||||
|
||||
@@ -5,6 +5,7 @@ import { NavBar } from "../components/NavBar";
|
||||
import SessionExpiredPopup from "../components/SessionExpiredPopup";
|
||||
import ScoreDisplay from "../components/displays/GenericScoreDisplay";
|
||||
import DancerushScoreDisplay from "../components/displays/DancerushScoreDisplay";
|
||||
import DancearoundScoreDisplay from "../components/displays/DancearoundScoreDisplay";
|
||||
type SortField = string;
|
||||
type SortDirection = "asc" | "desc";
|
||||
|
||||
@@ -204,6 +205,17 @@ const Score = () => {
|
||||
onDelete={handleDeleteScore}
|
||||
/>
|
||||
);
|
||||
case "dancearound":
|
||||
return (
|
||||
<DancearoundScoreDisplay
|
||||
scores={scores}
|
||||
viewMode={viewMode}
|
||||
sortField={sortField}
|
||||
sortDirection={sortDirection}
|
||||
onSort={handleSort}
|
||||
onDelete={handleDeleteScore}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<ScoreDisplay
|
||||
|
||||
Reference in New Issue
Block a user