Commit 3ef60774 authored by Kim, Subin's avatar Kim, Subin
Browse files

스케쥴, 신청, 홈 페이지

parent cd650135
......@@ -5,6 +5,9 @@ import "tui-date-picker/dist/tui-date-picker.css";
import "tui-time-picker/dist/tui-time-picker.css";
import moment from 'moment';
import axios from 'axios';
import { Image, Button } from 'react-bootstrap';
import leftArrow from '../caret-left-fill.svg';
import rightArrow from '../caret-right-fill.svg';
function Cal(props) {
const calendarRef = useRef(null);
......@@ -76,17 +79,17 @@ function Cal(props) {
return (
<div>
<div id="menu">
<div id="menu" className="p-2">
<span id="menu-navi" onClick={(e) => onClickNavi(e)}>
<button type="button" className="btn btn-default btn-sm move-today" data-action="move-today">Today</button>
<button type="button" className="btn btn-default btn-sm move-day" data-action="move-prev">
<i class="calendar-icon ic-arrow-line-left" data-action="move-prev"></i>
</button>
<button type="button" className="btn btn-default btn-sm move-day" data-action="move-next">
<i className="calendar-icon ic-arrow-line-right" data-action="move-next"></i>
</button>
<Button variant="default" size="sm" className="move-today" data-action="move-today">Today</Button>
<Button variant="default" size="sm" className="move-day" data-action="move-prev">
<Image class="calendar-icon" src={leftArrow} data-action="move-prev"></Image>
</Button>
<Button variant="default" size="sm" className="move-day" data-action="move-next">
<Image className="calendar-icon" src={rightArrow} data-action="move-next"></Image>
</Button>
</span>
<span id="renderRange" className="render-range" style={{ height: "5em" }}>{period}</span>
<span id="renderRange" className="render-range ml-2" style={{ height: "5em" }}>{period}</span>
</div>
<Calendar
ref={calendarRef}
......
......@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
import axios from 'axios';
import { Link, Redirect } from 'react-router-dom';
import 'bootstrap/dist/css/bootstrap.css';
function ACheck(props) {
const [state, setState] = useState()
......
......@@ -2,9 +2,9 @@ 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';
import { Col, Container, Row } from 'react-bootstrap';
function Apply(props) {
const [state, setState] = useState();
......@@ -23,25 +23,24 @@ function Apply(props) {
function time(starttime) {
if (starttime == 21) {
return (<Field as="select" name="usetime">
<option value="">이용시간 선택하세요</option>
return (<Field as="select" name="usetime" className="col-12">
<option value="">이용시간선택</option>
<option value="1">1시간</option>
</Field>)
}
if (starttime == 20) {
return (<Field as="select" name="usetime">
<option value="">이용시간 선택하세요</option>
return (<Field as="select" name="usetime" className="col-12">
<option value="">이용시간선택</option>
<option value="1">1시간</option>
<option value="2">2시간</option>
</Field>)
}
return (<Field as="select" name="usetime">
<option value="">이용시간 선택하세요</option>
return (<Field as="select" name="usetime" className="col-12">
<option value="">이용시간선택</option>
<option value="1">1시간</option>
<option value="2">2시간</option>
<option value="3">3시간</option>
</Field>)
}
function getUser() {
......@@ -63,141 +62,140 @@ function Apply(props) {
return (
<div>
<Menu />
<Formik
initialValues={{
_id: `${props.match.params.id}`,
date: '',
starttime: '',
usetime: '',
room: '',
reason: '',
students: [
{
member: '',
},
],
}}
validationSchema={Yup.object({
date: Yup.string()
.required('날짜를 입력해주세요.'),
room: Yup.string()
.required('강의실 번호를 입력해주세요.'),
reason: Yup.string()
.required('대관목적을 입력해주세요.'),
})}
onSubmit={(values, { setSubmitting }) => {
console.log(values)
axios({
method: 'post',
url: '/reserves',
data: values
}).then(res => {
if (res.status === 404) {
alert(res.data.error)
return window.location.reload();
}
alert("신청이 완료되었습니다!");
setState(true);
console.log("res.data", res.data)
})
.catch(err => {
alert(err.error)
});
<Container fluid className="mt-3">
<Row className="justify-content-center">
<Col md={5}>
<Formik
initialValues={{
_id: `${props.match.params.id}`,
date: '',
starttime: '',
usetime: '',
room: '',
reason: '',
students: [
{
member: '',
},
],
}}
validationSchema={Yup.object({
date: Yup.string()
.required('날짜를 입력해주세요.'),
reason: Yup.string()
.required('대관목적을 입력해주세요.'),
})}
onSubmit={(values, { setSubmitting }) => {
console.log(values)
axios({
method: 'post',
url: '/reserves',
data: values
}).then(res => {
if (res.status === 404) {
alert(res.data.error)
return window.location.reload();
}
alert("신청이 완료되었습니다!");
setState(true);
console.log("res.data", res.data)
})
.catch(err => {
alert(err.error)
});
setTimeout(() => {
setSubmitting(false);
}, 400); // finish the cycle in handler
}}
>
{({
errors,
touched,
values,
handleSubmit,
getFieldProps,
isSubmitting,
}) => (
<form onSubmit={handleSubmit} className="d-flex flex-column">
<h3 className="form-group font-weight-bold">
<label className="pr-2">대표자 :</label>{user.name}
</h3>
<div className="form-group mb-4">
<div className={touched.date && errors.date ? "text-danger" : ""}>신청날짜</div>
<input
className={(touched.date && errors.date ? 'form-control is-invalid' : "form-control")}
type="text"
name="date"
{...getFieldProps('date')}
placeholder="yyyy-mm-dd"
/>
</div>
setTimeout(() => {
setSubmitting(false);
}, 400); // finish the cycle in handler
}}
>
{({
errors,
touched,
values,
handleSubmit,
getFieldProps,
isSubmitting,
}) => (
<div className="row justify-content-center align-items-center">
<form onSubmit={handleSubmit} className="col-sm-3">
<div className="form-group mb-4">
<label>대표자</label>
<div>{user.name}</div>
</div>
<div className="form-group mb-4">
<label>신청날짜</label>
<input
className={(touched.date && errors.date ? 'form-control is-invalid' : "form-control")}
type="text"
name="date"
{...getFieldProps('date')}
placeholder="yyyy-mm-dd"
/>
{touched.date && errors.date ? (
<div className="invalid-feedback text-left">{errors.date}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>이용시작시간</label>
<Field as="select" name="starttime">
<option value="">이용시작시간</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</Field>
</div>
<div className="form-group mb-4">
<label>이용시간</label>
{time(values.starttime)}
</div>
<div className="form-group mb-4">
<label>강의실</label>
<input
className={(touched.room && errors.room ? 'form-control is-invalid' : "form-control")}
type="text"
name="room"
{...getFieldProps('room')}
placeholder="bn-nnn"
/>
{touched.room && errors.room ? (
<div className="invalid-feedback text-left">{errors.room}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>대관목적</label>
<input
className={(touched.reason && errors.reason ? 'form-control is-invalid' : "form-control")}
type="text"
name="reason"
{...getFieldProps('reason')}
placeholder="대관목적을 입력해 주세요."
/>
{touched.reason && errors.reason ? (
<div className="invalid-feedback text-left">{errors.reason}</div>
) : null}
</div>
<div className="form-group mb-4">
<FieldArray name="students">
{({ insert, remove, push }) => (
<div>
<label>이용자</label>
{
values.students.map((student, index) => (
<div className="row" key={index}>
<div className="col">
<Row className="form-group mb-4">
<div className="col-6 pr-0">
<label>이용시작시간</label>
<div>
<Field as="select" name="starttime" className="col-12">
<option value="">이용시작시간</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</Field>
</div>
</div>
<div className="col-6 pl-0">
<label>이용시간</label>
<div>
{time(values.starttime)}
</div>
</div>
</Row>
<div className="form-group mb-4">
<div className={touched.room && errors.room ? "text-danger" : ""}>강의실</div>
<Field as="select" name="room" className="col-6">
<option value="">강의실 선택</option>
<option value="9-116">9-116</option>
<option value="7-234">7-234</option>
<option value="25-101">25-101</option>
</Field>
</div>
<div className="form-group mb-4">
<div className={touched.reason && errors.reason ? "text-danger" : ""}>대관 목적</div>
<input
className={(touched.reason && errors.reason ? 'form-control is-invalid' : "form-control")}
type="text"
name="reason"
{...getFieldProps('reason')}
placeholder="대관목적을 입력해 주세요."
/>
</div>
<div className="form-group mb-4">
<FieldArray name="students">
{({ insert, remove, push }) => (
<div>
<div className={touched.date && errors.date ? "text-danger" : ""}>이용자</div>
{values.students.map((student, index) => (
<div key={index}>
<Field
name={`students.${index}.member`}
placeholder="이용자 성함을 입력하세요."
placeholder="이용자 이름 입력"
type="text"
className="col-6 mr-1"
/>
<ErrorMessage
name={`friends.${index}.name`}
......@@ -208,32 +206,29 @@ function Apply(props) {
type="button"
className="secondary"
onClick={() => remove(index)}
>
X
</button>
>X</button>
</div>
</div>
))}
<button
type="button"
className="btn btn-primary"
onClick={() => push({ member: '' })}
>
추가
</button>
</div>
)}
</FieldArray>
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>
신청하기
</button>
</form>
</div>
)}
</Formik>
))}
<button
type="button"
className="btn btn-primary"
onClick={() => push({ member: '' })}
>추가</button>
</div>
)}
</FieldArray>
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>
신청하기
</button>
</form>
)}
</Formik>
</Col>
</Row>
</Container>
</div>
)
}
export default Apply
export default Apply
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
import Schedule from '../Components/Schedule';
import Tabs from 'react-bootstrap/Tabs';
import Tab from 'react-bootstrap/Tab';
import { Container, Tabs, Tab } from 'react-bootstrap';
function Home() {
const [key, setKey] = useState('9-116');
......@@ -10,7 +9,7 @@ function Home() {
return (
<div>
<Menu />
<div className="container mt-3">
<Container className="col-md-10 mt-3">
<h2>대관 현황</h2>
<p>
<strong>대관 가능 시간</strong>
......@@ -41,7 +40,7 @@ function Home() {
<div className="bg-white">
<h6>고려대학교 대관시스템</h6>
</div>
</div>
</Container>
</div>
)
}
......
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-left-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M3.86 8.753l5.482 4.796c.646.566 1.658.106 1.658-.753V3.204a1 1 0 0 0-1.659-.753l-5.48 4.796a1 1 0 0 0 0 1.506z"/>
</svg>
\ No newline at end of file
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-right-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"/>
</svg>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment