diff --git a/src/App.tsx b/src/App.tsx index 9b0dbd5..ead6205 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -239,10 +239,6 @@ function App() { } }); - // Auto-select first file if none selected - if (!selectedFileId) { - setSelectedFileId(fileRecords[0].id); - } } else { setFiles([]); } @@ -569,18 +565,6 @@ function App() { )} - - {/* ICP Footer */} -
); } diff --git a/src/components/AuthModal.tsx b/src/components/AuthModal.tsx index 590f5d7..04e04d6 100644 --- a/src/components/AuthModal.tsx +++ b/src/components/AuthModal.tsx @@ -17,6 +17,7 @@ export default function AuthModal({ onClose, mandatory = false }: AuthModalProps const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [localError, setLocalError] = useState(''); + const [fieldErrors, setFieldErrors] = useState<{ email?: string; password?: string; confirmPassword?: string }>({}); const isBusy = useMemo( () => ['email_signing_in', 'email_signing_up', 'oauth_redirecting', 'oauth_exchanging'].includes(authPhase), @@ -28,20 +29,37 @@ export default function AuthModal({ onClose, mandatory = false }: AuthModalProps const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLocalError(''); + const nextFieldErrors: { email?: string; password?: string; confirmPassword?: string } = {}; + const normalizedEmail = email.trim(); + + if (!normalizedEmail) { + nextFieldErrors.email = t.auth.emailRequired; + } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) { + nextFieldErrors.email = t.auth.emailInvalid; + } + + if (!password) { + nextFieldErrors.password = t.auth.passwordRequired; + } if (mode === 'signup') { - if (password.length < 6) { - setLocalError(t.auth.passwordHint); - return; + if (password && password.length < 6) { + nextFieldErrors.password = t.auth.passwordHint; } - if (password !== confirmPassword) { - setLocalError(t.auth.passwordMismatch); - return; + if (!confirmPassword) { + nextFieldErrors.confirmPassword = t.auth.passwordRequired; + } else if (password !== confirmPassword) { + nextFieldErrors.confirmPassword = t.auth.passwordMismatch; } } - const result = mode === 'signup' ? await signUp(email, password) : await signIn(email, password); + setFieldErrors(nextFieldErrors); + if (Object.keys(nextFieldErrors).length > 0) { + return; + } + + const result = mode === 'signup' ? await signUp(normalizedEmail, password) : await signIn(normalizedEmail, password); if (!result.error) { onClose(); @@ -75,7 +93,11 @@ export default function AuthModal({ onClose, mandatory = false }: AuthModalProps