import React, { useState } from 'react'; import styled from 'styled-components'; import { Link, Redirect } from 'react-router-dom'; import { Formik } from 'formik'; import * as Yup from 'yup'; import axios from 'axios'; import 'bootstrap/dist/css/bootstrap.css'; const Log = styled.div` background-color: #7B031D; ` const Logo = styled.div` background-color: rgb(239, 218, 200); ` function Login() { const [state, setState]= useState(false); if (state) { return ; } return (

고려대학교

대관 시스템

{ axios({ method: 'post', url: '/login', data: values, }).then(res => { if (res.status === 404) return alert(res.data.error) alert("로그인이 완료되었습니다!") localStorage.setItem('token', res.data.token); localStorage.setItem('id', res.data.users._id); setState(true); }) .catch(err => { alert(err.error) }); setTimeout(() => { setSubmitting(false); }, 400); // finish the cycle in handler }} > {({ errors, touched, handleSubmit, getFieldProps, // contain values, handleChange, handleBlur isSubmitting, }) => (
{touched.id && errors.id ? (
{errors.id}
) : null}
{touched.password && errors.password ? (
{errors.password}
) : null}
비밀번호를 잊으셨나요?
회원이 아니신가요?
)}
) } export default Login