Skip to content

Commit 3d0fa61

Browse files
committed
feat: 채팅 UX의 매칭 렌더링 구현
1 parent d312ff2 commit 3d0fa61

16 files changed

Lines changed: 127 additions & 143 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import PostInstaFeedSelect from '@pages/Post/PostInstaFeedSelect';
2424

2525
import Chats from '@pages/Chats';
2626
import ChatRoom from '@pages/Chats/ChatRoom';
27+
import MatchingRoom from '@pages/Chats/MatchingRoom';
2728

2829
import NotFound from '@pages/NotFound';
2930

@@ -55,6 +56,7 @@ const protectedRoutes = [
5556
// 메시지/채팅
5657
{ path: '/chats', element: <Chats /> },
5758
{ path: '/chats/:chatRoomId', element: <ChatRoom /> },
59+
{ path: '/matching', element: <MatchingRoom /> },
5860
];
5961

6062
// 인증이 필요 없는 페이지 배열

src/apis/matching/dto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export interface CreateMatchingData {
2222

2323
// 최근 매칭 조회 (채팅방 리스트에서)
2424
export interface LatestMatchingData {
25-
id: number;
26-
requesterId: number;
27-
targetId: number;
28-
requestStatus: RequestStatusEnum;
25+
id?: number;
26+
requesterId?: number;
27+
targetId?: number;
28+
requestStatus?: RequestStatusEnum;
2929
createdAt: Date;
3030
}
3131

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { MatchingData } from '@apis/matching/dto';
2+
3+
// export interface CardProps {
4+
// removeRejectedMatching: () => void;
5+
// matching: MatchingData;
6+
// }
7+
8+
export type CardProps = Pick<MatchingData, 'id' | 'chatRoomId' | 'requester'>;

src/pages/Chats/MatchingRoom/Cards/Card/index.tsx renamed to src/pages/Chats/MatchingRoom/Card/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ import {
3737
SeeMore,
3838
} from './styles';
3939

40-
const Card: React.FC<CardProps> = ({ removeRejectedMatching, matching }) => {
40+
const Card: React.FC<CardProps> = ({ id, chatRoomId, requester }) => {
4141
const [isStatusModalOpen, setIsStatusModalOpen] = useState(false);
4242
const [modalContent, setModalContent] = useState('알 수 없는 오류가 발생했습니다.\n관리자에게 문의해 주세요.');
4343
const [, setOtherUser] = useRecoilState(OtherUserAtom);
4444
const nav = useNavigate();
45-
const requester = matching.requester;
4645

4746
const handleUserClick = () => {
4847
nav(`/profile/${requester.id}`);
@@ -59,19 +58,16 @@ const Card: React.FC<CardProps> = ({ removeRejectedMatching, matching }) => {
5958
// 매칭 거절 및 수락 api
6059
const modifyMatchingStatus = async (status: 'accept' | 'reject') => {
6160
try {
62-
console.log(matching);
63-
const response = await modifyMatchingStatusApi(matching.id, { requestStatus: status });
61+
const response = await modifyMatchingStatusApi(id, { requestStatus: status });
6462

6563
if (response.isSuccess) {
66-
removeRejectedMatching(); // 매칭 리스트에서 해당 매칭을 제거
67-
6864
if (status === 'accept') {
6965
setOtherUser({
7066
id: requester.id,
7167
nickname: requester.nickname,
7268
profilePictureUrl: requester.profilePictureUrl,
7369
});
74-
nav(`/chats/${response.data.chatRoomId}`);
70+
nav(`/chats/${chatRoomId}`);
7571
}
7672
}
7773
} catch (error) {
File renamed without changes.

src/pages/Chats/MatchingRoom/Cards/Card/dto.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/pages/Chats/MatchingRoom/Cards/dto.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 0 additions & 68 deletions
This file was deleted.

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

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import dayjs from 'dayjs';
2+
3+
import RcvdMessage from '@pages/Chats/RcvdMessage';
4+
5+
import type { MatchingData } from '@apis/matching/dto';
6+
import type { RcvdMessageProps } from '@pages/Chats/RcvdMessage/dto';
7+
8+
import type { CardProps } from '../Card/dto';
9+
10+
import Card from '../Card';
11+
12+
const MatchingMessage: React.FC<MatchingData> = ({ id, message, createdAt, chatRoomId, requester }: MatchingData) => {
13+
const formattedTime = dayjs(createdAt).format('HH:mm');
14+
15+
const firstMessageProps: RcvdMessageProps = {
16+
fromUserNickname: '오딩이',
17+
profilePictureUrl: '',
18+
content: '얘가 너 소개받고 싶대',
19+
isSenderChanged: true,
20+
isProfileImageVisible: true,
21+
isTimeVisible: false,
22+
formattedTime,
23+
};
24+
25+
const matchingMessageProps: RcvdMessageProps = {
26+
fromUserNickname: '오딩이',
27+
profilePictureUrl: '',
28+
content: message,
29+
isSenderChanged: false,
30+
isProfileImageVisible: false,
31+
isTimeVisible: true,
32+
formattedTime,
33+
};
34+
35+
const cardProps: CardProps = {
36+
id,
37+
chatRoomId,
38+
requester,
39+
};
40+
41+
return (
42+
<>
43+
<RcvdMessage {...firstMessageProps} />
44+
<RcvdMessage {...matchingMessageProps}>
45+
<Card {...cardProps} />
46+
</RcvdMessage>
47+
</>
48+
);
49+
};
50+
51+
export default MatchingMessage;

0 commit comments

Comments
 (0)