"use client"; import { BarChart3, Loader2, Shield, Zap } from "lucide-react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { signIn } from "next-auth/react"; import { useId, useState } from "react"; import { toast } from "sonner"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { ThemeToggle } from "@/components/ui/theme-toggle"; export default function LoginPage() { const emailId = useId(); const emailHelpId = useId(); const passwordId = useId(); const passwordHelpId = useId(); const loadingStatusId = useId(); 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