diff --git a/src/pages/GamePage/GameCode/CodeContainer.tsx b/src/pages/GamePage/GameCode/CodeContainer.tsx index 3ade8090..f7b49479 100644 --- a/src/pages/GamePage/GameCode/CodeContainer.tsx +++ b/src/pages/GamePage/GameCode/CodeContainer.tsx @@ -10,7 +10,7 @@ const CodeContainer = ({ codeItem }: CodeContainerProps) => { return ( <>
- {codeItem} + {codeItem}
); diff --git a/src/pages/GamePage/GameCode/GameCode.tsx b/src/pages/GamePage/GameCode/GameCode.tsx index ab952d1a..b56f2c9c 100644 --- a/src/pages/GamePage/GameCode/GameCode.tsx +++ b/src/pages/GamePage/GameCode/GameCode.tsx @@ -20,7 +20,19 @@ const GameCode = ({ publishIngame, userId }: GameCodeProps) => { const codeList = useRef(ingameRoomRes.questions!); const convertedCodeList = codeList.current.map(({ question }) => - question.split('\n').map((code) => code.trim()) + question.split('\n').flatMap((code) => { + const trimedCode = code.trim(); + const splitedTrimedCode = trimedCode.split(' '); + const SPLIT_INDEX = Math.floor((splitedTrimedCode.length - 1) / 2); + + if (splitedTrimedCode.length > 1 && trimedCode.length > 65) { + return [ + splitedTrimedCode.slice(0, SPLIT_INDEX).join(' '), + splitedTrimedCode.slice(SPLIT_INDEX).join(' '), + ]; + } + return [trimedCode]; + }) ); const handleNextRound = useCallback(() => {