Builds for
1 pipeline
failed
in
1 minute 24 seconds
Merge branch 'feature/rooms' into develop
Showing
4 changed files
with
10 additions
and
28 deletions
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | "web-vitals": "^1.0.1" | 23 | "web-vitals": "^1.0.1" |
24 | }, | 24 | }, |
25 | "scripts": { | 25 | "scripts": { |
26 | - "start": "npm run twcss && react-scripts start", | 26 | + "start": "npm run twcss && set PORT=3001 && react-scripts start", |
27 | "build": "npm run twcss && react-scripts build", | 27 | "build": "npm run twcss && react-scripts build", |
28 | "test": "react-scripts test", | 28 | "test": "react-scripts test", |
29 | "eject": "react-scripts eject", | 29 | "eject": "react-scripts eject", | ... | ... |
... | @@ -5,11 +5,11 @@ import { MessageResponse, MessageType } from '../common/types'; | ... | @@ -5,11 +5,11 @@ import { MessageResponse, MessageType } from '../common/types'; |
5 | import { RoomData } from '../room/types'; | 5 | import { RoomData } from '../room/types'; |
6 | import { Room } from './types'; | 6 | import { Room } from './types'; |
7 | 7 | ||
8 | -interface RoomProps { | 8 | +interface RoomBlockProps { |
9 | room: Room | 9 | room: Room |
10 | } | 10 | } |
11 | 11 | ||
12 | -export const RoomInfo: React.FC<RoomProps> = ({ room }) => { | 12 | +export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => { |
13 | const history = useHistory(); | 13 | const history = useHistory(); |
14 | const socket = useContext(SocketContext); | 14 | const socket = useContext(SocketContext); |
15 | const joinRoom = () => { | 15 | const joinRoom = () => { | ... | ... |
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | import { io } from 'socket.io-client'; | 2 | import { io } from 'socket.io-client'; |
3 | 3 | ||
4 | -export const socket = io('http://localhost/'); | 4 | +export const socket = io('http://localhost:3000/'); |
5 | const SocketContext = React.createContext(socket); | 5 | const SocketContext = React.createContext(socket); |
6 | 6 | ||
7 | export const SocketProvider = SocketContext.Provider; | 7 | export const SocketProvider = SocketContext.Provider; | ... | ... |
1 | -import React, { useContext, useEffect, useState } from 'react'; | 1 | +import React, { useCallback, useContext, useEffect, useState } from 'react'; |
2 | import { Main } from '../components/common/Main'; | 2 | import { Main } from '../components/common/Main'; |
3 | import { MessageResponse, MessageType } from '../components/common/types'; | 3 | import { MessageResponse, MessageType } from '../components/common/types'; |
4 | -import { RoomInfo } from '../components/rooms/RoomInfo'; | 4 | +import { RoomBlock } from '../components/rooms/RoomBlock'; |
5 | import { Room } from '../components/rooms/types'; | 5 | import { Room } from '../components/rooms/types'; |
6 | import SocketContext from '../contexts/SocketContext'; | 6 | import SocketContext from '../contexts/SocketContext'; |
7 | 7 | ||
... | @@ -9,25 +9,7 @@ export const Rooms: React.FC = () => { | ... | @@ -9,25 +9,7 @@ export const Rooms: React.FC = () => { |
9 | const socket = useContext(SocketContext); | 9 | const socket = useContext(SocketContext); |
10 | const [ rooms, setRooms ] = useState<Room[]>([]); | 10 | const [ rooms, setRooms ] = useState<Room[]>([]); |
11 | 11 | ||
12 | - // for test | 12 | + const refreshRooms = useCallback(() => { |
13 | - const testingRoom1: Room = { | ||
14 | - uuid: '23525', | ||
15 | - name: 'Hello World!', | ||
16 | - currentUsers: 3, | ||
17 | - maxUsers: 4 | ||
18 | - } | ||
19 | - const testingRoom2: Room = { | ||
20 | - uuid: '235252134', | ||
21 | - name: 'Bonjour World!', | ||
22 | - currentUsers: 6, | ||
23 | - maxUsers: 6 | ||
24 | - } | ||
25 | - useEffect(() => { | ||
26 | - setRooms([testingRoom1, testingRoom2]); | ||
27 | - // refreshRooms() | ||
28 | - }, []); | ||
29 | - | ||
30 | - const refreshRooms = () => { | ||
31 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { | 13 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { |
32 | if (response.ok) { | 14 | if (response.ok) { |
33 | setRooms(response.result!); | 15 | setRooms(response.result!); |
... | @@ -36,14 +18,14 @@ export const Rooms: React.FC = () => { | ... | @@ -36,14 +18,14 @@ export const Rooms: React.FC = () => { |
36 | console.log("방 목록을 수신하지 못함"); | 18 | console.log("방 목록을 수신하지 못함"); |
37 | } | 19 | } |
38 | }); | 20 | }); |
39 | - } | 21 | + }, []); |
40 | 22 | ||
41 | - // useEffect(refreshRooms, []); | 23 | + useEffect(refreshRooms, []); |
42 | 24 | ||
43 | return ( | 25 | return ( |
44 | <Main> | 26 | <Main> |
45 | <div className='mt-auto w-screen flex flex-col items-center'> | 27 | <div className='mt-auto w-screen flex flex-col items-center'> |
46 | - {rooms.map((room) => (<RoomInfo key={room.uuid} room={room} />))} | 28 | + {rooms.map((room) => (<RoomBlock key={room.uuid} room={room} />))} |
47 | </div> | 29 | </div> |
48 | </Main> | 30 | </Main> |
49 | ) | 31 | ) | ... | ... |
-
Please register or login to post a comment