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
653da10e
Commit
653da10e
authored
Oct 09, 2020
by
CHAERIN KIM
Browse files
스키마, 코드 시간표 맞춰 수정
parent
d0f6f520
Changes
4
Show whitespace changes
Inline
Side-by-side
server/client/src/Pages/ApplyPage.js
View file @
653da10e
...
@@ -21,6 +21,30 @@ function Apply(props) {
...
@@ -21,6 +21,30 @@ 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>
)
}
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
()
{
function
getUser
()
{
axios
.
get
(
`/users/
${
props
.
match
.
params
.
id
}
`
,
{
axios
.
get
(
`/users/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
...
@@ -44,7 +68,8 @@ function Apply(props) {
...
@@ -44,7 +68,8 @@ function Apply(props) {
initialValues
=
{{
initialValues
=
{{
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
date
:
''
,
date
:
''
,
time
:
''
,
starttime
:
''
,
usetime
:
''
,
room
:
''
,
room
:
''
,
reason
:
''
,
reason
:
''
,
students
:
[
students
:
[
...
@@ -56,8 +81,6 @@ function Apply(props) {
...
@@ -56,8 +81,6 @@ function Apply(props) {
validationSchema
=
{
Yup
.
object
({
validationSchema
=
{
Yup
.
object
({
date
:
Yup
.
string
()
date
:
Yup
.
string
()
.
required
(
'
날짜를 입력해주세요.
'
),
.
required
(
'
날짜를 입력해주세요.
'
),
time
:
Yup
.
string
()
.
required
(
'
시간을 입력해주세요.
'
),
room
:
Yup
.
string
()
room
:
Yup
.
string
()
.
required
(
'
강의실 번호를 입력해주세요.
'
),
.
required
(
'
강의실 번호를 입력해주세요.
'
),
reason
:
Yup
.
string
()
reason
:
Yup
.
string
()
...
@@ -92,7 +115,6 @@ function Apply(props) {
...
@@ -92,7 +115,6 @@ function Apply(props) {
isSubmitting
,
isSubmitting
,
})
=>
(
})
=>
(
<
div
className
=
"
row justify-content-center align-items-center
"
>
<
div
className
=
"
row justify-content-center align-items-center
"
>
{
console
.
log
(
user
)}
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
col-sm-3
"
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
col-sm-3
"
>
<
div
className
=
"
form-group mb-4
"
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
대표자
<
/label
>
<
label
>
대표자
<
/label
>
...
@@ -102,27 +124,37 @@ function Apply(props) {
...
@@ -102,27 +124,37 @@ function Apply(props) {
<
label
>
신청날짜
<
/label
>
<
label
>
신청날짜
<
/label
>
<
input
<
input
className
=
{(
touched
.
date
&&
errors
.
date
?
'
form-control is-invalid
'
:
"
form-control
"
)}
className
=
{(
touched
.
date
&&
errors
.
date
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
number
"
type
=
"
text
"
name
=
"
date
"
name
=
"
date
"
{...
getFieldProps
(
'
date
'
)}
{...
getFieldProps
(
'
date
'
)}
placeholder
=
"
2020
mmdd
"
placeholder
=
"
yyyy-
mm
-
dd
"
/>
/>
{
touched
.
date
&&
errors
.
date
?
(
{
touched
.
date
&&
errors
.
date
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
date
}
<
/div
>
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
date
}
<
/div
>
)
:
null
}
)
:
null
}
<
/div
>
<
/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
"
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시간
<
/label
>
<
label
>
이용시간
<
/label
>
<
input
{
time
(
values
.
starttime
)}
className
=
{(
touched
.
time
&&
errors
.
time
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
time
"
{...
getFieldProps
(
'
time
'
)}
placeholder
=
"
ex) 11:00~14:00
"
/>
{
touched
.
time
&&
errors
.
time
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
time
}
<
/div
>
)
:
null
}
<
/div
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
강의실
<
/label
>
<
label
>
강의실
<
/label
>
...
...
server/client/src/Pages/CheckPage.js
View file @
653da10e
...
@@ -55,10 +55,10 @@ function Check(props) {
...
@@ -55,10 +55,10 @@ function Check(props) {
return
(
return
(
<
tr
key
=
{
index
}
>
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
time
}
<
/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
.
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 @
653da10e
...
@@ -8,11 +8,13 @@ router.post('/', function (req, res, next) {
...
@@ -8,11 +8,13 @@ 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
({
id
:
req
.
body
.
_id
,
user
:
req
.
body
.
_id
,
date
:
req
.
body
.
date
,
date
:
req
.
body
.
date
,
time
:
req
.
body
.
time
,
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`
,
room
:
req
.
body
.
room
,
room
:
req
.
body
.
room
,
name
:
req
.
body
.
name
,
reason
:
req
.
body
.
reason
,
reason
:
req
.
body
.
reason
,
students
:
req
.
body
.
students
,
students
:
req
.
body
.
students
,
approve
:
req
.
body
.
approve
,
approve
:
req
.
body
.
approve
,
...
@@ -33,7 +35,8 @@ router.post('/', function (req, res, next) {
...
@@ -33,7 +35,8 @@ router.post('/', 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
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
Reserve
.
find
({
id
:
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
)
console
.
log
(
'
reserve list
'
,
reserve
)
res
.
status
(
201
).
json
(
reserve
);
res
.
status
(
201
).
json
(
reserve
);
...
...
server/schemas/reserve.js
View file @
653da10e
...
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
...
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
const
{
Schema
}
=
mongoose
;
const
{
Schema
}
=
mongoose
;
const
{
Types
:
{
ObjectId
}
}
=
Schema
;
const
{
Types
:
{
ObjectId
}
}
=
Schema
;
const
reserveSchema
=
new
Schema
({
const
reserveSchema
=
new
Schema
({
id
:
{
user
:
{
type
:
ObjectId
,
type
:
ObjectId
,
required
:
true
,
required
:
true
,
ref
:
'
User
'
,
ref
:
'
User
'
,
...
@@ -11,15 +11,20 @@ const reserveSchema = new Schema({
...
@@ -11,15 +11,20 @@ const reserveSchema = new Schema({
date
:
{
date
:
{
type
:
String
,
type
:
String
,
},
},
time
:
{
starttime
:
{
type
:
Number
,
},
usetime
:
{
type
:
Number
,
},
start
:
{
type
:
String
,
type
:
String
,
},
},
room
:
{
end
:
{
type
:
String
,
type
:
String
,
},
},
name
:
{
//대표자 이름
room
:
{
type
:
String
,
type
:
String
,
},
},
...
@@ -39,8 +44,6 @@ const reserveSchema = new Schema({
...
@@ -39,8 +44,6 @@ const reserveSchema = new Schema({
num
:
{
num
:
{
type
:
Number
,
type
:
Number
,
},
},
});
});
module
.
exports
=
mongoose
.
model
(
'
Reserve
'
,
reserveSchema
);
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