first round of review

This commit is contained in:
counterweight 2025-12-20 11:43:32 +01:00
parent 870804e7b9
commit 23049da55a
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
15 changed files with 325 additions and 182 deletions

View file

@ -1,6 +1,6 @@
"use client";
import { useState, useEffect, Suspense } from "react";
import { useState, useEffect, useCallback, Suspense } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import { useAuth } from "../auth-context";
import { api } from "../api";
@ -20,6 +20,7 @@ function SignupContent() {
const [inviteValid, setInviteValid] = useState<boolean | null>(null);
const [inviteError, setInviteError] = useState("");
const [isCheckingInvite, setIsCheckingInvite] = useState(false);
const [isCheckingInitialCode, setIsCheckingInitialCode] = useState(!!initialCode);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
@ -37,14 +38,7 @@ function SignupContent() {
}
}, [user, router]);
// Check invite code on mount if provided in URL
useEffect(() => {
if (initialCode) {
checkInvite(initialCode);
}
}, [initialCode]);
const checkInvite = async (code: string) => {
const checkInvite = useCallback(async (code: string) => {
if (!code.trim()) {
setInviteValid(null);
setInviteError("");
@ -72,7 +66,14 @@ function SignupContent() {
} finally {
setIsCheckingInvite(false);
}
};
}, []);
// Check invite code on mount if provided in URL
useEffect(() => {
if (initialCode) {
checkInvite(initialCode).finally(() => setIsCheckingInitialCode(false));
}
}, [initialCode, checkInvite]);
const handleInviteSubmit = (e: React.FormEvent) => {
e.preventDefault();
@ -110,6 +111,21 @@ function SignupContent() {
return null;
}
// Show loading state while checking initial code from URL
if (isCheckingInitialCode) {
return (
<main style={styles.main}>
<div style={styles.container}>
<div style={styles.card}>
<div style={{ textAlign: "center", color: "rgba(255,255,255,0.6)" }}>
Checking invite code...
</div>
</div>
</div>
</main>
);
}
// Step 1: Enter invite code
if (!inviteValid) {
return (