Commit 9063cd71 authored by CHAERIN KIM's avatar CHAERIN KIM
Browse files

room drop down, 수빈병합, 예약중복 체크수정, 예진 글쓰기textarea+엔터

parent dbfe342d
......@@ -3,53 +3,20 @@ import Calendar from '@toast-ui/react-calendar';
import "tui-calendar/dist/tui-calendar.css";
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';
function Cal(props) {
const calendarRef = useRef();
const calendarRef = useRef(null);
const [reserve, setReserve] = useState([]);
// const [day, setDay] = useState(props.calledday);
const [day, setDay] = useState(props.day);
const [period, setPeriod] = useState();
const [myTheme, setMyTheme] = useState({
'common.dayname.color': '#333',
'common.today.color': '#333',
// 'common.creationGuide.color': 'white',
'common.creationGuide.backgroundColor': 'gray',
// Theme object to extends default dark theme.
});
const yj = [
{
id: 'a',
calendarId: 'Subject',
category: 'time',
start: '2020-10-27T11:00:00',
end: '2020-10-27T12:00:00',
},
{
id: 'b',
calendarId: 'Subject',
category: 'time',
start: '2020-10-28T10:00:00',
end: '2020-10-28T11:00:00',
},
{
id: '3',
calendarId: 'Subject',
category: 'time',
start: '2020-10-29T11:00:00',
end: '2020-10-29T15:00:00',
}
]
function getReserve(room) {
console.log("room", room)
// setReserve({
// id: room,
// calendarId: 'Subject',
// category: 'time',
// })
axios.get(`/reserves/room/${room}`, {
headers: { authorization: localStorage.getItem('token') },
})
......@@ -61,56 +28,68 @@ function Cal(props) {
calendarId: 'Subject',
category: 'time',
}))
console.log("room list", res.data);
setReserve(reserves);
// console.log("room list",res.data);
})
.catch(err => {
alert(err.error)
});
}
useEffect(() => {
// const cal = calendarRef.current.getInstance();
// cal.setDate(new Date(day));
// cal.changeView('week', false);
// cal.today(new Date(day));
function getDataAction(target) {
return target.dataset ? target.dataset.action : target.getAttribute('data-action');
}
// calendar.on('clickSchedule', function (event) {
// const schedule = event.schedule;
function onClickNavi(e) {
const cal = calendarRef.current.getInstance();
const action = getDataAction(e.target);
// if (lastClickSchedule) {
// calendar.updateSchedule(lastClickSchedule.id, lastClickSchedule.calendarId, {
// isFocused: false,
// });
// }
// calendar.updateSchedule(schedule.id, schedule.calendarId, {
// isFocused: true,
// });
switch (action) {
case 'move-prev':
cal.prev();
break;
case 'move-next':
cal.next();
break;
case 'move-today':
cal.today();
break;
default:
return;
}
// lastClickSchedule = schedule;
// // open detail view
setRenderRangeText();
}
// return (console.log(isFocused))
// });
function setRenderRangeText() {
const cal = calendarRef.current.getInstance();
let html = [];
html.push(moment(cal.getDateRangeStart().getTime()).format('YYYY.MM.DD'));
html.push(' ~ ');
html.push(moment(cal.getDateRangeEnd().getTime()).format(' MM.DD'));
setPeriod(html.join(''))
}
// setReserve([
// {
// id: '3',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-29T11:00:00',
// end: '2020-10-29T15:00:00',
// }
// ])
useEffect(() => {
setRenderRangeText();
getReserve(props.room);
}, [day])
}, [props.room])
return (
<div>{
console.log("reserve", reserve)}
<div>
<div id="menu">
<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>
</span>
<span id="renderRange" className="render-range" style={{ height: "5em" }}>{period}</span>
</div>
<Calendar
ref={calendarRef}
height="100%"
calendars={[
{
......@@ -120,46 +99,11 @@ function Cal(props) {
isReadOnly: 'true'
}
]}
view="week"
disableDblClick={false}
disableClick={true}
isReadOnly={false}
// template={
// popupIsAllDay=function {
// return display: "none"
// }
// }
schedules={ reserve
// reserve.map(item=>({id: item._id,
// start: item.start,
// end: item.end,
// calendarId: 'Subject',
// category: 'time',}))
// [
// {
// id: 'a',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-27T11:00:00',
// end: '2020-10-27T12:00:00',
// },
// {
// id: 'b',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-28T10:00:00',
// end: '2020-10-28T11:00:00',
// },
// {
// id: '3',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-29T11:00:00',
// end: '2020-10-29T15:00:00',
// }
// ]
}
isReadOnly={true}
schedules={reserve}
scheduleView={['time']}
taskView={false}
theme={myTheme}
......
......@@ -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();
......@@ -41,7 +41,6 @@ function Apply(props) {
<option value="2">2시간</option>
<option value="3">3시간</option>
</Field>)
}
function getUser() {
......@@ -63,137 +62,134 @@ 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>
<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">
<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>
<div className="form-group mb-4">
<label>이용시작시간</label>
<div>
<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>
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 className="form-group mb-4">
<label>이용시간</label>
<div>
<label>이용자</label>
{
values.students.map((student, index) => (
<div className="row" key={index}>
<div className="col">
{time(values.starttime)}
</div>
</div>
<div className="form-group mb-4">
<div className={touched.room && errors.room ? "text-danger" : ""}>강의실</div>
<Field as="select" name="room">
<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) => (
<Row key={index}>
<Field
name={`students.${index}.member`}
placeholder="이용자 성함을 입력하세요."
......@@ -208,32 +204,29 @@ function Apply(props) {
type="button"
className="secondary"
onClick={() => remove(index)}
>
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>
>X</button>
</Row>
))}
<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
......@@ -4,7 +4,7 @@ import * as Yup from 'yup';
import axios from 'axios';
import Menu from '../Components/Menu';
import { Link, Redirect } from 'react-router-dom';
import { Container, Button, Col } from 'react-bootstrap';
import { Container, Button, Navbar, Col } from 'react-bootstrap';
import styled from 'styled-components';
const Check = styled.div`
......@@ -30,7 +30,13 @@ function Change(props) {
// console.log(props)
return (
<div className="">
<Menu />
{(localStorage.getItem("token") !== null) ? (
<Menu />
) : (
<Menu expand="md" variant="dark">
<Navbar.Brand>회원가입</Navbar.Brand>
</Menu>
)}
<Container fluid className="p-0 vh-90">
<Check className="row justify-content-center m-0">
<Col md={4} className="pt-5">
......
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
import Schedule from '../Components/Schedule';
import styled from 'styled-components';
import moment from 'moment';
import "moment/locale/ko";
moment.locale("ko", {
week: {
dow: 1
}
});
const Drop = styled.div`
& button {
border solid 1px;
}
`
const Tab = styled.ul`
& a, a:hover, a:active {
color: black;
}
`
import Tabs from 'react-bootstrap/Tabs';
import Tab from 'react-bootstrap/Tab';
function Home() {
const [show, setShow] = useState(false);
const [weeks, setWeeks] = useState([]);
const [days, setDays] = useState([]);
const [sendDate, setSendDate] = useState(null);
useEffect(() => {
Dateform();
}, []);
function Dateform() {
let today = moment();
let weeks = [];
let dates = [];
let sendDates = [];
for (let i = 0; i < 6; i++) {
if (i !== 0) {
today.add(7, 'd');
}
let date = { start: null, end: null };
date.start = today.startOf('week').format("MMM Do");
date.end = today.endOf('week').weekday(4).format("MMM Do");
dates.push(date);
const week = date.start + " ~ " + date.end;
weeks.push(week);
let sendDate = today.startOf('week').format("YYYY-MM-DD");
sendDates.push(sendDate);
};
setWeeks([...weeks])
setDays([...sendDates])
};
function choose(e, index) {
setShow(true)
setSendDate(days[index])
}
const [key, setKey] = useState('9-116');
return (
<div>
......@@ -75,38 +19,17 @@ function Home() {
<li>주말: 이용 불가</li>
</ul>
</p>
<Drop className="row dropdown mt-1 mb-2">
<button className="btn btn-lg dropdown-toggle mx-auto col-5" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
기간을 선택해주십시오.
</button>
<div className="dropdown-menu col-5" aria-labelledby="dropdownMenuButton">
{weeks.map((week, index) => (
<a className="dropdown-item" id={index} onClick={(e) => choose(e, index)}>{week}</a>
))}
</div>
</Drop>
<Tab className="nav nav-tabs nav-justified mt-4" id="myTab" role="tablist" style={show ? {} : { display: "none" }}>
<li className="nav-item">
<a className="nav-link active" id="7-tab" data-toggle="tab" href="#tab-7" role="tab" aria-controls="7" aria-selected="true"> 7-223 </a>
</li>
<li className="nav-item">
<a className="nav-link" id="9-tab" data-toggle="tab" href="#tab-9" role="tab" aria-controls="9" aria-selected="false"> 9-116 </a>
</li>
<li className="nav-item">
<a className="nav-link" id="25-tab" data-toggle="tab" href="#tab-25" role="tab" aria-controls="25" aria-selected="false"> 25-307 </a>
</li>
</Tab>
<div className="tab-content row justify-content-center" id="myTabContent" style={show ? {} : { display: "none" }}>
<div className="tab-pane fade show active col-md-11 col-12" id="tab-7" role="tabpanel" aria-labelledby="7-tab">
<Schedule day={sendDate}/>
</div>
<div className="tab-pane fade col-md-11 col-12" id="tab-9" role="tabpanel" aria-labelledby="9-tab">
<Schedule day={sendDate}/>
</div>
<div className="tab-pane fade col-md-11 col-12" id="tab-25" role="tabpanel" aria-labelledby="25-tab">
<Schedule day={sendDate}/>
</div>
</div>
<Tabs defaultActiveKey="9-116" id="uncontrolled-tab-example" onSelect={(k) => setKey(k)}>
<Tab eventKey="9-116" title="9-116">
<Schedule room={key}/>
</Tab>
<Tab eventKey="7-234" title="7-234">
<Schedule room={key}/>
</Tab>
<Tab eventKey="25-101" title="25-101">
<Schedule room={key}/>
</Tab>
</Tabs>
<h3>유의사항</h3>
<p>
<ul>
......
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
import axios from 'axios';
import { Link } from 'react-router-dom';
import { Container, Row, Col, Card, Navbar, Accordion, Button } from 'react-bootstrap';
import { Container, Row, Col, Card, Accordion, Button } from 'react-bootstrap';
function Notice() {
const [show, setShow] = useState(false);
const [notices, setNotices] = useState([]);
const [user, setUser] = useState({ role: "" })
useEffect(() => {
acheck();
getNotice();
}, []);
function acheck() {
axios.get(`/users/${localStorage.getItem('_id')}`)
.then(res => {
if (res.data.role == "admin") {
setUser(res.data)
}
}).catch(err => {
alert(err.error)
});
}
function dateForm(day) {
const post_day = new Date(day);
let year = post_day.getFullYear();
......@@ -36,27 +50,27 @@ function Notice() {
alert(err.error)
});
}
return (
<div>
{(localStorage.getItem("token") !== null) ? (
<Menu />
) : (
<Menu expand="md" variant="dark">
<Navbar.Brand>회원가입</Navbar.Brand>
</Menu>
)}
<Menu />
<Container fluid>
<Row className="justify-content-center vw-100 vh-90">
<Col md={7}>
<h2 className="p-3 border-bottom">공지사항 <Link to="/write"> 작성</Link></h2>
<div className="px-3 pt-3 mb-3 border-bottom d-flex justify-content-between align-items-end">
<h2>공지사항</h2>
{user.role === "admin" ? (
<Link to="/write"> 작성</Link>) : null}
</div>
<Accordion>
{notices.map((notice, index) =>
<Card>
<Card.Header>
<Accordion.Toggle as={Button} variant="link" eventKey={index + 1}>{notice.notice_title} <span className="text-right">{dateForm(notice.post_date)}</span></Accordion.Toggle>
<Card.Header className="d-flex justify-content-between">
<Accordion.Toggle as={Button} variant="link" eventKey={index + 1} className={"d-inline-block " + (show ? "text-wrap" : "text-truncate")} onClick={() => setShow(!show)}>{notice.notice_title}</Accordion.Toggle>
<span className="d-flex align-items-center" style={{ width: "50%" }}>{dateForm(notice.post_date)}</span>
</Card.Header>
<Accordion.Collapse eventKey={index + 1}>
<Card.Body>{notice.notice_content}</Card.Body>
<Card.Body><pre>{notice.notice_content}</pre></Card.Body>
</Accordion.Collapse>
</Card>)}
</Accordion>
......
......@@ -67,11 +67,8 @@ function Write() {
<div className="form-group ">
{/* mb-4 */}
<div className={touched.name && errors.name ? "text-danger" : ""}>내용</div>
<input className={(touched.name && errors.name ? 'form-control is-invalid' : "form-control")}
type="text"
content="content"
{...getFieldProps('content')}
placeholder="내용" />
<Field as="textarea" rows={8} cols={175}
{...getFieldProps('content')} />
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>공지 등록</button>
</form>
......
......@@ -38,8 +38,8 @@ router.post('/', function (req, res, next) {
const strt = new Date(reserve.start)
const endt = new Date(reserve.end)
const reserveArr = reserves.map(item => (
(strt >= new Date(item.start) && strt <= new Date(item.end)) ||
(endt >= new Date(item.start) && endt <= new Date(item.end)) ?
(strt >= new Date(item.start) && strt < new Date(item.end)) ||
(endt > new Date(item.start) && endt <= new Date(item.end)) ?
"item" :
null
))
......
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