website refactor

This commit is contained in:
2026-01-17 15:46:55 +01:00
parent 4d5ce9bfd6
commit 72a626ce71
346 changed files with 19308 additions and 8605 deletions

View File

@@ -1,25 +1,18 @@
'use client';
import React from 'react';
import {
Mail,
ArrowLeft,
AlertCircle,
Flag,
Shield,
CheckCircle2,
} from 'lucide-react';
import { Card } from '@/ui/Card';
import { Mail, ArrowLeft, AlertCircle, Shield, CheckCircle2 } from 'lucide-react';
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 { Box } from '@/ui/Box';
import { Stack } from '@/ui/Stack';
import { Icon } from '@/ui/Icon';
import { AuthCard } from '@/components/auth/AuthCard';
import { AuthForm } from '@/components/auth/AuthForm';
import { AuthFooterLinks } from '@/components/auth/AuthFooterLinks';
import { routes } from '@/lib/routing/RouteConfig';
import { ForgotPasswordViewData } from '@/lib/builders/view-data/types/ForgotPasswordViewData';
@@ -37,145 +30,97 @@ interface ForgotPasswordTemplateProps {
}
export function ForgotPasswordTemplate({ viewData, formActions, mutationState }: ForgotPasswordTemplateProps) {
const isSubmitting = mutationState.isPending;
return (
<Box as="main" minHeight="100vh" display="flex" alignItems="center" justifyContent="center" position="relative">
{/* Background Pattern */}
<Box position="absolute" inset={0} bg="linear-gradient(to bottom right, rgba(59, 130, 246, 0.05), transparent, rgba(147, 51, 234, 0.05))" />
<Box position="relative" w="full" maxWidth="28rem" px={4}>
{/* Header */}
<Box textAlign="center" mb={8}>
<Surface variant="muted" rounded="2xl" border padding={4} w="4rem" h="4rem" display="flex" alignItems="center" justifyContent="center" mx="auto" mb={4}>
<Icon icon={Flag} size={8} color="#3b82f6" />
</Surface>
<Heading level={1}>Reset Password</Heading>
<Text color="text-gray-400" block mt={2}>
Enter your email and we will send you a reset link
</Text>
</Box>
<AuthCard
title="Reset Password"
description={viewData.showSuccess ? undefined : "Enter your email and we'll send you a reset link"}
>
{!viewData.showSuccess ? (
<AuthForm onSubmit={formActions.handleSubmit}>
<Input
label="Email Address"
id="email"
name="email"
type="email"
value={viewData.formState.fields.email.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.email.error}
placeholder="you@example.com"
disabled={isSubmitting}
autoComplete="email"
icon={<Mail size={16} />}
/>
<Card position="relative" overflow="hidden">
{/* Background accent */}
<Box position="absolute" top={0} right={0} w="8rem" h="8rem" bg="linear-gradient(to bottom left, rgba(59, 130, 246, 0.1), transparent)" />
{!viewData.showSuccess ? (
<Box as="form" onSubmit={formActions.handleSubmit}>
<Stack gap={5} position="relative">
{/* Email */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Email Address
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Mail} size={4} color="#6b7280" />
</Box>
<Input
id="email"
type="email"
value={viewData.formState.fields.email.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.email.error ? 'error' : 'default'}
placeholder="you@example.com"
disabled={mutationState.isPending}
autoComplete="email"
/>
</Box>
{viewData.formState.fields.email.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.email.error}
</Text>
)}
</Box>
{/* Error Message */}
{mutationState.error && (
<Surface variant="muted" rounded="lg" border padding={3} bg="bg-red-500/10" borderColor="border-red-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="#ef4444" />
<Text size="sm" color="text-error-red">{mutationState.error}</Text>
</Stack>
</Surface>
)}
{/* Submit Button */}
<Button
type="submit"
variant="primary"
disabled={mutationState.isPending}
fullWidth
icon={mutationState.isPending ? <LoadingSpinner size={4} color="white" /> : <Icon icon={Shield} size={4} />}
>
{mutationState.isPending ? 'Sending...' : 'Send Reset Link'}
</Button>
{/* Back to Login */}
<Box textAlign="center">
<Link href={routes.auth.login}>
<Stack direction="row" align="center" justify="center" gap={1}>
<Icon icon={ArrowLeft} size={4} color="#3b82f6" />
<Text size="sm" color="text-primary-blue">Back to Login</Text>
</Stack>
</Link>
</Box>
{mutationState.error && (
<Box p={4} bg="critical-red/10" border borderColor="critical-red/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={4.5} color="var(--color-critical)" />
<Text size="sm" color="text-critical-red">{mutationState.error}</Text>
</Stack>
</Box>
) : (
<Stack gap={4} position="relative">
<Surface variant="muted" rounded="lg" border padding={4} bg="bg-green-500/10" borderColor="border-green-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={CheckCircle2} size={6} color="#10b981" />
<Box>
<Text size="sm" color="text-performance-green" weight="medium" block>{viewData.successMessage}</Text>
{viewData.magicLink && (
<Box mt={2}>
<Text size="xs" color="text-gray-400" block mb={1}>Development Mode - Magic Link:</Text>
<Surface variant="muted" rounded="md" border padding={2} bg="bg-neutral-800">
<Text size="xs" color="text-primary-blue">{viewData.magicLink}</Text>
</Surface>
<Text size="xs" color="text-gray-500" block mt={1}>
In production, this would be sent via email
</Text>
</Box>
)}
</Box>
</Stack>
</Surface>
<Button
type="button"
variant="secondary"
onClick={() => window.location.href = '/auth/login'}
fullWidth
>
Return to Login
</Button>
</Stack>
)}
</Card>
{/* Trust Indicators */}
<Stack direction="row" align="center" justify="center" gap={6} mt={6}>
<Stack direction="row" align="center" gap={2}>
<Icon icon={Shield} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">Secure reset process</Text>
</Stack>
<Stack direction="row" align="center" gap={2}>
<Icon icon={CheckCircle2} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">15 minute expiration</Text>
</Stack>
</Stack>
<Button
type="submit"
variant="primary"
disabled={isSubmitting}
fullWidth
icon={isSubmitting ? <LoadingSpinner size={4} /> : <Shield size={16} />}
>
{isSubmitting ? 'Sending...' : 'Send Reset Link'}
</Button>
{/* Footer */}
<Box mt={6} textAlign="center">
<Text size="xs" color="text-gray-500">
Need help?{' '}
<Link href="/support">
<Text color="text-gray-400">Contact support</Text>
<Box textAlign="center">
<Link href={routes.auth.login}>
<Stack direction="row" align="center" justify="center" gap={2} group>
<Icon icon={ArrowLeft} size={3.5} color="var(--color-primary)" groupHoverScale />
<Text size="sm" weight="bold" color="text-primary-accent">Back to Login</Text>
</Stack>
</Link>
</Text>
</Box>
</Box>
</Box>
</Box>
</AuthForm>
) : (
<Stack gap={6}>
<Box p={4} bg="success-green/10" border borderColor="success-green/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={CheckCircle2} size={5} color="var(--color-success)" />
<Box>
<Text size="sm" color="text-success-green" weight="bold" block>Check your email</Text>
<Text size="xs" color="text-gray-400" block mt={1}>{viewData.successMessage}</Text>
</Box>
</Stack>
</Box>
{viewData.magicLink && (
<Box p={3} bg="surface-charcoal" border borderColor="outline-steel" rounded="md">
<Text size="xs" color="text-gray-500" block mb={2} weight="bold">DEVELOPMENT MAGIC LINK</Text>
<Link href={viewData.magicLink}>
<Text size="xs" color="text-primary-accent" block>
{viewData.magicLink}
</Text>
</Link>
</Box>
)}
<Button
type="button"
variant="secondary"
onClick={() => window.location.href = '/auth/login'}
fullWidth
>
Return to Login
</Button>
</Stack>
)}
<AuthFooterLinks>
<Text size="xs" color="text-gray-600">
Need help?{' '}
<Link href="/support">Contact support</Link>
</Text>
</AuthFooterLinks>
</AuthCard>
);
}

View File

@@ -1,30 +1,20 @@
'use client';
import React from 'react';
import {
Mail,
Lock,
Eye,
EyeOff,
LogIn,
AlertCircle,
Flag,
Shield,
} from 'lucide-react';
import { Card } from '@/ui/Card';
import { LogIn, Mail, AlertCircle } from 'lucide-react';
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 { Box } from '@/ui/Box';
import { LoadingSpinner } from '@/ui/LoadingSpinner';
import { PasswordField } from '@/ui/PasswordField';
import { AuthCard } from '@/components/auth/AuthCard';
import { AuthForm } from '@/components/auth/AuthForm';
import { AuthFooterLinks } from '@/components/auth/AuthFooterLinks';
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';
@@ -45,264 +35,129 @@ interface LoginTemplateProps {
}
export function LoginTemplate({ viewData, formActions, mutationState }: LoginTemplateProps) {
const isSubmitting = viewData.formState.isSubmitting || mutationState.isPending;
return (
<Box as="main" minHeight="100vh" display="flex" position="relative">
{/* Background Pattern */}
<Box position="absolute" inset="0" bg="linear-gradient(to bottom right, rgba(59, 130, 246, 0.05), transparent, rgba(147, 51, 234, 0.05))" />
{/* Left Side - Info Panel (Hidden on mobile) */}
<Box display={{ base: 'none', lg: 'flex' }} w={{ lg: '1/2' }} position="relative" alignItems="center" justifyContent="center" p={12}>
<Box maxWidth="32rem">
{/* Logo */}
<Stack direction="row" align="center" gap={3} mb={8}>
<Surface variant="muted" rounded="xl" border padding={2} bg="bg-blue-500/10" borderColor="border-blue-500/30">
<Icon icon={Flag} size={6} color="#3b82f6" />
</Surface>
<Text size="2xl" weight="bold" color="text-white">GridPilot</Text>
</Stack>
<AuthCard
title="Welcome Back"
description="Sign in to access your racing dashboard"
>
<AuthForm onSubmit={formActions.handleSubmit}>
<Stack gap={4}>
<Input
label="Email Address"
id="email"
name="email"
type="email"
value={viewData.formState.fields.email.value as string}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.email.error}
placeholder="you@example.com"
disabled={isSubmitting}
autoComplete="email"
icon={<Mail size={16} />}
/>
<Box mb={4}>
<Heading level={2}>
Your Sim Racing Infrastructure
</Heading>
</Box>
<Text size="lg" color="text-gray-400" block mb={8}>
Manage leagues, track performance, join teams, and compete with drivers worldwide. One account, multiple roles.
</Text>
{/* Role Cards */}
<UserRolesPreview variant="full" />
{/* Workflow Mockup */}
<Box mt={8}>
<AuthWorkflowMockup />
</Box>
{/* Trust Indicators */}
<Stack direction="row" align="center" gap={6} mt={8}>
<Stack direction="row" align="center" gap={2}>
<Icon icon={Shield} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">Secure login</Text>
</Stack>
<Text size="sm" color="text-gray-500">iRacing verified</Text>
</Stack>
</Box>
</Box>
{/* Right Side - Login Form */}
<Box flex={1} display="flex" alignItems="center" justifyContent="center" p={{ base: 4, lg: 12 }} position="relative">
<Box w="full" maxWidth="28rem">
{/* Mobile Logo/Header */}
<Box display={{ base: 'block', lg: 'none' }} textAlign="center" mb={8}>
<Surface variant="muted" rounded="2xl" border padding={4} w="4rem" h="4rem" display="flex" alignItems="center" justifyContent="center" mx="auto" mb={4}>
<Icon icon={Flag} size={8} color="#3b82f6" />
</Surface>
<Heading level={1}>Welcome Back</Heading>
<Text color="text-gray-400" block mt={2}>
Sign in to continue to GridPilot
</Text>
</Box>
{/* Desktop Header */}
<Box display={{ base: 'none', lg: 'block' }} textAlign="center" mb={8}>
<Heading level={2}>Welcome Back</Heading>
<Text color="text-gray-400" block mt={2}>
Sign in to access your racing dashboard
</Text>
</Box>
<Card position="relative" overflow="hidden">
{/* Background accent */}
<Box position="absolute" top="0" right="0" w="8rem" h="8rem" bg="linear-gradient(to bottom left, rgba(59, 130, 246, 0.1), transparent)" />
<Box as="form" onSubmit={formActions.handleSubmit}>
<Stack gap={5} position="relative">
{/* Email */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Email Address
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Mail} size={4} color="#6b7280" />
</Box>
<Input
id="email"
name="email"
type="email"
value={viewData.formState.fields.email.value as string}
onChange={formActions.handleChange}
variant={viewData.formState.fields.email.error ? 'error' : 'default'}
placeholder="you@example.com"
disabled={viewData.formState.isSubmitting || mutationState.isPending}
autoComplete="email"
/>
</Box>
{viewData.formState.fields.email.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.email.error}
</Text>
)}
</Box>
{/* Password */}
<Box>
<Stack direction="row" align="center" justify="between" mb={2}>
<Text size="sm" weight="medium" color="text-gray-300">
Password
</Text>
<Link href={routes.auth.forgotPassword}>
<Text size="xs" color="text-primary-blue">Forgot password?</Text>
</Link>
</Stack>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Lock} size={4} color="#6b7280" />
</Box>
<Input
id="password"
name="password"
type={viewData.showPassword ? 'text' : 'password'}
value={viewData.formState.fields.password.value as string}
onChange={formActions.handleChange}
variant={viewData.formState.fields.password.error ? 'error' : 'default'}
placeholder="••••••••"
disabled={viewData.formState.isSubmitting || mutationState.isPending}
autoComplete="current-password"
/>
<Box
as="button"
type="button"
onClick={() => formActions.setShowPassword(!viewData.showPassword)}
position="absolute"
right="3"
top="50%"
zIndex={10}
bg="transparent"
borderStyle="none"
cursor="pointer"
>
<Icon icon={viewData.showPassword ? EyeOff : Eye} size={4} color="#6b7280" />
</Box>
</Box>
{viewData.formState.fields.password.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.password.error}
</Text>
)}
</Box>
{/* Remember Me */}
<Stack direction="row" align="center" gap={2}>
<Box
as="input"
id="rememberMe"
name="rememberMe"
type="checkbox"
checked={viewData.formState.fields.rememberMe.value as boolean}
onChange={formActions.handleChange}
disabled={viewData.formState.isSubmitting || mutationState.isPending}
/>
<Text size="sm" color="text-gray-300">Keep me signed in</Text>
</Stack>
{/* Insufficient Permissions Message */}
{viewData.hasInsufficientPermissions && (
<Surface variant="muted" rounded="lg" border padding={4} bg="bg-amber-500/10" borderColor="border-amber-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="#f59e0b" />
<Box>
<Text weight="bold" color="text-warning-amber" block>Insufficient Permissions</Text>
<Text size="sm" color="text-gray-300" block mt={1}>
You don&apos;t have permission to access that page. Please log in with an account that has the required role.
</Text>
</Box>
</Stack>
</Surface>
)}
{/* Enhanced Error Display */}
{viewData.submitError && (
<EnhancedFormError
error={new Error(viewData.submitError)}
onDismiss={() => {
formActions.setFormState((prev: FormState) => ({ ...prev, submitError: undefined }));
}}
showDeveloperDetails={viewData.showErrorDetails}
/>
)}
{/* Submit Button */}
<Button
type="submit"
variant="primary"
disabled={viewData.formState.isSubmitting || mutationState.isPending}
fullWidth
icon={mutationState.isPending || viewData.formState.isSubmitting ? <LoadingSpinner size={4} color="white" /> : <Icon icon={LogIn} size={4} />}
>
{mutationState.isPending || viewData.formState.isSubmitting ? 'Signing in...' : 'Sign In'}
</Button>
</Stack>
</Box>
{/* Divider */}
<Box position="relative" my={6}>
<Box position="absolute" inset="0" display="flex" alignItems="center">
<Box w="full" borderTop borderColor="border-neutral-800" />
</Box>
<Box position="relative" display="flex" justifyContent="center">
<Box px={4} bg="bg-neutral-900">
<Text size="xs" color="text-gray-500">or continue with</Text>
</Box>
</Box>
</Box>
{/* Sign Up Link */}
<Box textAlign="center" mt={6}>
<Text size="sm" color="text-gray-400">
Don&apos;t have an account?{' '}
<Link
href={viewData.returnTo && viewData.returnTo !== '/dashboard' ? `/auth/signup?returnTo=${encodeURIComponent(viewData.returnTo)}` : '/auth/signup'}
>
<Text color="text-primary-blue" weight="medium">Create one</Text>
</Link>
</Text>
</Box>
</Card>
{/* Name Immutability Notice */}
<Box mt={6}>
<Surface variant="muted" rounded="lg" border padding={4} bg="bg-neutral-800/30" borderColor="border-neutral-800">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="#737373" />
<Text size="xs" color="text-gray-400">
<Text weight="bold">Note:</Text> Your display name cannot be changed after signup. Please ensure it&apos;s correct when creating your account.
<Stack gap={1.5}>
<PasswordField
label="Password"
id="password"
name="password"
value={viewData.formState.fields.password.value as string}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.password.error}
placeholder="••••••••"
disabled={isSubmitting}
autoComplete="current-password"
showPassword={viewData.showPassword}
onTogglePassword={() => formActions.setShowPassword(!viewData.showPassword)}
/>
<Box textAlign="right">
<Link href={routes.auth.forgotPassword}>
<Text size="xs" color="text-primary-accent">
Forgot password?
</Text>
</Stack>
</Surface>
</Box>
</Link>
</Box>
</Stack>
{/* Footer */}
<Box mt={6} textAlign="center">
<Text size="xs" color="text-gray-500">
By signing in, you agree to our{' '}
<Link href="/terms">
<Text color="text-gray-400">Terms of Service</Text>
</Link>
{' '}and{' '}
<Link href="/privacy">
<Text color="text-gray-400">Privacy Policy</Text>
</Link>
<Stack direction="row" align="center" gap={2}>
<Box
as="input"
id="rememberMe"
name="rememberMe"
type="checkbox"
rounded="sm"
borderColor="outline-steel"
bg="surface-charcoal"
color="text-primary-accent"
ring="focus:ring-primary-accent/50"
w="1rem"
h="1rem"
checked={viewData.formState.fields.rememberMe.value as boolean}
onChange={formActions.handleChange}
disabled={isSubmitting}
/>
<Text as="label" htmlFor="rememberMe" size="sm" color="text-med" cursor="pointer">
Keep me signed in
</Text>
</Box>
</Stack>
</Stack>
{/* Mobile Role Info */}
<Box mt={8} display={{ base: 'block', lg: 'none' }}>
<UserRolesPreview variant="compact" />
{viewData.hasInsufficientPermissions && (
<Box p={4} bg="warning-amber/10" border borderColor="warning-amber/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="var(--color-warning)" />
<Box>
<Text weight="bold" color="text-warning-amber" block size="sm">Insufficient Permissions</Text>
<Text size="xs" color="text-gray-400" block mt={1}>
Please log in with an account that has the required role.
</Text>
</Box>
</Stack>
</Box>
)}
{viewData.submitError && (
<EnhancedFormError
error={new Error(viewData.submitError)}
onDismiss={() => {
formActions.setFormState((prev: FormState) => ({ ...prev, submitError: undefined }));
}}
showDeveloperDetails={viewData.showErrorDetails}
/>
)}
<Button
type="submit"
variant="primary"
disabled={isSubmitting}
fullWidth
icon={isSubmitting ? <LoadingSpinner size={4} /> : <LogIn size={16} />}
>
{isSubmitting ? 'Signing in...' : 'Sign In'}
</Button>
</AuthForm>
<AuthFooterLinks>
<Text size="sm" color="text-gray-400">
Don&apos;t have an account?{' '}
<Link
href={viewData.returnTo && viewData.returnTo !== '/dashboard' ? `/auth/signup?returnTo=${encodeURIComponent(viewData.returnTo)}` : '/auth/signup'}
>
<Text color="text-primary-accent" weight="bold">Create one</Text>
</Link>
</Text>
<Box mt={2}>
<Text size="xs" color="text-gray-600">
By signing in, you agree to our{' '}
<Link href="/terms">Terms</Link>
{' '}and{' '}
<Link href="/privacy">Privacy</Link>
</Text>
</Box>
</Box>
</Box>
</AuthFooterLinks>
</AuthCard>
);
}

View File

@@ -1,27 +1,18 @@
'use client';
import React from 'react';
import {
Lock,
Eye,
EyeOff,
AlertCircle,
Flag,
Shield,
CheckCircle2,
ArrowLeft,
} from 'lucide-react';
import { Card } from '@/ui/Card';
import { Shield, CheckCircle2, ArrowLeft, AlertCircle } from 'lucide-react';
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 { Box } from '@/ui/Box';
import { Stack } from '@/ui/Stack';
import { Icon } from '@/ui/Icon';
import { AuthCard } from '@/components/auth/AuthCard';
import { AuthForm } from '@/components/auth/AuthForm';
import { PasswordField } from '@/ui/PasswordField';
import { AuthFooterLinks } from '@/components/auth/AuthFooterLinks';
import { routes } from '@/lib/routing/RouteConfig';
import { ResetPasswordViewData } from '@/lib/builders/view-data/types/ResetPasswordViewData';
@@ -50,194 +41,102 @@ export function ResetPasswordTemplate({
uiState,
mutationState,
}: ResetPasswordTemplateProps) {
const isSubmitting = mutationState.isPending;
return (
<Box as="main" minHeight="100vh" display="flex" alignItems="center" justifyContent="center" position="relative">
{/* Background Pattern */}
<Box position="absolute" inset="0" bg="linear-gradient(to bottom right, rgba(59, 130, 246, 0.05), transparent, rgba(147, 51, 234, 0.05))" />
<Box position="relative" w="full" maxWidth="28rem" px={4}>
{/* Header */}
<Box textAlign="center" mb={8}>
<Surface variant="muted" rounded="2xl" border padding={4} w="4rem" h="4rem" display="flex" alignItems="center" justifyContent="center" mx="auto" mb={4}>
<Icon icon={Flag} size={8} color="#3b82f6" />
</Surface>
<Heading level={1}>Reset Password</Heading>
<Text color="text-gray-400" block mt={2}>
Create a new secure password for your account
</Text>
</Box>
<AuthCard
title="Reset Password"
description={viewData.showSuccess ? undefined : "Create a new secure password for your account"}
>
{!viewData.showSuccess ? (
<AuthForm onSubmit={formActions.handleSubmit}>
<Stack gap={4}>
<PasswordField
label="New Password"
id="newPassword"
name="newPassword"
value={viewData.formState.fields.newPassword.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.newPassword.error}
placeholder="••••••••"
disabled={isSubmitting}
autoComplete="new-password"
showPassword={uiState.showPassword}
onTogglePassword={() => formActions.setShowPassword(!uiState.showPassword)}
/>
<Card position="relative" overflow="hidden">
{/* Background accent */}
<Box position="absolute" top="0" right="0" w="8rem" h="8rem" bg="linear-gradient(to bottom left, rgba(59, 130, 246, 0.1), transparent)" />
<PasswordField
label="Confirm Password"
id="confirmPassword"
name="confirmPassword"
value={viewData.formState.fields.confirmPassword.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.confirmPassword.error}
placeholder="••••••••"
disabled={isSubmitting}
autoComplete="new-password"
showPassword={uiState.showConfirmPassword}
onTogglePassword={() => formActions.setShowConfirmPassword(!uiState.showConfirmPassword)}
/>
</Stack>
{!viewData.showSuccess ? (
<Box as="form" onSubmit={formActions.handleSubmit}>
<Stack gap={5} position="relative">
{/* New Password */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
New Password
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Lock} size={4} color="#6b7280" />
</Box>
<Input
id="newPassword"
name="newPassword"
type={uiState.showPassword ? 'text' : 'password'}
value={viewData.formState.fields.newPassword.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.newPassword.error ? 'error' : 'default'}
placeholder="••••••••"
disabled={mutationState.isPending}
autoComplete="new-password"
/>
<Box
as="button"
type="button"
onClick={() => formActions.setShowPassword(!uiState.showPassword)}
position="absolute"
right="3"
top="50%"
zIndex={10}
bg="transparent"
borderStyle="none"
cursor="pointer"
>
<Icon icon={uiState.showPassword ? EyeOff : Eye} size={4} color="#6b7280" />
</Box>
</Box>
{viewData.formState.fields.newPassword.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.newPassword.error}
</Text>
)}
</Box>
{/* Confirm Password */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Confirm Password
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Lock} size={4} color="#6b7280" />
</Box>
<Input
id="confirmPassword"
name="confirmPassword"
type={uiState.showConfirmPassword ? 'text' : 'password'}
value={viewData.formState.fields.confirmPassword.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.confirmPassword.error ? 'error' : 'default'}
placeholder="••••••••"
disabled={mutationState.isPending}
autoComplete="new-password"
/>
<Box
as="button"
type="button"
onClick={() => formActions.setShowConfirmPassword(!uiState.showConfirmPassword)}
position="absolute"
right="3"
top="50%"
zIndex={10}
bg="transparent"
borderStyle="none"
cursor="pointer"
>
<Icon icon={uiState.showConfirmPassword ? EyeOff : Eye} size={4} color="#6b7280" />
</Box>
</Box>
{viewData.formState.fields.confirmPassword.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.confirmPassword.error}
</Text>
)}
</Box>
{/* Error Message */}
{mutationState.error && (
<Surface variant="muted" rounded="lg" border padding={3} bg="bg-red-500/10" borderColor="border-red-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="#ef4444" />
<Text size="sm" color="text-error-red">{mutationState.error}</Text>
</Stack>
</Surface>
)}
{/* Submit Button */}
<Button
type="submit"
variant="primary"
disabled={mutationState.isPending}
fullWidth
icon={mutationState.isPending ? <LoadingSpinner size={4} color="white" /> : <Icon icon={Shield} size={4} />}
>
{mutationState.isPending ? 'Resetting...' : 'Reset Password'}
</Button>
{/* Back to Login */}
<Box textAlign="center">
<Link href={routes.auth.login}>
<Stack direction="row" align="center" justify="center" gap={1}>
<Icon icon={ArrowLeft} size={4} color="#3b82f6" />
<Text size="sm" color="text-primary-blue">Back to Login</Text>
</Stack>
</Link>
</Box>
{mutationState.error && (
<Box p={4} bg="critical-red/10" border borderColor="critical-red/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={4.5} color="var(--color-critical)" />
<Text size="sm" color="text-critical-red">{mutationState.error}</Text>
</Stack>
</Box>
) : (
<Stack gap={4} position="relative">
<Surface variant="muted" rounded="lg" border padding={4} bg="bg-green-500/10" borderColor="border-green-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={CheckCircle2} size={6} color="#10b981" />
<Box>
<Text size="sm" color="text-performance-green" weight="medium" block>{viewData.successMessage}</Text>
<Text size="xs" color="text-gray-400" block mt={1}>
Your password has been successfully reset
</Text>
</Box>
</Stack>
</Surface>
<Button
type="button"
variant="secondary"
onClick={() => window.location.href = '/auth/login'}
fullWidth
>
Return to Login
</Button>
</Stack>
)}
</Card>
{/* Trust Indicators */}
<Stack direction="row" align="center" justify="center" gap={6} mt={6}>
<Stack direction="row" align="center" gap={2}>
<Icon icon={Shield} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">Secure password reset</Text>
</Stack>
<Stack direction="row" align="center" gap={2}>
<Icon icon={CheckCircle2} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">Encrypted transmission</Text>
</Stack>
</Stack>
<Button
type="submit"
variant="primary"
disabled={isSubmitting}
fullWidth
icon={isSubmitting ? <LoadingSpinner size={4} /> : <Shield size={16} />}
>
{isSubmitting ? 'Resetting...' : 'Reset Password'}
</Button>
{/* Footer */}
<Box mt={6} textAlign="center">
<Text size="xs" color="text-gray-500">
Need help?{' '}
<Link href="/support">
<Text color="text-gray-400">Contact support</Text>
<Box textAlign="center">
<Link href={routes.auth.login}>
<Stack direction="row" align="center" justify="center" gap={2} group>
<Icon icon={ArrowLeft} size={3.5} color="var(--color-primary)" groupHoverScale />
<Text size="sm" weight="bold" color="text-primary-accent">Back to Login</Text>
</Stack>
</Link>
</Text>
</Box>
</Box>
</Box>
</Box>
</AuthForm>
) : (
<Stack gap={6}>
<Box p={4} bg="success-green/10" border borderColor="success-green/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={CheckCircle2} size={5} color="var(--color-success)" />
<Box>
<Text size="sm" color="text-success-green" weight="bold" block>Password Reset</Text>
<Text size="xs" color="text-gray-400" block mt={1}>{viewData.successMessage}</Text>
</Box>
</Stack>
</Box>
<Button
type="button"
variant="secondary"
onClick={() => window.location.href = '/auth/login'}
fullWidth
>
Return to Login
</Button>
</Stack>
)}
<AuthFooterLinks>
<Text size="xs" color="text-gray-600">
Need help?{' '}
<Link href="/support">Contact support</Link>
</Text>
</AuthFooterLinks>
</AuthCard>
);
}

View File

@@ -1,34 +1,19 @@
'use client';
import React from 'react';
import {
Mail,
Lock,
Eye,
EyeOff,
UserPlus,
AlertCircle,
Flag,
User,
Check,
X,
Car,
Users,
Trophy,
Shield,
Sparkles,
} from 'lucide-react';
import { Card } from '@/ui/Card';
import { UserPlus, Mail, User, Check, X, AlertCircle } from 'lucide-react';
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 { Box } from '@/ui/Box';
import { Stack } from '@/ui/Stack';
import { LoadingSpinner } from '@/ui/LoadingSpinner';
import { PasswordField } from '@/ui/PasswordField';
import { AuthCard } from '@/components/auth/AuthCard';
import { AuthForm } from '@/components/auth/AuthForm';
import { AuthFooterLinks } from '@/components/auth/AuthFooterLinks';
import { SignupViewData } from '@/lib/builders/view-data/types/SignupViewData';
import { checkPasswordStrength } from '@/lib/utils/validation';
@@ -50,432 +35,180 @@ interface SignupTemplateProps {
};
}
const USER_ROLES = [
{
icon: Car,
title: 'Driver',
description: 'Race, track stats, join teams',
color: '#3b82f6',
bg: 'bg-blue-500/10',
},
{
icon: Trophy,
title: 'League Admin',
description: 'Organize leagues and events',
color: '#10b981',
bg: 'bg-green-500/10',
},
{
icon: Users,
title: 'Team Manager',
description: 'Manage team and drivers',
color: '#a855f7',
bg: 'bg-purple-500/10',
},
];
const FEATURES = [
'Track your racing statistics and progress',
'Join or create competitive leagues',
'Build or join racing teams',
'Connect your iRacing account',
'Compete in organized events',
'Access detailed performance analytics',
];
export function SignupTemplate({ viewData, formActions, uiState, mutationState }: SignupTemplateProps) {
const passwordStrength = checkPasswordStrength(viewData.formState.fields.password.value);
const isSubmitting = mutationState.isPending;
const passwordValue = viewData.formState.fields.password.value || '';
const passwordStrength = checkPasswordStrength(passwordValue);
const passwordRequirements = [
{ met: viewData.formState.fields.password.value.length >= 8, label: 'At least 8 characters' },
{ met: /[a-z]/.test(viewData.formState.fields.password.value) && /[A-Z]/.test(viewData.formState.fields.password.value), label: 'Upper and lowercase letters' },
{ met: /\d/.test(viewData.formState.fields.password.value), label: 'At least one number' },
{ met: /[^a-zA-Z\d]/.test(viewData.formState.fields.password.value), label: 'At least one special character' },
{ met: passwordValue.length >= 8, label: '8+ characters' },
{ met: /[a-z]/.test(passwordValue) && /[A-Z]/.test(passwordValue), label: 'Case mix' },
{ met: /\d/.test(passwordValue), label: 'Number' },
{ met: /[^a-zA-Z\d]/.test(passwordValue), label: 'Special' },
];
return (
<Box as="main" minHeight="100vh" display="flex" position="relative">
{/* Background Pattern */}
<Box position="absolute" inset="0" bg="linear-gradient(to bottom right, rgba(59, 130, 246, 0.05), transparent, rgba(147, 51, 234, 0.05))" />
{/* Left Side - Info Panel (Hidden on mobile) */}
<Box display={{ base: 'none', lg: 'flex' }} w={{ lg: '1/2' }} position="relative" alignItems="center" justifyContent="center" p={12}>
<Box maxWidth="32rem">
{/* Logo */}
<Stack direction="row" align="center" gap={3} mb={8}>
<Surface variant="muted" rounded="xl" border padding={2} bg="bg-blue-500/10" borderColor="border-blue-500/30">
<Icon icon={Flag} size={6} color="#3b82f6" />
</Surface>
<Text size="2xl" weight="bold" color="text-white">GridPilot</Text>
<AuthCard
title="Create Account"
description="Join the GridPilot racing community"
>
<AuthForm onSubmit={formActions.handleSubmit}>
<Stack gap={6}>
<Stack gap={4}>
<Text size="xs" weight="bold" color="text-low" uppercase letterSpacing="wide" block>Personal Information</Text>
<Box display="grid" gridCols={{ base: 1, md: 2 }} gap={4}>
<Input
label="First Name"
id="firstName"
name="firstName"
value={viewData.formState.fields.firstName.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.firstName.error}
placeholder="John"
disabled={isSubmitting}
autoComplete="given-name"
icon={<User size={16} />}
/>
<Input
label="Last Name"
id="lastName"
name="lastName"
value={viewData.formState.fields.lastName.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.lastName.error}
placeholder="Smith"
disabled={isSubmitting}
autoComplete="family-name"
icon={<User size={16} />}
/>
</Box>
<Box p={3} bg="warning-amber/5" border borderColor="warning-amber/20" rounded="md">
<Stack direction="row" align="start" gap={2}>
<Icon icon={AlertCircle} size={3.5} color="var(--color-warning)" mt={0.5} />
<Text size="xs" color="text-med">
<Text weight="bold" color="text-warning-amber">Note:</Text> Your name cannot be changed after signup.
</Text>
</Stack>
</Box>
<Input
label="Email Address"
id="email"
name="email"
type="email"
value={viewData.formState.fields.email.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.email.error}
placeholder="you@example.com"
disabled={isSubmitting}
autoComplete="email"
icon={<Mail size={16} />}
/>
</Stack>
<Box mb={4}>
<Heading level={2}>Start Your Racing Journey</Heading>
</Box>
<Text size="lg" color="text-gray-400" block mb={8}>
Join thousands of sim racers. One account gives you access to all roles - race as a driver, organize leagues, or manage teams.
</Text>
<Stack gap={4}>
<Text size="xs" weight="bold" color="text-low" uppercase letterSpacing="wide" block>Security</Text>
<PasswordField
label="Password"
id="password"
name="password"
value={viewData.formState.fields.password.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.password.error}
placeholder="••••••••"
disabled={isSubmitting}
autoComplete="new-password"
showPassword={uiState.showPassword}
onTogglePassword={() => formActions.setShowPassword(!uiState.showPassword)}
/>
{/* Role Cards */}
<Stack gap={3} mb={8}>
{USER_ROLES.map((role) => (
<Surface
key={role.title}
variant="muted"
rounded="xl"
border
padding={4}
bg="bg-neutral-800/30"
borderColor="border-neutral-800"
>
<Stack direction="row" align="center" gap={4}>
<Surface variant="muted" rounded="lg" padding={2} bg={role.bg}>
<Icon icon={role.icon} size={5} color={role.color} />
</Surface>
<Box>
<Text weight="medium" color="text-white" block>{role.title}</Text>
<Text size="sm" color="text-gray-500" block mt={1}>{role.description}</Text>
{passwordValue && (
<Stack gap={3}>
<Stack direction="row" align="center" gap={2}>
<Box flexGrow={1} h="1px" bg="outline-steel" rounded="full" overflow="hidden">
<Box
h="full"
transition
w={`${(passwordStrength.score / 5) * 100}%`}
bg={
passwordStrength.score <= 2 ? 'critical-red' :
passwordStrength.score <= 4 ? 'warning-amber' : 'success-green'
}
/>
</Box>
<Text size="xs" weight="bold" color="text-low" uppercase>
{passwordStrength.label}
</Text>
</Stack>
</Surface>
))}
</Stack>
{/* Features List */}
<Box mb={8}>
<Surface variant="muted" rounded="xl" border padding={5} bg="bg-neutral-800/20" borderColor="border-neutral-800">
<Stack direction="row" align="center" gap={2} mb={4}>
<Icon icon={Sparkles} size={4} color="#3b82f6" />
<Text size="sm" weight="medium" color="text-white">What you&apos;ll get</Text>
</Stack>
<Stack gap={2}>
{FEATURES.map((feature, index) => (
<Stack key={index} direction="row" align="center" gap={2}>
<Icon icon={Check} size={3.5} color="#10b981" />
<Text size="sm" color="text-gray-400">{feature}</Text>
</Stack>
))}
</Stack>
</Surface>
</Box>
{/* Trust Indicators */}
<Stack direction="row" align="center" gap={6}>
<Stack direction="row" align="center" gap={2}>
<Icon icon={Shield} size={4} color="#737373" />
<Text size="sm" color="text-gray-500">Secure signup</Text>
</Stack>
<Text size="sm" color="text-gray-500">iRacing integration</Text>
</Stack>
</Box>
</Box>
{/* Right Side - Signup Form */}
<Box flex={1} display="flex" alignItems="center" justifyContent="center" p={{ base: 4, lg: 12 }} position="relative" overflow="auto">
<Box w="full" maxWidth="28rem">
{/* Mobile Logo/Header */}
<Box display={{ base: 'block', lg: 'none' }} textAlign="center" mb={8}>
<Surface variant="muted" rounded="2xl" border padding={4} w="4rem" h="4rem" display="flex" alignItems="center" justifyContent="center" mx="auto" mb={4}>
<Icon icon={Flag} size={8} color="#3b82f6" />
</Surface>
<Heading level={1}>Join GridPilot</Heading>
<Text color="text-gray-400" block mt={2}>
Create your account and start racing
</Text>
</Box>
{/* Desktop Header */}
<Box display={{ base: 'none', lg: 'block' }} textAlign="center" mb={8}>
<Heading level={2}>Create Account</Heading>
<Text color="text-gray-400" block mt={2}>
Get started with your free account
</Text>
</Box>
<Card position="relative" overflow="hidden">
{/* Background accent */}
<Box position="absolute" top="0" right="0" w="8rem" h="8rem" bg="linear-gradient(to bottom left, rgba(59, 130, 246, 0.1), transparent)" />
<Box as="form" onSubmit={formActions.handleSubmit}>
<Stack gap={4} position="relative">
{/* First Name */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
First Name
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={User} size={4} color="#6b7280" />
</Box>
<Input
id="firstName"
name="firstName"
type="text"
value={viewData.formState.fields.firstName.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.firstName.error ? 'error' : 'default'}
placeholder="John"
disabled={mutationState.isPending}
autoComplete="given-name"
/>
</Box>
{viewData.formState.fields.firstName.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.firstName.error}
</Text>
)}
</Box>
{/* Last Name */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Last Name
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={User} size={4} color="#6b7280" />
</Box>
<Input
id="lastName"
name="lastName"
type="text"
value={viewData.formState.fields.lastName.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.lastName.error ? 'error' : 'default'}
placeholder="Smith"
disabled={mutationState.isPending}
autoComplete="family-name"
/>
</Box>
{viewData.formState.fields.lastName.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.lastName.error}
</Text>
)}
<Text size="xs" color="text-gray-500" block mt={1}>Your name will be used as-is and cannot be changed later</Text>
</Box>
{/* Name Immutability Warning */}
<Surface variant="muted" rounded="lg" border padding={3} bg="bg-amber-500/10" borderColor="border-amber-500/30">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={5} color="#f59e0b" />
<Text size="sm" color="text-warning-amber">
<Text weight="bold">Important:</Text> Your name cannot be changed after signup. Please ensure it&apos;s correct.
</Text>
</Stack>
</Surface>
{/* Email */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Email Address
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Mail} size={4} color="#6b7280" />
</Box>
<Input
id="email"
name="email"
type="email"
value={viewData.formState.fields.email.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.email.error ? 'error' : 'default'}
placeholder="you@example.com"
disabled={mutationState.isPending}
autoComplete="email"
/>
</Box>
{viewData.formState.fields.email.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.email.error}
</Text>
)}
</Box>
{/* Password */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Password
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Lock} size={4} color="#6b7280" />
</Box>
<Input
id="password"
name="password"
type={uiState.showPassword ? 'text' : 'password'}
value={viewData.formState.fields.password.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.password.error ? 'error' : 'default'}
placeholder="••••••••"
disabled={mutationState.isPending}
autoComplete="new-password"
/>
<Box
as="button"
type="button"
onClick={() => formActions.setShowPassword(!uiState.showPassword)}
position="absolute"
right="3"
top="50%"
zIndex={10}
bg="transparent"
borderStyle="none"
cursor="pointer"
>
<Icon icon={uiState.showPassword ? EyeOff : Eye} size={4} color="#6b7280" />
</Box>
</Box>
{viewData.formState.fields.password.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.password.error}
</Text>
)}
{/* Password Strength */}
{viewData.formState.fields.password.value && (
<Box mt={3}>
<Stack direction="row" align="center" gap={2} mb={2}>
<Box flex={1} h="1.5" rounded="full" bg="bg-neutral-800" overflow="hidden">
<Box h="full" w={`${(passwordStrength.score / 5) * 100}%`} bg={passwordStrength.color === 'bg-red-500' ? 'bg-red-500' : passwordStrength.color === 'bg-yellow-500' ? 'bg-amber-500' : passwordStrength.color === 'bg-blue-500' ? 'bg-blue-500' : 'bg-green-500'} />
</Box>
<Text size="xs" weight="medium" color={passwordStrength.color === 'bg-red-500' ? 'text-red-400' : passwordStrength.color === 'bg-yellow-500' ? 'text-amber-400' : passwordStrength.color === 'bg-blue-500' ? 'text-blue-400' : 'text-green-400'}>
{passwordStrength.label}
</Text>
</Stack>
<Box display="grid" gridCols={2} gap={1}>
{passwordRequirements.map((req, index) => (
<Stack key={index} direction="row" align="center" gap={1.5}>
<Icon icon={req.met ? Check : X} size={3} color={req.met ? '#10b981' : '#525252'} />
<Text size="xs" color={req.met ? 'text-gray-300' : 'text-gray-500'}>
{req.label}
</Text>
</Stack>
))}
</Box>
</Box>
)}
</Box>
{/* Confirm Password */}
<Box>
<Text size="sm" weight="medium" color="text-gray-300" block mb={2}>
Confirm Password
</Text>
<Box position="relative">
<Box position="absolute" left="3" top="50%" zIndex={10}>
<Icon icon={Lock} size={4} color="#6b7280" />
</Box>
<Input
id="confirmPassword"
name="confirmPassword"
type={uiState.showConfirmPassword ? 'text' : 'password'}
value={viewData.formState.fields.confirmPassword.value}
onChange={formActions.handleChange}
variant={viewData.formState.fields.confirmPassword.error ? 'error' : 'default'}
placeholder="••••••••"
disabled={mutationState.isPending}
autoComplete="new-password"
/>
<Box
as="button"
type="button"
onClick={() => formActions.setShowConfirmPassword(!uiState.showConfirmPassword)}
position="absolute"
right="3"
top="50%"
zIndex={10}
bg="transparent"
borderStyle="none"
cursor="pointer"
>
<Icon icon={uiState.showConfirmPassword ? EyeOff : Eye} size={4} color="#6b7280" />
</Box>
</Box>
{viewData.formState.fields.confirmPassword.error && (
<Text size="xs" color="text-error-red" block mt={1}>
{viewData.formState.fields.confirmPassword.error}
</Text>
)}
{viewData.formState.fields.confirmPassword.value && viewData.formState.fields.password.value === viewData.formState.fields.confirmPassword.value && (
<Stack direction="row" align="center" gap={1} mt={1}>
<Icon icon={Check} size={3} color="#10b981" />
<Text size="xs" color="text-performance-green">Passwords match</Text>
<Box display="grid" gridCols={2} gap={2}>
{passwordRequirements.map((req, index) => (
<Stack key={index} direction="row" align="center" gap={1.5}>
<Icon icon={req.met ? Check : X} size={3} color={req.met ? 'var(--color-success)' : 'var(--color-text-low)'} />
<Text size="xs" color={req.met ? 'text-med' : 'text-low'}>
{req.label}
</Text>
</Stack>
)}
))}
</Box>
{/* Submit Button */}
<Button
type="submit"
variant="primary"
disabled={mutationState.isPending}
fullWidth
icon={mutationState.isPending ? <LoadingSpinner size={4} color="white" /> : <Icon icon={UserPlus} size={4} />}
>
{mutationState.isPending ? 'Creating account...' : 'Create Account'}
</Button>
</Stack>
</Box>
)}
{/* Divider */}
<Box position="relative" my={6}>
<Box position="absolute" inset="0" display="flex" alignItems="center">
<Box w="full" borderTop borderColor="border-neutral-800" />
</Box>
<Box position="relative" display="flex" justifyContent="center">
<Box px={4} bg="bg-neutral-900">
<Text size="xs" color="text-gray-500">or continue with</Text>
</Box>
</Box>
</Box>
<PasswordField
label="Confirm Password"
id="confirmPassword"
name="confirmPassword"
value={viewData.formState.fields.confirmPassword.value}
onChange={formActions.handleChange}
errorMessage={viewData.formState.fields.confirmPassword.error}
placeholder="••••••••"
disabled={isSubmitting}
autoComplete="new-password"
showPassword={uiState.showConfirmPassword}
onTogglePassword={() => formActions.setShowConfirmPassword(!uiState.showConfirmPassword)}
/>
</Stack>
</Stack>
{/* Login Link */}
<Box textAlign="center" mt={6}>
<Text size="sm" color="text-gray-400">
Already have an account?{' '}
<Link
href={viewData.returnTo && viewData.returnTo !== '/onboarding' ? `/auth/login?returnTo=${encodeURIComponent(viewData.returnTo)}` : '/auth/login'}
>
<Text color="text-primary-blue" weight="medium">Sign in</Text>
</Link>
</Text>
</Box>
</Card>
{/* Footer */}
<Box mt={6} textAlign="center">
<Text size="xs" color="text-gray-500">
By creating an account, you agree to our{' '}
<Link href="/terms">
<Text color="text-gray-400">Terms of Service</Text>
</Link>
{' '}and{' '}
<Link href="/privacy">
<Text color="text-gray-400">Privacy Policy</Text>
</Link>
</Text>
</Box>
{/* Mobile Role Info */}
<Box mt={8} display={{ base: 'block', lg: 'none' }}>
<Text size="xs" color="text-gray-500" block mb={4} textAlign="center">One account for all roles</Text>
<Stack direction="row" align="center" justify="center" gap={6}>
{USER_ROLES.map((role) => (
<Stack key={role.title} align="center" gap={1}>
<Surface variant="muted" rounded="lg" padding={2} bg={role.bg}>
<Icon icon={role.icon} size={4} color={role.color} />
</Surface>
<Text size="xs" color="text-gray-500">{role.title}</Text>
</Stack>
))}
{mutationState.error && (
<Box p={4} bg="critical-red/10" border borderColor="critical-red/30" rounded="md">
<Stack direction="row" align="start" gap={3}>
<Icon icon={AlertCircle} size={4.5} color="var(--color-critical)" />
<Text size="sm" color="text-critical-red">{mutationState.error}</Text>
</Stack>
</Box>
)}
<Button
type="submit"
variant="primary"
disabled={isSubmitting}
fullWidth
icon={isSubmitting ? <LoadingSpinner size={4} /> : <UserPlus size={16} />}
>
{isSubmitting ? 'Creating account...' : 'Create Account'}
</Button>
</AuthForm>
<AuthFooterLinks>
<Text size="sm" color="text-gray-400">
Already have an account?{' '}
<Link
href={viewData.returnTo && viewData.returnTo !== '/onboarding' ? `/auth/login?returnTo=${encodeURIComponent(viewData.returnTo)}` : '/auth/login'}
>
<Text color="text-primary-accent" weight="bold">Sign in</Text>
</Link>
</Text>
<Box mt={2}>
<Text size="xs" color="text-gray-600">
By creating an account, you agree to our{' '}
<Link href="/terms">Terms</Link>
{' '}and{' '}
<Link href="/privacy">Privacy</Link>
</Text>
</Box>
</Box>
</Box>
</AuthFooterLinks>
</AuthCard>
);
}