"use client"; import { useRouter } from "next/navigation"; import { signIn } from "next-auth/react"; import { useId, useState } from "react"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Card, CardContent, 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 PlatformLoginPage() { const emailId = useId(); const passwordId = useId(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(""); try { const result = await signIn("credentials", { email, password, redirect: false, callbackUrl: "/platform/dashboard", }); if (result?.error) { setError("Invalid credentials"); } else if (result?.ok) { // Login successful, redirect to dashboard router.push("/platform/dashboard"); } } catch (_error) { setError("An error occurred during login"); } finally { setIsLoading(false); } }; return (
Platform Login

Sign in to the Notso AI platform management dashboard

{error && ( {error} )}
setEmail(e.target.value)} required disabled={isLoading} autoComplete="email" />
setPassword(e.target.value)} required disabled={isLoading} autoComplete="current-password" />
); }