Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
reservation-service
Commits
27cc5b26
Commit
27cc5b26
authored
Nov 03, 2020
by
Choi Ga Young
Browse files
Merge remote-tracking branch 'origin/hyj' into rkyoung7
parents
5eb9fbc4
9e22fd14
Changes
12
Hide whitespace changes
Inline
Side-by-side
server/client/src/Components/Menu.js
View file @
27cc5b26
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
styled
from
'
styled-components
'
;
import
{
Navbar
,
Nav
,
NavDropdown
}
from
'
react-bootstrap
'
;
import
{
Navbar
,
Nav
,
NavLink
}
from
'
react-bootstrap
'
;
import
axios
from
'
axios
'
;
const
MENU
=
styled
(
Navbar
)
`
background-color: #7B031D;
a {
color : white;
}
`
function
Menu
()
{
const
[
state
,
setState
]
=
useState
()
const
[
user
,
setUser
]
=
useState
({
role
:
""
})
const
name
=
localStorage
.
getItem
(
'
name
'
);
function
logout
()
{
...
...
@@ -18,6 +23,21 @@ function Menu() {
setState
(
true
);
}
useEffect
(()
=>
{
acheck
();
},
[])
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
.
then
(
res
=>
{
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
}
}).
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
return
(
<
MENU
expand
=
"
md
"
variant
=
"
dark
"
>
...
...
@@ -25,76 +45,38 @@ function Menu() {
<
Navbar
.
Toggle
aria
-
controls
=
"
basic-navbar-nav
"
/>
<
Navbar
.
Collapse
id
=
"
basic-navbar-nav
"
>
<
Nav
className
=
"
mr-auto
"
>
<
Nav
.
Link
><
Link
to
=
"
/notice
"
>
공지사항
<
/Link></
Nav
.
Link
>
<
Nav
.
Link
><
Link
to
=
"
/home
"
>
대관
현황
<
/Link></
Nav
.
Link
>
<
Nav
.
Link
><
Link
to
=
{{
<
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></
Nav
.
Link
>
<
Nav
.
Link
><
Link
to
=
{{
}}
className
=
"
nav-link
"
>
대관
신청
<
/NavLink
>
<
NavLink
as
=
{
Link
}
to
=
{{
pathname
:
`/check/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
<
/Link></
Nav
.
Link
>
<
Nav
.
Link
><
Link
to
=
{{
pathname
:
`/acheck/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
(
관리자
)
<
/Link></
Nav
.
Link
>
<
Nav
.
Link
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
{
name
}
님
<
/small></
div
>
대관
확인
/
취소
<
/NavLink
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
<
Link
to
=
{{
{
user
.
role
===
"
admin
"
?
(
<
NavLink
as
=
{
Link
}
to
=
{{
pathname
:
`/acheck/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
(
관리자
)
<
/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
'
)
},
}}
>
비밀번호
변경
<
/Link> /
<
span
className
=
"
logoutBtn
"
onClick
=
{
logout
}
>
로그아웃
<
/
span
></
small
>
<
/div
>
<
/Nav
.
Link
>
}}
>
비밀번호
변경
<
/
Nav
Link> /
<
NavLink
className
=
"
p-0
"
onClick
=
{
logout
}
>
로그아웃
<
/
NavLink
></
small
>
<
/NavLink
>
<
/Nav
>
<
/Navbar.Collapse
>
{
/* <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={{
pathname: `/apply/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">대관 신청</Link>
</li>
<li className="nav-item">
<Link to={{
pathname: `/check/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
대관 확인/취소</Link>
</li>
<li className="nav-item">
<Link to={{
pathname: `/acheck/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
대관 확인/취소(관리자)</Link>
</li>
</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/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}}>비밀번호 변경</Link> / <span className="logoutBtn" onClick={logout} >로그아웃</span></small></div>
</div>
</div> */
}
<
/MENU
>
)
}
...
...
server/client/src/Pages/ACheckPage.js
View file @
27cc5b26
...
...
@@ -8,12 +8,12 @@ function ACheck(props) {
const
[
state
,
setState
]
=
useState
()
const
[
reserve
,
setReserve
]
=
useState
([]);
useEffect
(()
=>
{
getReserve
();
getReserve
();
},
[])
function
getReserve
()
{
axios
.
get
(
`/users/admin/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
axios
.
get
(
`/users/admin/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
{
...
...
@@ -30,10 +30,19 @@ function ACheck(props) {
if
(
state
)
return
<
Redirect
to
=
"
/home
"
/>
;
function
remove
(
index
)
{
axios
.
delete
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
// axios.delete(`/reserves/${reserve[index]._id}`)
// .then(res => {
// if (res.status === 404) return alert(res.data.error)
// alert("삭제되었습니다!");
// getReserve();
// })
// .catch(err => {
// alert(err.error)
// });
axios
.
put
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
삭제되었
습니다!
"
);
alert
(
"
승인을 거절했
습니다!
"
);
getReserve
();
})
.
catch
(
err
=>
{
...
...
@@ -42,7 +51,9 @@ function ACheck(props) {
};
function
admit
(
index
)
{
axios
.
put
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
axios
.
put
(
`/reserves/
${
reserve
[
index
].
_id
}
`
,
{
approve
:
true
,
})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
승인되었습니다!
"
);
...
...
@@ -69,25 +80,26 @@ function ACheck(props) {
<
/tr
>
<
/thead
>
<
tbody
>
{
reserve
.
map
((
reserve
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
user
.
name
}
<
/td
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
time
}
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
admit
(
index
)}
className
=
"
btn btn-primary
"
>
승인
{
reserve
!=
""
?
(
reserve
.
map
((
reserve
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
user
.
name
}
<
/td
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
admit
(
index
)}
className
=
"
btn btn-primary
"
>
승인
<
/button
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
거절
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
거절
<
/button
>
<
/td
>
<
/tr
>
)
})
}
<
/td
>
<
/tr
>
)
}))
:
<
div
>
최근
대관
신청
내역이
없습니다
.
<
/div>
}
<
/tbody
>
<
/table
>
...
...
@@ -96,4 +108,4 @@ function ACheck(props) {
)
}
export
default
ACheck
\ No newline at end of file
export
default
ACheck
server/client/src/Pages/ApplyPage.js
View file @
27cc5b26
...
...
@@ -22,27 +22,26 @@ function Apply(props) {
}
function
time
(
starttime
)
{
console
.
log
(
starttime
)
if
(
starttime
==
21
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
/Field>
)
}
if
(
starttime
==
20
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
/Field>
)
}
if
(
starttime
==
21
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
/Field>
)
}
if
(
starttime
==
20
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
option
value
=
"
3
"
>
3
시간
<
/option
>
<
/Field>
)
}
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
option
value
=
"
3
"
>
3
시간
<
/option
>
<
/Field>
)
}
function
getUser
()
{
...
...
@@ -93,17 +92,21 @@ function Apply(props) {
url
:
'
/reserves
'
,
data
:
values
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
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
setTimeout
(()
=>
{
setSubmitting
(
false
);
},
400
);
// finish the cycle in handler
}}
>
{({
...
...
@@ -208,7 +211,6 @@ function Apply(props) {
>
X
<
/button
>
<
/div
>
<
/div
>
))}
...
...
@@ -234,4 +236,4 @@ function Apply(props) {
)
}
export
default
Apply
\ No newline at end of file
export
default
Apply
server/client/src/Pages/ChangePage.js
View file @
27cc5b26
...
...
@@ -2,86 +2,106 @@ 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
=
"
/
"
/>
;
return
<
Redirect
to
=
"
/
"
/>
;
}
console
.
log
(
props
)
// console.log(props)
return
(
<
div
className
=
"
d-flex flex-column justify-content-between vh-100
"
>
<
Formik
initialValues
=
{{
password
:
''
}}
validationSchema
=
{
Yup
.
object
({
password
:
Yup
.
string
()
.
required
(
'
비밀번호를 입력해주세요.
'
)
.
min
(
8
,
'
8자 이상 입력해주세요.
'
),
password2
:
Yup
.
string
()
.
required
(
'
비밀번호를 다시 입력해주세요.
'
)
.
min
(
8
,
'
8자 이상 입력해주세요.
'
)
.
oneOf
([
Yup
.
ref
(
"
password
"
),
null
],
'
비밀번호가 일치하지 않습니다.
'
),
})}
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
axios
.
put
(
`/users/change/
${
props
.
location
.
state
.
id
}
`
,
{
...
values
},
)
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
회원정보가 수정되었습니다!
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
<
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
({
password
:
Yup
.
string
()
.
required
(
'
비밀번호를 입력해주세요.
'
)
.
min
(
8
,
'
8자 이상 입력해주세요.
'
),
password2
:
Yup
.
string
()
.
required
(
'
비밀번호를 다시 입력해주세요.
'
)
.
min
(
8
,
'
8자 이상 입력해주세요.
'
)
.
oneOf
([
Yup
.
ref
(
"
password
"
),
null
],
'
비밀번호가 일치하지 않습니다.
'
),
})}
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
axios
.
put
(
`/users/change/
${
props
.
location
.
state
.
id
}
`
,
{
...
values
},
)
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
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
=
"
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
=
"
새로운 비밀번호
"
/>
<
/div
>
<
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
"
name
=
"
password2
"
{...
getFieldProps
(
'
password2
'
)}
placeholder
=
"
새 비밀번호를 다시 입력해주세요.
"
/>
<
/div
>
<
Button
type
=
"
submit
"
variant
=
"
secondary
"
disabled
=
{
isSubmitting
}
>
저장하기
<
/Button
>
<
/form
>
)}
<
/Formik
>
<
/Col
>
<
/Check
>
setTimeout
(()
=>
{
setSubmitting
(
false
);
},
400
);
// finish the cycle in handler
}}
>
{({
errors
,
touched
,
handleSubmit
,
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
"
>
<
input
className
=
{(
touched
.
password
&&
errors
.
password
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
password
"
name
=
"
password
"
{...
getFieldProps
(
'
password
'
)}
placeholder
=
"
새 비밀번호를 입력해주세요.
"
/>
{
touched
.
password
&&
errors
.
password
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
password
}
<
/ div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
input
className
=
{(
touched
.
password2
&&
errors
.
password2
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
password
"
name
=
"
password2
"
{...
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
>
<
/form
>
<
/div
>
)}
<
/Formik
>
<
/Container
>
<
/div
>
);
}
...
...
server/client/src/Pages/CheckPage.js
View file @
27cc5b26
...
...
@@ -59,7 +59,7 @@ function Check(props) {
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
{
reserve
.
approve
?
"
승인
"
:
"
미승인
"
}
<
/td
>
<
td
>
{
reserve
.
check
?
(
reserve
.
approve
?
"
사용가능
"
:
"
사용불가
"
)
:
"
승인대기중
"
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
취소
...
...
server/client/src/Pages/FindPage.js
View file @
27cc5b26
...
...
@@ -4,14 +4,13 @@ import * as Yup from 'yup';
import
axios
from
'
axios
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
styled
from
'
styled-components
'
;
import
{
Container
,
Row
,
Col
}
from
'
react-bootstrap
'
;
import
{
Navbar
,
Container
,
Row
,
Col
,
Button
}
from
'
react-bootstrap
'
;
const
Nav
=
styled
.
nav
`
const
Menu
=
styled
(
Navbar
)
`
background-color: #7B031D;
height: 10vh;
a {
color:
#ffffff
;
color
:
white
;
}
`
...
...
@@ -26,12 +25,12 @@ function Find() {
}
return
(
<
div
className
=
"
vh-100
"
>
<
Nav
className
=
"
navbar sticky-top navbar-expand-md
"
>
<
a
class
=
"
n
avbar
-b
rand
"
href
=
"
#
"
>
비밀번호
찾기
<
/a
>
<
/
Nav
>
<
Menu
expand
=
"
md
"
variant
=
"
dark
"
>
<
N
avbar
.
B
rand
>
비밀번호
찾기
<
/Navbar.Brand
>
<
/
Menu
>
<
Container
fluid
>
<
Row
className
=
"
justify-content-center
rrooww
"
>
<
Col
md
=
{
4
}
className
=
"
d-flex align-items-center h-10
0
"
>
<
Row
className
=
"
justify-content-center
"
>
<
Col
md
=
{
3
}
xs
=
{
11
}
className
=
"
p-
0
"
>
<
Formik
initialValues
=
{{
id
:
''
,
question
:
''
,
answer
:
''
}}
validationSchema
=
{
Yup
.
object
({
...
...
@@ -67,47 +66,41 @@ function Find() {
getFieldProps
,
// contain values, handleChange, handleBlur
isSubmitting
,
})
=>
(
<
Row
className
=
"
justify-content-center align-items-center
"
>
<
form
onSubmit
=
{
handleSubmit
}
>
<
Col
sm
=
{
3
}
>
<
div
className
=
"
form-group mb-4
"
>
<
input
className
=
{(
touched
.
id
&&
errors
.
id
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
number
"
name
=
"
id
"
{...
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
>
<
Field
as
=
"
select
"
name
=
"
question
"
>
<
option
value
=
""
>
질문을
선택하세요
<
/option
>
<
option
value
=
"
life
"
>
자신의
인생
좌우명은
?
<
/option
>
<
option
value
=
"
school
"
>
자신이
다녔던
초등학교의
이름은
?
<
/option
>
<
option
value
=
"
place
"
>
기억에
남는
추억의
장소는
?
<
/option
>
<
/Field
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
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
>
<
/Col
>
<
/form
>
<
/Row
>
<
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
"
name
=
"
id
"
{...
getFieldProps
(
'
id
'
)}
placeholder
=
"
Input Student Id
"
/>
<
/div
>
<
div
className
=
"
form-group pb-2
"
>
<
label
className
=
"
pr-2
"
>
본인
확인
질문
<
/label
>
<
Field
as
=
"
select
"
name
=
"
question
"
>
<
option
value
=
""
>
질문을
선택하세요
<
/option
>
<
option
value
=
"
life
"
>
자신의
인생
좌우명은
?
<
/option
>
<
option
value
=
"
school
"
>
자신이
다녔던
초등학교의
이름은
?
<
/option
>
<
option
value
=
"
place
"
>
기억에
남는
추억의
장소는
?
<
/option
>
<
/Field
>
<
/div
>
<
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
"
/>
<
/div
>
<
Button
className
=
"
mb-2
"
variant
=
"
secondary
"
type
=
"
submit
"
disabled
=
{
isSubmitting
}
>
비밀번호
찾기
<
/Button
>
<
Button
variant
=
"
outline-secondary
"
as
=
{
Link
}
to
=
"
/login
"
>
로그인하러
가기
<
/Button
>
<
/form
>
)}
<
/Formik
>
<
/Col
>
...
...
server/client/src/Pages/LoginPage.js
View file @
27cc5b26
...
...
@@ -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;
...
...
@@ -58,10 +58,8 @@ const Col_2 = styled.div`
}
& .mob-container {
height: 35vh;
display: flex;
flex-direction: column;
justify-content: space-around;
}
& .webb {
...
...
@@ -70,18 +68,15 @@ const Col_2 = styled.div`
& .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 {
...
...
@@ -158,10 +153,10 @@ function Login() {
isSubmitting
,
})
=>
(
<
div
className
=
{
mobile
?
"
mob-formik p-0
"
:
"
web-form
"
}
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
{
mobile
?
"
w-75
h-50vh
"
:
"
d-flex webb
"
}
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
{
mobile
?
"
w-75
"
:
"
d-flex webb
"
}
>
<
div
className
=
{
mobile
?
"
mob-container
"
:
"
web-container
"
}
>
<
div
className
=
{
mobile
?
"
mob-input-form
h-100
"
:
"
web-input-form
"
}
>
<
div
className
=
{
"
form-group m-0
"
+
(
mobile
?
"
mb-2
"
:
""
)}
>
<
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
"
...
...
@@ -170,7 +165,7 @@ function Login() {
placeholder
=
"
Input Student Id
"
/>
<
/div
>
<
div
className
=
"
form-group
h-80 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
"
...
...
@@ -180,7 +175,7 @@ function Login() {
/>
<
/div
>
<
/div
>
<
b
utton
type
=
"
submit
"
className
=
{
"
btn btn-dark
"
+
(
mobile
?
"
w-100
"
:
"
w-20
"
)
}
disabled
=
{
isSubmitting
}
>
Login
<
/
b
utton
>
<
B
utton
type
=
"
submit
"
variant
=
"
dark
"
className
=
{
mobile
?
"
w-100
"
:
"
w-20
"
}
disabled
=
{
isSubmitting
}
>
Login
<
/
B
utton
>
<
/div
>
<
div
><
Link
to
=
"
/find
"
>
비밀번호를
잊으셨나요
?
<
/Link></
div
>
...
...
server/client/src/Pages/NoticePage.js
View file @
27cc5b26
...
...
@@ -28,7 +28,7 @@ function Notice() {
axios
.
get
(
`/notices`
)
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
//
alert(res.data.error);
}
setNotices
(
res
.
data
);
})
...
...
server/client/src/Pages/SignupPage.js
View file @
27cc5b26
...
...
@@ -4,13 +4,13 @@ import * as Yup from 'yup';
import
axios
from
'
axios
'
;
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
;
}
`
...
...
@@ -22,7 +22,7 @@ const Wow = styled.div`
}
& #reCheck:not(.right) {
content: '비밀번호가
다릅
니다.';
content: '비밀번호가
일치하지 않습
니다.';
color: red;
}
...
...
@@ -41,12 +41,12 @@ function Signup() {
}
return
(
<
div
className
=
"
vh-100
"
>
<
Nav
className
=
"
navbar sticky-top navbar-expand-md
"
>
<
a
class
=
"
n
avbar
-b
rand
"
href
=
"
#
"
>
회원가입
<
/a
>
<
/
Nav
>
<
div
className
=
"
c
ontainer
-
fluid
"
>
<
Wow
className
=
"
row justify-content-center
rrooww
"
>
<
div
className
=
"
col-md-4 col-12 d-flex align-items-center h-10
0
"
>
<
Menu
expand
=
"
md
"
variant
=
"
dark
"
>
<
N
avbar
.
B
rand
>
회원가입
<
/Navbar.Brand
>
<
/
Menu
>
<
C
ontainer
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
({
...
...
@@ -92,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
"
)}
...
...
@@ -104,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
"
...
...
@@ -115,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
"
...
...
@@ -130,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
...
...
@@ -145,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
>
...
...
@@ -158,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
"
...
...
@@ -168,18 +154,17 @@ function Signup() {
{...
getFieldProps
(
'
answer
'
)}
placeholder
=
"
Input answer
"
/>
<
/div
>
<
b
utton
type
=
"
submit
"
className
=
"
btn btn-
dar
k
"
disabled
=
{
isSubmitting
}
>
회원가입
<
/
b
utton
>
<
b
utton
class
=
"
btn btn-light
"
><
Link
to
=
"
/login
"
>
로그인하러
가기
<
/
Link></
b
utton
>
<
B
utton
type
=
"
submit
"
variant
=
"
secon
dar
y
"
disabled
=
{
isSubmitting
}
>
회원가입
<
/
B
utton
>
<
B
utton
variant
=
"
outline-secondary
"
as
=
{
Link
}
to
=
"
/login
"
>
로그인하러
가기
<
/
B
utton
>
<
/form
>
)}
<
/Formik
>
<
/
div
>
<
/
Col
>
<
/Wow
>
<
/
div
>
<
/
Container
>
<
/div
>
);
}
export
default
Signup
;
\ No newline at end of file
server/routes/notices.js
View file @
27cc5b26
...
...
@@ -10,6 +10,7 @@ router.get('/', function (req, res, next) {
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
next
(
err
);
});
});
...
...
server/routes/reserves.js
View file @
27cc5b26
...
...
@@ -7,14 +7,13 @@ const router = express.Router();
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserve post req.body
'
,
req
.
body
)
const
reserve
=
new
Reserve
({
user
:
req
.
body
.
_id
,
date
:
req
.
body
.
date
,
starttime
:
Number
(
req
.
body
.
starttime
),
usetime
:
Number
(
req
.
body
.
usetime
),
start
:
`
${
req
.
body
.
date
}
T`
+
`
${
req
.
body
.
starttime
}
:00:00`
,
end
:
`
${
req
.
body
.
date
}
T`
+
`
${
Number
(
req
.
body
.
starttime
)
+
Number
(
req
.
body
.
usetime
)}
:00:00`
,
start
:
`
${
req
.
body
.
date
}
T`
+
`
${
req
.
body
.
starttime
}
:00:00`
,
end
:
`
${
req
.
body
.
date
}
T`
+
`
${
Number
(
req
.
body
.
starttime
)
+
Number
(
req
.
body
.
usetime
)}
:00:00`
,
room
:
req
.
body
.
room
,
reason
:
req
.
body
.
reason
,
students
:
req
.
body
.
students
,
...
...
@@ -22,26 +21,60 @@ router.post('/', function (req, res, next) {
num
:
req
.
body
.
students
.
length
+
1
,
});
reserve
.
save
()
.
then
((
result
)
=>
{
console
.
log
(
result
);
res
.
status
(
201
).
json
(
result
);
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
next
(
err
);
});
Reserve
.
find
({
room
:
req
.
body
.
room
,
approve
:
true
},
function
(
err
,
reserves
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
!
reserves
)
{
reserve
.
save
()
.
then
((
result
)
=>
{
console
.
log
(
result
);
res
.
status
(
201
).
json
(
result
);
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
next
(
err
);
});
}
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
))
?
"
item
"
:
null
))
console
.
log
(
"
array
"
,
reserveArr
)
if
(
!
reserveArr
.
includes
(
"
item
"
))
{
reserve
.
save
()
.
then
((
result
)
=>
{
console
.
log
(
result
);
res
.
status
(
201
).
json
(
reserves
);
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
next
(
err
);
});
}
else
return
res
.
status
(
404
).
json
({
error
:
"
다른 시간을 선택해주세요.
"
})
})
});
router
.
get
(
'
/room/:room
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
reserves get room req.params
'
,
req
.
params
)
Reserve
.
find
({
room
:
req
.
params
.
room
,
approve
:
true
},
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
'
reserve room list
'
,
reserve
);
res
.
status
(
201
).
json
(
reserve
);
})
})
// router.get('/:_id', verifyToken, function (req, res, next) {
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
console
.
log
(
'
id.name
'
,
reserve
)
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
'
reserve list
'
,
reserve
)
res
.
status
(
201
).
json
(
reserve
);
})
});
...
...
@@ -73,9 +106,10 @@ router.delete('/:_id', function (req, res, next) {
router
.
put
(
'
/:id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves put req.body
'
,
req
.
params
)
Reserve
.
findOne
({
_id
:
req
.
params
.
id
},
'
approve
'
,
function
(
err
,
reserve
)
{
Reserve
.
findOne
({
_id
:
req
.
params
.
id
},
'
check
approve
'
,
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
reserve
.
approve
=
true
;
reserve
.
check
=
true
;
reserve
.
approve
=
req
.
body
.
approve
;
reserve
.
save
()
.
then
((
result
)
=>
{
console
.
log
(
result
);
...
...
server/schemas/reserve.js
View file @
27cc5b26
...
...
@@ -39,11 +39,14 @@ const reserveSchema = new Schema({
approve
:
{
type
:
Boolean
,
default
:
false
,
},
check
:
{
type
:
Boolean
,
default
:
false
,
},
num
:
{
type
:
Number
,
},
});
module
.
exports
=
mongoose
.
model
(
'
Reserve
'
,
reserveSchema
);
\ No newline at end of file
module
.
exports
=
mongoose
.
model
(
'
Reserve
'
,
reserveSchema
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment