"use client" import { useState } from "react" import { signIn } from "next-auth/react" import { useRouter } from "next/navigation" export default function LoginPage() { const router = useRouter() const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [userType, setUserType] = useState("operator") const [error, setError] = useState("") const [loading, setLoading] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") setLoading(true) const result = await signIn("credentials", { email, password, userType, redirect: false, }) setLoading(false) if (result?.error) { setError("Invalid credentials") } else { if (userType === "admin") router.push("/admin") else if (userType === "shift_manager") router.push("/shift-manager") else router.push("/operator") } } return (
Bottle Production System