diff --git a/frontend/src/components/AuthForm.tsx b/frontend/src/components/AuthForm.tsx index 7a39ec1..21c6fab 100644 --- a/frontend/src/components/AuthForm.tsx +++ b/frontend/src/components/AuthForm.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, FormEvent } from 'react'; import { Link } from 'react-router-dom'; +import { authApi } from '../api/client'; interface AuthFormProps { mode: 'login' | 'register'; @@ -12,6 +13,7 @@ export default function AuthForm({ mode, onSubmit }: AuthFormProps) { const [confirmPassword, setConfirmPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); + const [registrationEnabled, setRegistrationEnabled] = useState(null); const [theme, setTheme] = useState<'light' | 'dark'>(() => { const saved = localStorage.getItem('theme'); return (saved as 'light' | 'dark') || 'light'; @@ -22,6 +24,13 @@ export default function AuthForm({ mode, onSubmit }: AuthFormProps) { localStorage.setItem('theme', theme); }, [theme]); + useEffect(() => { + // Check if registration is enabled + authApi.getRegistrationStatus() + .then(res => setRegistrationEnabled(res.data.registration_enabled)) + .catch(() => setRegistrationEnabled(true)); // Default to true on error + }, []); + const toggleTheme = () => { setTheme((prev) => (prev === 'light' ? 'dark' : 'light')); }; @@ -206,17 +215,16 @@ export default function AuthForm({ mode, onSubmit }: AuthFormProps) { -
- {mode === 'login' ? ( - <> - Don't have an account? Sign up - - ) : ( - <> - Already have an account? Sign in - - )} -
+ {mode === 'login' && registrationEnabled && ( +
+ Don't have an account? Sign up +
+ )} + {mode === 'register' && ( +
+ Already have an account? Sign in +
+ )} );