Skip to content

Commit 40b6948

Browse files
authored
Merge pull request #19 from 100-hours-a-week/feature/setting
feat: 채팅 내역 조회 바텀시트 구현 및 API 연동
2 parents c7451b8 + ca8657e commit 40b6948

File tree

5 files changed

+567
-62
lines changed

5 files changed

+567
-62
lines changed

src/app/api/endpoints/chats.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,35 @@ export const fetchChats = async () => {
1111
const response = await apiClient.get(API_CONFIG.ENDPOINTS.CHATS);
1212
return response.data.data;
1313
};
14+
15+
/**
16+
* Fetch chat messages for a specific chatroom (cursor-based pagination)
17+
* @param {number} chatroomId - Chatroom ID
18+
* @param {string | null} cursor - Cursor value (timestamp|messageId format)
19+
* @param {number} size - Page size (default: 20)
20+
* @returns {Promise<{chats: Array, before: string | null, next: string | null}>}
21+
* @throws {Error} 401 if not authenticated, 400 if invalid cursor/size
22+
*/
23+
export const fetchChatMessages = async (chatroomId, cursor = null, size = 20) => {
24+
const params = { size };
25+
if (cursor) {
26+
params.after = cursor;
27+
}
28+
29+
const response = await apiClient.get(API_CONFIG.ENDPOINTS.CHAT_MESSAGES(chatroomId), {
30+
params,
31+
});
32+
return response.data.data;
33+
};
34+
35+
/**
36+
* Send a message to a chatroom
37+
* TODO: Implement after POST API spec is provided
38+
* @param {number} chatroomId - Chatroom ID
39+
* @param {object} payload - Message payload (text, files, etc.)
40+
* @returns {Promise<object>} Created message object
41+
*/
42+
export const sendChatMessage = async (chatroomId, payload) => {
43+
// TODO: Implement after POST /chats/{chatroomId} spec is provided
44+
throw new Error('POST /chats/{chatroomId} API spec not yet provided');
45+
};

0 commit comments

Comments
 (0)