Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/features/chat/api/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type { ChatProduct, ChatRole, SaleStatus, TradeStatus } from '../model/ty
import type { ChatRoomDetailResponse, ProductStatus } from './dto';

// 채팅방 생성 또는 조회 (아이템 상세 페이지 채팅하기 버튼).
// 판매자가 받은 구매 제안 상세에서 열 땐 purchaseOfferId를 함께 보내 제안자↔소유자 방을 잡는다.
export const createOrGetChatRoom = (itemId: number, purchaseOfferId?: number) =>
api.post<{ chatRoomId: number }>('/chats', {
itemId,
...(purchaseOfferId != null && { purchaseOfferId }),
});
api.post<{ chatRoomId: number }>('/chats', { itemId, purchaseOfferId });

// 채팅방 생성 또는 조회 (거래 상세 페이지 채팅하기 버튼).
export const createOrGetChatRoomByTrade = (tradeId: number) =>
api.post<{ chatRoomId: number }>(`/chats/trades/${tradeId}`);

// 채팅방 상세 조회 (프로덕트 바 데이터)
export const getChatRoom = (chatRoomId: number) => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/mypage/TradeDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTradeStatusChange } from '@/features/trade/api/useTradeStatusChange'
import type { TradeStatus } from '@/features/trade/api/types';
import { buildTradeTimeline } from '@/features/trade/lib/buildTradeTimeline';
import { resolveImageUrl } from '@/shared/lib/resolveImageUrl';
import { createOrGetChatRoom } from '@/features/chat/api/room';
import { createOrGetChatRoomByTrade } from '@/features/chat/api/room';

const SectionTitle = ({ children }: { children: ReactNode }) => (
<p className="px-[16px] pt-[24px] pb-[8px] text-[12px] text-[#767676]">{children}</p>
Expand Down Expand Up @@ -152,7 +152,7 @@ const TradeDetailPage = () => {
if (isChatLoading) return;
setIsChatLoading(true);
try {
const { chatRoomId } = await createOrGetChatRoom(trade.itemId);
const { chatRoomId } = await createOrGetChatRoomByTrade(trade.tradeId);
navigate(`/chat/${chatRoomId}`);
} finally {
setIsChatLoading(false);
Expand Down
Loading