diff --git a/src/frontend/src/api/endpoints/room/room.api.ts b/src/frontend/src/api/endpoints/room/room.api.ts index 79b2d11c..f4de8766 100644 --- a/src/frontend/src/api/endpoints/room/room.api.ts +++ b/src/frontend/src/api/endpoints/room/room.api.ts @@ -1,5 +1,12 @@ import instance from '@/api/axios.instance'; -import { PlaylistDto, RoomRequestDto, MyRoomDto, RoomDto, CurrentRoomDto } from './room.interface'; +import { + PlaylistDto, + RoomRequestDto, + MyRoomDto, + RoomDto, + CurrentRoomDto, + ReceiveMessageDto, +} from './room.interface'; export const roomApi = { // 방 생성 @@ -41,6 +48,14 @@ export const roomApi = { // return data; // }, + // 메시지 조회 + getMessages: async (roomId: number, cursor?: number, limit?: number) => { + const { data } = await instance.get(`/messages/${roomId}`, { + params: { cursor, limit: limit ?? 10 }, + }); + return data; + }, + // 방 참여자 조회 getParticipants: async (roomId: string) => { const { data } = await instance.get(`/rooms/participants`, { params: { roomId } }); diff --git a/src/frontend/src/api/endpoints/room/room.interface.ts b/src/frontend/src/api/endpoints/room/room.interface.ts index e18dd491..9484b6a1 100644 --- a/src/frontend/src/api/endpoints/room/room.interface.ts +++ b/src/frontend/src/api/endpoints/room/room.interface.ts @@ -66,3 +66,18 @@ export interface CurrentRoomDto { playlist: CurrentRoomPlaylistDto[]; }; } + +export interface SendMessageDto { + roomId: number; + userId: number; + nickname: string | null; + role: number; + profileImageUrl: string | null; + content: string | null; + message: string; +} + +export interface ReceiveMessageDto extends SendMessageDto { + id: string; + timestamp: number; +} diff --git a/src/frontend/src/components/Modal/RoomCreateModal/index.tsx b/src/frontend/src/components/Modal/RoomCreateModal/index.tsx index ddfbd838..f0207bfc 100644 --- a/src/frontend/src/components/Modal/RoomCreateModal/index.tsx +++ b/src/frontend/src/components/Modal/RoomCreateModal/index.tsx @@ -24,6 +24,7 @@ interface IRoomCreateModal { export const RoomCreateModal = ({ onCancel }: IRoomCreateModal) => { const titleRef = useRef(null); + const descriptionRef = useRef(null); const [isPublic, setIsPublic] = useState(true); const [titleLength, setTitleLength] = useState(0); const createRoom = useCreateRoom(); @@ -50,7 +51,7 @@ export const RoomCreateModal = ({ onCancel }: IRoomCreateModal) => { createRoom.mutate({ title: titleRef.current?.value || '', - description: '', + description: descriptionRef.current?.value || '', isPublic: isPublic, }); onCancel(); @@ -81,7 +82,7 @@ export const RoomCreateModal = ({ onCancel }: IRoomCreateModal) => { required /> {`${titleLength} / 60`} -