/*! ========================================================= * Argon Dashboard Chakra PRO - v1.0.0 ========================================================= * Product Page: https://www.creative-tim.com/product/argon-dashboard-chakra-pro * Copyright 2022 Creative Tim (https://www.creative-tim.com/) * Designed and Coded by Simmmple & Creative Tim ========================================================= * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */ // Chakra imports import React, { useState } from "react"; import { Box, Button, Flex, FormControl, FormLabel, Heading, Input, Stack, useColorModeValue, Text, Link, InputGroup, InputRightElement, IconButton, useToast, } from "@chakra-ui/react"; import { ViewIcon, ViewOffIcon } from "@chakra-ui/icons"; import { useNavigate } from "react-router-dom"; import { useAuth } from "../../../contexts/AuthContext"; export default function SignInBasic() { const [showPassword, setShowPassword] = useState(false); const [formData, setFormData] = useState({ email: "", password: "", }); const navigate = useNavigate(); const toast = useToast(); const { login, isLoading } = useAuth(); const handleInputChange = (e) => { const { name, value } = e.target; setFormData(prev => ({ ...prev, [name]: value })); }; const handleSubmit = async (e) => { e.preventDefault(); if (!formData.email || !formData.password) { toast({ title: "请填写完整信息", description: "邮箱和密码都是必填项", status: "warning", duration: 3000, isClosable: true, }); return; } const result = await login(formData.email, formData.password, 'email'); if (result.success) { // 登录成功,跳转到首页 navigate("/home"); } }; return ( 价小前投研 登录您的账户
邮箱地址 密码 : } onClick={() => setShowPassword(!showPassword)} variant="ghost" size="sm" /> 还没有账户?{" "} navigate("/auth/signup")}> 立即注册
); }