Compare commits
2 Commits
15c9a64de2
...
df94b151a6
Author | SHA1 | Date | |
---|---|---|---|
df94b151a6 | |||
9647e890f6 |
@ -1,6 +1,5 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { apiAuth, baseUrl, token } from "./api";
|
import { apiAuth } from "./api";
|
||||||
import useAuthContext from "./AuthContext";
|
|
||||||
|
|
||||||
//const debounce = <T extends (...args: any[]) => void>(
|
//const debounce = <T extends (...args: any[]) => void>(
|
||||||
// func: T,
|
// func: T,
|
||||||
@ -67,8 +66,7 @@ export default function Analysis() {
|
|||||||
setImage(data.image);
|
setImage(data.image);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
const { checkAuth } = useAuthContext();
|
console.log("best to just reload... ", e);
|
||||||
checkAuth();
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +87,6 @@ export default function Analysis() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { user } = useAuthContext()!
|
|
||||||
console.log(`logged in as ${user.username}`);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="stack column dropdown">
|
<div className="stack column dropdown">
|
||||||
<button onClick={() => setShowControlPanel(!showControlPanel)}>
|
<button onClick={() => setShowControlPanel(!showControlPanel)}>
|
||||||
|
@ -19,6 +19,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
|
margin-top: 24px;
|
||||||
font-size: x-small;
|
font-size: x-small;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +209,10 @@ button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
|
span {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
margin: 4px 0.5%;
|
margin: 4px 0.5%;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import Analysis from "./Analysis";
|
import Analysis from "./Analysis";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { AuthProvider } from "./AuthContext";
|
|
||||||
import Footer from "./Footer";
|
import Footer from "./Footer";
|
||||||
import Header from "./Header";
|
import Header from "./Header";
|
||||||
import Rankings from "./Rankings";
|
import Rankings from "./Rankings";
|
||||||
import { BrowserRouter, Routes, Route } from "react-router";
|
import { BrowserRouter, Routes, Route } from "react-router";
|
||||||
|
import { SessionProvider } from "./Session";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
//const [data, setData] = useState({ nodes: [], links: [] } as SociogramData);
|
//const [data, setData] = useState({ nodes: [], links: [] } as SociogramData);
|
||||||
@ -19,9 +19,9 @@ function App() {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Rankings />} />
|
<Route index element={<Rankings />} />
|
||||||
<Route path="/analysis" element={
|
<Route path="/analysis" element={
|
||||||
<AuthProvider>
|
<SessionProvider>
|
||||||
<Analysis />
|
<Analysis />
|
||||||
</AuthProvider>
|
</SessionProvider>
|
||||||
} />
|
} />
|
||||||
</Routes>
|
</Routes>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
|
import { Link } from "react-router";
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
return <footer>
|
return <footer>
|
||||||
<p className="grey">
|
<div className="navbar">
|
||||||
|
<Link to="/" ><span>Form</span></Link>
|
||||||
|
<span>|</span>
|
||||||
|
<Link to="/analysis" ><span>Trainer Analysis</span></Link>
|
||||||
|
</div>
|
||||||
|
<p className="grey extra-margin">
|
||||||
something not working?
|
something not working?
|
||||||
<br />
|
<br />
|
||||||
message <a href="https://t.me/x0124816">me</a>.
|
message <a href="https://t.me/x0124816">me</a>.
|
||||||
|
@ -334,7 +334,8 @@ export default function Rankings() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span className="grey">assign as many or as few players as you want 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">
|
<div id="Chemistry" className="tabcontent">
|
||||||
<Chemistry {...{ user, players }} />
|
<Chemistry {...{ user, players }} />
|
||||||
|
15
src/api.ts
15
src/api.ts
@ -1,7 +1,3 @@
|
|||||||
import { useContext } from "react";
|
|
||||||
import useAuthContext from "./AuthContext";
|
|
||||||
import { createCookie } from "react-router";
|
|
||||||
|
|
||||||
export const baseUrl = import.meta.env.VITE_BASE_URL as string;
|
export const baseUrl = import.meta.env.VITE_BASE_URL as string;
|
||||||
export const token = () => localStorage.getItem("access_token") as string;
|
export const token = () => localStorage.getItem("access_token") as string;
|
||||||
|
|
||||||
@ -90,15 +86,8 @@ export const login = (req: LoginRequest) => {
|
|||||||
method: "POST", headers: {
|
method: "POST", headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
}, body: new URLSearchParams(req).toString()
|
}, body: new URLSearchParams(req).toString()
|
||||||
}).then(resp => resp.json() as unknown as Token).then(token => token ? localStorage.setItem("access_token", token.access_token) : console.log("token not acquired")).catch((e) => console.log("catch error " + e + " in login"));
|
}).then(resp => resp.json() as Promise<Token>).then(token => token ? localStorage.setItem("access_token", token.access_token) : console.log("token not acquired")).catch((e) => console.log("catch error " + e + " in login"));
|
||||||
}
|
return Promise<void>
|
||||||
|
|
||||||
export const cookielogin = (req: LoginRequest) => {
|
|
||||||
fetch(`${baseUrl}api/token`, {
|
|
||||||
method: "POST", headers: {
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
|
||||||
}, body: new URLSearchParams(req).toString()
|
|
||||||
}).then(resp => { createCookie(resp.headers.getSetCookie()) }).catch((e) => console.log("catch error " + e + " in login"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const logout = () => localStorage.removeItem("access_token");
|
export const logout = () => localStorage.removeItem("access_token");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user