diff --git a/src/domains/freetalk/components/ChatRoomModal.jsx b/src/domains/freetalk/components/ChatRoomModal.jsx index c62ca79..1856abc 100644 --- a/src/domains/freetalk/components/ChatRoomModal.jsx +++ b/src/domains/freetalk/components/ChatRoomModal.jsx @@ -35,6 +35,8 @@ import {useAuth} from '../../../contexts/AuthContext' import {useThemeMode} from '../../../contexts/ThemeContext' import {DESIGN_TOKENS, getChatStyles} from '../../../theme/theme' import {useChatWebSocket} from '../hooks/useChatWebSocket' +import SystemCommandMessage from './SystemCommandMessage' +import {MessageType} from '../types/chatCommandTypes' const ChatRoomModal = ({open, onClose, room, onLeave}) => { const theme = useTheme() @@ -456,7 +458,15 @@ const ChatRoomModal = ({open, onClose, room, onLeave}) => { ) : ( - messages.map((message) => ( + messages.map((message) => { + // 시스템 명령어 메시지 (SYSTEM_COMMAND) + if (message.messageType === MessageType.SYSTEM_COMMAND || message.messageType === 'SYSTEM_COMMAND') { + return ( + + ) + } + + return ( { )} - )) + )}) )}
diff --git a/src/domains/freetalk/components/SystemCommandMessage.jsx b/src/domains/freetalk/components/SystemCommandMessage.jsx index 12a1423..253382f 100644 --- a/src/domains/freetalk/components/SystemCommandMessage.jsx +++ b/src/domains/freetalk/components/SystemCommandMessage.jsx @@ -18,9 +18,18 @@ const SystemCommandMessage = ({ data }) => { const { mode } = useThemeMode() const isDark = mode === 'dark' - const config = SystemCommandConfig[data.commandType] || SystemCommandConfig.help + // 명령어 타입 추출 + const commandType = data?.commandType || data?.type || data?.raw?.type || 'help' + const config = SystemCommandConfig[commandType] || SystemCommandConfig.help const { icon, color, bgColor } = config + // 표시 텍스트 추출 + const displayText = data?.displayText || data?.message || data?.content || '' + const userId = data?.userId || data?.nickname || '' + + // 결과 값 추출 + const result = data?.result || data?.raw || {} + return ( { {/* 내용 */} - - - {data.userId} - + {/* displayText가 있으면 그대로 표시 (백엔드에서 이미 포맷팅됨) */} + {displayText ? ( - {data.displayText} + {displayText} - - - {/* 추가 결과 정보 */} - {renderCommandResult(data.commandType, data.result, isDark)} + ) : ( + <> + + + {userId} + + + {/* 추가 결과 정보 */} + {renderCommandResult(commandType, result, isDark)} + + )} diff --git a/src/domains/freetalk/hooks/useChatWebSocket.js b/src/domains/freetalk/hooks/useChatWebSocket.js index 8aad516..fd6eaaa 100644 --- a/src/domains/freetalk/hooks/useChatWebSocket.js +++ b/src/domains/freetalk/hooks/useChatWebSocket.js @@ -165,14 +165,21 @@ export function useChatWebSocket(roomId, userId) { }, onSystemCommand: (data) => { - console.log('[useChatWebSocket] System command:', data) - const commandData = data.data || data + const commandData = data.data || {} const commandMessage = { id: `syscmd-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, messageType: 'SYSTEM_COMMAND', - userId: commandData.userId, - createdAt: new Date().toISOString(), - data: commandData, + userId: commandData.userId || commandData.nickname || data.userId, + createdAt: data.createdAt || new Date().toISOString(), + data: { + commandType: commandData.type || 'help', + userId: commandData.userId || commandData.nickname, + displayText: data.content || data.message || '', + result: typeof commandData.result === 'object' + ? commandData.result + : { value: commandData.result }, + raw: commandData, + }, } setMessages((prev) => [...prev, commandMessage]) },