From 0b1ca2f196497c596c50380eed57100caa236764 Mon Sep 17 00:00:00 2001 From: JitHoon Date: Thu, 9 Nov 2023 16:27:39 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Feat:=20Search=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/search/page.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/search/page.tsx b/app/search/page.tsx index c01a8b1..c1d1d4f 100644 --- a/app/search/page.tsx +++ b/app/search/page.tsx @@ -1,15 +1,19 @@ import React from 'react'; import { fetchAllOpenChat } from './search.utils'; +import SearchOpenChat from '../../Components/Search/SearchOpenChat'; +import FilterOpenChat from '../../Components/Search/FilterOpenChat'; +import ShowAllOpenChat from '../../Components/Search/ShowAllOpenChat'; -const accessToken = process.env.ACCESSTOKEN as string; // 임시 access token +const accessToken = process.env.NEXT_PUBLIC_ACCESSTOKEN as string; // 임시 access token const Search = async () => { const allOpenChat = await fetchAllOpenChat(accessToken); - console.log(allOpenChat); return ( <> -

Search 페이지

+ + + ); }; From b30b399d3dd0735494b3041a6f8c634e8b048139 Mon Sep 17 00:00:00 2001 From: JitHoon Date: Thu, 9 Nov 2023 16:30:21 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Feat:=20Search=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EC=97=90=20=EC=B6=94=EA=B0=80=ED=95=A0=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=EB=93=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Components/Search/FilterOpenChat.tsx | 15 +++++++++++++++ Components/Search/SearchOpenChat.tsx | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Components/Search/FilterOpenChat.tsx create mode 100644 Components/Search/SearchOpenChat.tsx diff --git a/Components/Search/FilterOpenChat.tsx b/Components/Search/FilterOpenChat.tsx new file mode 100644 index 0000000..c98f940 --- /dev/null +++ b/Components/Search/FilterOpenChat.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { AllOpenChat } from '@/app/search/search.type'; + +const FilterOpenChat = ({ initialData }: { initialData: AllOpenChat }) => { + console.log(initialData); + return ( + <> +
+

FilterOpenChat

+
+ + ); +}; + +export default FilterOpenChat; diff --git a/Components/Search/SearchOpenChat.tsx b/Components/Search/SearchOpenChat.tsx new file mode 100644 index 0000000..7185aac --- /dev/null +++ b/Components/Search/SearchOpenChat.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { AllOpenChat } from '@/app/search/search.type'; + +const SearchOpenChat = ({ initialData }: { initialData: AllOpenChat }) => { + console.log(initialData); + return ( + <> +
+

SearchOpenChat

+ + ); +}; + +export default SearchOpenChat; From 292067ff8bd7b22e17e54648be5a16c47764e4ba Mon Sep 17 00:00:00 2001 From: JitHoon Date: Thu, 9 Nov 2023 16:31:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?Fix:=20=ED=99=98=EA=B2=BD=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/search/search.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/search/search.utils.ts b/app/search/search.utils.ts index 01af8c8..427ce2e 100644 --- a/app/search/search.utils.ts +++ b/app/search/search.utils.ts @@ -6,7 +6,7 @@ export const fetchAllOpenChat = async (accessToken: string) => { method: GET, headers: { 'content-type': CONTENT_TYPE, - serverId: process.env.SERVER_ID as string, // 서버 아이디 임시 사용 + serverId: process.env.NEXT_PUBLIC_SERVER_ID as string, // 서버 아이디 임시 사용 Authorization: `Bearer ${accessToken}`, }, }; From 972667f954381947568fee8037d8b273cd18f79b Mon Sep 17 00:00:00 2001 From: JitHoon Date: Thu, 9 Nov 2023 16:33:20 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Feat:=20=EB=AA=A8=EB=93=A0=20=EC=98=A4?= =?UTF-8?q?=ED=94=88=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EB=A0=8C=EB=8D=94=EB=A7=81=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=84=B8=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Components/Search/OpenChatPicture.tsx | 28 +++++++++++++++++++++++++++ Components/Search/OpenChatText.tsx | 14 ++++++++++++++ Components/Search/ShowAllOpenChat.tsx | 20 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 Components/Search/OpenChatPicture.tsx create mode 100644 Components/Search/OpenChatText.tsx create mode 100644 Components/Search/ShowAllOpenChat.tsx diff --git a/Components/Search/OpenChatPicture.tsx b/Components/Search/OpenChatPicture.tsx new file mode 100644 index 0000000..94ffe97 --- /dev/null +++ b/Components/Search/OpenChatPicture.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { User } from '@/app/search/search.type'; + +const OpenChatPicture = ({ openChatUsers }: { openChatUsers: User[] }) => { + let userCount = 0; + + return ( + <> +
    + {openChatUsers.map((user) => { + userCount++; + + if (userCount > 4) { + return null; // 사진이 4개 이상인 경우 렌더링을 하지 않음 + } + + return ( +
  1. + user picture +
  2. + ); + })} +
+ + ); +}; + +export default OpenChatPicture; diff --git a/Components/Search/OpenChatText.tsx b/Components/Search/OpenChatText.tsx new file mode 100644 index 0000000..291e6a3 --- /dev/null +++ b/Components/Search/OpenChatText.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Chat } from '@/app/search/search.type'; + +const OpenChatText = ({ openChat }: { openChat: Chat }) => { + return ( + <> +

{openChat.name}

+ {openChat.users.length} + {openChat.updatedAt.toString()} + + ); +}; + +export default OpenChatText; diff --git a/Components/Search/ShowAllOpenChat.tsx b/Components/Search/ShowAllOpenChat.tsx new file mode 100644 index 0000000..15e91d3 --- /dev/null +++ b/Components/Search/ShowAllOpenChat.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { AllOpenChat } from '@/app/search/search.type'; +import OpenChatText from './OpenChatText'; +import OpenChatPicture from './OpenChatPicture'; + +// 채팅방 이름, 채팅방 참여자 수, 최근 대화 시간 +const ShowAllOpenChat = ({ allOpenChat }: { allOpenChat: AllOpenChat }) => { + return ( +
    + {allOpenChat.map((openChat) => ( +
  • + + +
  • + ))} +
+ ); +}; + +export default ShowAllOpenChat; From 8ddcf6c6448c30933cc547ad24b4fbff5dda9f7f Mon Sep 17 00:00:00 2001 From: JitHoon Date: Thu, 9 Nov 2023 16:33:35 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Feat:=20=EB=AA=A8=EB=93=A0=20=EC=98=A4?= =?UTF-8?q?=ED=94=88=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=97=90=20=EB=B3=B4=EC=97=AC=EC=A3=BC?= =?UTF-8?q?=EA=B8=B0=20=EC=97=90=20=ED=95=84=EC=9A=94=ED=95=9C=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/search/search.type.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/search/search.type.ts b/app/search/search.type.ts index ca070aa..8b42afd 100644 --- a/app/search/search.type.ts +++ b/app/search/search.type.ts @@ -1,10 +1,12 @@ +// search.type.ts + export type AllOpenChat = Chat[]; export type AllOpenChatJSON = { chats: AllOpenChat; }; -type Chat = { +export type Chat = { id: string; name: string; users: User[]; @@ -13,7 +15,7 @@ type Chat = { updatedAt: Date; }; -type User = { +export type User = { id: string; name: string; picture: string;