import React, { useState } from 'react'; import { Formik } from 'formik'; import * as Yup from 'yup'; import axios from 'axios'; import Menu from '../Components/Menu'; import { Link, Redirect } from 'react-router-dom'; import { Container, Button, Navbar, Col } from 'react-bootstrap'; import styled from 'styled-components'; const Check = styled.div` & #reCheck::after { content: '새로운 비밀번호를 다시 입력하세요'; } & #reCheck:not(.right) { content: '비밀번호가 일치하지 않습니다.'; color: red; } ` function Change(props) { const [state, setState] = useState(); const [checkPw, setCheckPw] = useState(true); if (state) { return ; } // console.log(props) return (
{(localStorage.getItem("token") !== null) ? ( ) : ( 회원가입 )} { axios.put(`/users/change/${props.location.state.id}`, { ...values }, ) .then(res => { console.log(res.data); 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, }) => (
새 비밀번호를 입력하세요(8자리 이상)
{touched.password2 && errors.password2 ? setCheckPw(false) : null}
)}
); } export default Change;