feat: inelegant and buggy version of auth

This commit is contained in:
2025-02-16 17:22:36 +01:00
parent fbe17479f7
commit 15c9a64de2
5 changed files with 121 additions and 19 deletions

View File

@@ -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)}>