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
5d0a841d
Commit
5d0a841d
authored
Nov 04, 2020
by
Lee Jin Ju
Browse files
Merge remote-tracking branch 'origin/rkyoung7' into hijinju
parents
fc35fa9d
5eda65e7
Changes
13
Hide whitespace changes
Inline
Side-by-side
server/client/.gitignore
View file @
5d0a841d
...
@@ -21,3 +21,5 @@
...
@@ -21,3 +21,5 @@
npm-debug.log*
npm-debug.log*
yarn-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
debug.log
\ No newline at end of file
server/client/src/Components/Menu.js
View file @
5d0a841d
import
axios
from
'
axios
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
styled
from
'
styled-components
'
;
import
styled
from
'
styled-components
'
;
import
axios
from
'
axios
'
;
import
{
Navbar
,
Nav
,
NavLink
}
from
'
react-bootstrap
'
;
import
{
Navbar
,
Nav
,
NavLink
}
from
'
react-bootstrap
'
;
const
MENU
=
styled
(
Navbar
)
`
const
MENU
=
styled
(
Navbar
)
`
...
@@ -28,8 +28,10 @@ function Menu() {
...
@@ -28,8 +28,10 @@ function Menu() {
},
[])
},
[])
function
acheck
()
{
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
.
then
(
res
=>
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
}).
then
(
res
=>
{
console
.
log
(
res
.
data
)
if
(
res
.
data
.
role
==
"
admin
"
)
{
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
setUser
(
res
.
data
)
}
}
...
@@ -59,12 +61,12 @@ function Menu() {
...
@@ -59,12 +61,12 @@ function Menu() {
}}
className
=
"
nav-link
"
>
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
<
/NavLink
>
대관
확인
/
취소
<
/NavLink
>
{
user
.
role
===
"
admin
"
?
(
{
/*
{user.role === "admin" ? (
<NavLink as={Link} to={{
<NavLink as={Link} to={{
pathname: `/acheck/${localStorage.getItem('_id')}`,
pathname: `/acheck/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
}} className="nav-link">
대관
확인
/
취소
(
관리자
)
<
/NavLink>
)
: null
}
대관 확인/취소(관리자)</NavLink>) : null}
*/
}
<
/Nav
>
<
/Nav
>
<
Nav
>
<
Nav
>
<
NavLink
>
<
NavLink
>
...
...
server/client/src/Components/Schedule.js
View file @
5d0a841d
...
@@ -3,53 +3,20 @@ import Calendar from '@toast-ui/react-calendar';
...
@@ -3,53 +3,20 @@ import Calendar from '@toast-ui/react-calendar';
import
"
tui-calendar/dist/tui-calendar.css
"
;
import
"
tui-calendar/dist/tui-calendar.css
"
;
import
"
tui-date-picker/dist/tui-date-picker.css
"
;
import
"
tui-date-picker/dist/tui-date-picker.css
"
;
import
"
tui-time-picker/dist/tui-time-picker.css
"
;
import
"
tui-time-picker/dist/tui-time-picker.css
"
;
import
moment
from
'
moment
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
function
Cal
(
props
)
{
function
Cal
(
props
)
{
const
calendarRef
=
useRef
();
const
calendarRef
=
useRef
(
null
);
const
[
reserve
,
setReserve
]
=
useState
([]);
const
[
reserve
,
setReserve
]
=
useState
([]);
// const [day, setDay] = useState(props.calledday);
const
[
period
,
setPeriod
]
=
useState
();
const
[
day
,
setDay
]
=
useState
(
props
.
day
);
const
[
myTheme
,
setMyTheme
]
=
useState
({
const
[
myTheme
,
setMyTheme
]
=
useState
({
'
common.dayname.color
'
:
'
#333
'
,
'
common.dayname.color
'
:
'
#333
'
,
'
common.today.color
'
:
'
#333
'
,
'
common.today.color
'
:
'
#333
'
,
// 'common.creationGuide.color': 'white',
'
common.creationGuide.backgroundColor
'
:
'
gray
'
,
'
common.creationGuide.backgroundColor
'
:
'
gray
'
,
// Theme object to extends default dark theme.
});
});
const
yj
=
[
{
id
:
'
a
'
,
calendarId
:
'
Subject
'
,
category
:
'
time
'
,
start
:
'
2020-10-27T11:00:00
'
,
end
:
'
2020-10-27T12:00:00
'
,
},
{
id
:
'
b
'
,
calendarId
:
'
Subject
'
,
category
:
'
time
'
,
start
:
'
2020-10-28T10:00:00
'
,
end
:
'
2020-10-28T11:00:00
'
,
},
{
id
:
'
3
'
,
calendarId
:
'
Subject
'
,
category
:
'
time
'
,
start
:
'
2020-10-29T11:00:00
'
,
end
:
'
2020-10-29T15:00:00
'
,
}
]
function
getReserve
(
room
)
{
function
getReserve
(
room
)
{
console
.
log
(
"
room
"
,
room
)
// setReserve({
// id: room,
// calendarId: 'Subject',
// category: 'time',
// })
axios
.
get
(
`/reserves/room/
${
room
}
`
,
{
axios
.
get
(
`/reserves/room/
${
room
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
})
...
@@ -61,56 +28,68 @@ function Cal(props) {
...
@@ -61,56 +28,68 @@ function Cal(props) {
calendarId
:
'
Subject
'
,
calendarId
:
'
Subject
'
,
category
:
'
time
'
,
category
:
'
time
'
,
}))
}))
console
.
log
(
"
room list
"
,
res
.
data
);
setReserve
(
reserves
);
setReserve
(
reserves
);
// console.log("room list",res.data);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
alert
(
err
.
error
)
alert
(
err
.
error
)
});
});
}
}
useEffect
(()
=>
{
function
getDataAction
(
target
)
{
// const cal = calendarRef.current.getInstance();
return
target
.
dataset
?
target
.
dataset
.
action
:
target
.
getAttribute
(
'
data-action
'
);
// cal.setDate(new Date(day));
}
// cal.changeView('week', false);
// cal.today(new Date(day));
// calendar.on('clickSchedule', function (event) {
function
onClickNavi
(
e
)
{
// const schedule = event.schedule;
const
cal
=
calendarRef
.
current
.
getInstance
();
const
action
=
getDataAction
(
e
.
target
);
// if (lastClickSchedule) {
switch
(
action
)
{
// calendar.updateSchedule(lastClickSchedule.id, lastClickSchedule.calendarId, {
case
'
move-prev
'
:
// isFocused: false,
cal
.
prev
();
// });
break
;
// }
case
'
move-next
'
:
// calendar.updateSchedule(schedule.id, schedule.calendarId, {
cal
.
next
();
// isFocused: true,
break
;
// });
case
'
move-today
'
:
cal
.
today
();
break
;
default
:
return
;
}
// lastClickSchedule = schedule
;
setRenderRangeText
()
;
// // open detail view
}
// return (console.log(isFocused))
function
setRenderRangeText
()
{
// });
const
cal
=
calendarRef
.
current
.
getInstance
();
let
html
=
[];
html
.
push
(
moment
(
cal
.
getDateRangeStart
().
getTime
()).
format
(
'
YYYY.MM.DD
'
));
html
.
push
(
'
~
'
);
html
.
push
(
moment
(
cal
.
getDateRangeEnd
().
getTime
()).
format
(
'
MM.DD
'
));
setPeriod
(
html
.
join
(
''
))
}
// setReserve([
useEffect
(()
=>
{
// {
setRenderRangeText
();
// id: '3',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-29T11:00:00',
// end: '2020-10-29T15:00:00',
// }
// ])
getReserve
(
props
.
room
);
getReserve
(
props
.
room
);
},
[
day
])
},
[
props
.
room
])
return
(
return
(
<
div
>
{
<
div
>
console
.
log
(
"
reserve
"
,
reserve
)}
<
div
id
=
"
menu
"
>
<
span
id
=
"
menu-navi
"
onClick
=
{(
e
)
=>
onClickNavi
(
e
)}
>
<
button
type
=
"
button
"
className
=
"
btn btn-default btn-sm move-today
"
data
-
action
=
"
move-today
"
>
Today
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-default btn-sm move-day
"
data
-
action
=
"
move-prev
"
>
<
i
class
=
"
calendar-icon ic-arrow-line-left
"
data
-
action
=
"
move-prev
"
><
/i
>
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-default btn-sm move-day
"
data
-
action
=
"
move-next
"
>
<
i
className
=
"
calendar-icon ic-arrow-line-right
"
data
-
action
=
"
move-next
"
><
/i
>
<
/button
>
<
/span
>
<
span
id
=
"
renderRange
"
className
=
"
render-range
"
style
=
{{
height
:
"
5em
"
}}
>
{
period
}
<
/span
>
<
/div
>
<
Calendar
<
Calendar
ref
=
{
calendarRef
}
height
=
"
100%
"
height
=
"
100%
"
calendars
=
{[
calendars
=
{[
{
{
...
@@ -120,46 +99,11 @@ function Cal(props) {
...
@@ -120,46 +99,11 @@ function Cal(props) {
isReadOnly
:
'
true
'
isReadOnly
:
'
true
'
}
}
]}
]}
view
=
"
week
"
view
=
"
week
"
disableDblClick
=
{
false
}
disableDblClick
=
{
false
}
disableClick
=
{
true
}
disableClick
=
{
true
}
isReadOnly
=
{
false
}
isReadOnly
=
{
true
}
// template={
schedules
=
{
reserve
}
// popupIsAllDay=function {
// return display: "none"
// }
// }
schedules
=
{
reserve
// reserve.map(item=>({id: item._id,
// start: item.start,
// end: item.end,
// calendarId: 'Subject',
// category: 'time',}))
// [
// {
// id: 'a',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-27T11:00:00',
// end: '2020-10-27T12:00:00',
// },
// {
// id: 'b',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-28T10:00:00',
// end: '2020-10-28T11:00:00',
// },
// {
// id: '3',
// calendarId: 'Subject',
// category: 'time',
// start: '2020-10-29T11:00:00',
// end: '2020-10-29T15:00:00',
// }
// ]
}
scheduleView
=
{[
'
time
'
]}
scheduleView
=
{[
'
time
'
]}
taskView
=
{
false
}
taskView
=
{
false
}
theme
=
{
myTheme
}
theme
=
{
myTheme
}
...
...
server/client/src/Pages/ACheckPage.js
View file @
5d0a841d
...
@@ -47,18 +47,9 @@ function ACheck(props) {
...
@@ -47,18 +47,9 @@ function ACheck(props) {
alert
(
err
.
error
)
alert
(
err
.
error
)
});
});
}
}
if
(
state
)
return
<
Redirect
to
=
"
/
home
"
/>
;
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
remove
(
index
)
{
function
remove
(
index
)
{
// 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
}
`
)
axios
.
put
(
`/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
)
...
...
server/client/src/Pages/ApplyPage.js
View file @
5d0a841d
...
@@ -4,16 +4,17 @@ import Menu from '../Components/Menu';
...
@@ -4,16 +4,17 @@ import Menu from '../Components/Menu';
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
*
as
Yup
from
'
yup
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
{
Col
,
Container
,
Row
}
from
'
react-bootstrap
'
;
function
Apply
(
props
)
{
function
Apply
(
props
)
{
const
[
state
,
setState
]
=
useState
();
const
[
state
,
setState
]
=
useState
(
{
ok
:
""
}
);
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
useEffect
(()
=>
{
useEffect
(()
=>
{
getUser
();
getUser
();
},
[])
},
[])
if
(
state
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
)
{
if
(
state
.
ok
===
"
ok
"
)
{
return
<
Redirect
to
=
{{
return
<
Redirect
to
=
{{
pathname
:
`/check/
${
props
.
match
.
params
.
id
}
`
,
pathname
:
`/check/
${
props
.
match
.
params
.
id
}
`
,
state
:
{
id
:
props
.
match
.
params
.
id
},
state
:
{
id
:
props
.
match
.
params
.
id
},
...
@@ -40,7 +41,6 @@ function Apply(props) {
...
@@ -40,7 +41,6 @@ function Apply(props) {
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
option
value
=
"
3
"
>
3
시간
<
/option
>
<
option
value
=
"
3
"
>
3
시간
<
/option
>
<
/Field>
)
<
/Field>
)
}
}
function
getUser
()
{
function
getUser
()
{
...
@@ -50,6 +50,8 @@ function Apply(props) {
...
@@ -50,6 +50,8 @@ function Apply(props) {
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
({
ok
:
"
no
"
});
}
}
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
setUser
(
res
.
data
);
setUser
(
res
.
data
);
...
@@ -62,137 +64,134 @@ function Apply(props) {
...
@@ -62,137 +64,134 @@ function Apply(props) {
return
(
return
(
<
div
>
<
div
>
<
Menu
/>
<
Menu
/>
<
Formik
<
Container
fluid
>
initialValues
=
{{
<
Row
className
=
"
justify-content-center
"
>
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
<
Col
md
=
{
5
}
>
date
:
''
,
<
Formik
starttime
:
''
,
initialValues
=
{{
usetime
:
''
,
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
room
:
''
,
date
:
''
,
reason
:
''
,
starttime
:
''
,
students
:
[
usetime
:
''
,
{
room
:
''
,
member
:
''
,
reason
:
''
,
},
students
:
[
],
{
}}
member
:
''
,
validationSchema
=
{
Yup
.
object
({
},
date
:
Yup
.
string
()
],
.
required
(
'
날짜를 입력해주세요.
'
),
}}
room
:
Yup
.
string
()
validationSchema
=
{
Yup
.
object
({
.
required
(
'
강의실 번호를 입력해주세요.
'
),
date
:
Yup
.
string
()
reason
:
Yup
.
string
()
.
required
(
'
날짜를 입력해주세요.
'
),
.
required
(
'
대관목적을 입력해주세요.
'
),
reason
:
Yup
.
string
()
})}
.
required
(
'
대관목적을 입력해주세요.
'
),
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
})}
console
.
log
(
values
)
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
axios
({
console
.
log
(
values
)
method
:
'
post
'
,
axios
({
url
:
'
/reserves
'
,
method
:
'
post
'
,
data
:
values
url
:
'
/reserves
'
,
}).
then
(
res
=>
{
data
:
values
if
(
res
.
status
===
404
)
{
}).
then
(
res
=>
{
alert
(
res
.
data
.
error
)
if
(
res
.
status
===
404
)
{
return
window
.
location
.
reload
();
alert
(
res
.
data
.
error
)
}
return
window
.
location
.
reload
();
alert
(
"
신청이 완료되었습니다!
"
);
}
setState
(
true
);
alert
(
"
신청이 완료되었습니다!
"
);
console
.
log
(
"
res.data
"
,
res
.
data
)
setState
({
ok
:
"
ok
"
});
})
console
.
log
(
"
res.data
"
,
res
.
data
)
.
catch
(
err
=>
{
})
alert
(
err
.
error
)
.
catch
(
err
=>
{
});
alert
(
err
.
error
)
});
setTimeout
(()
=>
{
setSubmitting
(
false
);
},
400
);
// finish the cycle in handler
}}
>
{({
errors
,
touched
,
values
,
handleSubmit
,
getFieldProps
,
isSubmitting
,
})
=>
(
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
d-flex flex-column
"
>
<
h3
className
=
"
form-group font-weight-bold
"
>
<
label
className
=
"
pr-2
"
>
대표자
:
<
/label>{user.name
}
<
/h3
>
<
div
className
=
"
form-group
"
>
<
div
className
=
{
touched
.
date
&&
errors
.
date
?
"
text-danger
"
:
""
}
>
신청날짜
<
/div
>
<
input
className
=
{(
touched
.
date
&&
errors
.
date
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
date
"
{...
getFieldProps
(
'
date
'
)}
placeholder
=
"
yyyy-mm-dd
"
/>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시작시간
<
/label
>
<
div
>
<
Field
as
=
"
select
"
name
=
"
starttime
"
>
<
option
value
=
""
>
이용시작시간
<
/option
>
<
option
value
=
"
9
"
>
9
시
<
/option
>
<
option
value
=
"
10
"
>
10
시
<
/option
>
<
option
value
=
"
11
"
>
11
시
<
/option
>
<
option
value
=
"
12
"
>
12
시
<
/option
>
<
option
value
=
"
13
"
>
13
시
<
/option
>
<
option
value
=
"
14
"
>
14
시
<
/option
>
<
option
value
=
"
15
"
>
15
시
<
/option
>
<
option
value
=
"
16
"
>
16
시
<
/option
>
<
option
value
=
"
17
"
>
17
시
<
/option
>
<
option
value
=
"
18
"
>
18
시
<
/option
>
<
option
value
=
"
19
"
>
19
시
<
/option
>
<
option
value
=
"
20
"
>
20
시
<
/option
>
<
option
value
=
"
21
"
>
21
시
<
/option
>
<
/Field
>
<
/div
>
<
/div
>
setTimeout
(()
=>
{
<
div
className
=
"
form-group mb-4
"
>
setSubmitting
(
false
);
<
label
>
이용시간
<
/label
>
},
400
);
// finish the cycle in handler
}}
>
{({
errors
,
touched
,
values
,
handleSubmit
,
getFieldProps
,
isSubmitting
,
})
=>
(
<
div
className
=
"
row justify-content-center align-items-center
"
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
col-sm-3
"
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
대표자
<
/label
>
<
div
>
{
user
.
name
}
<
/div
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
신청날짜
<
/label
>
<
input
className
=
{(
touched
.
date
&&
errors
.
date
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
date
"
{...
getFieldProps
(
'
date
'
)}
placeholder
=
"
yyyy-mm-dd
"
/>
{
touched
.
date
&&
errors
.
date
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
date
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시작시간
<
/label
>
<
Field
as
=
"
select
"
name
=
"
starttime
"
>
<
option
value
=
""
>
이용시작시간
<
/option
>
<
option
value
=
"
9
"
>
9
시
<
/option
>
<
option
value
=
"
10
"
>
10
시
<
/option
>
<
option
value
=
"
11
"
>
11
시
<
/option
>
<
option
value
=
"
12
"
>
12
시
<
/option
>
<
option
value
=
"
13
"
>
13
시
<
/option
>
<
option
value
=
"
14
"
>
14
시
<
/option
>
<
option
value
=
"
15
"
>
15
시
<
/option
>
<
option
value
=
"
16
"
>
16
시
<
/option
>
<
option
value
=
"
17
"
>
17
시
<
/option
>
<
option
value
=
"
18
"
>
18
시
<
/option
>
<
option
value
=
"
19
"
>
19
시
<
/option
>
<
option
value
=
"
20
"
>
20
시
<
/option
>
<
option
value
=
"
21
"
>
21
시
<
/option
>
<
/Field
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시간
<
/label
>
{
time
(
values
.
starttime
)}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
강의실
<
/label
>
<
input
className
=
{(
touched
.
room
&&
errors
.
room
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
room
"
{...
getFieldProps
(
'
room
'
)}
placeholder
=
"
bn-nnn
"
/>
{
touched
.
room
&&
errors
.
room
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
room
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
대관목적
<
/label
>
<
input
className
=
{(
touched
.
reason
&&
errors
.
reason
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
reason
"
{...
getFieldProps
(
'
reason
'
)}
placeholder
=
"
대관목적을 입력해 주세요.
"
/>
{
touched
.
reason
&&
errors
.
reason
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
reason
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
FieldArray
name
=
"
students
"
>
{({
insert
,
remove
,
push
})
=>
(
<
div
>
<
div
>
<
label
>
이용자
<
/label
>
{
time
(
values
.
starttime
)}
{
<
/div
>
values
.
students
.
map
((
student
,
index
)
=>
(
<
/div
>
<
div
className
=
"
row
"
key
=
{
index
}
>
<
div
className
=
"
col
"
>
<
div
className
=
"
form-group mb-4
"
>
<
div
className
=
{
touched
.
room
&&
errors
.
room
?
"
text-danger
"
:
""
}
>
강의실
<
/div
>
<
Field
as
=
"
select
"
name
=
"
room
"
>
<
option
value
=
""
>
강의실을
선택하세요
<
/option
>
<
option
value
=
"
9-116
"
>
9
-
116
<
/option
>
<
option
value
=
"
7-234
"
>
7
-
234
<
/option
>
<
option
value
=
"
25-101
"
>
25
-
101
<
/option
>
<
/Field
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
div
className
=
{
touched
.
reason
&&
errors
.
reason
?
"
text-danger
"
:
""
}
>
대관
목적
<
/div
>
<
input
className
=
{(
touched
.
reason
&&
errors
.
reason
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
reason
"
{...
getFieldProps
(
'
reason
'
)}
placeholder
=
"
대관목적을 입력해 주세요.
"
/>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
FieldArray
name
=
"
students
"
>
{({
insert
,
remove
,
push
})
=>
(
<
div
>
<
div
className
=
{
touched
.
date
&&
errors
.
date
?
"
text-danger
"
:
""
}
>
이용자
<
/div
>
{
values
.
students
.
map
((
student
,
index
)
=>
(
<
Row
key
=
{
index
}
>
<
Field
<
Field
name
=
{
`students.
${
index
}
.member`
}
name
=
{
`students.
${
index
}
.member`
}
placeholder
=
"
이용자 성함을 입력하세요.
"
placeholder
=
"
이용자 성함을 입력하세요.
"
...
@@ -207,32 +206,29 @@ function Apply(props) {
...
@@ -207,32 +206,29 @@ function Apply(props) {
type
=
"
button
"
type
=
"
button
"
className
=
"
secondary
"
className
=
"
secondary
"
onClick
=
{()
=>
remove
(
index
)}
onClick
=
{()
=>
remove
(
index
)}
>
>
X
<
/button
>
X
<
/Row
>
<
/button
>
))}
<
/div
>
<
button
<
/div
>
type
=
"
button
"
))}
className
=
"
btn btn-primary
"
<
button
onClick
=
{()
=>
push
({
member
:
''
})}
type
=
"
button
"
>
추가
<
/button
>
className
=
"
btn btn-primary
"
<
/div
>
onClick
=
{()
=>
push
({
member
:
''
})}
)}
>
<
/FieldArray
>
추가
<
/div
>
<
/button
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
<
/div
>
신청하기
)}
<
/button
>
<
/FieldArray
>
<
/form
>
<
/div
>
)}
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
<
/Formik
>
신청하기
<
/Col
>
<
/button
>
<
/Row
>
<
/form
>
<
/Container
>
<
/div
>
)}
<
/Formik
>
<
/div
>
<
/div
>
)
)
}
}
export
default
Apply
export
default
Apply
\ No newline at end of file
server/client/src/Pages/ChangePage.js
View file @
5d0a841d
...
@@ -4,7 +4,7 @@ import * as Yup from 'yup';
...
@@ -4,7 +4,7 @@ import * as Yup from 'yup';
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Container
,
Button
,
Col
}
from
'
react-bootstrap
'
;
import
{
Container
,
Button
,
Navbar
,
Col
}
from
'
react-bootstrap
'
;
import
styled
from
'
styled-components
'
;
import
styled
from
'
styled-components
'
;
const
Check
=
styled
.
div
`
const
Check
=
styled
.
div
`
...
@@ -30,7 +30,13 @@ function Change(props) {
...
@@ -30,7 +30,13 @@ function Change(props) {
// console.log(props)
// console.log(props)
return
(
return
(
<
div
className
=
""
>
<
div
className
=
""
>
<
Menu
/>
{(
localStorage
.
getItem
(
"
token
"
)
!==
null
)
?
(
<
Menu
/>
)
:
(
<
Menu
expand
=
"
md
"
variant
=
"
dark
"
>
<
Navbar
.
Brand
>
회원가입
<
/Navbar.Brand
>
<
/Menu
>
)}
<
Container
fluid
className
=
"
p-0 vh-90
"
>
<
Container
fluid
className
=
"
p-0 vh-90
"
>
<
Check
className
=
"
row justify-content-center m-0
"
>
<
Check
className
=
"
row justify-content-center m-0
"
>
<
Col
md
=
{
4
}
className
=
"
pt-5
"
>
<
Col
md
=
{
4
}
className
=
"
pt-5
"
>
...
...
server/client/src/Pages/CheckPage.js
View file @
5d0a841d
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
Table
from
'
react-bootstrap/Table
'
import
Table
from
'
react-bootstrap/Table
'
import
{
Container
}
from
'
react-bootstrap
'
;
import
{
Container
}
from
'
react-bootstrap
'
;
...
@@ -30,20 +31,31 @@ margin-top: 0.5em;
...
@@ -30,20 +31,31 @@ margin-top: 0.5em;
function
Check
(
props
)
{
function
Check
(
props
)
{
const
[
reserve
,
setReserve
]
=
useState
([]);
const
[
reserve
,
setReserve
]
=
useState
([]);
const
[
state
,
setState
]
=
useState
()
useEffect
(()
=>
{
useEffect
(()
=>
{
getReserve
();
getReserve
();
},
[])
},
[])
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
getReserve
()
{
function
getReserve
()
{
axios
.
get
(
`/reserves/
${
props
.
match
.
params
.
id
}
`
,
{
axios
.
get
(
`/reserves/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
if
(
res
.
status
===
404
)
{
alert
(
res
.
data
.
error
);
}
if
(
res
.
status
===
419
)
{
alert
(
res
.
data
.
error
);
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
(
true
);
}
}
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
setReserve
(
res
.
data
);
const
reserves
=
res
.
data
.
filter
(
function
(
item
)
{
return
item
!==
''
;
});
setReserve
(
reserves
);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
alert
(
err
.
error
)
alert
(
err
.
error
)
...
...
server/client/src/Pages/HomePage.js
View file @
5d0a841d
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Schedule
from
'
../Components/Schedule
'
;
import
Schedule
from
'
../Components/Schedule
'
;
import
styled
from
'
styled-components
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
moment
from
'
moment
'
;
import
Tabs
from
'
react-bootstrap/Tabs
'
;
import
"
moment/locale/ko
"
;
import
axios
from
'
axios
'
;
import
Tab
from
'
react-bootstrap/Tab
'
;
moment
.
locale
(
"
ko
"
,
{
week
:
{
dow
:
1
}
});
const
Drop
=
styled
.
div
`
& button {
border solid 1px;
}
`
const
Tab
=
styled
.
ul
`
& a, a:hover, a:active {
color: black;
}
`
function
Home
()
{
function
Home
()
{
const
[
show
,
setShow
]
=
useState
(
false
);
const
[
key
,
setKey
]
=
useState
(
'
9-116
'
);
const
[
weeks
,
setWeeks
]
=
useState
([]);
const
[
state
,
setState
]
=
useState
()
const
[
days
,
setDays
]
=
useState
([]);
const
[
sendDate
,
setSendDate
]
=
useState
(
null
);
useEffect
(()
=>
{
useEffect
(()
=>
{
Dateform
();
tcheck
();
},
[]);
},
[]);
function
Dateform
()
{
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
let
today
=
moment
();
let
weeks
=
[];
let
dates
=
[];
let
sendDates
=
[];
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
if
(
i
!==
0
)
{
today
.
add
(
7
,
'
d
'
);
}
let
date
=
{
start
:
null
,
end
:
null
};
date
.
start
=
today
.
startOf
(
'
week
'
).
format
(
"
MMM Do
"
);
date
.
end
=
today
.
endOf
(
'
week
'
).
weekday
(
4
).
format
(
"
MMM Do
"
);
dates
.
push
(
date
);
const
week
=
date
.
start
+
"
~
"
+
date
.
end
;
weeks
.
push
(
week
);
let
sendDate
=
today
.
startOf
(
'
week
'
).
format
(
"
YYYY-MM-DD
"
);
sendDates
.
push
(
sendDate
);
};
setWeeks
([...
weeks
])
setDays
([...
sendDates
])
};
function
choose
(
e
,
index
)
{
function
tcheck
()
{
setShow
(
true
)
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
setSendDate
(
days
[
index
])
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
(
true
);
}
}).
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
}
return
(
return
(
...
@@ -75,52 +43,30 @@ function Home() {
...
@@ -75,52 +43,30 @@ function Home() {
<
li
>
주말
:
이용
불가
<
/li
>
<
li
>
주말
:
이용
불가
<
/li
>
<
/ul
>
<
/ul
>
<
/p
>
<
/p
>
<
Tabs
defaultActiveKey
=
"
9-116
"
id
=
"
uncontrolled-tab-example
"
onSelect
=
{(
k
)
=>
setKey
(
k
)}
>
<
Drop
className
=
"
row dropdown mt-1 mb-2
"
>
<
Tab
eventKey
=
"
9-116
"
title
=
"
9-116
"
>
<
button
className
=
"
btn btn-lg dropdown-toggle mx-auto col-5
"
type
=
"
button
"
id
=
"
dropdownMenuButton
"
data
-
toggle
=
"
dropdown
"
aria
-
haspopup
=
"
true
"
aria
-
expanded
=
"
false
"
>
<
Schedule
room
=
{
key
}
/
>
기간을
선택해주십시오
.
<
/Tab
>
<
/button
>
<
Tab
eventKey
=
"
7-234
"
title
=
"
7-234
"
>
<
div
className
=
"
dropdown-menu col-5
"
aria
-
labelledby
=
"
dropdownMenuButton
"
>
<
Schedule
room
=
{
key
}
/
>
{
weeks
.
map
((
week
,
index
)
=>
(
<
a
className
=
"
dropdown-item
"
id
=
{
index
}
onClick
=
{(
e
)
=>
choose
(
e
,
index
)}
>
{
week
}
<
/a
>
))}
<
/div
>
<
/Drop
>
<
Tab
className
=
"
nav nav-tabs nav-justified mt-4
"
id
=
"
myTab
"
role
=
"
tablist
"
style
=
{
show
?
{}
:
{
display
:
"
none
"
}}
>
<
li
className
=
"
nav-item
"
>
<
a
className
=
"
nav-link active
"
id
=
"
7-tab
"
data
-
toggle
=
"
tab
"
href
=
"
#tab-7
"
role
=
"
tab
"
aria
-
controls
=
"
7
"
aria
-
selected
=
"
true
"
>
7
-
223
<
/a
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
a
className
=
"
nav-link
"
id
=
"
9-tab
"
data
-
toggle
=
"
tab
"
href
=
"
#tab-9
"
role
=
"
tab
"
aria
-
controls
=
"
9
"
aria
-
selected
=
"
false
"
>
9
-
116
<
/a
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
a
className
=
"
nav-link
"
id
=
"
25-tab
"
data
-
toggle
=
"
tab
"
href
=
"
#tab-25
"
role
=
"
tab
"
aria
-
controls
=
"
25
"
aria
-
selected
=
"
false
"
>
25
-
307
<
/a
>
<
/li
>
<
/Tab
>
<
/Tab
>
<
div
className
=
"
tab-content row justify-content-center
"
id
=
"
myTabContent
"
style
=
{
show
?
{}
:
{
display
:
"
none
"
}}
>
<
Tab
eventKey
=
"
25-101
"
title
=
"
25-101
"
>
<
div
className
=
"
tab-pane fade show active col-md-11 col-12
"
id
=
"
tab-7
"
role
=
"
tabpanel
"
aria
-
labelledby
=
"
7-tab
"
>
<
Schedule
room
=
{
key
}
/
>
<
Schedule
day
=
{
sendDate
}
/
>
<
/Tab
>
<
/div
>
<
/Tabs
>
<
div
className
=
"
tab-pane fade col-md-11 col-12
"
id
=
"
tab-9
"
role
=
"
tabpanel
"
aria
-
labelledby
=
"
9-tab
"
>
<
h3
>
유의사항
<
/h3
>
<
Schedule
day
=
{
sendDate
}
/
>
<
p
>
<
/div
>
<
ul
>
<
div
className
=
"
tab-pane fade col-md-11 col-12
"
id
=
"
tab-25
"
role
=
"
tabpanel
"
aria
-
labelledby
=
"
25-tab
"
>
<
li
>
강의실을
대관하는
대표자를
기준으로
최대
주
6
시간까지
대관이
가능합니다
.
<
/li
>
<
Schedule
day
=
{
sendDate
}
/
>
<
li
>
1
회
대관시
최대
3
시간까지
이용이
가능합니다
.
(
1
시간
단위로
대관
가능
)
<
/li
>
<
/div
>
<
li
><
strong
style
=
{{
color
:
"
red
"
}}
>
대관
시간
이외
강의실을
이용하다
적발될
경우
한달
간
강의실
이용이
불가합니다
.
<
/strong></
li
>
<
/div
>
<
/ul
>
<
h3
>
유의사항
<
/h3
>
<
/p
>
<
p
>
<
div
className
=
"
bg-white
"
>
<
ul
>
<
h6
>
고려대학교
대관시스템
<
/h6
>
<
li
>
강의실을
대관하는
대표자를
기준으로
최대
주
6
시간까지
대관이
가능합니다
.
<
/li
>
<
li
>
1
회
대관시
최대
3
시간까지
이용이
가능합니다
.
(
1
시간
단위로
대관
가능
)
<
/li
>
<
li
><
strong
style
=
{{
color
:
"
red
"
}}
>
대관
시간
이외
강의실을
이용하다
적발될
경우
한달
간
강의실
이용이
불가합니다
.
<
/strong></
li
>
<
/ul
>
<
/p
>
<
div
className
=
"
bg-white
"
>
<
h6
>
고려대학교
대관시스템
<
/h6
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
...
...
server/client/src/Pages/NoticePage.js
View file @
5d0a841d
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
Link
}
from
'
react-router-dom
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Container
,
Row
,
Col
,
Card
,
Accordion
,
Button
}
from
'
react-bootstrap
'
;
import
{
Container
,
Row
,
Col
,
Card
,
Accordion
,
Button
}
from
'
react-bootstrap
'
;
function
Notice
()
{
function
Notice
()
{
const
[
show
,
setShow
]
=
useState
(
false
);
const
[
notices
,
setNotices
]
=
useState
([]);
const
[
notices
,
setNotices
]
=
useState
([]);
const
[
user
,
setUser
]
=
useState
({
role
:
""
})
const
[
user
,
setUser
]
=
useState
({
role
:
""
})
const
[
state
,
setState
]
=
useState
()
useEffect
(()
=>
{
useEffect
(()
=>
{
acheck
();
acheck
();
getNotice
();
getNotice
();
},
[]);
},
[]);
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
acheck
()
{
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
(
true
);
}
if
(
res
.
data
.
role
==
"
admin
"
)
{
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
setUser
(
res
.
data
)
}
}
...
@@ -49,6 +60,7 @@ function Notice() {
...
@@ -49,6 +60,7 @@ function Notice() {
alert
(
err
.
error
)
alert
(
err
.
error
)
});
});
}
}
return
(
return
(
<
div
>
<
div
>
<
style
type
=
"
text/css
"
>
<
style
type
=
"
text/css
"
>
...
@@ -73,11 +85,12 @@ function Notice() {
...
@@ -73,11 +85,12 @@ function Notice() {
<
Accordion
>
<
Accordion
>
{
notices
.
map
((
notice
,
index
)
=>
{
notices
.
map
((
notice
,
index
)
=>
<
Card
>
<
Card
>
<
Card
.
Header
>
<
Card
.
Header
className
=
"
d-flex justify-content-between
"
>
<
Accordion
.
Toggle
as
=
{
Button
}
variant
=
"
link hidden
"
eventKey
=
{
index
+
1
}
>
{
notice
.
notice_title
}
<
span
className
=
"
text-right
"
>
{
dateForm
(
notice
.
post_date
)}
<
/span></
Accordion
.
Toggle
>
<
Accordion
.
Toggle
as
=
{
Button
}
variant
=
"
link
"
eventKey
=
{
index
+
1
}
className
=
{
"
d-inline-block
"
+
(
show
?
"
text-wrap
"
:
"
text-truncate
"
)}
onClick
=
{()
=>
setShow
(
!
show
)}
>
{
notice
.
notice_title
}
<
/Accordion.Toggle
>
<
span
className
=
"
d-flex align-items-center
"
style
=
{{
width
:
"
50%
"
}}
>
{
dateForm
(
notice
.
post_date
)}
<
/span
>
<
/Card.Header
>
<
/Card.Header
>
<
Accordion
.
Collapse
eventKey
=
{
index
+
1
}
>
<
Accordion
.
Collapse
eventKey
=
{
index
+
1
}
>
<
Card
.
Body
>
{
notice
.
notice_content
}
<
/Card.Body
>
<
Card
.
Body
>
<
pre
>
{
notice
.
notice_content
}
<
/
pre></
Card
.
Body
>
<
/Accordion.Collapse
>
<
/Accordion.Collapse
>
<
/Card>
)
}
<
/Card>
)
}
<
/Accordion
>
<
/Accordion
>
...
...
server/client/src/Pages/WritePage.js
View file @
5d0a841d
...
@@ -67,11 +67,8 @@ function Write() {
...
@@ -67,11 +67,8 @@ function Write() {
<
div
className
=
"
form-group
"
>
<
div
className
=
"
form-group
"
>
{
/* mb-4 */
}
{
/* mb-4 */
}
<
div
className
=
{
touched
.
name
&&
errors
.
name
?
"
text-danger
"
:
""
}
>
내용
<
/div
>
<
div
className
=
{
touched
.
name
&&
errors
.
name
?
"
text-danger
"
:
""
}
>
내용
<
/div
>
<
input
className
=
{(
touched
.
name
&&
errors
.
name
?
'
form-control is-invalid
'
:
"
form-control
"
)}
<
Field
as
=
"
textarea
"
rows
=
{
8
}
cols
=
{
175
}
type
=
"
text
"
{...
getFieldProps
(
'
content
'
)}
/
>
content
=
"
content
"
{...
getFieldProps
(
'
content
'
)}
placeholder
=
"
내용
"
/>
<
/div
>
<
/div
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
공지
등록
<
/button
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
공지
등록
<
/button
>
<
/form
>
<
/form
>
...
...
server/routes/login.js
View file @
5d0a841d
...
@@ -37,7 +37,7 @@ router.post('/', function (req, res, next) {
...
@@ -37,7 +37,7 @@ router.post('/', function (req, res, next) {
const
token
=
jwt
.
sign
({
const
token
=
jwt
.
sign
({
id
:
users
.
id
,
id
:
users
.
id
,
},
process
.
env
.
JWT_SECRET
,
{
},
process
.
env
.
JWT_SECRET
,
{
expiresIn
:
'
1
m
'
,
expiresIn
:
'
1
h
'
,
});
});
return
res
.
status
(
201
).
json
({
return
res
.
status
(
201
).
json
({
token
,
token
,
...
...
server/routes/reserves.js
View file @
5d0a841d
...
@@ -17,7 +17,8 @@ router.post('/', function (req, res, next) {
...
@@ -17,7 +17,8 @@ router.post('/', function (req, res, next) {
room
:
req
.
body
.
room
,
room
:
req
.
body
.
room
,
reason
:
req
.
body
.
reason
,
reason
:
req
.
body
.
reason
,
students
:
req
.
body
.
students
,
students
:
req
.
body
.
students
,
approve
:
req
.
body
.
approve
,
approve
:
true
,
check
:
true
,
num
:
req
.
body
.
students
.
length
+
1
,
num
:
req
.
body
.
students
.
length
+
1
,
});
});
...
@@ -38,8 +39,8 @@ router.post('/', function (req, res, next) {
...
@@ -38,8 +39,8 @@ router.post('/', function (req, res, next) {
const
strt
=
new
Date
(
reserve
.
start
)
const
strt
=
new
Date
(
reserve
.
start
)
const
endt
=
new
Date
(
reserve
.
end
)
const
endt
=
new
Date
(
reserve
.
end
)
const
reserveArr
=
reserves
.
map
(
item
=>
(
const
reserveArr
=
reserves
.
map
(
item
=>
(
(
strt
>=
new
Date
(
item
.
start
)
&&
strt
<
=
new
Date
(
item
.
end
))
||
(
strt
>=
new
Date
(
item
.
start
)
&&
strt
<
new
Date
(
item
.
end
))
||
(
endt
>
=
new
Date
(
item
.
start
)
&&
endt
<=
new
Date
(
item
.
end
))
?
(
endt
>
new
Date
(
item
.
start
)
&&
endt
<=
new
Date
(
item
.
end
))
?
"
item
"
:
"
item
"
:
null
null
))
))
...
@@ -70,15 +71,25 @@ router.get('/room/:room', function (req, res, next) {
...
@@ -70,15 +71,25 @@ router.get('/room/:room', function (req, res, next) {
})
})
// router.get('/:_id', verifyToken, function (req, res, next) {
// router.get('/:_id', verifyToken, function (req, res, next) {
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'
/:_id
'
,
verifyToken
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
res
.
status
(
201
).
json
(
reserve
);
// console.log(reserve, Date.now())
const
reserves
=
reserve
.
map
(
item
=>
(
new
Date
(
item
.
end
)
>=
Date
.
now
()
?
item
:
""
));
if
(
!
reserves
)
{
console
.
log
(
"
no신청
"
)
res
.
status
(
404
).
json
({
error
:
"
신청내역이 없습니다.
"
})
}
console
.
log
(
"
reserves
"
,
reserves
)
res
.
status
(
201
).
json
(
reserves
);
})
})
});
});
router
.
get
(
'
/admin/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'
/admin/:_id
'
,
verifyToken
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves/admin get req.params
'
,
req
.
params
)
console
.
log
(
'
/reserves/admin get req.params
'
,
req
.
params
)
Reserve
.
find
({
approve
:
false
}).
populate
(
'
user
'
).
exec
(
function
(
err
,
reserve
)
{
Reserve
.
find
({
approve
:
false
}).
populate
(
'
user
'
).
exec
(
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
...
...
server/routes/users.js
View file @
5d0a841d
...
@@ -34,7 +34,7 @@ router.post('/', function (req, res, next) {
...
@@ -34,7 +34,7 @@ router.post('/', function (req, res, next) {
})
})
});
});
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'
/:_id
'
,
verifyToken
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/users get req.params
'
,
req
.
params
)
console
.
log
(
'
/users get req.params
'
,
req
.
params
)
User
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
user
)
{
User
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
user
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
...
...
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