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
ec0852e1
Commit
ec0852e1
authored
Nov 05, 2020
by
Kim, Subin
Browse files
채린+진주+수빈 병합
parents
f9eab7b0
5d0a841d
Changes
10
Show whitespace changes
Inline
Side-by-side
server/client/src/Components/Menu.js
View file @
ec0852e1
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
'
;
import
{
Navbar
,
Nav
,
NavLink
}
from
'
react-bootstrap
'
;
const
MENU
=
styled
(
Navbar
)
`
background-color: #7B031D;
...
...
@@ -28,8 +28,10 @@ function Menu() {
},
[])
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
.
then
(
res
=>
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
}).
then
(
res
=>
{
console
.
log
(
res
.
data
)
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
}
...
...
@@ -59,12 +61,12 @@ function Menu() {
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
<
/NavLink
>
{
user
.
role
===
"
admin
"
?
(
{
/*
{user.role === "admin" ? (
<NavLink as={Link} to={{
pathname: `/acheck/${localStorage.getItem('_id')}`,
state: { id: localStorage.getItem('_id') },
}} className="nav-link">
대관
확인
/
취소
(
관리자
)
<
/NavLink>
)
: null
}
대관 확인/취소(관리자)</NavLink>) : null}
*/
}
<
/Nav
>
<
Nav
>
<
NavLink
>
...
...
server/client/src/Pages/ACheckPage.js
View file @
ec0852e1
...
...
@@ -2,10 +2,31 @@ import React, { useState, useEffect } from 'react';
import
Menu
from
'
../Components/Menu
'
;
import
axios
from
'
axios
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Container
,
Table
}
from
'
react-bootstrap
'
;
import
styled
from
'
styled-components
'
;
const
Ta
=
styled
(
Table
)
`
& th, & td {
padding: 0;
vertical-align: middle;
};
& tr {
display: d-flex;
width: 50px;
};
& td {
align-items: center;
width: 70px;
};
`
function
ACheck
(
props
)
{
const
[
state
,
setState
]
=
useState
()
const
[
reserve
,
setReserve
]
=
useState
([]);
useEffect
(()
=>
{
getReserve
();
},
[])
...
...
@@ -57,16 +78,17 @@ function ACheck(props) {
return
(
<
div
>
<
Menu
/>
<
div
className
=
""
>
<
table
className
=
"
table
"
>
<
thead
>
<
Container
fluid
>
<
Ta
responsive
=
"
lg
"
>
<
thead
className
=
"
thead-light
"
>
<
tr
>
<
th
>
대표자
<
/th
>
<
th
>
날짜
<
/th
>
<
th
>
시간
<
/th
>
<
th
>
강의실
<
/th
>
<
th
>
사용인원
<
/th
>
<
th
>
승인여부
<
/th
>
<
th
>
사용
인원
<
/th
>
<
th
>
승인
여부
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
...
...
@@ -80,10 +102,10 @@ function ACheck(props) {
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
admit
(
index
)}
className
=
"
btn btn-primary
"
>
<
button
onClick
=
{()
=>
admit
(
index
)}
className
=
"
btn btn-primary
btn-sm
"
>
승인
<
/button
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
btn-sm
"
>
거절
<
/button
>
<
/td
>
...
...
@@ -91,9 +113,8 @@ function ACheck(props) {
)
}))
:
<
div
>
최근
대관
신청
내역이
없습니다
.
<
/div>
}
<
/tbody
>
<
/table
>
<
/div
>
<
/Ta
>
<
/Container
>
<
/div
>
)
}
...
...
server/client/src/Pages/ApplyPage.js
View file @
ec0852e1
...
...
@@ -7,15 +7,15 @@ import { Redirect } from 'react-router-dom';
import
{
Col
,
Container
,
Row
}
from
'
react-bootstrap
'
;
function
Apply
(
props
)
{
const
[
state
,
setState
]
=
useState
();
const
[
state
,
setState
]
=
useState
(
{
ok
:
""
}
);
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
const
[
room_Num
,
setRoom_Num
]
=
useState
({
"
9-116
"
:
5
,
"
7-234
"
:
7
,
"
25-101
"
:
10
});
useEffect
(()
=>
{
getUser
();
},
[])
if
(
state
)
{
if
(
state
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
.
ok
===
"
ok
"
)
{
return
<
Redirect
to
=
{{
pathname
:
`/check/
${
props
.
match
.
params
.
id
}
`
,
state
:
{
id
:
props
.
match
.
params
.
id
},
...
...
@@ -51,6 +51,8 @@ function Apply(props) {
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
({
ok
:
"
no
"
});
}
console
.
log
(
res
.
data
);
setUser
(
res
.
data
);
...
...
@@ -106,7 +108,7 @@ function Apply(props) {
return
window
.
location
.
reload
();
}
alert
(
"
신청이 완료되었습니다!
"
);
setState
(
true
);
setState
(
{
ok
:
"
ok
"
}
);
console
.
log
(
"
res.data
"
,
res
.
data
)
})
.
catch
(
err
=>
{
...
...
server/client/src/Pages/CheckPage.js
View file @
ec0852e1
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
axios
from
'
axios
'
;
import
Table
from
'
react-bootstrap/Table
'
import
{
Container
}
from
'
react-bootstrap
'
;
import
styled
from
'
styled-components
'
;
const
Ta
=
styled
(
Table
)
`
margin-top: 0.5em;
& th, & td {
padding: 0;
vertical-align: middle;
font-size: 0.9rem;
margin-left : auto; margin-right : auto;
border-spacing: initial;
};
& tr {
display: d-flex;
width: 150px;
};
& td {
align-items: center;
margin: 10px;
};
`
function
Check
(
props
)
{
const
[
reserve
,
setReserve
]
=
useState
([]);
const
[
state
,
setState
]
=
useState
()
useEffect
(()
=>
{
getReserve
();
},
[])
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
getReserve
()
{
axios
.
get
(
`/reserves/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
if
(
res
.
status
===
404
)
{
alert
(
res
.
data
.
error
);
}
if
(
res
.
status
===
419
)
{
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
(
true
);
}
console
.
log
(
res
.
data
);
setReserve
(
res
.
data
);
const
reserves
=
res
.
data
.
filter
(
function
(
item
)
{
return
item
!==
''
;
});
setReserve
(
reserves
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
...
...
@@ -38,29 +76,29 @@ function Check(props) {
return
(
<
div
>
<
Menu
/>
<
div
className
=
""
>
<
table
className
=
"
table
"
>
<
thead
>
<
Container
fluid
>
<
Ta
responsive
=
"
lg ml-2rem
"
>
<
thead
className
=
"
thead-light
"
>
<
tr
>
<
th
>
날짜
<
/th
>
<
th
>
시간
<
/th
>
<
th
>
강의실
<
/th
>
<
th
>
사용인원
<
/th
>
<
th
>
승인여부
<
/th
>
<
th
>
예약취소
<
/th
>
<
th
className
=
"
text-center
"
>
날짜
<
/th
>
<
th
className
=
"
text-center
"
>
시간
<
/th
>
<
th
className
=
"
text-center
"
>
강의실
<
/th
>
<
th
className
=
"
text-center
"
>
사용인원
<
/th
>
{
/*
<th>승인여부</th>
*/
}
<
th
className
=
"
text-center
"
>
예약취소
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
{
reserve
.
map
((
reserve
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
{
reserve
.
check
?
(
reserve
.
approve
?
"
사용가능
"
:
"
사용불가
"
)
:
"
승인대기중
"
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
<
td
className
=
"
text-center
"
>
{
reserve
.
date
}
<
/td
>
<
td
className
=
"
text-center
"
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
className
=
"
text-center
"
>
{
reserve
.
room
}
<
/td
>
<
td
className
=
"
text-center
"
>
{
reserve
.
num
}
<
/td
>
{
/*
<td>{reserve.check ? (reserve.approve ? "사용가능" : "사용불가") : "승인대기중"}</td>
*/
}
<
td
className
=
"
text-center
"
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
btn-sm
"
>
취소
<
/button
>
<
/td
>
...
...
@@ -68,9 +106,8 @@ function Check(props) {
)
})}
<
/tbody
>
<
/table
>
<
/div
>
<
/Ta
>
<
/Container
>
<
/div
>
)
}
...
...
server/client/src/Pages/HomePage.js
View file @
ec0852e1
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
axios
from
'
axios
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Schedule
from
'
../Components/Schedule
'
;
import
{
Container
,
Tabs
,
Tab
}
from
'
react-bootstrap
'
;
function
Home
()
{
const
[
key
,
setKey
]
=
useState
(
'
9-116
'
);
const
[
state
,
setState
]
=
useState
()
useEffect
(()
=>
{
tcheck
();
},
[]);
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
tcheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
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
(
<
div
>
...
...
@@ -28,13 +52,13 @@ function Home() {
<
/p
>
<
Tabs
defaultActiveKey
=
"
9-116
"
id
=
"
uncontrolled-tab-example
"
onSelect
=
{(
k
)
=>
setKey
(
k
)}
>
<
Tab
eventKey
=
"
9-116
"
title
=
"
9-116
"
>
<
Schedule
room
=
{
key
}
/
>
<
Schedule
room
=
{
key
}
/
>
<
/Tab
>
<
Tab
eventKey
=
"
7-234
"
title
=
"
7-234
"
>
<
Schedule
room
=
{
key
}
/
>
<
Schedule
room
=
{
key
}
/
>
<
/Tab
>
<
Tab
eventKey
=
"
25-101
"
title
=
"
25-101
"
>
<
Schedule
room
=
{
key
}
/
>
<
Schedule
room
=
{
key
}
/
>
<
/Tab
>
<
/Tabs
>
<
/Container
>
...
...
server/client/src/Pages/NoticePage.js
View file @
ec0852e1
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
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
CARD
from
'
../Components/Card
'
;
...
...
@@ -9,15 +9,25 @@ function Notice() {
const
[
show
,
setShow
]
=
useState
(
false
);
const
[
notices
,
setNotices
]
=
useState
([]);
const
[
user
,
setUser
]
=
useState
({
role
:
""
})
const
[
state
,
setState
]
=
useState
()
useEffect
(()
=>
{
acheck
();
getNotice
();
},
[]);
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
)
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
setState
(
true
);
}
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
}
...
...
server/client/src/Pages/SignupPage.js
View file @
ec0852e1
...
...
@@ -67,7 +67,6 @@ function Signup() {
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
회원가입이 완료되었습니다!
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
...
...
server/routes/login.js
View file @
ec0852e1
...
...
@@ -37,7 +37,7 @@ router.post('/', function (req, res, next) {
const
token
=
jwt
.
sign
({
id
:
users
.
id
,
},
process
.
env
.
JWT_SECRET
,
{
expiresIn
:
'
1
m
'
,
expiresIn
:
'
1
h
'
,
});
return
res
.
status
(
201
).
json
({
token
,
...
...
server/routes/reserves.js
View file @
ec0852e1
...
...
@@ -27,7 +27,8 @@ router.post('/', function (req, res, next) {
room
:
req
.
body
.
room
,
reason
:
req
.
body
.
reason
,
students
:
req
.
body
.
students
,
approve
:
req
.
body
.
approve
,
approve
:
true
,
check
:
true
,
num
:
req
.
body
.
students
.
length
+
1
,
});
...
...
@@ -79,15 +80,25 @@ router.get('/room/:room', 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
)
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
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
)
Reserve
.
find
({
approve
:
false
}).
populate
(
'
user
'
).
exec
(
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
...
...
server/routes/users.js
View file @
ec0852e1
...
...
@@ -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
)
User
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
user
)
{
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