49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
"use client"
|
||
|
||
import { useState } from "react"
|
||
import { useRouter } from "next/navigation"
|
||
import { Button } from "@/components/ui/button"
|
||
import { Input } from "@/components/ui/input"
|
||
import { Label } from "@/components/ui/label"
|
||
import { useAuth } from "@/contexts/auth-context"
|
||
|
||
export default function LoginPage() {
|
||
const [email, setEmail] = useState("")
|
||
const [password, setPassword] = useState("")
|
||
const router = useRouter()
|
||
const { login } = useAuth()
|
||
|
||
const handleSubmit = (e: React.FormEvent) => {
|
||
e.preventDefault()
|
||
// In a real application, you would validate credentials here
|
||
login()
|
||
router.push("/")
|
||
}
|
||
|
||
return (
|
||
<div className="container mx-auto px-4 py-8">
|
||
<h1 className="text-2xl font-bold mb-6">Войти</h1>
|
||
<form onSubmit={handleSubmit} className="space-y-4 max-w-md mx-auto">
|
||
<div>
|
||
<Label htmlFor="email">Email</Label>
|
||
<Input type="email" id="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
|
||
</div>
|
||
<div>
|
||
<Label htmlFor="password">Пароль</Label>
|
||
<Input
|
||
type="password"
|
||
id="password"
|
||
value={password}
|
||
onChange={(e) => setPassword(e.target.value)}
|
||
required
|
||
/>
|
||
</div>
|
||
<Button type="submit" className="w-full">
|
||
Войти
|
||
</Button>
|
||
</form>
|
||
</div>
|
||
)
|
||
}
|
||
|