"use client"; import { useState } from "react"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import Image from "next/image"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { ThemeToggle } from "@/components/ui/theme-toggle"; import { Loader2, Shield, BarChart3, Zap } from "lucide-react"; import { toast } from "sonner"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); async function handleLogin(e: React.FormEvent) { e.preventDefault(); setIsLoading(true); setError(""); try { const res = await signIn("credentials", { email, password, redirect: false, }); if (res?.ok) { toast.success("Login successful! Redirecting..."); router.push("/dashboard"); } else { setError("Invalid email or password. Please try again."); toast.error("Login failed. Please check your credentials."); } } catch { setError("An error occurred. Please try again."); toast.error("An unexpected error occurred."); } finally { setIsLoading(false); } } return (
Monitor, analyze, and optimize your customer conversations with AI-powered insights.
By signing in, you agree to our{" "} Terms of Service {" "} and{" "} Privacy Policy