import React, { useState } from 'react' export default function AuthButton({ user, onLogin, onLogout, loading }) { const [handleInput, setHandleInput] = useState('') const [isLoading, setIsLoading] = useState(false) const handleSubmit = async (e) => { e.preventDefault() if (!handleInput.trim() || isLoading) return setIsLoading(true) try { await onLogin(handleInput.trim()) } catch (error) { console.error('Login failed:', error) alert('ログインに失敗しました: ' + error.message) } finally { setIsLoading(false) } } if (loading) { return
認証状態を確認中...
} if (user) { return (
{user.avatar && ( Profile )}
{user.displayName}
@{user.handle}
) } return (
setHandleInput(e.target.value)} placeholder="your.handle.com" disabled={isLoading} className="handle-input" onKeyPress={(e) => { if (e.key === 'Enter') { handleSubmit(e) } }} />
) }