Commit 5486346c authored by 이재연's avatar 이재연
Browse files

z

parent 1da6b905
...@@ -27,7 +27,6 @@ const CreateRoom = () => { ...@@ -27,7 +27,6 @@ const CreateRoom = () => {
} else { } else {
setRoom({ ...room, [name]: value }) setRoom({ ...room, [name]: value })
} }
console.log(room)
} }
async function handleSubmit(e) { async function handleSubmit(e) {
......
...@@ -9,24 +9,17 @@ const ChannelSingle = (props) => { ...@@ -9,24 +9,17 @@ const ChannelSingle = (props) => {
const [succes, setSucces] = useState(false); const [succes, setSucces] = useState(false);
const [roomName, setRoomName] = useState(''); const [roomName, setRoomName] = useState('');
const { roomId, channelId } = useParams(); const { roomId, channelId } = useParams();
console.log('props', props.channel)
console.log('hi', channelId)
const userId = localStorage.getItem('user') const userId = localStorage.getItem('user')
async function joinChannel(e) { async function joinChannel(e) {
console.log(e, userId)
try { try {
const data = await userApi.getUser(userId); const data = await userApi.getUser(userId);
const key = indexCheck(e) const key = indexCheck(e)
console.log(key)
const mem = props.channel[key].joinUser const mem = props.channel[key].joinUser
console.log(mem)
const joinCh = mem.includes(data.name); const joinCh = mem.includes(data.name);
console.log(joinCh)
if (!joinCh) { if (!joinCh) {
const roomA = await roomApi.joinChannel({ roomId: roomId, channelName: e, plusUser: data.name, index: key }) const roomA = await roomApi.joinChannel({ roomId: roomId, channelName: e, plusUser: data.name, index: key })
console.log(roomA)
setRoomName(e) setRoomName(e)
setSucces(true) setSucces(true)
} else { } else {
...@@ -39,10 +32,7 @@ const ChannelSingle = (props) => { ...@@ -39,10 +32,7 @@ const ChannelSingle = (props) => {
function indexCheck(e) { function indexCheck(e) {
for (const key in props.channel) { for (const key in props.channel) {
console.log('체크', props.channel[key].channelName, e)
console.log('체크', props.channel[key].channelName === e)
if (props.channel[key].channelName === e) { if (props.channel[key].channelName === e) {
console.log('key', key)
return key return key
} }
} }
......
...@@ -17,9 +17,7 @@ const InitRoom = () => { ...@@ -17,9 +17,7 @@ const InitRoom = () => {
async function getRoom(roomId) { async function getRoom(roomId) {
try { try {
const data = await roomApi.getRoom([roomId]); const data = await roomApi.getRoom([roomId]);
console.log(data)
setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg}) setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg})
console.log(room.profileimg)
} catch (error) { } catch (error) {
catchErrors(error, setError); catchErrors(error, setError);
} }
......
...@@ -43,14 +43,10 @@ const RightHamburger = () => { ...@@ -43,14 +43,10 @@ const RightHamburger = () => {
try { try {
const data = await RoomApi.getRoom([ID]); const data = await RoomApi.getRoom([ID]);
const Channel = data[0].channel; const Channel = data[0].channel;
console.log("방데이터:", Channel);
const channelList = []; const channelList = [];
for (const prop in Channel) { for (const prop in Channel) {
// Channel의 항목(prop)으로 작업을 실행합니다 // Channel의 항목(prop)으로 작업을 실행합니다
for (const key in Channel[prop]) { for (const key in Channel[prop]) {
console.log(key);
console.log(prop);
console.log(Channel[prop][key]);
channelList.push({ channelList.push({
channelName: key, channelName: key,
joinUser: Channel[prop][key], joinUser: Channel[prop][key],
......
...@@ -124,10 +124,13 @@ const joinChannel = async (req, res) => { ...@@ -124,10 +124,13 @@ const joinChannel = async (req, res) => {
const room = await Room.findOne({ where: { id: roomId } }); const room = await Room.findOne({ where: { id: roomId } });
room.channel[index][channelName].push(plusUser) room.channel[index][channelName].push(plusUser)
console.log('확인2',room.channel[index]) console.log('확인2',room.channel[index])
await Room.update({ channel: room.channel }, { where: { id: roomId } }); await Room.update({ channel: room.channel }, { where: { id: roomId } });
return res.json(true) return res.json(true)
} }
export default { export default {
joinRoom, roomImgUpload, createRoom, getRoom, exitRoom, joinChannel, joinRoom, roomImgUpload, createRoom, getRoom, exitRoom, joinChannel,
}; };
...@@ -23,22 +23,6 @@ sequelize ...@@ -23,22 +23,6 @@ sequelize
roomNumber : ["1234567abc","abc7654321"], roomNumber : ["1234567abc","abc7654321"],
}); });
await Room.create({
id: "1234567abc",
name: "room",
owner: 8888,
member: ['8888','9999'],
profileimg: "defaultimg",
});
await Room.create({
id: "abc7654321",
name: "room1",
owner: 9999,
member: ['9999'],
profileimg: "defaultimg",
});
app.listen(appConfig.port, () => { app.listen(appConfig.port, () => {
console.log(`Server is running on port ${appConfig.port}`); console.log(`Server is running on port ${appConfig.port}`);
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment