diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 83e004a..4d320ba 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -80,9 +80,12 @@ const App = () => { }; const [loginLoading, setLoginLoading] = useState(false); + const [authCode, setAuthCode] = useState(''); + const [codeSubmitting, setCodeSubmitting] = useState(false); const handleLogin = async () => { setLoginLoading(true); + setAuthCode(''); try { const response = await fetch('/api/auth/login', { method: 'POST' }); const data = await response.json(); @@ -99,6 +102,29 @@ const App = () => { setLoginLoading(false); }; + const handleSubmitCode = async (e) => { + e.preventDefault(); + if (!authCode.trim()) return; + setCodeSubmitting(true); + try { + const response = await fetch('/api/auth/code', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ code: authCode.trim() }) + }); + const data = await response.json(); + if (data.status === 'logged_in') { + setAuthCode(''); + fetchAuthStatus(); + } else { + alert(data.message || 'Code submission failed'); + } + } catch (error) { + console.error('Error submitting auth code:', error); + } + setCodeSubmitting(false); + }; + const handleLogout = async () => { try { await fetch('/api/auth/logout', { method: 'POST' }); @@ -229,7 +255,13 @@ const App = () => { {authStatus?.status === 'logged_in' ? ( ● {authStatus.account || 'Logged in'} ) : authStatus?.status === 'pending' ? ( - ⏳ Awaiting login… +
) : (