aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/components
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-07-10 20:50:06 -0700
committerPinapelz <yukais@pinapelz.com>2025-07-10 20:50:06 -0700
commitb136869448339b24dd95560c77222e544d152a3e (patch)
tree852608d055172ff8ed5692afa169405bd38924c5 /frontend/src/components
parent4fc648449d2275d34a4f94e8e2671d7d05125b1f (diff)
add link to chartview from score views
Diffstat (limited to 'frontend/src/components')
-rw-r--r--frontend/src/components/displays/DancerushScoreDisplay.tsx8
-rw-r--r--frontend/src/components/displays/GenericScoreDisplay.tsx9
2 files changed, 12 insertions, 5 deletions
diff --git a/frontend/src/components/displays/DancerushScoreDisplay.tsx b/frontend/src/components/displays/DancerushScoreDisplay.tsx
index 4799787..e3bae96 100644
--- a/frontend/src/components/displays/DancerushScoreDisplay.tsx
+++ b/frontend/src/components/displays/DancerushScoreDisplay.tsx
@@ -1,7 +1,9 @@
import React from "react";
+import {Link} from "react-router";
import { globalSkipKeys } from "../../types/constants";
import dancerushEasyImg from "../../assets/games/dancerush/easy.webp";
import dancerushNormalImg from "../../assets/games/dancerush/normal.webp";
+import SHA1 from "crypto-js/sha1";
interface Score {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -273,7 +275,7 @@ const DancerushScoreDisplay: React.FC<ScoreDisplayProps> = ({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { primary, mainStats, expandable, others, timestamp } =
getScoreEntries(score);
-
+ const chartIdHash = SHA1(`dancerush${score.title}${score.artist}`).toString();
return (
<div
key={score.id || index}
@@ -283,7 +285,7 @@ const DancerushScoreDisplay: 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}`}>
<h3 className="text-lg font-semibold text-white mb-1 break-words leading-tight">
{score.title || score.song || "Unknown Title"}
</h3>
@@ -292,7 +294,7 @@ const DancerushScoreDisplay: React.FC<ScoreDisplayProps> = ({
{score.artist}
</p>
)}
- </>
+ </Link>
)}
{showUsername && score.username && (
<p className="text-slate-500 text-xs break-words leading-tight">
diff --git a/frontend/src/components/displays/GenericScoreDisplay.tsx b/frontend/src/components/displays/GenericScoreDisplay.tsx
index 66bfe2a..255c804 100644
--- a/frontend/src/components/displays/GenericScoreDisplay.tsx
+++ b/frontend/src/components/displays/GenericScoreDisplay.tsx
@@ -1,4 +1,6 @@
import React from "react";
+import SHA1 from "crypto-js/sha1";
+import { Link } from "react-router";
import { globalSkipKeys } from "../../types/constants";
interface Score {
@@ -73,6 +75,8 @@ const ScoreDisplay: React.FC<ScoreDisplayProps> = ({
"grade",
];
const expandableKeys = ["judgements", "optional"];
+ // get ?game=
+ const internalGameName =new URLSearchParams(window.location.search).get("game") || "dancerush";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const formatValue = (value: any, key: string): string => {
if (value === null || value === undefined) return "N/A";
@@ -266,6 +270,7 @@ const ScoreDisplay: React.FC<ScoreDisplayProps> = ({
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) => {
+ const chartIdHash = SHA1(`${internalGameName}${score.title}${score.artist}`).toString();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { primary, mainStats, expandable, others, timestamp } =
getScoreEntries(score);
@@ -279,7 +284,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}`}>
<h3 className="text-lg font-semibold text-white mb-1 break-words leading-tight">
{score.title || score.song || "Unknown Title"}
</h3>
@@ -288,7 +293,7 @@ const ScoreDisplay: React.FC<ScoreDisplayProps> = ({
{score.artist}
</p>
)}
- </>
+ </Link>
)}
{showUsername && score.username && (
<p className="text-slate-500 text-xs break-words leading-tight">
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage