feat: roll back refresh tokens, use single token only

This commit is contained in:
2025-03-07 18:24:25 +01:00
parent 8b092fed51
commit d3f5c3cb82
5 changed files with 62 additions and 71 deletions

View File

@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";
import { ReactSortable, ReactSortableProps } from "react-sortablejs";
import api, { baseUrl } from "./api";
import { apiAuth } from "./api";
interface Player {
id: number;
@@ -124,7 +124,7 @@ export function Chemistry({ user, players }: PlayerInfoProps) {
let middle = playersMiddle.map(({ name }) => name);
let right = playersRight.map(({ name }) => name);
const data = { user: _user, hate: left, undecided: middle, love: right };
const response = await api("chemistry", data);
const response = await apiAuth("chemistry", data);
response.ok ? setDialog("success!") : setDialog("try sending again");
}
}
@@ -203,7 +203,7 @@ export function MVP({ user, players }: PlayerInfoProps) {
let _user = user.map(({ name }) => name)[0];
let mvps = rankedPlayers.map(({ name }) => name);
const data = { user: _user, mvps: mvps };
const response = await api("mvps", data);
const response = await apiAuth("mvps", data);
response.ok ? setDialog("success!") : setDialog("try sending again");
}
}
@@ -272,10 +272,7 @@ export default function Rankings() {
const [openTab, setOpenTab] = useState("Chemistry");
async function loadPlayers() {
const response = await fetch(`${baseUrl}api/player/list`, {
method: "GET",
});
const data = await response.json();
const data = await apiAuth("player/list", null, "GET");
setPlayers(data as Player[]);
}
@@ -334,8 +331,11 @@ export default function Rankings() {
</button>
</div>
<span className="grey">assign as many or as few players as you want<br />
and don't forget to <b>submit</b> (💾) when you're done :)</span>
<span className="grey">
assign as many or as few players as you want
<br />
and don't forget to <b>submit</b> (💾) when you're done :)
</span>
<div id="Chemistry" className="tabcontent">
<Chemistry {...{ user, players }} />