Skip to content

Commit 4acece6

Browse files
committed
fix: 새 매칭이 없을 때 렌더링 로직 수정
1 parent d41b30c commit 4acece6

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { styled } from 'styled-components';
33
export const CardLayout = styled.div`
44
border-radius: 0.5rem;
55
position: relative;
6+
height: fit-content;
67
`;
78

89
export const ProfileContainer = styled.div`

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const MatchingMessage: React.FC<MatchingData> = ({ id, message, createdAt, chatR
2828
content: message,
2929
isSenderChanged: false,
3030
isProfileImageVisible: false,
31-
isTimeVisible: true,
31+
isTimeVisible: false,
3232
formattedTime,
3333
};
3434

@@ -41,9 +41,11 @@ const MatchingMessage: React.FC<MatchingData> = ({ id, message, createdAt, chatR
4141
return (
4242
<>
4343
<RcvdMessage {...firstMessageProps} />
44-
<RcvdMessage {...matchingMessageProps}>
45-
<Card {...cardProps} />
46-
</RcvdMessage>
44+
<div style={{ maxWidth: '90%' }}>
45+
<RcvdMessage {...matchingMessageProps}>
46+
<Card {...cardProps} />
47+
</RcvdMessage>
48+
</div>
4749
</>
4850
);
4951
};

src/pages/Chats/MatchingRoom/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MessagesContainer } from './styles';
1919

2020
const MatchingRoom: React.FC = () => {
2121
const [allMatchings, setAllMatchings] = useState<MatchingData[]>([]);
22+
const [hasNewMatching, setHasNewMatching] = useState(true);
2223

2324
const [isLoading, setIsLoading] = useState(true);
2425
const [isScroll, setIsScroll] = useState(false);
@@ -55,15 +56,17 @@ const MatchingRoom: React.FC = () => {
5556
useEffect(() => {
5657
// 전체 매칭 불러오기 socket api
5758
const getAllMatchings = ({ matching }: { matching: MatchingData[] }) => {
58-
console.log(allMatchings);
5959
setAllMatchings(matching);
6060
setIsScroll(true);
6161
setIsLoading(false);
6262
};
6363

6464
const getNewMatching = (data: MatchingData) => {
65-
if (JSON.stringify(data) === '{}') return;
66-
setAllMatchings([...allMatchings, data]);
65+
if (JSON.stringify(data) === '{}') {
66+
setHasNewMatching(false);
67+
} else {
68+
setAllMatchings([...allMatchings, data]);
69+
}
6770
};
6871

6972
if (socket) {
@@ -95,7 +98,6 @@ const MatchingRoom: React.FC = () => {
9598
<NoMatchingMessage />
9699
) : (
97100
allMatchings.map((matching: MatchingData) => {
98-
// TODO: 매칭 상태에 따라 응답 버튼 렌더링
99101
return (
100102
<div key={matching.id}>
101103
<MatchingMessage {...matching} />
@@ -104,6 +106,7 @@ const MatchingRoom: React.FC = () => {
104106
);
105107
})
106108
)}
109+
{!hasNewMatching && <NoMatchingMessage />}
107110
<div ref={chatWindowRef} />
108111
</MessagesContainer>
109112
<ChatBox disabled={true} />

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ const MatchingRoomItem: React.FC<Partial<LatestMatchingData>> = ({ requestStatus
3838
}
3939
}, []);
4040

41-
console.log(requestStatus);
42-
4341
return (
4442
<MatchingRoomLayout onClick={handleMatchingRoomClick}>
4543
<UserImage src={'오딩이 프로필 이미지'} alt="user" />

src/pages/Chats/RecentChat/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ const RecentChat: React.FC = () => {
3535
// 최근 매칭 조회
3636
const getLatestMatching = (data: LatestMatchingData) => {
3737
setLatestMatching(data);
38-
console.log('getLatestMatching');
3938
};
4039

41-
const matchingNotFound = (data: LatestMatchingData) => {
42-
console.log(data);
43-
console.log('matchingNotFound');
40+
const matchingNotFound = (data: { joinedAt: Date }) => {
41+
setLatestMatching({
42+
createdAt: data.joinedAt,
43+
});
4444
};
4545

4646
if (socket) {

0 commit comments

Comments
 (0)