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
171d5080
Commit
171d5080
authored
Nov 06, 2020
by
Yoon, Daeki
😅
Browse files
reload
parent
1e75d62c
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/Components/Card.js
View file @
171d5080
...
...
@@ -13,7 +13,7 @@ const Text = styled(Card.Body)`
}
`
function
Notice
({
card_id
,
card_index
,
title
,
date
,
content
,
admin
})
{
function
Notice
({
card_id
,
card_index
,
title
,
date
,
content
,
admin
,
remove
})
{
function
ContextAwareToggle
({
children
,
eventKey
,
callback
})
{
const
currentEventKey
=
useContext
(
AccordionContext
);
...
...
@@ -46,18 +46,6 @@ function Notice({ card_id, card_index, title, date, content, admin }) {
return
new_date
}
function
remove
(
card_id
)
{
axios
.
delete
(
`/api/notices/
${
card_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
삭제되었습니다!
"
);
window
.
location
.
reload
();
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
return
(
<
Card
className
=
"
w-100
"
>
<
Card
.
Header
className
=
"
row flex-row py-3
"
>
...
...
client/src/Pages/ApplyPage.js
View file @
171d5080
...
...
@@ -10,6 +10,7 @@ function Apply(props) {
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
});
const
[
values
,
setValues
]
=
useState
()
useEffect
(()
=>
{
getUser
();
...
...
@@ -96,7 +97,7 @@ function Apply(props) {
reason
:
Yup
.
string
()
.
required
(
'
대관목적을 입력해주세요.
'
),
})}
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
onSubmit
=
{(
values
,
{
setSubmitting
,
resetForm
})
=>
{
addRoomInfo
(
values
);
axios
({
method
:
'
post
'
,
...
...
@@ -105,7 +106,8 @@ function Apply(props) {
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
{
alert
(
res
.
data
.
error
)
return
window
.
location
.
reload
();
resetForm
({})
return
}
alert
(
"
신청이 완료되었습니다!
"
);
setState
({
ok
:
"
ok
"
});
...
...
client/src/Pages/NoticePage.js
View file @
171d5080
...
...
@@ -34,6 +34,19 @@ function Notice() {
alert
(
err
.
error
)
});
}
function
remove
(
card_id
)
{
axios
.
delete
(
`/api/notices/
${
card_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
삭제되었습니다!
"
);
getNotice
();
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
function
getNotice
()
{
axios
.
get
(
`/api/notices`
)
...
...
@@ -58,7 +71,7 @@ function Notice() {
<
h2
className
=
"
p-3 border-bottom d-flex justify-content-between
"
>
공지사항
{
user
.
role
===
"
admin
"
?
(
<
Button
as
=
{
Link
}
to
=
"
/write
"
>
글
작성
<
/Button>
)
: null}</
h2
>
<
Accordion
>
{
notices
.
map
((
notice
,
index
)
=>
<
CARD
card_id
=
{
notice
.
_id
}
card_index
=
{
index
}
title
=
{
notice
.
notice_title
}
date
=
{
notice
.
post_date
}
content
=
{
notice
.
notice_content
}
admin
=
{
user
.
role
}
/
>
{
notices
.
map
((
notice
,
index
)
=>
<
CARD
card_id
=
{
notice
.
_id
}
card_index
=
{
index
}
title
=
{
notice
.
notice_title
}
date
=
{
notice
.
post_date
}
content
=
{
notice
.
notice_content
}
admin
=
{
user
.
role
}
remove
=
{
remove
}
/
>
)}
<
/Accordion
>
<
/Col
>
...
...
client/src/index.js
View file @
171d5080
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
{
BrowserRouter
as
Router
,
Route
,
Redirect
,
Switch
}
from
'
react-router-dom
'
;
import
{
BrowserRouter
as
Router
,
HashRouter
,
Route
,
Redirect
,
Switch
}
from
'
react-router-dom
'
;
import
*
as
serviceWorker
from
'
./serviceWorker
'
;
import
'
bootstrap
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
...
...
@@ -24,7 +24,7 @@ axios.defaults.validateStatus = function (status) {
}
ReactDOM
.
render
(
<
Router
>
<
Hash
Router
>
<
Switch
>
<
PrivateRoute
exact
path
=
"
/
"
component
=
{
Home
}
/
>
<
Route
path
=
"
/login
"
component
=
{
Login
}
/
>
...
...
@@ -42,7 +42,7 @@ ReactDOM.render(
<
Redirect
path
=
"
/change/:id
"
to
=
"
/change
"
/>
<
Redirect
path
=
"
/notice
"
to
=
"
/notice
"
/>
<
/Switch
>
<
/Router>
,
<
/
Hash
Router>
,
document
.
getElementById
(
'
root
'
)
);
...
...
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