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
messenger
Commits
c0fb0244
Commit
c0fb0244
authored
Jan 29, 2021
by
우지원
Browse files
Merge remote-tracking branch 'origin/young' into jiweon827
parents
79e0fc87
bd853bc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/src/Components/EnterRoom.js
View file @
c0fb0244
...
@@ -7,15 +7,29 @@ import catchErrors from '../utils/catchErrors'
...
@@ -7,15 +7,29 @@ import catchErrors from '../utils/catchErrors'
function
EnterRoom
(
props
)
{
function
EnterRoom
(
props
)
{
const
[
enterCode
,
setEnterCode
]
=
useState
(
''
);
const
[
enterCode
,
setEnterCode
]
=
useState
(
''
);
const
[
error
,
setError
]
=
useState
(
''
);
const
[
error
,
setError
]
=
useState
(
''
);
const
realTime
=
new
Date
().
toISOString
()
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
);
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
);
async
function
recordEntryLog
()
{
const
leaveInfo
=
{
userId
:
userId
,
roomCode
:
enterCode
,
leaveTime
:
realTime
}
try
{
const
check
=
await
axios
.
get
(
'
/room/entrylog
'
,
{
params
:
leaveInfo
})
if
(
check
.
data
)
{
//있으면 put으로
await
axios
.
put
(
'
/room/entrylog
'
,
leaveInfo
)
}
else
{
//없으면 post
await
axios
.
post
(
'
/room/entrylog
'
,
leaveInfo
)
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
const
{
name
,
value
}
=
event
.
target
const
{
name
,
value
}
=
event
.
target
setEnterCode
(
value
)
setEnterCode
(
value
)
console
.
log
(
enterCode
)
console
.
log
(
enterCode
)
}
}
async
function
handleSubmit
(
event
)
{
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
()
event
.
preventDefault
()
try
{
try
{
...
@@ -31,6 +45,7 @@ function EnterRoom(props) {
...
@@ -31,6 +45,7 @@ function EnterRoom(props) {
props
.
handleCloseEnter
()
props
.
handleCloseEnter
()
props
.
handleChato
()
props
.
handleChato
()
setEnterCode
(
''
)
setEnterCode
(
''
)
recordEntryLog
()
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
...
...
client/src/Components/RoomMake.js
View file @
c0fb0244
...
@@ -12,8 +12,25 @@ const INIT_ROOM = {
...
@@ -12,8 +12,25 @@ const INIT_ROOM = {
function
RoomMake
(
props
)
{
function
RoomMake
(
props
)
{
const
[
room
,
setRoom
]
=
useState
(
INIT_ROOM
);
const
[
room
,
setRoom
]
=
useState
(
INIT_ROOM
);
const
[
error
,
setError
]
=
useState
(
''
);
const
[
error
,
setError
]
=
useState
(
''
);
const
[
roomCode
,
setRoomCode
]
=
useState
(
''
)
const
member
=
sessionStorage
.
getItem
(
'
userId
'
);
const
member
=
sessionStorage
.
getItem
(
'
userId
'
);
const
realTime
=
new
Date
().
toISOString
()
async
function
recordEntryLog
(
Id
)
{
const
leaveInfo
=
{
userId
:
member
,
roomCode
:
Id
,
leaveTime
:
realTime
}
try
{
const
check
=
await
axios
.
get
(
'
/room/entrylog
'
,
{
params
:
leaveInfo
})
if
(
check
.
data
)
{
//있으면 put으로
await
axios
.
put
(
'
/room/entrylog
'
,
leaveInfo
)
}
else
{
//없으면 post
await
axios
.
post
(
'
/room/entrylog
'
,
leaveInfo
)
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
const
{
name
,
value
}
=
event
.
target
const
{
name
,
value
}
=
event
.
target
setRoom
({
...
room
,
[
name
]:
value
,
member
})
setRoom
({
...
room
,
[
name
]:
value
,
member
})
...
@@ -29,6 +46,8 @@ function RoomMake(props) {
...
@@ -29,6 +46,8 @@ function RoomMake(props) {
alert
(
`방암호는
${
Id
}
입니다`
)
alert
(
`방암호는
${
Id
}
입니다`
)
props
.
handleCloseModal
()
props
.
handleCloseModal
()
setRoom
(
INIT_ROOM
)
setRoom
(
INIT_ROOM
)
// setRoomCode(Id)
recordEntryLog
(
Id
)
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
...
@@ -80,7 +99,7 @@ function RoomMake(props) {
...
@@ -80,7 +99,7 @@ function RoomMake(props) {
}
}
<
Form
.
Group
as
=
{
Row
}
>
<
Form
.
Group
as
=
{
Row
}
>
<
Col
sm
=
{{
span
:
5
,
offset
:
4
}}
>
<
Col
sm
=
{{
span
:
5
,
offset
:
4
}}
>
<
Button
type
=
"
submit
"
style
=
{{
backgroundColor
:
"
#9174ad
"
,
borderColor
:
"
#9174ad
"
}}
>
방
생성
<
/Button
>
<
Button
type
=
"
submit
"
style
=
{{
backgroundColor
:
"
#9174ad
"
,
borderColor
:
"
#9174ad
"
}}
>
방
생성
<
/Button
>
<
/Col
>
<
/Col
>
<
/Form.Group
>
<
/Form.Group
>
<
/Form
>
<
/Form
>
...
...
client/src/Pages/HomePage.js
View file @
c0fb0244
...
@@ -10,6 +10,7 @@ import RoomMake from "../Components/RoomMake"
...
@@ -10,6 +10,7 @@ import RoomMake from "../Components/RoomMake"
import
EnterRoom
from
"
../Components/EnterRoom
"
import
EnterRoom
from
"
../Components/EnterRoom
"
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
"
./Home.css
"
import
"
./Home.css
"
import
catchErrors
from
'
../utils/catchErrors
'
;
const
socket
=
io
();
const
socket
=
io
();
...
@@ -34,6 +35,9 @@ const INIT_UNREAD = {
...
@@ -34,6 +35,9 @@ const INIT_UNREAD = {
function
Home
()
{
function
Home
()
{
const
userName
=
sessionStorage
.
getItem
(
'
name
'
)
const
userName
=
sessionStorage
.
getItem
(
'
name
'
)
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
)
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
)
const
realTime
=
new
Date
().
toISOString
()
const
[
error
,
setError
]
=
useState
(
''
)
const
[
checknew
,
setChecknew
]
=
useState
(
''
)
const
[
checknew
,
setChecknew
]
=
useState
(
''
)
const
[
unreadnumber
,
setUnreadnumber
]
=
useState
(
INIT_UNREAD
)
const
[
unreadnumber
,
setUnreadnumber
]
=
useState
(
INIT_UNREAD
)
...
@@ -128,11 +132,27 @@ function Home() {
...
@@ -128,11 +132,27 @@ function Home() {
alert
(
'
참가되었습니다.
'
)
alert
(
'
참가되었습니다.
'
)
setSysmsg
(
`
${
userNick
}
님이 들어왔습니다.`
)
setSysmsg
(
`
${
userNick
}
님이 들어왔습니다.`
)
getClosedList
()
getClosedList
()
recordEntryLog
()
}
else
{
}
else
{
alert
(
'
이미 참가된 방입니다.
'
)
alert
(
'
이미 참가된 방입니다.
'
)
}
}
}
}
async
function
recordEntryLog
()
{
const
leaveInfo
=
{
userId
:
userId
,
roomCode
:
roomCode
,
leaveTime
:
realTime
}
try
{
const
check
=
await
axios
.
get
(
'
/room/entrylog
'
,
{
params
:
leaveInfo
})
if
(
check
.
data
)
{
//있으면 put으로
await
axios
.
put
(
'
/room/entrylog
'
,
leaveInfo
)
}
else
{
//없으면 post
await
axios
.
post
(
'
/room/entrylog
'
,
leaveInfo
)
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
enterButton
()
{
function
enterButton
()
{
setOpen
(
false
)
setOpen
(
false
)
}
}
...
...
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