-
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 branch 'main' of https://github.com/MOVIEJOJO7/cat-talk into Fe…
…ature/#2
Showing
7 changed files
with
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## 관련 이슈 | ||
|
||
<!-- 관련있는 이슈 번호(#000)을 적어주세요. --> | ||
|
||
## Description | ||
|
||
<!-- 작업 내용을 적어주세요. --> | ||
<!-- 강조할 부분은 볼드체로 작성해 주세요. --> | ||
|
||
## 유의할 점 및 ETC (optional) | ||
|
||
<!-- 팀원이 유의해야할 변경 사항이나 로직 및 기타 사항이 생겼다면 적어주세요. --> |
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,17 @@ | ||
import React from 'react'; | ||
import { fetchAllOpenChat } from './search.utils'; | ||
|
||
const accessToken = process.env.ACCESSTOKEN as string; // 임시 access token | ||
|
||
const Search = async () => { | ||
const allOpenChat = await fetchAllOpenChat(accessToken); | ||
console.log(allOpenChat); | ||
|
||
return ( | ||
<> | ||
<h1>Search 페이지</h1> | ||
</> | ||
); | ||
}; | ||
|
||
export default Search; |
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,9 @@ | ||
// http Method | ||
export const GET = 'GET'; | ||
|
||
// API URL | ||
export const BASE_URL = 'https://fastcampus-chat.net/'; | ||
export const GET_CHAT_ALL = 'chat/all'; | ||
|
||
// API Request 조건 정보 | ||
export const CONTENT_TYPE = 'application/json'; |
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,36 @@ | ||
export type AllOpenChat = Chat[]; | ||
|
||
export type AllOpenChatJSON = { | ||
chats: AllOpenChat; | ||
}; | ||
|
||
type Chat = { | ||
id: string; | ||
name: string; | ||
users: User[]; | ||
isPrivate: boolean; | ||
latestMessage: Message | null; | ||
updatedAt: Date; | ||
}; | ||
|
||
type User = { | ||
id: string; | ||
name: string; | ||
picture: string; | ||
}; | ||
|
||
type Message = { | ||
id: string; | ||
text: string; | ||
userId: string; | ||
createAt: Date; | ||
}; | ||
|
||
export type Request = { | ||
method: string; | ||
headers: { | ||
'content-type': string; | ||
serverId: string; | ||
Authorization: string; | ||
}; | ||
}; |
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,19 @@ | ||
import { Request, AllOpenChatJSON, AllOpenChat } from './search.type'; | ||
import { GET, CONTENT_TYPE, BASE_URL, GET_CHAT_ALL } from './search.constant'; | ||
|
||
export const fetchAllOpenChat = async (accessToken: string) => { | ||
const Request: Request = { | ||
method: GET, | ||
headers: { | ||
'content-type': CONTENT_TYPE, | ||
serverId: process.env.SERVER_ID as string, // 서버 아이디 임시 사용 | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}; | ||
|
||
const res = await fetch(`${BASE_URL}${GET_CHAT_ALL}`, Request); | ||
const resJson: AllOpenChatJSON = await res.json(); | ||
const allOpenChat: AllOpenChat = resJson.chats; | ||
|
||
return allOpenChat; | ||
}; |
Empty file.
Empty file.