import React, { useState, useEffect } from 'react';
import { Formik, Field, ErrorMessage, FieldArray } from 'formik';
import Menu from '../Components/Menu';
import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css';
import * as Yup from 'yup';
import { Redirect } from 'react-router-dom';
function Apply(props) {
const [state, setState] = useState();
const [user, setUser] = useState({ name: "" });
useEffect(() => {
getUser();
}, [])
if (state) {
return ;
}
function time(starttime) {
console.log(starttime)
if (starttime == 21) {
return (
)
}
if (starttime == 20) {
return (
)
}
return (
)
}
function getUser() {
axios.get(`/users/${props.match.params.id}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
if (res.status !== 201) {
alert(res.data.error);
}
console.log(res.data);
setUser(res.data);
})
.catch(err => {
alert(err.error)
});
}
return (
{
console.log(values)
axios({
method: 'post',
url: '/reserves',
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,
values,
handleSubmit,
getFieldProps,
isSubmitting,
}) => (
)}
)
}
export default Apply