Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/148 채팅에서 직업 보여주기 #150

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: 채팅에서 직업 찾아서 보여주기
cheonjiyun committed Dec 15, 2024
commit 231aa5f42ec7fa6ba37b542ebd61cff6702ee5b1
7 changes: 6 additions & 1 deletion src/components/chat/ChatGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { forwardRef } from 'react';
import { useRecoilState } from 'recoil';

import { roomInfoState } from '../../recoil/roominfo/atom';
import { VariablesCSS } from '../../styles/VariablesCSS';
import { Chat } from '../../type';
import { getPlayerJob } from '../../util/job';
import PlayerChat from '../player/PlayerChat';
import ChatMessage from './ChatMessage';

@@ -15,9 +18,11 @@ interface PropsType {
export default forwardRef(function ChatGroup(props: PropsType, ref: any) {
const { chats } = props;

const [roomInfo] = useRecoilState(roomInfoState);

return (
<div ref={ref} css={container(props)}>
<PlayerChat job={chats[0].job} />
<PlayerChat job={getPlayerJob(roomInfo.players, chats[0].name)} />
<div css={right(props)}>
<p css={nameText}>{chats[0].name}</p>
{chats.map((chat, idx) => (
5 changes: 5 additions & 0 deletions src/util/job.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Job, Player } from '../type';

export const getPlayerJob = (players: Player[], name: string): Job => {
return players.find(el => el.name == name)?.job || null;
};