import styles from "./login.module.scss"; import { useState } from "react"; import authApi from "../../apis/auth.api.js"; import { Redirect } from "react-router"; import catchErrors from "../../utils/catchErrors"; const Login = () => { //useState를 이용해서 각 state 생성 및 초기값 저장 const [state, setState] = useState(true); // 이 줄은 css에 해당하는 state //state변수 지정 하지만 이 변수는 react에 의해 없어지지 않음, 그리고 그 다음 변수는 state변수를 갱신해주는 함수 const [login, setLogin] = useState({ id:'', password:'' }); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [guest, setGuset] = useState({ guestName:'', gusetBirthday:'', gusetMbnum:'', guestPassword:'' }) //input태그에 걸려있는 onchange에서 실행할 함수설정 const handleLoginOnChange = (e) =>{ // ... 전개 연산자 // 현재 state에 방금 변화한 값을 다시 저장함 setLogin({ ...login, [e.target.name]:e.target.value }) }; const handleGuestOnChange = (e) =>{ setGuset({ ...guest, [e.target.name]:e.target.value }) } const handleOnSummitUser = async(e) => { e.preventDefault(); try{ console.log("하하") setError(""); setLoading(true); const userData = login; await authApi.login(userData); alert('로그인이 완료되었습니다.') setSuccess(true); }catch(error){ catchErrors(error, setError); }finally{ setLoading(false); } } const handleOnSummitGuest = async(e) => { e.preventDefault(); try{ setError(""); setLoading(true); const gusetData = guest; await authApi.post(gusetData); alert('로그인이 완료되었습니다.') setSuccess(true); }catch(error){ catchErrors(error, setError); }finally{ setLoading(false); } } if (success) { return ; } return (
{/* nav-tabs */} {/* {console.log(login)} */} {console.log(success)}
{/* 로그인 */} {/* 비회원예매 학인 */}

※ 비회원 정보 오 입력 시 예매 내역 확인/취소 및 티켓 발권이 어려울 수 있으니 다시 한번 확인해 주시기 바랍니다.

) } export default Login