Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | 'use client' import { signIn } from 'next-auth/react' import Link from 'next/link' import { useRouter } from 'next/navigation' import { useState } from 'react' import { css } from '../../../../styled-system/css' import { useTheme } from '@/contexts/ThemeContext' export default function SignInPage() { const { resolvedTheme } = useTheme() const router = useRouter() const isDark = resolvedTheme === 'dark' const [email, setEmail] = useState('') const [isLoading, setIsLoading] = useState<'google' | 'email' | null>(null) const handleGoogleSignIn = async () => { setIsLoading('google') await signIn('google', { callbackUrl: '/' }) } const handleEmailSignIn = async (e: React.FormEvent) => { e.preventDefault() if (!email.trim()) return setIsLoading('email') // Use redirect: false to avoid NextAuth's server-side redirect // which uses the internal localhost:3000 origin behind the proxy const result = await signIn('nodemailer', { email: email.trim(), redirect: false, callbackUrl: '/', }) if (result?.ok) { router.push('/auth/verify-request') } else { setIsLoading(null) } } return ( <main data-component="signin-page" className={css({ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', backgroundColor: isDark ? 'gray.900' : 'gray.50', padding: '1rem', })} > <div className={css({ width: '100%', maxWidth: '400px', padding: '2rem', borderRadius: '16px', backgroundColor: isDark ? 'gray.800' : 'white', border: '1px solid', borderColor: isDark ? 'gray.700' : 'gray.200', boxShadow: isDark ? '0 8px 24px rgba(0, 0, 0, 0.4)' : '0 8px 24px rgba(0, 0, 0, 0.1)', })} > {/* Branding */} <div className={css({ textAlign: 'center', marginBottom: '2rem' })}> <h1 className={css({ fontSize: '1.5rem', fontWeight: 'bold', color: isDark ? 'white' : 'gray.900', marginBottom: '0.5rem', })} > Abaci One </h1> <p className={css({ fontSize: '0.875rem', color: isDark ? 'gray.400' : 'gray.600', })} > Sign in to access your students and practice data from any device </p> </div> {/* Google Sign In */} <button type="button" onClick={handleGoogleSignIn} disabled={isLoading !== null} data-action="google-signin" className={css({ width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.75rem', padding: '0.75rem 1rem', borderRadius: '8px', border: '1px solid', borderColor: isDark ? 'gray.600' : 'gray.300', backgroundColor: isDark ? 'gray.700' : 'white', color: isDark ? 'white' : 'gray.700', fontSize: '0.9375rem', fontWeight: 500, cursor: 'pointer', transition: 'all 0.2s ease', _hover: { backgroundColor: isDark ? 'gray.600' : 'gray.50', borderColor: isDark ? 'gray.500' : 'gray.400', }, _disabled: { opacity: 0.6, cursor: 'not-allowed', }, })} > <svg width="18" height="18" viewBox="0 0 18 18"> <path d="M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844c-.209 1.125-.843 2.078-1.796 2.717v2.258h2.908c1.702-1.567 2.684-3.874 2.684-6.615z" fill="#4285F4" /> <path d="M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18z" fill="#34A853" /> <path d="M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.997 8.997 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332z" fill="#FBBC05" /> <path d="M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z" fill="#EA4335" /> </svg> {isLoading === 'google' ? 'Signing in...' : 'Sign in with Google'} </button> {/* Divider */} <div className={css({ display: 'flex', alignItems: 'center', gap: '0.75rem', margin: '1.5rem 0', })} > <div className={css({ flex: 1, height: '1px', backgroundColor: isDark ? 'gray.700' : 'gray.200', })} /> <span className={css({ fontSize: '0.8125rem', color: isDark ? 'gray.500' : 'gray.400', fontWeight: 500, })} > or </span> <div className={css({ flex: 1, height: '1px', backgroundColor: isDark ? 'gray.700' : 'gray.200', })} /> </div> {/* Email Sign In */} <form onSubmit={handleEmailSignIn}> <label htmlFor="email" className={css({ display: 'block', fontSize: '0.875rem', fontWeight: 500, color: isDark ? 'gray.300' : 'gray.700', marginBottom: '0.375rem', })} > Email address </label> <input id="email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="you@example.com" required data-element="email-input" className={css({ width: '100%', padding: '0.625rem 0.75rem', borderRadius: '8px', border: '1px solid', borderColor: isDark ? 'gray.600' : 'gray.300', backgroundColor: isDark ? 'gray.700' : 'white', color: isDark ? 'white' : 'gray.900', fontSize: '0.9375rem', outline: 'none', transition: 'border-color 0.2s ease', _focus: { borderColor: 'purple.500', }, _placeholder: { color: isDark ? 'gray.500' : 'gray.400', }, })} /> <button type="submit" disabled={isLoading !== null || !email.trim()} data-action="email-signin" className={css({ width: '100%', marginTop: '0.75rem', padding: '0.75rem 1rem', borderRadius: '8px', border: 'none', backgroundColor: 'purple.600', color: 'white', fontSize: '0.9375rem', fontWeight: 500, cursor: 'pointer', transition: 'all 0.2s ease', _hover: { backgroundColor: 'purple.700', }, _disabled: { opacity: 0.6, cursor: 'not-allowed', }, })} > {isLoading === 'email' ? 'Sending link...' : 'Send magic link'} </button> </form> {/* Continue as guest */} <div className={css({ textAlign: 'center', marginTop: '1.5rem' })}> <Link href="/" data-action="continue-as-guest" className={css({ fontSize: '0.875rem', color: isDark ? 'gray.400' : 'gray.500', textDecoration: 'none', _hover: { color: isDark ? 'gray.300' : 'gray.700', textDecoration: 'underline', }, })} > Continue as guest </Link> </div> </div> </main> ) } |