Commit ae1406c4 authored by CHAERIN KIM's avatar CHAERIN KIM
Browse files

Merge remote-tracking branch 'origin/hyj' into cherry

parents fc4d0a01 9e22fd14
......@@ -12,6 +12,7 @@ const loginRouter = require('./routes/login');
const reservesRouter = require('./routes/reserves');
const noticeRouter = require('./routes/notices');
const connect = require('./schemas');
const writesRouter = require('./routes/writes');
const app = express();
connect();
......@@ -31,6 +32,7 @@ app.use('/users', usersRouter, reservesRouter);
app.use('/login', loginRouter);
app.use('/reserves', reservesRouter);
app.use('/notices', noticeRouter);
app.use('/writes', writesRouter);
app.listen(port, () => console.log(port));
......
......@@ -2,17 +2,14 @@ import axios from 'axios';
import React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom';
import styled from 'styled-components';
import { Navbar, Nav, NavLink } from 'react-bootstrap';
import axios from 'axios';
const Nav = styled.nav`
const MENU = styled(Navbar)`
background-color: #7B031D;
height: 6vh;
a {
color: #ffffff;
}
& .logoutBtn:hover {
text-decoration: underline;
color : white;
}
`
......@@ -21,18 +18,16 @@ function Menu() {
const [user, setUser] = useState({ role: "" })
const name = localStorage.getItem('name');
useEffect(() => {
acheck();
}, [])
if (state) return <Redirect to="/" />;
function logout() {
localStorage.clear();
alert("로그아웃 되었습니다.");
setState(true);
}
useEffect(() => {
acheck();
}, [])
function acheck() {
axios.get(`/users/${localStorage.getItem('_id')}`)
.then(res => {
......@@ -44,52 +39,46 @@ function Menu() {
});
}
if (state) return <Redirect to="/" />
return (
<Nav className="navbar sticky-top navbar-expand-md">
<a class="navbar-brand" href="#">대관 서비스</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
<ul className="navbar-nav">
<li className="nav-item">
<Link to="/notice" className="nav-link">공지사항</Link>
</li>
<li className="nav-item">
<Link to="/home" className="nav-link">대관 현황</Link>
</li>
<li className="nav-item">
<Link to={{
<MENU expand="md" variant="dark">
<Navbar.Brand href="#">대관 서비스</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="mr-auto">
<NavLink as={Link} to="/notice">공지사항</NavLink>
<NavLink as={Link} to="/home">대관 현황</NavLink>
<NavLink as={Link} to={{
pathname: `/apply/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">대관 신청</Link>
</li>
<li className="nav-item">
<Link to={{
}} className="nav-link">대관 신청</NavLink>
<NavLink as={Link} to={{
pathname: `/check/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
대관 확인/취소</Link>
</li>
대관 확인/취소</NavLink>
{user.role === "admin" ? (
<li className="nav-item">
<Link to={{
<NavLink as={Link} to={{
pathname: `/acheck/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
대관 확인/취소(관리자)</Link>
</li>) : null}
</ul>
<div className="h-100 mr-3">
<div className="text-white text-right font-weight-light"><small>{name} 안녕하세요</small></div>
<div className="text-white text-right font-weight-light"><small>
<Link to={{
pathname: `/change/${user._id}`,
state: { id: user._id },
}}>비밀번호 변경</Link> / <span className="logoutBtn" onClick={logout} >로그아웃</span></small></div>
</div>
</div>
대관 확인/취소(관리자)</NavLink>) : null}
</Nav>
<Nav >
<NavLink>
<small className="d-flex flex-row justify-content-end">
<div className="text-white text-right font-weight-light pr-2">{name}</div>
<NavLink className="p-0" as={Link} to={{
pathname: `/change/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}}> 비밀번호 변경 </NavLink> / <NavLink className="p-0" onClick={logout} > 로그아웃</NavLink></small>
</NavLink>
</Nav>
</Navbar.Collapse>
</MENU >
)
}
......
......@@ -211,7 +211,6 @@ function Apply(props) {
>
X
</button>
</div>
</div>
))}
......
......@@ -2,18 +2,38 @@ import React, { useState } from 'react';
import { Formik } from 'formik';
import * as Yup from 'yup';
import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css';
import Menu from '../Components/Menu';
import { Link, Redirect } from 'react-router-dom';
import { Container, Button, 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 <Redirect to="/" />;
}
console.log(props)
// console.log(props)
return (
<div className="d-flex flex-column justify-content-between vh-100">
<div className="">
<Menu />
<Container fluid className="p-0 vh-90">
<Check className="row justify-content-center m-0">
<Col md={4} className="pt-5">
<Formik
initialValues={{ password: '' }}
validationSchema={Yup.object({
......@@ -38,7 +58,6 @@ function Change(props) {
alert(err.error)
});
setTimeout(() => {
setSubmitting(false);
}, 400); // finish the cycle in handler
......@@ -51,21 +70,21 @@ function Change(props) {
getFieldProps, // contain values, handleChange, handleBlur
isSubmitting,
}) => (
<div className="row justify-content-center align-items-center">
<form onSubmit={handleSubmit} className="col-sm-3">
<div className="form-group mb-4">
<form onSubmit={handleSubmit} className="d-flex flex-column">
<div className="form-group">
<div className={touched.password && errors.password ? "text-danger" : ""}> 비밀번호를 입력하세요(8자리 이상)</div>
<input
className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")}
type="password"
name="password"
{...getFieldProps('password')}
placeholder="새 비밀번호를 입력해주세요."
placeholder="로운 비밀번호"
/>
{touched.password && errors.password ? (
<div className="invalid-feedback text-left">{errors.password}</ div>
) : null}
</div>
<div className="form-group mb-4">
<div className="form-group">
{touched.password2 && errors.password2 ? setCheckPw(false) : null}
<div id="reCheck" className={checkPw ? "right" : "err"}></div>
<input
className={(touched.password2 && errors.password2 ? 'form-control is-invalid' : "form-control")}
type="password"
......@@ -73,15 +92,16 @@ function Change(props) {
{...getFieldProps('password2')}
placeholder="새 비밀번호를 다시 입력해주세요."
/>
{touched.password2 && errors.password2 ? (
<div className="invalid-feedback text-left">{errors.password2}</div>
) : null}
</div>
<button type="submit" className="btn btn-light" disabled={isSubmitting}>저장</button>
<Button type="submit" variant="secondary" disabled={isSubmitting}>저장하기</Button>
</form>
</div>
)}
</Formik>
</Col>
</Check>
</Container>
</div >
);
}
......
......@@ -2,11 +2,20 @@ import React, { useState } from 'react';
import { Field, Formik } from 'formik';
import * as Yup from 'yup';
import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css';
import { Link, Redirect } from 'react-router-dom';
import styled from 'styled-components';
import { Navbar, Container, Row, Col, Button } from 'react-bootstrap';
const Menu = styled(Navbar)`
background-color: #7B031D;
a {
color : white;
}
`
function Find() {
const [state, setState] = useState();
const [state, setState] = useState(false);
if (state) {
return <Redirect to={{
......@@ -14,9 +23,14 @@ function Find() {
state: { id: localStorage.getItem('_id') },
}} />;
}
return (
<div className="d-flex flex-column justify-content-between vh-100">
<div className="vh-100">
<Menu expand="md" variant="dark">
<Navbar.Brand>비밀번호 찾기</Navbar.Brand>
</Menu>
<Container fluid>
<Row className="justify-content-center">
<Col md={3} xs={11} className="p-0">
<Formik
initialValues={{ id: '', question: '', answer: '' }}
validationSchema={Yup.object({
......@@ -52,9 +66,9 @@ function Find() {
getFieldProps, // contain values, handleChange, handleBlur
isSubmitting,
}) => (
<div className="row justify-content-center align-items-center">
<form onSubmit={handleSubmit} className="col-sm-3">
<div className="form-group mb-4">
<form onSubmit={handleSubmit} className="d-flex flex-column pt-5">
<div className="form-group pb-2">
<div className={touched.id && errors.id ? "text-danger" : ""}>학번을 입력하세요</div>
<input
className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")}
type="number"
......@@ -62,12 +76,10 @@ function Find() {
{...getFieldProps('id')}
placeholder="Input Student Id"
/>
{touched.id && errors.id ? (
<div className="invalid-feedback text-left">{errors.id}</div>
) : null}
</div>
<div className="form-group mb-4">
<label>본인 확인 질문</label>
<div className="form-group pb-2">
<label className="pr-2">본인 확인 질문</label>
<Field as="select" name="question">
<option value="">질문을 선택하세요</option>
<option value="life">자신의 인생 좌우명은?</option>
......@@ -75,27 +87,26 @@ function Find() {
<option value="place">기억에 남는 추억의 장소는?</option>
</Field>
</div>
<div className="form-group mb-4">
<div className="form-group pb-2">
<div className={touched.answer && errors.answer ? "text-danger" : ""}>답변을 입력해주세요.</div>
<input
className={(touched.answer && errors.answer ? 'form-control is-invalid' : "form-control")}
type="text"
name="answer"
{...getFieldProps('answer')}
placeholder="Input answer" />
{touched.answer && errors.answer ? (
<div className="invalid-feedback text-left">{errors.answer}</div>
) : null}
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>
submit
</button>
<button><Link to="/login">로그인</Link></button>
<button><Link to="/"></Link></button>
<Button className="mb-2" variant="secondary" type="submit" disabled={isSubmitting}>비밀번호 찾기</Button>
<Button variant="outline-secondary" as={Link} to="/login">로그인하러 가기</Button>
</form>
</div>
)}
</Formik>
</div>
</Col>
</Row>
</Container >
</div >
);
}
......
......@@ -5,7 +5,7 @@ import { Formik } from 'formik';
import * as Yup from 'yup';
import axios from 'axios';
import Logo from '../icon.png';
import { Container, Row } from 'react-bootstrap';
import { Container, Row, Button } from 'react-bootstrap';
const Col_1 = styled.div`
background-color: #7B031D;
......@@ -37,11 +37,12 @@ const Col_1 = styled.div`
const Col_2 = styled.div`
background-color: rgb(239, 218, 200);
a {
color : #7B031D;
}
&.mob-formik {
& .mob-formik {
height : 80vh;
width: 100%;
display: flex;
......@@ -49,41 +50,39 @@ const Col_2 = styled.div`
align-items: center;
}
&.web-formik {
& .web-form {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
& .mobb {
height: 35vh;
& .mob-container {
display: flex;
flex-direction: column;
justify-content: space-around;
}
& .webb {
flex-direction: column;
}
& .qwer {
& .web-container {
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;
flex-direction: column;
justify-content: space-around;
}
& .mob-input-form {
display: flex;
flex-direction: column;
justify-content: space-around;
}
`
......@@ -105,7 +104,7 @@ function Login() {
}
return (
<Container fluid className="p-0">
<Row className="vw-100 vh-100 m-0" >
<Row className="vw-100 vh-100 m-0 " >
<Col_1 className={"col-md-4 col-12" + (mobile ? " mobile" : " web")}>
<div className={mobile ? "mob-head" : ""}>
<img className={mobile ? "mob-img" : "img-fluid"} src={Logo} />
......@@ -114,7 +113,7 @@ function Login() {
</div>
</div>
</Col_1>
<Col_2 className={"col-md-8 col-12" + (mobile ? " mob-formik p-0" : " web-formik")}>
<Col_2 className="col-md-8 col-12" >
<Formik
initialValues={{ id: '', password: '' }}
validationSchema={Yup.object({
......@@ -153,10 +152,11 @@ function Login() {
getFieldProps, // contain values, handleChange, handleBlur
isSubmitting,
}) => (
<form onSubmit={handleSubmit} className={mobile ? "w-75 h-50vh" : "d-flex webb"}>
<div className={mobile ? "mobb" : "qwer"}>
<div className={(mobile ? "mob-" : "web-") + "input-form"}>
<div className={"form-group m-0" + (mobile ? " mb-2" : "")}>
<div className={mobile ? " mob-formik p-0" : " web-form"}>
<form onSubmit={handleSubmit} className={mobile ? "w-75" : "d-flex webb"}>
<div className={mobile ? "mob-container" : "web-container"}>
<div className={mobile ? "mob-input-form" : "web-input-form mr-2"}>
<div className={"form-group m-0" + (mobile ? " mb-2" : " ")}>
<input
className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")}
type="number"
......@@ -165,7 +165,7 @@ function Login() {
placeholder="Input Student Id"
/>
</div>
<div className="form-group m-0">
<div className={"form-group m-0"+ (mobile ? " mb-2" : " ")}>
<input
className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")}
type="password"
......@@ -175,13 +175,14 @@ function Login() {
/>
</div>
</div>
<button type="submit" className={"btn btn-dark" + (mobile ? " w-100" : " w-20")} disabled={isSubmitting}> Login </button>
<Button type="submit" variant="dark" className={mobile ? " w-100" : " w-20"} disabled={isSubmitting}> Login </Button>
</div>
<div><Link to="/find">비밀번호를 잊으셨나요?</Link></div>
<div><Link to="/signup">회원이 아니신가요?</Link></div>
</form>
</div>
)}
</Formik>
</Col_2>
......
import React, { useState, useEffect, useRef } from 'react';
import Menu from '../Components/Menu';
import axios from 'axios';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { Container, Row, Col, Card, Accordion, Button } from 'react-bootstrap';
function Notice() {
const [notices, setNotices] = useState([]);
......@@ -27,9 +28,8 @@ function Notice() {
axios.get(`/notices`)
.then(res => {
if (res.status !== 201) {
alert(res.data.error);
// alert(res.data.error);
}
console.log(res.data);
setNotices(res.data);
})
.catch(err => {
......@@ -39,46 +39,24 @@ function Notice() {
return (
<div>
<Menu />
<div className="container-fluid">
<div className="row justify-content-center vw-100 vh-90">
<div className="col-md-7 col-12">
<h2 className="p-3 border-bottom">공지사항</h2>
<div id="accordion pt-1">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
{/* {notices.map((notice, index) =>
<div className="card">
<div className="card-header" id={"Hnotice_" + index}>
<div className="row card-link collapsed" data-toggle="collapse" data-target={"#notice_" + index} aria-expanded="false" aria-controls={"notice_" + index}>
<div className="col-6 p-0">{notice.notice_title}</div>
<div className="col-3 p-0 text-center">{notice.notice_author}</div>
<div className="col-3 p-0 text-right">{dateForm(notice.post_date)}</div>
</div>
</div>
<div id={"notice_" + index} aria-labelledby={"Hnotice_" + index} className="collapse" data-parent="#accordion">
<div className="card-body">{notice.notice_content}</div>
</div>
</div>
)} */}
</div>
</div>
</div >
</div >
<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>
<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>
<Accordion.Collapse eventKey={index + 1}>
<Card.Body>{notice.notice_content}</Card.Body>
</Accordion.Collapse>
</Card>)}
</Accordion>
</Col>
</Row>
</Container>
</div>
)
}
......
......@@ -2,16 +2,15 @@ import React, { useState } from 'react';
import { Field, Formik } from 'formik';
import * as Yup from 'yup';
import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.css';
import { Link, Redirect } from 'react-router-dom';
import styled from 'styled-components';
import { Col, Container, Navbar, Button } from 'react-bootstrap';
const Nav = styled.nav`
const Menu = styled(Navbar)`
background-color: #7B031D;
height: 10vh;
a {
color: #ffffff;
color : white;
}
`
......@@ -23,7 +22,7 @@ const Wow = styled.div`
}
& #reCheck:not(.right) {
content: '비밀번호가 다릅니다.';
content: '비밀번호가 일치하지 않습니다.';
color: red;
}
......@@ -40,15 +39,14 @@ function Signup() {
if (state) {
return <Redirect to="/login" />;
}
return (
<div className="vh-100">
<Nav className="navbar sticky-top navbar-expand-md">
<a class="navbar-brand" href="#">회원가입</a>
</Nav>
<div className="container-fluid">
<Wow className="row justify-content-center rrooww">
<div className="col-md-4 col-12 d-flex align-items-center h-100">
<Menu expand="md" variant="dark">
<Navbar.Brand>회원가입</Navbar.Brand>
</Menu>
<Container fluid>
<Wow className="row justify-content-center">
<Col md={3} xs={11} className="p-0">
<Formik
initialValues={{ name: '', id: '', password: '', password2: '', question: '', answer: '' }}
validationSchema={Yup.object({
......@@ -94,10 +92,7 @@ function Signup() {
isSubmitting,
}) => (
< form onSubmit={handleSubmit} className="asd">
{/* col-sm-3 */}
<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")}
......@@ -106,10 +101,9 @@ function Signup() {
{...getFieldProps('name')}
placeholder="이름" />
</div>
<div className="form-group">
{/* mb-4 */}
<div className={touched.id && errors.id ? "text-danger" : ""}>학번을 입력하세요</div>
<input
className={(touched.id && errors.id ? 'form-control is-invalid' : "form-control")}
type="text"
......@@ -117,14 +111,10 @@ function Signup() {
{...getFieldProps('id')}
placeholder="학번/교번"
/>
{/* {touched.id && errors.id ? (
<div className="invalid-feedback text-left">{errors.id}</div>
) : null} */}
</div>
<div className="form-group">
{/* mb-4 */}
<div className={touched.password && errors.password ? "text-danger" : ""}>비밀번호를 입력하세요(8자리 이상)</div>
<input
className={(touched.password && errors.password ? 'form-control is-invalid' : "form-control")}
type="password"
......@@ -132,12 +122,9 @@ function Signup() {
{...getFieldProps('password')}
placeholder="비밀번호"
/>
{/* {touched.password && errors.password ? (
<div className="invalid-feedback text-left">{errors.password}</div>
) : null} */}
</div>
<div className="form-group">
{/* mb-4 */}
{touched.password2 && errors.password2 ? setCheckPw(false) : null}
<div id="reCheck" className={checkPw ? "right" : "err"}></div>
<input
......@@ -147,10 +134,9 @@ function Signup() {
{...getFieldProps('password2')}
placeholder="비밀번호 확인"
/>
</div>
<div className="form-group">
{/* mb-4 */}
<label>본인 확인 질문</label>
<Field as="select" name="question">
<option value="">질문을 선택하세요</option>
......@@ -160,9 +146,7 @@ function Signup() {
</Field>
</div>
<div className="form-group">
{/* mb-4 */}
<div className={touched.answer && errors.answer ? "text-danger" : ""}>답변을 입력해주세요.</div>
<input
className={(touched.answer && errors.answer ? 'form-control is-invalid' : "form-control")}
type="text"
......@@ -170,19 +154,17 @@ function Signup() {
{...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>
<Button type="submit" variant="secondary" disabled={isSubmitting}>회원가입</Button>
<Button variant="outline-secondary" as={Link} to="/login">로그인하러 가기</Button>
</form>
)}
</Formik>
</div>
</Col>
</Wow>
</div>
</Container>
</div >
);
}
export default Signup;
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom';
import Menu from '../Components/Menu';
import * as Yup from 'yup';
import axios from 'axios';
import { Container, Row, Col } from 'react-bootstrap';
import { Field, Formik } from 'formik';
function Write() {
const [submitData, setSubmitData] = useState(false);
const [state, setState] = useState(false);
if (state) {
return <Redirect to="/notice" />;
}
return (
<div>
<Menu />
<Container fluid>
<Row className="justify-content-center">
<Col md={12} xl={8} style={{ height: "35em" }}>
<Formik
initialValues={{ title: '', content: '' }}
validationSchema={Yup.object({
title: Yup.string()
.required('제목을 입력해주세요.'),
content: Yup.string()
.required('내용을 입력해주세요.'),
})}
onSubmit={(values, { setSubmitting }) => {
axios({
method: 'post',
url: '/writes',
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,
handleSubmit,
getFieldProps, // contain values, handleChange, handleBlur
isSubmitting,
}) => (
<form onSubmit={handleSubmit} className="asd">
{/* col-sm-3 */}
<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"
title="title"
{...getFieldProps('title')}
placeholder="제목" />
</div>
<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="내용" />
</div>
<button type="submit" className="btn btn-dark" disabled={isSubmitting}>공지 등록</button>
</form>
)}
</Formik>
</Col>
</Row>
</Container>
</div>
)
}
export default Write
......@@ -16,13 +16,14 @@ import Apply from './Pages/ApplyPage';
import Check from './Pages/CheckPage';
import Notice from './Pages/NoticePage';
import ACheck from './Pages/ACheckPage';
import Write from './Pages/WritePage';
axios.defaults.validateStatus = function (status) {
return status < 500; // default
}
ReactDOM.render(
<Router>
<Router>
<Switch>
<PrivateRoute exact path="/" component={Home} />
<Route path="/login" component={Login} />
......@@ -32,11 +33,12 @@ ReactDOM.render(
<Route path="/change" component={Change} />
<Route path="/apply/:id" component={Apply} />
<Route path="/check/:id" component={Check} />
<Route path="/write" component={Write} />
<Route path="/notice" component={Notice} />
<Route path="/acheck/:id" component={ACheck} />
<Redirect path="/" to="/" />
<Redirect path="/home" to="/" />
<Redirect path="/change/:id" to="/change"/>
<Redirect path="/change/:id" to="/change" />
<Redirect path="/notice" to="/notice" />
</Switch>
</Router>,
document.getElementById('root')
......
......@@ -10,6 +10,7 @@ router.get('/', function (req, res, next) {
})
.catch((err) => {
console.error(err);
next(err);
});
// res.status(404).json({error:"없음."})
......
const express = require('express');
// const path = require('path');
// const multer = require('multer');
// const fs = require('fs');
const Notice = require('../schemas/notice');
const router = express.Router();
router.post('/', function (req, res, next) {
console.log("writes req.body", req.body)
const notice = new Notice({
notice_title: req.body.title,
notice_author: "예진",
notice_content: req.body.content
});
console.log(notice);
notice.save()
.then((result) => {
console.log(result);
res.status(201).json(result);
})
.catch((err) => {
console.error(err);
next(err);
});
});
module.exports = router;
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