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
06c802e0
Commit
06c802e0
authored
Nov 05, 2020
by
Choi Ga Young
Browse files
날짜 불러오기 수정해야해요
parent
5eda65e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
server/client/package-lock.json
View file @
06c802e0
...
@@ -4150,6 +4150,15 @@
...
@@ -4150,6 +4150,15 @@
"sha.js": "^2.4.8"
"sha.js": "^2.4.8"
}
}
},
},
"create-react-context": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/create-react-context/-/create-react-context-0.3.0.tgz",
"integrity": "sha512-dNldIoSuNSvlTJ7slIKC/ZFGKexBMBrrcc+TTe1NdmROnaASuLPvqpwj9v4XS4uXZ8+YPu0sNmShX2rXI5LNsw==",
"requires": {
"gud": "^1.0.0",
"warning": "^4.0.3"
}
},
"cross-spawn": {
"cross-spawn": {
"version": "6.0.5",
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
...
@@ -4521,6 +4530,11 @@
...
@@ -4521,6 +4530,11 @@
}
}
}
}
},
},
"date-fns": {
"version": "2.16.1",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.16.1.tgz",
"integrity": "sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ=="
},
"debug": {
"debug": {
"version": "4.1.1",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
...
@@ -6544,6 +6558,11 @@
...
@@ -6544,6 +6558,11 @@
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE="
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE="
},
},
"gud": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz",
"integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw=="
},
"gzip-size": {
"gzip-size": {
"version": "5.1.1",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz",
...
@@ -11181,6 +11200,18 @@
...
@@ -11181,6 +11200,18 @@
"warning": "^4.0.3"
"warning": "^4.0.3"
}
}
},
},
"react-datepicker": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-3.3.0.tgz",
"integrity": "sha512-QnIlBxDSWEGBi2X5P1BqWzvfnPFRKhtrsgAcujUVwyWeID/VatFaAOEjEjfD1bXR9FuSYVLlLR3j/vbG19hWOA==",
"requires": {
"classnames": "^2.2.6",
"date-fns": "^2.0.1",
"prop-types": "^15.7.2",
"react-onclickoutside": "^6.9.0",
"react-popper": "^1.3.4"
}
},
"react-dev-utils": {
"react-dev-utils": {
"version": "10.2.1",
"version": "10.2.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
...
@@ -11413,6 +11444,11 @@
...
@@ -11413,6 +11444,11 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
},
"react-onclickoutside": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/react-onclickoutside/-/react-onclickoutside-6.9.0.tgz",
"integrity": "sha512-8ltIY3bC7oGhj2nPAvWOGi+xGFybPNhJM0V1H8hY/whNcXgmDeaeoCMPPd8VatrpTsUWjb/vGzrmu6SrXVty3A=="
},
"react-overlays": {
"react-overlays": {
"version": "4.1.1",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-4.1.1.tgz",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-4.1.1.tgz",
...
@@ -11438,6 +11474,20 @@
...
@@ -11438,6 +11474,20 @@
}
}
}
}
},
},
"react-popper": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.7.tgz",
"integrity": "sha512-nmqYTx7QVjCm3WUZLeuOomna138R1luC4EqkW3hxJUrAe+3eNz3oFCLYdnPwILfn0mX1Ew2c3wctrjlUMYYUww==",
"requires": {
"@babel/runtime": "^7.1.2",
"create-react-context": "^0.3.0",
"deep-equal": "^1.1.1",
"popper.js": "^1.14.4",
"prop-types": "^15.6.1",
"typed-styles": "^0.0.7",
"warning": "^4.0.2"
}
},
"react-router": {
"react-router": {
"version": "5.2.0",
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
...
@@ -13688,6 +13738,11 @@
...
@@ -13688,6 +13738,11 @@
"mime-types": "~2.1.24"
"mime-types": "~2.1.24"
}
}
},
},
"typed-styles": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/typed-styles/-/typed-styles-0.0.7.tgz",
"integrity": "sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q=="
},
"typedarray": {
"typedarray": {
"version": "0.0.6",
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
...
...
server/client/package.json
View file @
06c802e0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
"popper.js"
:
"^1.16.1"
,
"popper.js"
:
"^1.16.1"
,
"react"
:
"^16.13.1"
,
"react"
:
"^16.13.1"
,
"react-bootstrap"
:
"^1.4.0"
,
"react-bootstrap"
:
"^1.4.0"
,
"react-datepicker"
:
"^3.3.0"
,
"react-dom"
:
"^16.13.1"
,
"react-dom"
:
"^16.13.1"
,
"react-router-dom"
:
"^5.2.0"
,
"react-router-dom"
:
"^5.2.0"
,
"react-scripts"
:
"3.4.3"
,
"react-scripts"
:
"3.4.3"
,
...
...
server/client/src/Components/Menu.js
View file @
06c802e0
...
@@ -28,10 +28,9 @@ function Menu() {
...
@@ -28,10 +28,9 @@ function Menu() {
},
[])
},
[])
function
acheck
()
{
function
acheck
()
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
}},)
}).
then
(
res
=>
{
.
then
(
res
=>
{
console
.
log
(
res
.
data
)
if
(
res
.
data
.
role
==
"
admin
"
)
{
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
setUser
(
res
.
data
)
}
}
...
@@ -61,12 +60,12 @@ function Menu() {
...
@@ -61,12 +60,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/Pages/ApplyPage.js
View file @
06c802e0
...
@@ -5,16 +5,22 @@ import axios from 'axios';
...
@@ -5,16 +5,22 @@ 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
'
;
import
{
Col
,
Container
,
Row
}
from
'
react-bootstrap
'
;
import
DatePicker
,
{
registerLocale
}
from
"
react-datepicker
"
;
import
"
react-datepicker/dist/react-datepicker.css
"
;
import
ko
from
'
date-fns/locale/ko
'
;
registerLocale
(
"
ko
"
,
ko
);
function
Apply
(
props
)
{
function
Apply
(
props
)
{
const
[
state
,
setState
]
=
useState
({
ok
:
""
});
const
[
state
,
setState
]
=
useState
({
ok
:
""
});
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
//const [date, setDate] = useState(new Date());
useEffect
(()
=>
{
useEffect
(()
=>
{
getUser
();
getUser
();
},
[])
},
[])
if
(
state
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
.
ok
===
"
ok
"
)
{
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
},
...
@@ -51,7 +57,7 @@ function Apply(props) {
...
@@ -51,7 +57,7 @@ function Apply(props) {
if
(
res
.
status
!==
201
)
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
alert
(
res
.
data
.
error
);
localStorage
.
clear
();
localStorage
.
clear
();
setState
({
ok
:
"
no
"
});
setState
({
ok
:
"
no
"
});
}
}
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
setUser
(
res
.
data
);
setUser
(
res
.
data
);
...
@@ -70,7 +76,7 @@ function Apply(props) {
...
@@ -70,7 +76,7 @@ function Apply(props) {
<
Formik
<
Formik
initialValues
=
{{
initialValues
=
{{
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
date
:
''
,
date
:
new
Date
()
,
starttime
:
''
,
starttime
:
''
,
usetime
:
''
,
usetime
:
''
,
room
:
''
,
room
:
''
,
...
@@ -82,8 +88,8 @@ function Apply(props) {
...
@@ -82,8 +88,8 @@ function Apply(props) {
],
],
}}
}}
validationSchema
=
{
Yup
.
object
({
validationSchema
=
{
Yup
.
object
({
date
:
Yup
.
string
()
/*
date: Yup.string()
.
required
(
'
날짜를 입력해주세요.
'
),
.required('날짜를 입력해주세요.'),
*/
reason
:
Yup
.
string
()
reason
:
Yup
.
string
()
.
required
(
'
대관목적을 입력해주세요.
'
),
.
required
(
'
대관목적을 입력해주세요.
'
),
})}
})}
...
@@ -99,7 +105,7 @@ function Apply(props) {
...
@@ -99,7 +105,7 @@ function Apply(props) {
return
window
.
location
.
reload
();
return
window
.
location
.
reload
();
}
}
alert
(
"
신청이 완료되었습니다!
"
);
alert
(
"
신청이 완료되었습니다!
"
);
setState
({
ok
:
"
ok
"
});
setState
({
ok
:
"
ok
"
});
console
.
log
(
"
res.data
"
,
res
.
data
)
console
.
log
(
"
res.data
"
,
res
.
data
)
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
@@ -117,6 +123,7 @@ function Apply(props) {
...
@@ -117,6 +123,7 @@ function Apply(props) {
values
,
values
,
handleSubmit
,
handleSubmit
,
getFieldProps
,
getFieldProps
,
setFieldValue
,
isSubmitting
,
isSubmitting
,
})
=>
(
})
=>
(
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
d-flex flex-column
"
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
d-flex flex-column
"
>
...
@@ -125,14 +132,23 @@ function Apply(props) {
...
@@ -125,14 +132,23 @@ function Apply(props) {
<
/h3
>
<
/h3
>
<
div
className
=
"
form-group
"
>
<
div
className
=
"
form-group
"
>
<
div
className
=
{
touched
.
date
&&
errors
.
date
?
"
text-danger
"
:
""
}
>
신청날짜
<
/div
>
<
DatePicker
locale
=
"
ko
"
selected
=
{
values
.
date
}
name
=
"
date
"
onChange
=
{
date
=>
setFieldValue
(
'
date
'
,
date
)}
dateFormat
=
"
yyyy.MM.dd(eee)
"
placeholderText
=
"
yyyy-mm-dd
"
minDate
=
{
new
Date
()}
/
>
{
/*<div className={touched.date && errors.date ? "text-danger" : ""}>신청날짜</div>
<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="text"
type="text"
name="date"
name="date"
{...getFieldProps('date')}
{...getFieldProps('date')}
placeholder="yyyy-mm-dd"
placeholder="yyyy-mm-dd"
/>
/>
*/
}
<
/div
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
div
className
=
"
form-group mb-4
"
>
...
...
server/routes/login.js
View file @
06c802e0
...
@@ -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
:
'
1h
'
,
expiresIn
:
'
30m
'
,
});
});
return
res
.
status
(
201
).
json
({
return
res
.
status
(
201
).
json
({
token
,
token
,
...
...
server/schemas/reserve.js
View file @
06c802e0
...
@@ -9,7 +9,8 @@ const reserveSchema = new Schema({
...
@@ -9,7 +9,8 @@ const reserveSchema = new Schema({
ref
:
'
User
'
,
ref
:
'
User
'
,
},
},
date
:
{
date
:
{
type
:
String
,
type
:
Date
,
default
:
Date
.
now
},
},
starttime
:
{
starttime
:
{
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