-
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
- Loading branch information
Showing
7 changed files
with
98 additions
and
6 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,28 @@ | ||
import React from 'react'; | ||
import { User } from '@/app/search/search.type'; | ||
|
||
const OpenChatPicture = ({ openChatUsers }: { openChatUsers: User[] }) => { | ||
let userCount = 0; | ||
|
||
return ( | ||
<> | ||
<ol> | ||
{openChatUsers.map((user) => { | ||
userCount++; | ||
|
||
if (userCount > 4) { | ||
return null; // 사진이 4개 이상인 경우 렌더링을 하지 않음 | ||
} | ||
|
||
return ( | ||
<li key={user.id}> | ||
<img src={user.picture} alt="user picture" /> | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
</> | ||
); | ||
}; | ||
|
||
export default OpenChatPicture; |
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 React from 'react'; | ||
import { Chat } from '@/app/search/search.type'; | ||
|
||
const OpenChatText = ({ openChat }: { openChat: Chat }) => { | ||
return ( | ||
<> | ||
<h2>{openChat.name}</h2> | ||
<span>{openChat.users.length}</span> | ||
<span>{openChat.updatedAt.toString()}</span> | ||
</> | ||
); | ||
}; | ||
|
||
export default OpenChatText; |
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,29 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import { AllOpenChat } from '@/app/search/search.type'; | ||
import ShowAllOpenChat from './ShowAllOpenChat'; | ||
|
||
const SearchOpenChat = ({ allOpenChat }: { allOpenChat: AllOpenChat }) => { | ||
const [userInput, setUserInput] = useState(''); | ||
const [openChats] = useState<AllOpenChat>(allOpenChat); | ||
|
||
const getUserInput = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setUserInput(e.target.value.toLowerCase().replace(/(\s*)/g, '')); | ||
}; | ||
|
||
const searched = openChats.filter((item) => | ||
item.name.toLowerCase().replace(/(\s*)/g, '').includes(userInput), | ||
); | ||
|
||
return ( | ||
<> | ||
<input onChange={getUserInput} /> | ||
{searched.map((item) => ( | ||
<ShowAllOpenChat key={item.id} openChat={item} /> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default SearchOpenChat; |
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 React from 'react'; | ||
import { Chat } from '@/app/search/search.type'; | ||
import OpenChatText from './OpenChatText'; | ||
import OpenChatPicture from './OpenChatPicture'; | ||
|
||
const ShowAllOpenChat = ({ openChat }: { openChat: Chat }) => { | ||
return ( | ||
<ul> | ||
{ | ||
<li key={openChat.id}> | ||
<OpenChatText openChat={openChat} /> | ||
<OpenChatPicture openChatUsers={openChat.users} /> | ||
</li> | ||
} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default ShowAllOpenChat; |
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
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