Skip to content

Commit d0d8695

Browse files
committed
fix: 매칭룸 버그 해결
1 parent 3341925 commit d0d8695

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

src/pages/Chats/MatchingRoom/Card/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Card: React.FC<CardProps> = ({ requester }) => {
3030
</ProfileImgBox>
3131
<ProfileInfo>
3232
<StyledText
33-
$textTheme={{ style: 'body1-medium' }}
33+
$textTheme={{ style: 'body2-medium' }}
3434
color={theme.colors.text.primary}
3535
onClick={handleUserClick}
3636
>
@@ -39,7 +39,7 @@ const Card: React.FC<CardProps> = ({ requester }) => {
3939
<div className="row-flex">
4040
{requester.representativePost.styleTags.map((tag, index) => (
4141
<div className="row-flex" key={tag}>
42-
<StyledText $textTheme={{ style: 'caption2-regular' }} color={theme.colors.gray[200]}>
42+
<StyledText $textTheme={{ style: 'caption2-regular' }} color={theme.colors.gray[600]}>
4343
{tag}
4444
</StyledText>
4545
{index < requester.representativePost.styleTags.length - 1 && (

src/pages/Chats/MatchingRoom/ResponseMessage/index.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import { useNavigate } from 'react-router-dom';
22

3+
import { useRecoilState } from 'recoil';
4+
5+
import theme from '@styles/theme';
6+
7+
import { RequesterDto } from '@apis/matching/dto';
38
import { useSocket } from '@context/SocketProvider';
9+
import { OtherUserAtom } from '@recoil/util/OtherUser';
10+
11+
import { StyledText } from '@components/Text/StyledText';
412

513
import { ResponseButton, ResponseContainer } from './styles';
614

715
export interface ResponseMessageProps {
816
matchingId: number;
917
chatRoomId: number;
18+
requester: Omit<RequesterDto, 'RepresentativePostDto'>;
1019
requestStatus: 'accepted' | 'rejected' | 'pending';
1120
}
1221

13-
const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomId, requestStatus }) => {
22+
const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomId, requester, requestStatus }) => {
1423
const socket = useSocket('matching');
1524
const isPending = requestStatus === 'pending';
1625
const nav = useNavigate();
26+
const [, setOtherUser] = useRecoilState(OtherUserAtom);
1727

1828
const handlebuttonClick = (status: 'accept' | 'reject') => {
1929
if (requestStatus !== 'pending') return;
2030
if (socket) {
2131
socket.emit('patchMatching', { id: matchingId, requestStatus: status });
2232
if (status === 'accept') {
33+
setOtherUser(requester);
2334
nav(`/chats/${chatRoomId}`);
2435
}
2536
}
@@ -29,12 +40,16 @@ const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomI
2940
<ResponseContainer>
3041
{(requestStatus === 'pending' || requestStatus === 'rejected') && (
3142
<ResponseButton $isPending={isPending} onClick={() => handlebuttonClick('reject')}>
32-
거절
43+
<StyledText $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
44+
거절
45+
</StyledText>
3346
</ResponseButton>
3447
)}
3548
{(requestStatus === 'pending' || requestStatus === 'accepted') && (
3649
<ResponseButton $isPending={isPending} onClick={() => handlebuttonClick('accept')}>
37-
수락
50+
<StyledText $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
51+
수락
52+
</StyledText>
3853
</ResponseButton>
3954
)}
4055
</ResponseContainer>

src/pages/Chats/MatchingRoom/ResponseMessage/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export const ResponseButton = styled.button<{ $isPending: boolean }>`
1111
padding: 0.4rem 0.8rem;
1212
margin: 0.5rem 0;
1313
background-color: #f2f2f2;
14-
border-radius: 0.5rem;
14+
border-radius: 0.8rem;
1515
overflow-wrap: break-word;
1616
`;

src/pages/Chats/MatchingRoom/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MatchingRoom: React.FC = () => {
5656
useEffect(() => {
5757
// 전체 매칭 불러오기 socket api
5858
const getAllMatchings = ({ matching }: { matching: MatchingData[] }) => {
59+
console.log(matching);
5960
setAllMatchings(matching);
6061
setIsScroll(true);
6162
setIsLoading(false);
@@ -70,16 +71,23 @@ const MatchingRoom: React.FC = () => {
7071
}
7172
};
7273

74+
const handleError = (data: string) => {
75+
alert(data);
76+
};
77+
7378
if (socket) {
7479
socket.emit('getAllMatchings', { userId: currentUserId });
7580
socket.emit('getMatching', { userId: currentUserId });
7681
socket.on('matchings', getAllMatchings);
7782
socket.on('nextMatching', getNewMatching);
83+
socket.on('error', handleError);
7884
}
7985

8086
return () => {
8187
if (socket) {
82-
socket.off();
88+
socket.off('matchings');
89+
socket.off('nextMatching');
90+
socket.off('error');
8391
}
8492
};
8593
}, [socket]);
@@ -103,6 +111,7 @@ const MatchingRoom: React.FC = () => {
103111
<ResponseMessage
104112
matchingId={matching.id}
105113
chatRoomId={matching.chatRoomId}
114+
requester={matching.requester}
106115
requestStatus={matching.requestStatus}
107116
/>
108117
</div>

src/pages/Chats/RcvdMessage/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@ const RcvdMessage: React.FC<RcvdMessageProps & { onClickProfile?: () => void; ch
2222
return (
2323
<FirstMessageLayout $isSenderChanged={isSenderChanged}>
2424
<UserImage onClick={onClickProfile} src={profilePictureUrl} alt="프로필 사진" />
25-
<MessageBox>
25+
<div>
2626
<UsernameText
2727
onClick={onClickProfile}
2828
$textTheme={{ style: 'body2-regular' }}
2929
color={theme.colors.text.primary}
3030
>
3131
{fromUserNickname}
3232
</UsernameText>
33-
<Message $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
34-
{children}
35-
{content}
36-
</Message>
37-
</MessageBox>
38-
{isTimeVisible && <TimeWrapper>{formattedTime}</TimeWrapper>}
33+
<MessageBox>
34+
<Message $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
35+
{children}
36+
{content}
37+
</Message>
38+
{isTimeVisible && <TimeWrapper>{formattedTime}</TimeWrapper>}
39+
</MessageBox>
40+
</div>
3941
</FirstMessageLayout>
4042
);
4143
} else {

src/pages/Chats/RcvdMessage/styles.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ export const UserImage = styled.img`
2424

2525
export const UsernameText = styled(StyledText)`
2626
cursor: pointer;
27+
margin-bottom: 0.2rem;
2728
`;
2829

2930
export const MessageBox = styled.div`
3031
display: flex;
31-
flex-direction: column;
3232
gap: 0.2rem;
33-
/* max-width: 75%; */
3433
margin-right: 0.5rem;
3534
`;
3635

src/pages/Chats/RecentChat/ChatRoomItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ChatRoomItem: React.FC<ChatRoomData> = ({ id, otherUser, latestMessage })
5252
<StyledText $textTheme={{ style: 'body2-medium' }} color={theme.colors.text.primary}>
5353
{otherUser?.nickname || '알수없음'}
5454
</StyledText>
55-
<LatestMessage $textTheme={{ style: 'caption2-regular' }} color={theme.colors.text.primary}>
55+
<LatestMessage $textTheme={{ style: 'caption1-regular' }} color={theme.colors.text.primary}>
5656
{latestMessage.content}
5757
</LatestMessage>
5858
</LeftBox>

src/pages/Chats/RecentChat/MatchingRoomItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const MatchingRoomItem: React.FC<Partial<LatestMatchingData>> = ({ requestStatus
4747
<StyledText $textTheme={{ style: 'body2-medium' }} color={theme.colors.text.primary}>
4848
오딩이
4949
</StyledText>
50-
<LatestMessage $textTheme={{ style: 'caption2-regular' }} color={theme.colors.text.primary}>
50+
<LatestMessage $textTheme={{ style: 'caption1-regular' }} color={theme.colors.text.primary}>
5151
{requestStatus === 'pending' ? '얘가 너 소개받고 싶대' : '매칭이 들어오면 오딩이가 알려줄게!'}
5252
</LatestMessage>
5353
</LeftBox>

0 commit comments

Comments
 (0)