feat: inelegant and buggy version of auth
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { baseUrl } from "./api";
|
||||
import { apiAuth, baseUrl, token } from "./api";
|
||||
import useAuthContext from "./AuthContext";
|
||||
|
||||
//const debounce = <T extends (...args: any[]) => void>(
|
||||
// func: T,
|
||||
@@ -61,18 +62,14 @@ export default function Analysis() {
|
||||
// Function to generate and fetch the graph image
|
||||
async function loadImage() {
|
||||
setLoading(true);
|
||||
await fetch(`${baseUrl}api/analysis/image`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
.then((resp) => resp.json())
|
||||
await apiAuth("analysis/image", params, "POST")
|
||||
.then((data) => {
|
||||
setImage(data.image);
|
||||
setLoading(false);
|
||||
});
|
||||
}).catch((e) => {
|
||||
const { checkAuth } = useAuthContext();
|
||||
checkAuth();
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -92,6 +89,9 @@ export default function Analysis() {
|
||||
}
|
||||
}
|
||||
|
||||
const { user } = useAuthContext()!
|
||||
console.log(`logged in as ${user.username}`);
|
||||
|
||||
return (
|
||||
<div className="stack column dropdown">
|
||||
<button onClick={() => setShowControlPanel(!showControlPanel)}>
|
||||
|
Reference in New Issue
Block a user