import React from "react"; import { useState } from "react"; import { loginFunc } from "@/utils/loginUser"; import MyAlert from "../components/myChakra/MyAlert"; import { Button, Card, Field, Input, Stack } from "@chakra-ui/react"; const Login: React.FC<{ onSuccess: () => void }> = ({ onSuccess }) => { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [isError, setIsError] = useState(false); const [errorMsg, setErrorMsg] = useState(""); const [errorDsc, setErrorDsc] = useState(""); const handleLogin = async () => { const result = await loginFunc(username, password); if (!result.success) { setErrorMsg(result.message); setErrorDsc(result.description); setIsError(true); return; } onSuccess(); }; return (