Compare commits

..

3 Commits

Author SHA1 Message Date
8def52fbf2
feat: make entire logo clickable 2025-01-29 17:29:00 +01:00
16a6814d69
feat: open automatically 2025-01-29 17:28:17 +01:00
bb7f795175
useEffect -> useMemo 2025-01-29 17:19:30 +01:00
2 changed files with 48 additions and 42 deletions

View File

@ -8,8 +8,8 @@ function App() {
<div className="logo"> <div className="logo">
<a href={baseUrl}> <a href={baseUrl}>
<img alt="logo" height="66%" src="logo.svg" /> <img alt="logo" height="66%" src="logo.svg" />
</a>
<h3 className="centered">cutt</h3> <h3 className="centered">cutt</h3>
</a>
<span className="grey">cool ultimate team tool</span> <span className="grey">cool ultimate team tool</span>
</div> </div>
<Rankings /> <Rankings />

View File

@ -1,4 +1,4 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";
import { ReactSortable, ReactSortableProps } from "react-sortablejs"; import { ReactSortable, ReactSortableProps } from "react-sortablejs";
import api, { baseUrl } from "./api"; import api, { baseUrl } from "./api";
@ -268,7 +268,28 @@ export function MVP({ user, players }: PlayerInfoProps) {
); );
} }
function openPage(pageName: string, color: string) { export default function Rankings() {
const [user, setUser] = useState<Player[]>([]);
const [players, setPlayers] = useState<Player[]>([]);
const [openTab, setOpenTab] = useState("Chemistry");
async function loadPlayers() {
const response = await fetch(`${baseUrl}player/list`, {
method: "GET",
});
const data = await response.json();
setPlayers(data as Player[]);
}
useMemo(() => {
loadPlayers();
}, []);
useEffect(() => {
user.length === 1 && openPage(openTab, "aliceblue");
}, [user]);
function openPage(pageName: string, color: string) {
// Hide all elements with class="tabcontent" by default */ // Hide all elements with class="tabcontent" by default */
var i, tabcontent, tablinks; var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent"); tabcontent = document.getElementsByClassName("tabcontent");
@ -290,24 +311,9 @@ function openPage(pageName: string, color: string) {
activeButton.style.fontWeight = "bold"; activeButton.style.fontWeight = "bold";
activeButton.style.opacity = "100%"; activeButton.style.opacity = "100%";
document.body.style.backgroundColor = color; document.body.style.backgroundColor = color;
} setOpenTab(pageName);
export default function Rankings() {
const [user, setUser] = useState<Player[]>([]);
const [players, setPlayers] = useState<Player[]>([]);
async function loadPlayers() {
const response = await fetch(`${baseUrl}player/list`, {
method: "GET",
});
const data = await response.json();
setPlayers(data as Player[]);
} }
useEffect(() => {
loadPlayers();
}, []);
return ( return (
<> <>
<SelectUser {...{ user, setUser, players, setPlayers }} /> <SelectUser {...{ user, setUser, players, setPlayers }} />