Overnap

RoundInfo 컴포넌트 추가 및 적용

...@@ -3,6 +3,7 @@ import { useLocation } from 'react-router'; ...@@ -3,6 +3,7 @@ import { useLocation } from 'react-router';
3 import SocketContext from '../../contexts/SocketContext'; 3 import SocketContext from '../../contexts/SocketContext';
4 import { MessageType, RawMessage } from '../common/types'; 4 import { MessageType, RawMessage } from '../common/types';
5 import { Canvas } from './Canvas'; 5 import { Canvas } from './Canvas';
6 +import { RoundInfo } from './RoundInfo';
6 import { Role, RoundData } from './types'; 7 import { Role, RoundData } from './types';
7 import { Word } from './Word'; 8 import { Word } from './Word';
8 9
...@@ -21,6 +22,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => { ...@@ -21,6 +22,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
21 const [ isDrawer, setIsDrawer ] = useState(false); 22 const [ isDrawer, setIsDrawer ] = useState(false);
22 const [ words, setWords ] = useState<string[]>([]); 23 const [ words, setWords ] = useState<string[]>([]);
23 const [ wordChosen, setWordChosen ] = useState(''); 24 const [ wordChosen, setWordChosen ] = useState('');
25 + const [ round, setRound ] = useState(0);
24 26
25 const handleWordSet = useCallback((rawMessage: RawMessage) => { 27 const handleWordSet = useCallback((rawMessage: RawMessage) => {
26 if (rawMessage.type === MessageType.GAME_WORDSET) { 28 if (rawMessage.type === MessageType.GAME_WORDSET) {
...@@ -40,6 +42,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => { ...@@ -40,6 +42,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
40 const index = data.roles.findIndex(x => x.username === location.state.username); 42 const index = data.roles.findIndex(x => x.username === location.state.username);
41 setIsDrawer(data.roles[index].role === 'drawer'); 43 setIsDrawer(data.roles[index].role === 'drawer');
42 setWordChosen(''); 44 setWordChosen('');
45 + setRound(data.round);
43 } 46 }
44 }, []); 47 }, []);
45 48
...@@ -69,6 +72,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => { ...@@ -69,6 +72,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
69 <div className='w-full flex flex-col justify-center items-center'> 72 <div className='w-full flex flex-col justify-center items-center'>
70 {words.map((word, i) => (<Word key={word} index={i} word={word} setWordChosen={setWordChosen} setWords={setWords} />))} 73 {words.map((word, i) => (<Word key={word} index={i} word={word} setWordChosen={setWordChosen} setWords={setWords} />))}
71 </div> 74 </div>
75 + <RoundInfo round={round} wordChosen={wordChosen}/>
72 <Canvas isDrawer={isDrawer && wordChosen !== ''}/> 76 <Canvas isDrawer={isDrawer && wordChosen !== ''}/>
73 </div> 77 </div>
74 ); 78 );
......
1 +import React from 'react';
2 +import SocketContext from '../../contexts/SocketContext';
3 +import { RoundData } from './types';
4 +
5 +interface RoundInfoProps {
6 + round: number;
7 + wordChosen: string;
8 +}
9 +
10 +export const RoundInfo: React.FC<RoundInfoProps> = ({ round, wordChosen }) => {
11 + return (
12 + <div className='w-full p-3 flex items-center place-content-between'>
13 + <div>대충 타이머 위치</div>
14 + <div>{wordChosen}</div>
15 + <div>R{round}</div>
16 + </div>
17 + );
18 +}
...\ No newline at end of file ...\ No newline at end of file