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