"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "@/hooks/use-auth"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { getErrorMessage } from "@/lib/api"; 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 { login } = useAuth(); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); try { await login(email, password); router.push("/dashboard"); } catch (err: unknown) { setError(getErrorMessage(err, "登录失败")); } finally { setLoading(false); } }; return (
The University of Hong Kong

香港大学中国商业学院

班级信息管理平台

公告与课程通知 成员名录与班级连接 活动排期与资源协同
HKU ICB
欢迎回来 登录班级信息管理平台
setEmail(e.target.value)} required />
setPassword(e.target.value)} required />
{error && (

{error}

)}
还没有账号?{" "} 激活账号
); }