mirror of
https://gitea.tendokyu.moe/pinapelz/Mirage.git
synced 2026-10-05 05:08:01 +03:00
frontend: pull formatted name for game on personal scores page
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default tseslint.config({
|
||||
extends: [
|
||||
// Remove ...tseslint.configs.recommended and replace with this
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
...tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
languageOptions: {
|
||||
// other options...
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default tseslint.config({
|
||||
plugins: {
|
||||
// Add the react-x and react-dom plugins
|
||||
'react-x': reactX,
|
||||
'react-dom': reactDom,
|
||||
},
|
||||
rules: {
|
||||
// other rules...
|
||||
// Enable its recommended typescript rules
|
||||
...reactX.configs['recommended-typescript'].rules,
|
||||
...reactDom.configs.recommended.rules,
|
||||
},
|
||||
})
|
||||
```
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState, useCallback } from "react";
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
import { useNavigate } from "react-router";
|
||||
import { NavBar } from "../components/NavBar";
|
||||
import type { SupportedGame} from "../types/game";
|
||||
import SessionExpiredPopup from "../components/SessionExpiredPopup";
|
||||
import ScoreDisplay from "../components/displays/GenericScoreDisplay";
|
||||
import DancerushScoreDisplay from "../components/displays/DancerushScoreDisplay";
|
||||
@@ -14,6 +15,7 @@ import { getFilterOptions } from "../types/constants";
|
||||
const Score = () => {
|
||||
const { user, isLoading, logout } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const [formattedGameName, setFormattedGameName] = useState("");
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const [scores, setScores] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -37,6 +39,21 @@ const Score = () => {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
try{
|
||||
fetch(import.meta.env.VITE_API_URL + `/supportedGames`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const game = data.find((game: SupportedGame) => game.internalName === gameName);
|
||||
setFormattedGameName(game ? game.formattedName : gameName);
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
alert("Network error. Please try again.");
|
||||
}
|
||||
}, [gameName]);
|
||||
|
||||
const renderRequestFilterMenu = () => {
|
||||
const filterOptions = getFilterOptions(gameName);
|
||||
return (
|
||||
@@ -158,7 +175,7 @@ const Score = () => {
|
||||
<div className="mb-6 sm:mb-12">
|
||||
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-4">
|
||||
<h1 className="text-2xl sm:text-3xl md:text-4xl font-bold bg-linear-to-r from-violet-400 to-violet-600 bg-clip-text text-transparent">
|
||||
Your Scores
|
||||
Your Scores for {formattedGameName}
|
||||
</h1>
|
||||
<div className="flex items-center space-x-1 sm:space-x-2 bg-slate-900/50 backdrop-blur-sm rounded-xl p-1 border border-slate-800/50">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user