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

z

parent 1da6b905
......@@ -27,7 +27,6 @@ const CreateRoom = () => {
} else {
setRoom({ ...room, [name]: value })
}
console.log(room)
}
async function handleSubmit(e) {
......
......@@ -9,24 +9,17 @@ const ChannelSingle = (props) => {
const [succes, setSucces] = useState(false);
const [roomName, setRoomName] = useState('');
const { roomId, channelId } = useParams();
console.log('props', props.channel)
console.log('hi', channelId)
const userId = localStorage.getItem('user')
async function joinChannel(e) {
console.log(e, userId)
try {
const data = await userApi.getUser(userId);
const key = indexCheck(e)
console.log(key)
const mem = props.channel[key].joinUser
console.log(mem)
const joinCh = mem.includes(data.name);
console.log(joinCh)
if (!joinCh) {
const roomA = await roomApi.joinChannel({ roomId: roomId, channelName: e, plusUser: data.name, index: key })
console.log(roomA)
setRoomName(e)
setSucces(true)
} else {
......@@ -39,10 +32,7 @@ const ChannelSingle = (props) => {
function indexCheck(e) {
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) {
console.log('key', key)
return key
}
}
......
......@@ -17,9 +17,7 @@ const InitRoom = () => {
async function getRoom(roomId) {
try {
const data = await roomApi.getRoom([roomId]);
console.log(data)
setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg})
console.log(room.profileimg)
} catch (error) {
catchErrors(error, setError);
}
......
......@@ -43,14 +43,10 @@ const RightHamburger = () => {
try {
const data = await RoomApi.getRoom([ID]);
const Channel = data[0].channel;
console.log("방데이터:", Channel);
const channelList = [];
for (const prop in Channel) {
// Channel의 항목(prop)으로 작업을 실행합니다
for (const key in Channel[prop]) {
console.log(key);
console.log(prop);
console.log(Channel[prop][key]);
channelList.push({
channelName: key,
joinUser: Channel[prop][key],
......
......@@ -124,10 +124,13 @@ const joinChannel = async (req, res) => {
const room = await Room.findOne({ where: { id: roomId } });
room.channel[index][channelName].push(plusUser)
console.log('확인2',room.channel[index])
await Room.update({ channel: room.channel }, { where: { id: roomId } });
return res.json(true)
}
export default {
joinRoom, roomImgUpload, createRoom, getRoom, exitRoom, joinChannel,
};
......@@ -23,22 +23,6 @@ sequelize
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, () => {
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