-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Toy2-team10/TALK-9--feat/chatList/get_list
Feat: 채팅방 목록 조회 기능 구현
- Loading branch information
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import instance from './axios'; | ||
|
||
const chatListAPI = { | ||
// 로그인 | ||
getAllChatList() { | ||
return instance.get('/chat/all'); | ||
}, | ||
// 회원가입 | ||
getMyChatList() { | ||
return instance.get('/chat'); | ||
}, | ||
}; | ||
|
||
export default chatListAPI; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useState, useEffect } from 'react'; | ||
import Link from 'next/link'; | ||
import chatListAPI from '../../apis/chatListAPI'; | ||
|
||
export default function AllChatList() { | ||
const [allChatList, setAllChatList] = useState([]); | ||
const getAllChat = async () => { | ||
const chatAllList = await chatListAPI.getAllChatList(); | ||
setAllChatList(chatAllList.data.chats); | ||
}; | ||
useEffect(() => { | ||
getAllChat(); | ||
}, []); | ||
return ( | ||
<> | ||
{allChatList.map(chat => ( | ||
<Link href={`/chat/${chat.id}`} key={chat.id}> | ||
<div>{chat.name}</div> | ||
</Link> | ||
))} | ||
</> | ||
); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useState, useEffect } from 'react'; | ||
import Link from 'next/link'; | ||
import chatListAPI from '../../apis/chatListAPI'; | ||
|
||
export default function MyChatList() { | ||
const [myChatList, setMyChatList] = useState([]); | ||
const getMyChat = async () => { | ||
const ChatMyList = await chatListAPI.getMyChatList(); | ||
setMyChatList(ChatMyList.data.chats); | ||
}; | ||
useEffect(() => { | ||
getMyChat(); | ||
}, []); | ||
return ( | ||
<> | ||
{myChatList.map(chat => ( | ||
<Link href={`/chat/${chat.id}`} key={chat.id}> | ||
<div>{chat.name}</div> | ||
</Link> | ||
))} | ||
</> | ||
); | ||
} |