import React from 'react'; type LoginStatus = 'idle' | 'waiting' | 'success' | 'error'; interface LoginPromptProps { authState: string; errorMessage?: string; onLogin: () => void; onRetry: () => void; loginStatus?: LoginStatus; } export function LoginPrompt({ authState, errorMessage, onLogin, onRetry, loginStatus = 'idle' }: LoginPromptProps) { // Show success state when login completed if (loginStatus === 'success') { return (

Login Successful!

You're now connected to iRacing.

Redirecting...

); } const getStateMessage = () => { switch (authState) { case 'EXPIRED': return 'Your iRacing session has expired. Please log in again to continue.'; case 'LOGGED_OUT': return 'You have been logged out. Please log in to use GridPilot.'; case 'UNKNOWN': return errorMessage ? `Unable to verify authentication: ${errorMessage}` : 'Unable to verify your authentication status.'; default: return null; // Will show explanation instead } }; const stateMessage = getStateMessage(); const isWaiting = loginStatus === 'waiting'; return (
{isWaiting ? '⏳' : '🔐'}

{isWaiting ? 'Waiting for Login...' : 'iRacing Login Required'}

{stateMessage ? (

{stateMessage}

) : (

Why do I need to log in?

GridPilot needs to access your iRacing account to create and manage hosted sessions on your behalf. This requires authentication with iRacing's website.

  • ✓ Your credentials are entered directly on iRacing.com
  • ✓ GridPilot never sees or stores your password
  • ✓ Session cookies are stored locally for convenience
)} {isWaiting ? (

A browser window has opened. Please log in to iRacing.

This window will update automatically when login is detected.

) : (
{(authState === 'UNKNOWN' || errorMessage) && ( )}
)} {!isWaiting && (

A browser window will open for you to log in securely to iRacing. The window will close automatically once login is complete.

)}
); }