"use client"; import React, { useState } from "react"; import { signInWithEmailAndPassword } from "firebase/auth"; import { auth } from "@/lib/firebase"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import Link from "next/link"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); try { await signInWithEmailAndPassword(auth, email, password); router.push("/"); } catch (err: any) { console.error(err); setError("Credenciais inválidas. Verifique o seu email e palavra-passe."); } finally { setLoading(false); } }; return ( ReservaMesa Inicie sessão no seu painel de restaurante
{error && (
{error}
)}
setEmail(e.target.value)} required />
setPassword(e.target.value)} required />
Ainda não tem conta?{" "} Registe o seu restaurante
); }