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
f3752c81
Commit
f3752c81
authored
Oct 31, 2020
by
CHAERIN KIM
Browse files
관리자페이지-미승인,숨김
parent
d910be68
Changes
6
Show whitespace changes
Inline
Side-by-side
server/client/package.json
View file @
f3752c81
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
"bootstrap"
:
"^4.5.2"
,
"bootstrap"
:
"^4.5.2"
,
"formik"
:
"^2.1.5"
,
"formik"
:
"^2.1.5"
,
"jquery"
:
"^3.5.1"
,
"jquery"
:
"^3.5.1"
,
"moment"
:
"^2.29.
0
"
,
"moment"
:
"^2.29.
1
"
,
"popper.js"
:
"^1.16.1"
,
"popper.js"
:
"^1.16.1"
,
"react"
:
"^16.13.1"
,
"react"
:
"^16.13.1"
,
"react-dom"
:
"^16.13.1"
,
"react-dom"
:
"^16.13.1"
,
...
...
server/client/src/Components/Menu.js
View file @
f3752c81
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
'
;
...
@@ -17,8 +18,13 @@ const Nav = styled.nav`
...
@@ -17,8 +18,13 @@ const Nav = styled.nav`
function
Menu
()
{
function
Menu
()
{
const
[
state
,
setState
]
=
useState
()
const
[
state
,
setState
]
=
useState
()
const
[
user
,
setUser
]
=
useState
({
role
:
""
})
const
name
=
localStorage
.
getItem
(
'
name
'
);
const
name
=
localStorage
.
getItem
(
'
name
'
);
useEffect
(()
=>
{
acheck
();
},
[])
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
logout
()
{
function
logout
()
{
...
@@ -27,6 +33,17 @@ function Menu() {
...
@@ -27,6 +33,17 @@ function Menu() {
setState
(
true
);
setState
(
true
);
}
}
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
.
then
(
res
=>
{
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
}
}).
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
return
(
return
(
<
Nav
className
=
"
navbar sticky-top navbar-expand-md
"
>
<
Nav
className
=
"
navbar sticky-top navbar-expand-md
"
>
<
a
class
=
"
navbar-brand
"
href
=
"
#
"
>
대관
서비스
<
/a
>
<
a
class
=
"
navbar-brand
"
href
=
"
#
"
>
대관
서비스
<
/a
>
...
@@ -54,20 +71,21 @@ function Menu() {
...
@@ -54,20 +71,21 @@ function Menu() {
}}
className
=
"
nav-link
"
>
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
<
/Link
>
대관
확인
/
취소
<
/Link
>
<
/li
>
<
/li
>
{
user
.
role
===
"
admin
"
?
(
<
li
className
=
"
nav-item
"
>
<
li
className
=
"
nav-item
"
>
<
Link
to
=
{{
<
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
"
>
대관
확인
/
취소
(
관리자
)
<
/Link
>
대관
확인
/
취소
(
관리자
)
<
/Link
>
<
/li
>
<
/li>
)
: null
}
<
/ul
>
<
/ul
>
<
div
className
=
"
h-100 mr-3
"
>
<
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
>
{
name
}
님
안녕하세요
<
/small></
div
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
<
Link
to
=
{{
<
Link
to
=
{{
pathname
:
`/change/
${
localStorage
.
getItem
(
'
_id
'
)
}
`
,
pathname
:
`/change/
${
user
.
_id
}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
state
:
{
id
:
user
.
_id
},
}}
>
비밀번호
변경
<
/Link> /
<
span
className
=
"
logoutBtn
"
onClick
=
{
logout
}
>
로그아웃
<
/span></
small
><
/div
>
}}
>
비밀번호
변경
<
/Link> /
<
span
className
=
"
logoutBtn
"
onClick
=
{
logout
}
>
로그아웃
<
/span></
small
><
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
server/client/src/Pages/CheckPage.js
View file @
f3752c81
...
@@ -59,7 +59,7 @@ function Check(props) {
...
@@ -59,7 +59,7 @@ function Check(props) {
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
{
reserve
.
approve
?
"
승인
"
:
"
미승인
"
}
<
/td
>
<
td
>
{
reserve
.
check
?
(
reserve
.
approve
?
"
사용가능
"
:
"
사용불가
"
)
:
"
승인대기중
"
}
<
/td
>
<
td
>
<
td
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
취소
취소
...
...
server/routes/reserves.js
View file @
f3752c81
...
@@ -7,14 +7,13 @@ const router = express.Router();
...
@@ -7,14 +7,13 @@ const router = express.Router();
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserve post req.body
'
,
req
.
body
)
console
.
log
(
'
/reserve post req.body
'
,
req
.
body
)
const
reserve
=
new
Reserve
({
const
reserve
=
new
Reserve
({
user
:
req
.
body
.
_id
,
user
:
req
.
body
.
_id
,
date
:
req
.
body
.
date
,
date
:
req
.
body
.
date
,
starttime
:
Number
(
req
.
body
.
starttime
),
starttime
:
Number
(
req
.
body
.
starttime
),
usetime
:
Number
(
req
.
body
.
usetime
),
usetime
:
Number
(
req
.
body
.
usetime
),
start
:
`
${
req
.
body
.
date
}
T`
+
`
${
req
.
body
.
starttime
}
: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`
,
end
:
`
${
req
.
body
.
date
}
T`
+
`
${
Number
(
req
.
body
.
starttime
)
+
Number
(
req
.
body
.
usetime
)}
:00:00`
,
room
:
req
.
body
.
room
,
room
:
req
.
body
.
room
,
reason
:
req
.
body
.
reason
,
reason
:
req
.
body
.
reason
,
students
:
req
.
body
.
students
,
students
:
req
.
body
.
students
,
...
@@ -22,6 +21,10 @@ router.post('/', function (req, res, next) {
...
@@ -22,6 +21,10 @@ router.post('/', function (req, res, next) {
num
:
req
.
body
.
students
.
length
+
1
,
num
:
req
.
body
.
students
.
length
+
1
,
});
});
Reserve
.
find
({
room
:
req
.
body
.
room
,
approve
:
true
},
function
(
err
,
reserves
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
!
reserves
)
{
reserve
.
save
()
reserve
.
save
()
.
then
((
result
)
=>
{
.
then
((
result
)
=>
{
console
.
log
(
result
);
console
.
log
(
result
);
...
@@ -31,17 +34,47 @@ router.post('/', function (req, res, next) {
...
@@ -31,17 +34,47 @@ router.post('/', function (req, res, next) {
console
.
error
(
err
);
console
.
error
(
err
);
next
(
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', verifyToken, function (req, res, next) {
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'
/:_id
'
,
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
)
{
console
.
log
(
'
id.name
'
,
reserve
)
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
'
reserve list
'
,
reserve
)
res
.
status
(
201
).
json
(
reserve
);
res
.
status
(
201
).
json
(
reserve
);
})
})
});
});
...
@@ -73,9 +106,10 @@ router.delete('/:_id', function (req, res, next) {
...
@@ -73,9 +106,10 @@ router.delete('/:_id', function (req, res, next) {
router
.
put
(
'
/:id
'
,
function
(
req
,
res
,
next
)
{
router
.
put
(
'
/:id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves put req.body
'
,
req
.
params
)
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
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
reserve
.
approve
=
true
;
reserve
.
check
=
true
;
reserve
.
approve
=
req
.
body
.
approve
;
reserve
.
save
()
reserve
.
save
()
.
then
((
result
)
=>
{
.
then
((
result
)
=>
{
console
.
log
(
result
);
console
.
log
(
result
);
...
...
server/schemas/index.js
View file @
f3752c81
...
@@ -5,7 +5,7 @@ module.exports = () => {
...
@@ -5,7 +5,7 @@ module.exports = () => {
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
mongoose
.
set
(
'
debug
'
,
true
);
mongoose
.
set
(
'
debug
'
,
true
);
}
}
mongoose
.
connect
(
'
mongodb://
kimpen:kim65811025
@localhost:27017/admin
'
,
{
mongoose
.
connect
(
'
mongodb://
cherry:1q2w3e4r
@localhost:27017/admin
'
,
{
dbName
:
'
ku_rental
'
,
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
dbName
:
'
ku_rental
'
,
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
},
(
error
)
=>
{
},
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
...
server/schemas/reserve.js
View file @
f3752c81
...
@@ -39,7 +39,10 @@ const reserveSchema = new Schema({
...
@@ -39,7 +39,10 @@ const reserveSchema = new Schema({
approve
:
{
approve
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
false
,
default
:
false
,
},
check
:
{
type
:
Boolean
,
default
:
false
,
},
},
num
:
{
num
:
{
type
:
Number
,
type
:
Number
,
...
...
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