Spaces:
Build error
Build error
Upload pages/index.js with huggingface_hub
Browse files- pages/index.js +122 -0
pages/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react'
|
| 2 |
+
import Head from 'next/head'
|
| 3 |
+
import LoginForm from '../components/LoginForm'
|
| 4 |
+
import GoogleButton from '../components/GoogleButton'
|
| 5 |
+
|
| 6 |
+
export default function Home() {
|
| 7 |
+
const [isLoading, setIsLoading] = useState(false)
|
| 8 |
+
const [error, setError] = useState('')
|
| 9 |
+
|
| 10 |
+
const handleLogin = async (email, password) => {
|
| 11 |
+
setIsLoading(true)
|
| 12 |
+
setError('')
|
| 13 |
+
|
| 14 |
+
try {
|
| 15 |
+
// Simulate API call
|
| 16 |
+
await new Promise(resolve => setTimeout(resolve, 1500))
|
| 17 |
+
|
| 18 |
+
// Here you would make actual API call
|
| 19 |
+
console.log('Login with:', email, password)
|
| 20 |
+
alert('Login successful!')
|
| 21 |
+
} catch (err) {
|
| 22 |
+
setError('Invalid email or password')
|
| 23 |
+
} finally {
|
| 24 |
+
setIsLoading(false)
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const handleGoogleLogin = async () => {
|
| 29 |
+
setIsLoading(true)
|
| 30 |
+
setError('')
|
| 31 |
+
|
| 32 |
+
try {
|
| 33 |
+
// Redirect to Google OAuth
|
| 34 |
+
window.location.href = '/api/auth/google'
|
| 35 |
+
} catch (err) {
|
| 36 |
+
setError('Failed to initiate Google login')
|
| 37 |
+
setIsLoading(false)
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
return (
|
| 42 |
+
<>
|
| 43 |
+
<Head>
|
| 44 |
+
<title>Sign in - Google Style</title>
|
| 45 |
+
<meta name="description" content="Sign in to your account" />
|
| 46 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 47 |
+
<link rel="icon" href="/favicon.ico" />
|
| 48 |
+
</Head>
|
| 49 |
+
|
| 50 |
+
<main className="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
| 51 |
+
<div className="absolute top-4 right-4">
|
| 52 |
+
<a
|
| 53 |
+
href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 54 |
+
target="_blank"
|
| 55 |
+
rel="noopener noreferrer"
|
| 56 |
+
className="text-sm text-gray-600 hover:text-gray-900 transition-colors"
|
| 57 |
+
>
|
| 58 |
+
Built with anycoder
|
| 59 |
+
</a>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
| 63 |
+
<div className="flex justify-center">
|
| 64 |
+
<div className="w-20 h-20 bg-gradient-to-r from-blue-400 via-red-500 to-yellow-400 rounded-full flex items-center justify-center text-white font-bold text-2xl shadow-lg">
|
| 65 |
+
G
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
|
| 69 |
+
Sign in to your account
|
| 70 |
+
</h2>
|
| 71 |
+
<p className="mt-2 text-center text-sm text-gray-600">
|
| 72 |
+
Or{' '}
|
| 73 |
+
<a href="#" className="font-medium text-google-blue hover:text-google-blue/80">
|
| 74 |
+
create a new account
|
| 75 |
+
</a>
|
| 76 |
+
</p>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
| 80 |
+
<div className="bg-white py-8 px-4 shadow-xl sm:rounded-lg sm:px-10">
|
| 81 |
+
<LoginForm
|
| 82 |
+
onSubmit={handleLogin}
|
| 83 |
+
isLoading={isLoading}
|
| 84 |
+
error={error}
|
| 85 |
+
/>
|
| 86 |
+
|
| 87 |
+
<div className="mt-6">
|
| 88 |
+
<div className="relative">
|
| 89 |
+
<div className="absolute inset-0 flex items-center">
|
| 90 |
+
<div className="w-full border-t border-gray-300" />
|
| 91 |
+
</div>
|
| 92 |
+
<div className="relative flex justify-center text-sm">
|
| 93 |
+
<span className="px-2 bg-white text-gray-500">Or continue with</span>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<div className="mt-6">
|
| 98 |
+
<GoogleButton
|
| 99 |
+
onClick={handleGoogleLogin}
|
| 100 |
+
isLoading={isLoading}
|
| 101 |
+
/>
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
+
|
| 105 |
+
<div className="mt-6 text-center">
|
| 106 |
+
<p className="text-xs text-gray-500">
|
| 107 |
+
By signing in, you agree to our{' '}
|
| 108 |
+
<a href="#" className="font-medium text-google-blue hover:text-google-blue/80">
|
| 109 |
+
Terms
|
| 110 |
+
</a>{' '}
|
| 111 |
+
and{' '}
|
| 112 |
+
<a href="#" className="font-medium text-google-blue hover:text-google-blue/80">
|
| 113 |
+
Privacy Policy
|
| 114 |
+
</a>
|
| 115 |
+
</p>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
</main>
|
| 120 |
+
</>
|
| 121 |
+
)
|
| 122 |
+
}
|