diff --git a/src/components/LoginReg/LoginCard.jsx b/src/components/LoginReg/LoginCard.jsx
index 0a998ec9d29cb0dff5de8a32e1d64c70da7ba73e..dffb11ba885bac94c27c00621ee421242b7dd112 100644
--- a/src/components/LoginReg/LoginCard.jsx
+++ b/src/components/LoginReg/LoginCard.jsx
@@ -1,31 +1,76 @@
-import React, { useState } from "react";
-import { AiOutlineUser } from "react-icons/ai";
+import React, { useState, useEffect } from "react";
+import { AiOutlineUser, AiOutlineCheck } from "react-icons/ai";
import { Navigate } from "react-router-dom";
+import { motion } from "framer-motion";
+
import InputArea from "../InputArea";
import LoginBtn from "./LoginBtn";
import PwArea from "./PwArea";
import RememberPw from "./RememberPw";
import { onLogin } from "../../utils/adminCookie";
import { accounts } from "../../utils/data";
+import axios from "axios";
const LoginCard = () => {
const [userInput, setUserInput] = useState("");
const [pwInput, setPwInput] = useState("");
+ const [codeInput, setCodeInput] = useState("");
+
+ const [imgCode, setImgCode] = useState("");
+
const [loginSucc, setLoginSucc] = useState(false);
+ const [loginFail, setLoginFail] = useState(false);
+
+ const getCode = (e) => {
+ e.stopPropagation();
+ axios
+ .get("http://localhost:8081/code", { withCredentials: true })
+ .then((res) => {
+ setImgCode(res.data);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+
const handleSubmit = (e) => {
e.preventDefault();
- const [uname, upw] = document.forms[0];
+ const [uname, upw, ucode] = document.forms[0];
if (uname.value === "12" && upw.value === "12") {
setLoginSucc(true);
- onLogin(accounts.filter(item=>item.username===uname.value))
- }else if (uname.value === "34" && upw.value === "34"){
+ onLogin(accounts.filter((item) => item.username === uname.value));
+ } else if (uname.value === "34" && upw.value === "34") {
setLoginSucc(true);
- onLogin(accounts.filter(item=>item.username===uname.value))
+ onLogin(accounts.filter((item) => item.username === uname.value));
}
+ axios
+ .get(
+ "http://localhost:8081/login",
+ { params: { username: uname, password: upw, code: ucode } },
+ { withCredentials: true }
+ )
+ .then((res) => {
+ setLoginSucc(true);
+ })
+ .catch((error) => {
+ setLoginFail(true);
+ console.log(error);
+ });
};
+ useEffect(() => {
+ axios
+ .get("http://localhost:8081/code", { withCredentials: true })
+ .then((res) => {
+ setImgCode(res.data);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ }, []);
+
return loginSucc ? (
-
+
) : (
diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx
index 4d1b288366986ffb56b0357fd7e7fdb3cf493ca0..cf26efd5bda46badfcf93d39861edaa6be6d101a 100644
--- a/src/components/Selector.jsx
+++ b/src/components/Selector.jsx
@@ -3,6 +3,7 @@ import React from "react";
const Selector = ({ value, onChange, className, categories }) => {
return (