'use client'; import React from 'react'; import { Mail, Lock, Eye, EyeOff, LogIn, AlertCircle, Flag, Shield, } from 'lucide-react'; import { Card } from '@/ui/Card'; import { Button } from '@/ui/Button'; import { Input } from '@/ui/Input'; import { Heading } from '@/ui/Heading'; import { Box } from '@/ui/Box'; import { Stack } from '@/ui/Stack'; import { Text } from '@/ui/Text'; import { Link } from '@/ui/Link'; import { Surface } from '@/ui/Surface'; import { Icon } from '@/ui/Icon'; import { LoadingSpinner } from '@/ui/LoadingSpinner'; import { EnhancedFormError } from '@/components/errors/EnhancedFormError'; import { UserRolesPreview } from '@/components/auth/UserRolesPreview'; import { AuthWorkflowMockup } from '@/components/auth/AuthWorkflowMockup'; import { routes } from '@/lib/routing/RouteConfig'; import { LoginViewData } from '@/lib/builders/view-data/types/LoginViewData'; import { FormState } from '@/lib/builders/view-data/types/FormState'; interface LoginTemplateProps { viewData: LoginViewData; formActions: { handleChange: (e: React.ChangeEvent) => void; handleSubmit: (e: React.FormEvent) => Promise; setFormState: React.Dispatch>; setShowPassword: (show: boolean) => void; setShowErrorDetails: (show: boolean) => void; }; mutationState: { isPending: boolean; error: string | null; }; } export function LoginTemplate({ viewData, formActions, mutationState }: LoginTemplateProps) { return ( {/* Background Pattern */} {/* Left Side - Info Panel (Hidden on mobile) */} {/* Logo */} GridPilot Your Sim Racing Infrastructure Manage leagues, track performance, join teams, and compete with drivers worldwide. One account, multiple roles. {/* Role Cards */} {/* Workflow Mockup */} {/* Trust Indicators */} Secure login iRacing verified {/* Right Side - Login Form */} {/* Mobile Logo/Header */} Welcome Back Sign in to continue to GridPilot {/* Desktop Header */} Welcome Back Sign in to access your racing dashboard {/* Background accent */} {/* Email */} Email Address {viewData.formState.fields.email.error && ( {viewData.formState.fields.email.error} )} {/* Password */} Password Forgot password? formActions.setShowPassword(!viewData.showPassword)} position="absolute" right="3" top="50%" zIndex={10} bg="transparent" borderStyle="none" cursor="pointer" > {viewData.formState.fields.password.error && ( {viewData.formState.fields.password.error} )} {/* Remember Me */} Keep me signed in {/* Insufficient Permissions Message */} {viewData.hasInsufficientPermissions && ( Insufficient Permissions You don't have permission to access that page. Please log in with an account that has the required role. )} {/* Enhanced Error Display */} {viewData.submitError && ( { formActions.setFormState((prev: FormState) => ({ ...prev, submitError: undefined })); }} showDeveloperDetails={viewData.showErrorDetails} /> )} {/* Submit Button */} {/* Divider */} or continue with {/* Sign Up Link */} Don't have an account?{' '} Create one {/* Name Immutability Notice */} Note: Your display name cannot be changed after signup. Please ensure it's correct when creating your account. {/* Footer */} By signing in, you agree to our{' '} Terms of Service {' '}and{' '} Privacy Policy {/* Mobile Role Info */} ); }