import React, { useState } from 'react'; import { Field, Formik } from 'formik'; import * as Yup from 'yup'; import axios from 'axios'; import 'bootstrap/dist/css/bootstrap.css'; import { Link, Redirect } from 'react-router-dom'; import styled from 'styled-components'; const Nav = styled.nav` background-color: #7B031D; height: 10vh; a { color: #ffffff; } ` const Wow = styled.div` height: 90vh; & #reCheck::after { content: '비밀번호를 다시 입력하세요'; } & #reCheck:not(.right) { content: '비밀번호가 다릅니다.'; color: red; } & .asd { display: flex; flex-direction: column; } ` function Signup() { const [state, setState] = useState(false); const [checkPw, setCheckPw] = useState(true); if (state) { return ; } return (
{ axios({ method: 'post', url: '/users', data: values, }).then(res => { if (res.status === 404) return alert(res.data.error) alert("회원가입이 완료되었습니다!") 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, }) => ( < form onSubmit={handleSubmit} className="asd"> {/* col-sm-3 */}
{/* mb-4 */}
이름을 입력하세요
{/* mb-4 */}
학번을 입력하세요
{/* {touched.id && errors.id ? (
{errors.id}
) : null} */}
{/* mb-4 */}
비밀번호를 입력하세요(8자리 이상)
{/* {touched.password && errors.password ? (
{errors.password}
) : null} */}
{/* mb-4 */} {touched.password2 && errors.password2 ? setCheckPw(false) : null}
{/* mb-4 */}
{/* mb-4 */}
답변을 입력해주세요.
)}
); } export default Signup;