Commit 813db703 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

채린 머지

parents 6aa8c061 d0f6f520
...@@ -8,6 +8,7 @@ const indexRouter = require('./routes/index'); ...@@ -8,6 +8,7 @@ const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users'); const usersRouter = require('./routes/users');
const loginRouter = require('./routes/login'); const loginRouter = require('./routes/login');
const reserveRouter = require('./routes/reserves'); const reserveRouter = require('./routes/reserves');
const noticeRouter = require('./routes/notices');
const connect = require('./schemas'); const connect = require('./schemas');
const app = express(); const app = express();
...@@ -33,6 +34,7 @@ app.use('/', indexRouter); ...@@ -33,6 +34,7 @@ app.use('/', indexRouter);
app.use('/users', usersRouter); app.use('/users', usersRouter);
app.use('/login', loginRouter); app.use('/login', loginRouter);
app.use('/reserves', reserveRouter); app.use('/reserves', reserveRouter);
app.use('/notices', noticeRouter);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {
......
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
import React, { useState, useEffect } from 'react';
import { Field, Formik } from 'formik';
import axios from 'axios';
import { render } from 'react-dom';
import { Link, Redirect } from 'react-router-dom';
import styled from 'styled-components';
function List(props) {
function remove() {
console.log(props._id)
axios.delete(`/reserves/${props._id}`, { data: { _id: props._id, }})
.then(res => {
if (res.status === 404) return alert(res.data.error)
alert("신청이 완료되었습니다!")
})
.catch(err => {
alert(err.error)
});
};
return (
<div>
<div>날짜 : {props.date}</div>
<div>이름 : {props.name}</div>
<div>강의실 : {props.room}</div>
<div>시간 : {props.time}</div>
<div>사용인원 : {props.num}</div>
<div>{props._id}</div>
<form onSubmit={remove} className="col-sm-3">
<button type="submit" className="btn btn-dark">
신청 취소
</button>
</form>
</div>
)
}
export default List;
\ No newline at end of file
...@@ -3,7 +3,12 @@ import { Link, Redirect } from 'react-router-dom'; ...@@ -3,7 +3,12 @@ import { Link, Redirect } from 'react-router-dom';
import styled from 'styled-components'; import styled from 'styled-components';
const Nav = styled.nav` const Nav = styled.nav`
background-color: #981e1e; background-color: #7B031D;
height: 6vh;
a {
color: #ffffff;
}
` `
function Menu() { function Menu() {
...@@ -20,17 +25,24 @@ function Menu() { ...@@ -20,17 +25,24 @@ function Menu() {
return ( return (
<Nav className="navbar sticky-top navbar-expand-md"> <Nav className="navbar sticky-top navbar-expand-md">
<Link to="/home" className="navbar-brand">대관 서비스</Link> <a class="navbar-brand" href="#">대관 서비스</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar"> <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar">
<span className="navbar-toggler-icon"></span> <span className="navbar-toggler-icon"></span>
</button> </button>
<div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar"> <div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
<ul className="navbar-nav"> <ul className="navbar-nav">
<li className="nav-item"> <li className="nav-item">
<Link to="/notice" className="nav-link">공지사항</Link>
</li>
<li className="nav-item">
{console.log(name)}
<Link to="/home" className="nav-link">대관 현황</Link> <Link to="/home" className="nav-link">대관 현황</Link>
</li> </li>
<li className="nav-item"> <li className="nav-item">
<Link to="/apply" className="nav-link">대관 신청</Link> <Link to={{
pathname: `/apply/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">대관 신청</Link>
</li> </li>
<li className="nav-item"> <li className="nav-item">
<Link to={{ <Link to={{
...@@ -39,14 +51,10 @@ function Menu() { ...@@ -39,14 +51,10 @@ function Menu() {
}} className="nav-link"> }} className="nav-link">
대관 확인/취소</Link> 대관 확인/취소</Link>
</li> </li>
<li className="nav-item">
<Link to="/notice" className="nav-link">공지사항</Link>
</li>
</ul> </ul>
<div> <div>
<div>{name} 안녕하세요.</div> <div>{name} 안녕하세요.</div>
<button onClick={logout} type="button">로그아웃</button> <button onClick={logout} type="button">로그아웃</button>
<button><Link to="/signup">회원가입</Link></button>
</div> </div>
</div> </div>
</Nav> </Nav>
......
import React from 'react'; import React, { useState, useEffect } from 'react';
import { Formik } from 'formik'; import { Formik, Field, ErrorMessage, FieldArray } from 'formik';
import Menu from '../Components/Menu'; import Menu from '../Components/Menu';
import axios from 'axios'; import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
import * as Yup from 'yup'; 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 <Redirect to={{
pathname: `/check/${props.match.params.id}`,
state: { id: props.match.params.id },
}} />;
}
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)
});
}
function Apply() {
return ( return (
<div> <div>
<Menu /> <Menu />
<div className="container">apply
<Formik <Formik
initialValues={{ initialValues={{
date: '', _id: `${props.match.params.id}`,
time: '', date: '',
room: '', time: '',
name: '', room: '',
_id: "5f786720c45bbf6c68899c51", reason: '',
reason: '', students: [
member: '', {
approve: false, member: '',
num: 5, },
}} ],
validationSchema={Yup.object({ }}
date: Yup.string() validationSchema={Yup.object({
.required('날짜를 입력해주세요.'), date: Yup.string()
time: Yup.string() .required('날짜를 입력해주세요.'),
.required('시간을 입력해주세요.'), time: Yup.string()
room: Yup.string() .required('시간을 입력해주세요.'),
.required('강의실 번호를 입력해주세요.'), room: Yup.string()
reason: Yup.string() .required('강의실 번호를 입력해주세요.'),
.required('대관목적을 입력해주세요.'), reason: Yup.string()
name: Yup.string() .required('대관목적을 입력해주세요.'),
.required('대표자 성함을 입력해주세요.'), })}
member: Yup.string() onSubmit={(values, { setSubmitting }) => {
.required('이용자 성함을 입력해주세요.'), console.log(values)
})} axios({
onSubmit={(values, { setSubmitting }) => { method: 'post',
axios({ url: '/reserves',
method: 'post', data: values
url: '/reserves', }).then(res => {
data: values, if (res.status === 404) return alert(res.data.error)
}).then(res => { alert("신청이 완료되었습니다!");
if (res.status === 404) return alert(res.data.error) setState(true);
alert("신청이 완료되었습니다!") })
.catch(err => {
alert(err.error)
});
}) // setTimeout(() => {
.catch(err => { // setSubmitting(false);
alert(err.error) // }, 400); // finish the cycle in handler
}); }}
>
{({
errors,
touched,
values,
handleSubmit,
getFieldProps,
isSubmitting,
}) => (
<div className="row justify-content-center align-items-center">
{console.log(user)}
<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="number"
name="date"
{...getFieldProps('date')}
placeholder="2020mmdd"
/>
{touched.date && errors.date ? (
<div className="invalid-feedback text-left">{errors.date}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>이용시간</label>
<input
className={(touched.time && errors.time ? 'form-control is-invalid' : "form-control")}
type="text"
name="time"
{...getFieldProps('time')}
placeholder="ex) 11:00~14:00"
/>
{touched.time && errors.time ? (
<div className="invalid-feedback text-left">{errors.time}</div>
) : null}
</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">
<Field
name={`students.${index}.member`}
placeholder="이용자 성함을 입력하세요."
type="text"
/>
<ErrorMessage
name={`friends.${index}.name`}
component="div"
className="field-error"
/>
<button
type="button"
className="secondary"
onClick={() => remove(index)}
>
X
</button>
setTimeout(() => { </div>
setSubmitting(false); </div>
}, 400); // finish the cycle in handler ))}
}} <button
> type="button"
{({ className="btn btn-primary"
errors, onClick={() => push({ member: '' })}
touched, >
handleSubmit, 추가
getFieldProps, </button>
isSubmitting, </div>
}) => ( )}
<div className="row justify-content-center align-items-center"> </FieldArray>
<form onSubmit={handleSubmit} className="col-sm-3"> </div>
<div className="form-group mb-4"> <button type="submit" className="btn btn-dark" disabled={isSubmitting}>
<label>신청날짜</label> 신청하기
<input </button>
className={(touched.date && errors.date ? 'form-control is-invalid' : "form-control")} </form>
type="number" </div>
name="date" )}
{...getFieldProps('date')} </Formik>
placeholder="2020mmdd"
/>
{touched.date && errors.date ? (
<div className="invalid-feedback text-left">{errors.date}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>이용시간</label>
<input
className={(touched.time && errors.time ? 'form-control is-invalid' : "form-control")}
type="text"
name="time"
{...getFieldProps('time')}
placeholder="ex) 11:00~14:00"
/>
{touched.time && errors.time ? (
<div className="invalid-feedback text-left">{errors.time}</div>
) : null}
</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">
<label>대표자</label>
<input
className={(touched.name && errors.name ? 'form-control is-invalid' : "form-control")}
type="text"
name="name"
{...getFieldProps('name')}
placeholder="대표자 성함을 입력해 주세요"
/>
{touched.name && errors.name ? (
<div className="invalid-feedback text-left">{errors.name}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>이용자</label>
<input
className={(touched.member && errors.member ? 'form-control is-invalid' : "form-control")}
type="text"
name="member"
{...getFieldProps('member')}
placeholder="이용자 성함을 입력해 주세요. "
/>
{touched.member && errors.member ? (
<div className="invalid-feedback text-left">{errors.member}</div>
) : null}
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>
신청하기
</button>
</form>
</div>
)}
</Formik>
</div>
</div> </div>
) )
} }
......
...@@ -4,6 +4,10 @@ import axios from 'axios'; ...@@ -4,6 +4,10 @@ import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
function Check(props) { function Check(props) {
const [reserve, setReserve] = useState([]);
useEffect(() => {
getReserve();
}, [])
function getReserve() { function getReserve() {
axios.get(`/reserves/${props.match.params.id}`, { axios.get(`/reserves/${props.match.params.id}`, {
...@@ -24,7 +28,7 @@ function Check(props) { ...@@ -24,7 +28,7 @@ function Check(props) {
axios.delete(`/reserves/${reserve[index]._id}`) axios.delete(`/reserves/${reserve[index]._id}`)
.then(res => { .then(res => {
if (res.status === 404) return alert(res.data.error) if (res.status === 404) return alert(res.data.error)
alert("삭제되었습니다!") alert("삭제되었습니다!");
getReserve(); getReserve();
}) })
.catch(err => { .catch(err => {
...@@ -32,22 +36,18 @@ function Check(props) { ...@@ -32,22 +36,18 @@ function Check(props) {
}); });
}; };
const [reserve, setReserve] = useState([]);
useEffect(() => {
getReserve();
}, [])
return ( return (
<div> <div>
<Menu /> <Menu />
<div className="">check <div className="">
<table className="table"> <table className="table">
<thead> <thead>
<tr> <tr>
<th>아이디</th>
<th>이름</th>
<th>날짜</th> <th>날짜</th>
<th>시간</th>
<th>강의실</th> <th>강의실</th>
<th>사용인원</th>
<th>승인여부</th>
<th>예약취소</th> <th>예약취소</th>
</tr> </tr>
</thead> </thead>
...@@ -55,10 +55,11 @@ function Check(props) { ...@@ -55,10 +55,11 @@ function Check(props) {
{reserve.map((reserve, index) => { {reserve.map((reserve, index) => {
return ( return (
<tr key={index}> <tr key={index}>
<td>{props.match.params.id}</td>
<td>{reserve.name}</td>
<td>{reserve.date}</td> <td>{reserve.date}</td>
<td>{reserve.time}</td>
<td>{reserve.room}</td> <td>{reserve.room}</td>
<td>{reserve.num}</td>
<td>{reserve.approve?"사용허가":"글쎄..."}</td>
<td> <td>
<button onClick={() => remove(index)} className="btn btn-danger"> <button onClick={() => remove(index)} className="btn btn-danger">
취소 취소
......
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { Link, Redirect } from 'react-router-dom'; import { Link, Redirect } from 'react-router-dom';
import { Formik } from 'formik'; import { Formik } from 'formik';
import * as Yup from 'yup'; import * as Yup from 'yup';
import axios from 'axios'; import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
import Logo from '../icon.png';
const Log = styled.div` const Asd = styled.div`
background-color: #7B031D; background-color: #7B031D;
&.web {
display : flex;
align-items: center;
}
&.mobile {
height : 20vh;
display : flex;
padding:0;
}
& .mob-head {
display: flex;
flex-direction: row;
height : 100%;
width: 100%;
justify-content: space-evenly;
}
& .mob-img {
max-width: 30vw;
}
` `
const Logo = styled.div`
const Asdf = styled.div`
background-color: rgb(239, 218, 200); background-color: rgb(239, 218, 200);
` a {
color : #7B031D;
}
&.mob-formik {
height : 80vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
&.web-formik {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
& .mobb {
height: 35vh;
display: flex;
flex-direction: column;
justify-content: space-around;
}
& .webb {
flex-direction: column;
}
& .qwer {
display: flex;
justify-content: space-between;
height: 12vh;
width: 30vw;
margin-bottom: 25px;
}
& .web-input-form {
width: 80%;
justify-content: space-between;
align-content: space-around;
flex-direction: column;
display: flex;
}
& .mob-input-form {
}
`
function Login() { function Login() {
const [state, setState]= useState(false); const [state, setState] = useState(false);
const [mobile, setMobile] = useState(false);
useEffect(() => {
if (window.innerWidth < 960) {
setMobile(true)
} else {
setMobile(false)
}
}, []);
if (state) { if (state) {
return <Redirect to="/home" />; return <Redirect to="/home" />;
} }
return ( return (
<div className="container-fluid"> <div className="row vw-100 vh-100 m-0">
<div className="row"> <Asd className={"col-md-4 col-12" + (mobile ? " mobile" : " web")}>
<Logo className="col-md-5 col-12"> <div className={mobile ? "mob-head" : ""}>
<h2>고려대학교</h2> <img className={mobile ? "mob-img" : "img-fluid"} src={Logo} />
<h4>대관 시스템</h4> <div className={"d-flex " + (mobile ? "align-items-center" : "justify-content-center")}>
</Logo> <h1 className="font-weight-bold text-white">고려대학교<br />대관 서비스</h1>
<Log className="col-md-7 col-12"> </div>
<Formik </div>
initialValues={{ id: '', password: '' }} </Asd>
validationSchema={Yup.object({ <Asdf className={"col-md-8 col-12" + (mobile ? " mob-formik p-0" : " web-formik")}>
id: Yup.string() <Formik
.required('학번을 입력해주세요.'), initialValues={{ id: '', password: '' }}
password: Yup.string() validationSchema={Yup.object({
.required('비밀번호를 입력해주세요.') id: Yup.string()
.min(8, '8자 이상 입력해주세요.'), .required('학번을 입력해주세요.'),
})} password: Yup.string()
onSubmit={(values, { setSubmitting }) => { .required('비밀번호를 입력해주세요.')
axios({ .min(8, '8자 이상 입력해주세요.'),
method: 'post', })}
url: '/login', onSubmit={(values, { setSubmitting }) => {
data: values, axios({
}).then(res => { method: 'post',
if (res.status === 404) return alert(res.data.error) url: '/login',
localStorage.setItem('token', res.data.token); data: values,
localStorage.setItem('_id', res.data.users._id); }).then(res => {
localStorage.setItem('name', res.data.users.name); if (res.status === 404) return alert(res.data.error)
setState(true);
}) localStorage.setItem('token', res.data.token);
.catch(err => { localStorage.setItem('_id', res.data.users._id);
localStorage.setItem('name', res.data.users.name);
setState(true);
})
.catch(err => {
alert(err.error) alert(err.error)
}); });
setTimeout(() => { setTimeout(() => {
setSubmitting(false); setSubmitting(false);
}, 400); // finish the cycle in handler }, 400); // finish the cycle in handler
}} }}
> >
{({ {({
errors, errors,
touched, touched,
handleSubmit, handleSubmit,
getFieldProps, // contain values, handleChange, handleBlur getFieldProps, // contain values, handleChange, handleBlur
isSubmitting, isSubmitting,
}) => ( }) => (
<div className="row justify-content-center align-items-center"> <form onSubmit={handleSubmit} className={mobile ? "w-75 h-50vh" : "d-flex webb"}>
<form onSubmit={handleSubmit} className="col-sm-3"> <div className={mobile ? "mobb" : "qwer"}>
<div className="form-group mb-4"> <div className={(mobile ? "mob-" : "web-") + "input-form"}>
<div className={"form-group m-0" + (mobile ? " mb-2" : "")}>
<input <input
className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")} className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")}
type="number" type="number"
...@@ -75,11 +163,8 @@ function Login() { ...@@ -75,11 +163,8 @@ function Login() {
{...getFieldProps('id')} {...getFieldProps('id')}
placeholder="Input Student Id" placeholder="Input Student Id"
/> />
{touched.id && errors.id ? (
<div className="invalid-feedback text-left">{errors.id}</div>
) : null}
</div> </div>
<div className="form-group mb-4"> <div className="form-group m-0">
<input <input
className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")} className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")}
type="password" type="password"
...@@ -87,26 +172,20 @@ function Login() { ...@@ -87,26 +172,20 @@ function Login() {
{...getFieldProps('password')} {...getFieldProps('password')}
placeholder="Input Password" placeholder="Input Password"
/> />
{touched.password && errors.password ? (
<div className="invalid-feedback text-left">{errors.password}</div>
) : null}
</div> </div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}> </div>
Login <button type="submit" className={"btn btn-dark" + (mobile ? " w-100" : " w-20")} disabled={isSubmitting}> Login </button>
</button>
<button><Link to="/home"></Link></button>
<div></div>
<Link to="/find">비밀번호를 잊으셨나요?</Link>
<div></div>
<Link to="/signup">회원이 아니신가요?</Link>
</form>
</div> </div>
)}
</Formik>
</Log> <div><Link to="/find">비밀번호를 잊으셨나요?</Link></div>
</div> <div><Link to="/signup">회원이 아니신가요?</Link></div>
</div>
</form>
)}
</Formik>
</Asdf>
</div >
) )
} }
......
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu'; import Menu from '../Components/Menu';
import axios from 'axios';
function Notice() { function Notice() {
const [notices, setNotices] = useState([]);
useEffect(() => {
getNotice();
}, []);
function getNotice() {
axios.get(`/notices`)
.then(res => {
if (res.status !== 201) {
alert(res.data.error);
}
console.log(res.data);
setNotices(res.data);
})
.catch(err => {
alert(err.error)
});
}
return ( return (
<div> <div>
<Menu /> <Menu />
<div className="container">notice <div className="container">
<div className="row">
<div className="col-12">
{notices.map((notice) => <div>{notice.notice_title}</div>)}
</div>
</div>
</div> </div>
</div> </div>
) )
......
...@@ -4,139 +4,183 @@ import * as Yup from 'yup'; ...@@ -4,139 +4,183 @@ import * as Yup from 'yup';
import axios from 'axios'; import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
import { Link, Redirect } from 'react-router-dom'; 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() { function Signup() {
const [state, setState] = useState(false); const [state, setState] = useState(false);
const [checkPw, setCheckPw] = useState(true);
if (state) { if (state) {
return <Redirect to="/login" />; return <Redirect to="/login" />;
} }
return ( return (
<div className="d-flex flex-column justify-content-between vh-100"> <div className="vh-100">
<Formik <Nav className="navbar sticky-top navbar-expand-md">
initialValues={{ name: '', id: '', password: '', password2: '', question: '', answer: '' }} <a class="navbar-brand" href="#">회원가입</a>
validationSchema={Yup.object({ </Nav>
name: Yup.string() <div className="container-fluid">
.required('이름을 입력해주세요.'), <Wow className="row justify-content-center rrooww">
id: Yup.string() <div className="col-md-4 col-12 d-flex align-items-center h-100">
.required('학번을 입력해주세요.'), <Formik
password: Yup.string() initialValues={{ name: '', id: '', password: '', password2: '', question: '', answer: '' }}
.required('비밀번호를 입력해주세요.') validationSchema={Yup.object({
.min(8, '8자 이상 입력해주세요.'), name: Yup.string()
password2: Yup.string() .required('이름을 입력해주세요.'),
.required('비밀번호를 다시 입력해주세요.') id: Yup.string()
.min(8, '8자 이상 입력해주세요.') .required('학번을 입력해주세요.'),
.oneOf([Yup.ref("password"), null], '비밀번호가 일치하지 않습니다.'), password: Yup.string()
answer: Yup.string() .required('비밀번호를 입력해주세요.')
.required('답변을 입력해주세요.'), .min(8, '8자 이상 입력해주세요.'),
})} password2: Yup.string()
onSubmit={(values, { setSubmitting }) => { .required('비밀번호를 다시 입력해주세요.')
axios({ .min(8, '8자 이상 입력해주세요.')
method: 'post', .oneOf([Yup.ref("password"), null], '비밀번호가 일치하지 않습니다.'),
url: '/users', answer: Yup.string()
data: values, .required('답변을 입력해주세요.'),
}).then(res => { })}
if (res.status === 404) return alert(res.data.error) onSubmit={(values, { setSubmitting }) => {
alert("회원가입이 완료되었습니다!") axios({
method: 'post',
setState(true); url: '/users',
}) data: values,
.catch(err => { }).then(res => {
alert(err.error) if (res.status === 404) return alert(res.data.error)
}); alert("회원가입이 완료되었습니다!")
setTimeout(() => { setState(true);
setSubmitting(false); })
}, 400); // finish the cycle in handler .catch(err => {
}} alert(err.error)
> });
{({
errors, setTimeout(() => {
touched, setSubmitting(false);
handleSubmit, }, 400); // finish the cycle in handler
getFieldProps, // contain values, handleChange, handleBlur }}
isSubmitting, >
}) => ( {({
<div className="row justify-content-center align-items-center"> errors,
<form onSubmit={handleSubmit} className="col-sm-3"> touched,
<div className="form-group mb-4"> handleSubmit,
<input getFieldProps, // contain values, handleChange, handleBlur
className={(touched.name && errors.name ? 'form-control is-invalid' : "form-control")} isSubmitting,
type="text" }) => (
name="name" < form onSubmit={handleSubmit} className="asd">
{...getFieldProps('name')} {/* col-sm-3 */}
placeholder="이름" />
{touched.name && errors.name ? ( <div className="form-group ">
<div className="invalid-feedback text-left">{errors.name}</div> {/* mb-4 */}
) : null} <div className={touched.name && errors.name ? "text-danger" : ""}>이름을 입력하세요</div>
</div> <input
<div className="form-group mb-4"> className={(touched.name && errors.name ? 'form-control is-invalid' : "form-control")}
<input type="text"
className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")} name="name"
type="text" {...getFieldProps('name')}
name="id" placeholder="이름" />
{...getFieldProps('id')} </div>
placeholder="학번/교번" <div className="form-group">
/> {/* mb-4 */}
{touched.id && errors.id ? ( <div className={touched.id && errors.id ? "text-danger" : ""}>학번을 입력하세요</div>
<div className="invalid-feedback text-left">{errors.id}</div>
) : null} <input
</div> className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")}
<div className="form-group mb-4"> type="text"
<input name="id"
className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")} {...getFieldProps('id')}
type="password" placeholder="학번/교번"
name="password" />
{...getFieldProps('password')} {/* {touched.id && errors.id ? (
placeholder="비밀번호" <div className="invalid-feedback text-left">{errors.id}</div>
/> ) : null} */}
{touched.password && errors.password ? ( </div>
<div className="invalid-feedback text-left">{errors.password}</div> <div className="form-group">
) : null} {/* mb-4 */}
</div> <div className={touched.password && errors.password ? "text-danger" : ""}>비밀번호를 입력하세요(8자리 이상)</div>
<div className="form-group mb-4">
<input <input
className={(touched.password2 && errors.password2 ? 'form-control is-invalid' : "form-control")} className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")}
type="password" type="password"
name="password2" name="password"
{...getFieldProps('password2')} {...getFieldProps('password')}
placeholder="비밀번호 확인" placeholder="비밀번호"
/> />
{touched.password2 && errors.password2 ? ( {/* {touched.password && errors.password ? (
<div className="invalid-feedback text-left">{errors.password2}</div> <div className="invalid-feedback text-left">{errors.password}</div>
) : null} ) : null} */}
</div> </div>
<div className="form-group mb-4"> <div className="form-group">
<label>본인 확인 질문</label> {/* mb-4 */}
<Field as="select" name="question"> {touched.password2 && errors.password2 ? setCheckPw(false) : null}
<option value="">질문을 선택하세요</option> <div id="reCheck" className={checkPw ? "right" : "err"}></div>
<option value="life">자신의 인생 좌우명은?</option> <input
<option value="school">자신이 다녔던 초등학교의 이름은?</option> className={touched.password2 && errors.password2 ? "form-control is-invalid" : "form-control"}
<option value="place">기억에 남는 추억의 장소는?</option> type="password"
</Field> name="password2"
</div> {...getFieldProps('password2')}
<div className="form-group mb-4"> placeholder="비밀번호 확인"
<input />
className={(touched.answer && errors.answer ? 'form-control is-invalid' : "form-control")}
type="text" </div>
name="answer" <div className="form-group">
{...getFieldProps('answer')} {/* mb-4 */}
placeholder="Input answer" /> <label>본인 확인 질문</label>
{touched.answer && errors.answer ? ( <Field as="select" name="question">
<div className="invalid-feedback text-left">{errors.answer}</div> <option value="">질문을 선택하세요</option>
) : null} <option value="life">자신의 인생 좌우명은?</option>
</div> <option value="school">자신이 다녔던 초등학교의 이름은?</option>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}> <option value="place">기억에 남는 추억의 장소는?</option>
Sign Up </Field>
</button> </div>
<button class="btn btn-light"><Link to="/login">로그인</Link></button> <div className="form-group">
<button class="btn btn-light"><Link to="/"></Link></button> {/* mb-4 */}
</form> <div className={touched.answer && errors.answer ? "text-danger" : ""}>답변을 입력해주세요.</div>
</div>
)} <input
</Formik> className={(touched.answer && errors.answer ? 'form-control is-invalid' : "form-control")}
</div> type="text"
name="answer"
{...getFieldProps('answer')}
placeholder="Input answer" />
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>회원가입</button>
<button class="btn btn-light"><Link to="/login">로그인</Link></button>
<button class="btn btn-light"><Link to="/"></Link></button>
</form>
)}
</Formik>
</div>
</Wow>
</div>
</div >
); );
} }
......
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
...@@ -2,7 +2,8 @@ import React from 'react'; ...@@ -2,7 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker'; import * as serviceWorker from './serviceWorker';
import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom'; import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom';
import 'bootstrap/dist/css/bootstrap.css'; // import 'bootstrap';
// import 'bootstrap/dist/css/bootstrap.css';
import axios from 'axios'; import axios from 'axios';
import { PrivateRoute } from './Components/PrivateRoute'; import { PrivateRoute } from './Components/PrivateRoute';
...@@ -28,7 +29,7 @@ ReactDOM.render( ...@@ -28,7 +29,7 @@ ReactDOM.render(
<Route path="/signup" component={Signup} /> <Route path="/signup" component={Signup} />
<Route path="/find" component={Find} /> <Route path="/find" component={Find} />
<Route path="/change" component={Change} /> <Route path="/change" component={Change} />
<Route path="/apply" component={Apply} /> <Route path="/apply/:id" component={Apply} />
<Route path="/check/:id" component={Check} /> <Route path="/check/:id" component={Check} />
<Route path="/notice" component={Notice} /> <Route path="/notice" component={Notice} />
<Redirect path="/" to="/" /> <Redirect path="/" to="/" />
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>
This diff is collapsed.
const express = require('express');
const Notice = require('../schemas/notice');
const router = express.Router();
router.get('/', function (req, res, next) {
Notice.find({}).sort({ post_date: -1 })
.then((notices) => {
res.json(notices);
})
.catch((err) => {
console.error(err);
next(err);
});
});
module.exports = router;
\ No newline at end of file
...@@ -8,15 +8,15 @@ router.post('/', function (req, res, next) { ...@@ -8,15 +8,15 @@ router.post('/', function (req, res, next) {
console.log('/reserve post req.body', req.body) console.log('/reserve post req.body', req.body)
const reserve = new Reserve({ const reserve = new Reserve({
id: req.body._id,
date: req.body.date, date: req.body.date,
time: req.body.time, time: req.body.time,
room: req.body.room, room: req.body.room,
name: req.body.name, name: req.body.name,
id: req.body._id,
reason: req.body.reason, reason: req.body.reason,
member: req.body.member, students: req.body.students,
approve: req.body.approve, approve: req.body.approve,
num: req.body.num, num: req.body.students.length + 1,
}); });
reserve.save() reserve.save()
......
...@@ -34,6 +34,15 @@ router.post('/', function (req, res, next) { ...@@ -34,6 +34,15 @@ router.post('/', function (req, res, next) {
}) })
}); });
router.get('/:_id', function (req, res, next) {
console.log('/users get req.params', req.params)
User.findOne({ _id: req.params._id }, function (err, user) {
if (err) return res.status(500).json({ error: err });
res.status(201).json(user);
})
})
router.put('/change/:id', function (req, res, next) { router.put('/change/:id', function (req, res, next) {
console.log('/change put req.body', req.params) console.log('/change put req.body', req.params)
User.findOne({ _id: req.params.id }, 'password', function (err, user) { User.findOne({ _id: req.params.id }, 'password', function (err, user) {
......
const mongoose = require('mongoose');
const { Schema } = mongoose;
const noticeSchema = new Schema({
notice_img: {
type: Array,
},
notice_title: {
type: String,
required: true,
},
notice_author: {
type: String,
// default: "나야나"
required: true,
},
post_date: {
type: Date,
default: Date.now,
required: true,
},
notice_content: {
type: String,
required: true,
},
});
module.exports = mongoose.model('Notice', noticeSchema);
...@@ -27,8 +27,8 @@ const reserveSchema = new Schema({ ...@@ -27,8 +27,8 @@ const reserveSchema = new Schema({
type: String, type: String,
}, },
member: { students: {
type: String, type: Array,
}, },
approve: { approve: {
......
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