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
bora-it
Commits
84e6503b
Commit
84e6503b
authored
Aug 04, 2021
by
이재연
Browse files
aaaa
parent
e74098fc
Changes
4
Show whitespace changes
Inline
Side-by-side
client/src/components/Room/InitRoom.js
View file @
84e6503b
...
...
@@ -17,7 +17,8 @@ const InitRoom = () => {
async
function
getRoom
(
roomId
)
{
try
{
const
data
=
await
roomApi
.
getRoom
([
roomId
]);
setRoom
(
data
[
0
]);
console
.
log
(
data
)
setRoom
({...
room
,
id
:
data
[
0
].
id
,
name
:
data
[
0
].
name
,
profileimg
:
data
[
0
].
profileimg
})
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
...
...
client/src/components/Room/RightHamburger.js
View file @
84e6503b
...
...
@@ -2,23 +2,36 @@ import { useState, useEffect } from "react";
import
{
Link
,
useParams
}
from
"
react-router-dom
"
;
import
ChannelSingle
from
"
./ChannelSingle
"
;
import
RoomApi
from
"
../../apis/room.api
"
;
import
roomApi
from
"
../../apis/room.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
INIT_ROOM
=
{
name
:
""
,
};
const
INIT_CHANNEL
=
{
channelName
:
""
,
joinName
:
[],
};
const
RightHamburger
=
()
=>
{
const
[
channel
,
setChannel
]
=
useState
([
INIT_CHANNEL
]);
const
[
room
,
setRoom
]
=
useState
([
INIT_ROOM
])
const
{
roomId
}
=
useParams
();
const
[
error
,
setError
]
=
useState
(
""
);
const
id
=
localStorage
.
getItem
(
'
user
'
);
async
function
getRoom
(
roomId
)
{
try
{
const
data
=
await
RoomApi
.
getRoom
([
roomId
]);
setRoom
({...
room
,
name
:
data
[
0
].
name
});
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
}
async
function
exitRoom
()
{
console
.
log
(
'
id, roomid정보
'
,
id
,
roomId
)
try
{
const
data
=
await
r
oomApi
.
exitRoom
({
id
,
roomId
})
const
data
=
await
R
oomApi
.
exitRoom
({
id
,
roomId
})
console
.
log
(
data
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
...
...
@@ -28,10 +41,9 @@ const RightHamburger = () => {
}
async
function
getChannel
(
roomId
)
{
// console.log('roomId', roomId)
const
ID
=
roomId
try
{
const
data
=
await
r
oomApi
.
getRoom
([
ID
]);
const
data
=
await
R
oomApi
.
getRoom
([
ID
]);
const
Channel
=
data
[
0
].
channel
console
.
log
(
'
방데이터:
'
,
Channel
)
const
channelList
=
[];
...
...
@@ -56,7 +68,7 @@ const RightHamburger = () => {
useEffect
(()
=>
{
getChannel
(
roomId
);
get
r
oom
(
roomId
)
get
R
oom
(
roomId
)
},
[
roomId
]);
function
roomIdCopy
()
{
...
...
@@ -115,42 +127,13 @@ const RightHamburger = () => {
><
/button
>
<
/div
>
<
div
>
<
div
>
<
button
className
=
"
navbar-toggler
"
type
=
"
button
"
data
-
bs
-
toggle
=
"
offcanvas
"
data
-
bs
-
target
=
"
#right-hamburger
"
aria
-
controls
=
"
right-hamburger
"
aria
-
expanded
=
"
false
"
aria
-
label
=
"
Toggle navigation
"
style
=
{{
border
:
"
#f4c1f2
"
}}
>
<
img
src
=
{
Rightimg
}
width
=
"
50px
"
height
=
"
30px
"
/>
<
/button
>
<
/div
>
<
ChannelSingle
channel
=
{
channel
}
/
>
<
div
>
<
div
className
=
"
d-flex flex-row-reverse
"
>
<
button
type
=
"
button
"
className
=
"
m-3 rounded text-white
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#exitRoom
"
style
=
{{
height
:
"
30px
"
,
fontWeight
:
"
bold
"
,
backgroundColor
:
"
#d86da6
"
,
color
:
"
black
"
,
border
:
"
1px #d86da6
"
,
}}
>
퇴장
<
/button
>
{
/* {admin ? (
<
button
type
=
"
button
"
className
=
"
m-3 rounded
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#inviteRoom
"
style
=
{{
height
:
"
30px
"
,
fontWeight
:
"
bold
"
,
...
...
@@ -159,13 +142,11 @@ const RightHamburger = () => {
border
:
"
1px #D64D61
"
,
}}
>
설정
초대
<
/button
>
) : null} */
}
<
div
className
=
"
modal fade
"
id
=
"
ex
itRoom
"
id
=
"
inv
it
e
Room
"
tabIndex
=
"
-1
"
aria
-
labelledby
=
"
exitRoomLabel
"
aria
-
hidden
=
"
true
"
...
...
@@ -181,26 +162,25 @@ const RightHamburger = () => {
><
/button
>
<
/div
>
<
div
className
=
"
modal-body d-flex justify-content-center
"
>
이방에서
퇴장
하시겠습니까
?
어떤
방식으로
초대
하시겠습니까
?
<
/div
>
<
div
className
=
"
row mb-3
"
>
<
div
className
=
"
d-flex justify-content-evenly
"
>
<
Link
to
=
{
`/user/
${
id
}
`
}
className
=
"
col-2 p-1 btn btn-primary
"
>
<
button
type
=
"
button
"
onClick
=
{
exitRoom
}
className
=
"
btn btn-primary
"
data
-
bs
-
dismiss
=
"
modal
"
type
=
"
submit
"
className
=
"
col-2 p-1 btn btn-primary
"
style
=
{{
width
:
"
120px
"
}}
>
예
카카오로
초대
<
/button
>
<
/Link
>
<
button
type
=
"
submit
"
className
=
"
btn btn-primary
"
className
=
"
col-2 p-1
btn btn-primary
"
data
-
bs
-
dismiss
=
"
modal
"
style
=
{{
width
:
"
120px
"
}}
onClick
=
{
roomIdCopy
}
>
아니요
방
Id
복사
<
/button
>
<
/div
>
<
/div
>
...
...
@@ -209,12 +189,27 @@ const RightHamburger = () => {
<
/div
>
<
/div
>
<
/div
>
<
div
>
<
div
className
=
"
d-flex flex-row-reverse
"
>
<
button
type
=
"
button
"
className
=
"
m-3 rounded
"
className
=
"
m-3 rounded
text-white
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#inviteRoom
"
data
-
bs
-
target
=
"
#exitRoom
"
style
=
{{
height
:
"
30px
"
,
fontWeight
:
"
bold
"
,
backgroundColor
:
"
#d86da6
"
,
color
:
"
black
"
,
border
:
"
1px #d86da6
"
,
}}
>
퇴장
<
/button
>
{
/* {admin ? (
<button
type="button"
className="m-3 rounded"
style={{
height: "30px",
fontWeight: "bold",
...
...
@@ -223,11 +218,13 @@ const RightHamburger = () => {
border: "1px #D64D61",
}}
>
초대
설정
</button>
) : null} */
}
<
div
className
=
"
modal fade
"
id
=
"
inv
it
e
Room
"
id
=
"
ex
itRoom
"
tabIndex
=
"
-1
"
aria
-
labelledby
=
"
exitRoomLabel
"
aria
-
hidden
=
"
true
"
...
...
@@ -243,25 +240,26 @@ const RightHamburger = () => {
><
/button
>
<
/div
>
<
div
className
=
"
modal-body d-flex justify-content-center
"
>
어떤
방식으로
초대
하시겠습니까
?
이방에서
퇴장
하시겠습니까
?
<
/div
>
<
div
className
=
"
row mb-3
"
>
<
div
className
=
"
d-flex justify-content-evenly
"
>
<
Link
to
=
{
`/user/
${
id
}
`
}
className
=
"
col-2 p-1 btn btn-primary
"
>
<
button
type
=
"
submit
"
className
=
"
col-2 p-1 btn btn-primary
"
style
=
{{
width
:
"
120px
"
}}
type
=
"
button
"
onClick
=
{
exitRoom
}
className
=
"
btn btn-primary
"
data
-
bs
-
dismiss
=
"
modal
"
>
카카오로
초대
예
<
/button
>
<
/Link
>
<
button
type
=
"
submit
"
className
=
"
col-2 p-1
btn btn-primary
"
className
=
"
btn btn-primary
"
data
-
bs
-
dismiss
=
"
modal
"
style
=
{{
width
:
"
120px
"
}}
onClick
=
{
roomIdCopy
}
>
방
Id
복사
아니요
<
/button
>
<
/div
>
<
/div
>
...
...
server/controllers/room.controller.js
View file @
84e6503b
...
...
@@ -2,7 +2,7 @@ import { Room, User } from "../models/index.js";
import
{
customAlphabet
}
from
"
nanoid
"
;
import
isLength
from
"
validator/lib/isLength.js
"
;
import
RoomModel
from
"
../models/room.model.js
"
;
import
multer
from
"
multer
"
;
const
nanoid
=
customAlphabet
(
"
1234567890abcdef
"
,
10
);
const
joinRoom
=
async
(
req
,
res
)
=>
{
...
...
@@ -43,7 +43,6 @@ const joinRoom = async (req, res) => {
}
};
const
multer
=
require
(
"
multer
"
);
const
upLoadRoomImg
=
multer
({
dest
:
"
roomUploads/
"
});
const
roomImgUpload
=
upLoadRoomImg
.
fields
([{
name
:
"
profileimg
"
,
maxCount
:
1
}]);
...
...
server/models/room.model.js
View file @
84e6503b
import
{
DataTypes
}
from
"
sequelize
"
;
import
pkg
from
'
sequelize
'
;
const
{
DataTypes
}
=
pkg
;
const
RoomModel
=
(
sequelize
)
=>
{
const
Room
=
sequelize
.
define
(
...
...
@@ -15,7 +16,7 @@ const RoomModel = (sequelize) => {
type
:
DataTypes
.
INTEGER
,
},
member
:
{
type
:
DataTypes
.
ARRAY
(
DataTypes
.
STRING
),
type
:
DataTypes
.
ARRAY
(
DataTypes
.
INTEGER
),
//type: DataTypes.STRING,
},
profileimg
:
{
...
...
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