Fix the frontend API calls and implement logins on frontend #7

Merged
dylan merged 24 commits from feat/update-frontend-api-calls into main 2026-03-04 20:20:50 +00:00
Showing only changes of commit 249528bb5c - Show all commits

View File

@@ -34,9 +34,6 @@ const AppLayout = () => {
const navigate = useNavigate();
const [isSignedIn, setIsSignedIn] = useState(false);
const [currentUser, setCurrentUser] = useState<Record<string, unknown> | null>(null);
const [lastDatasetId, setLastDatasetId] = useState<string | null>(
localStorage.getItem("last_dataset_id")
);
const syncAuthState = useCallback(async () => {
const token = localStorage.getItem("access_token");
@@ -66,17 +63,6 @@ const AppLayout = () => {
void syncAuthState();
}, [location.pathname, syncAuthState]);
useEffect(() => {
const datasetMatch = location.pathname.match(/^\/dataset\/(\d+)\/(status|stats)$/);
if (!datasetMatch) {
return;
}
const datasetId = datasetMatch[1];
localStorage.setItem("last_dataset_id", datasetId);
setLastDatasetId(datasetId);
}, [location.pathname]);
const onAuthButtonClick = () => {
if (isSignedIn) {
localStorage.removeItem("access_token");
@@ -109,14 +95,6 @@ const AppLayout = () => {
</div>
<div style={styles.controlsWrapped}>
<button
type="button"
style={location.pathname === "/upload" ? styles.buttonPrimary : styles.buttonSecondary}
onClick={() => navigate("/upload")}
>
Upload
</button>
<button
type="button"
style={location.pathname === "/datasets" ? styles.buttonPrimary : styles.buttonSecondary}
@@ -125,15 +103,6 @@ const AppLayout = () => {
My datasets
</button>
<button
type="button"
style={location.pathname.endsWith("/stats") ? styles.buttonPrimary : styles.buttonSecondary}
onClick={() => lastDatasetId && navigate(`/dataset/${lastDatasetId}/stats`)}
disabled={!lastDatasetId}
>
{lastDatasetId ? "Last stats" : "Last stats (none)"}
</button>
<button
type="button"
style={isSignedIn ? styles.buttonSecondary : styles.buttonPrimary}