input to select ajout mot de si channel prive

This commit is contained in:
Little Dipper 2023-06-21 01:57:37 +02:00
parent b53151ac5f
commit 93ed2a7eff
7 changed files with 50 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -107,12 +107,16 @@ function Chats(){
const convs = await api.get("/conv")
const tmpInvite = await api.get("/partyInvite")
const tmpUser = await api.get("/profile")
const tmpUsers = await api.get("/users");
console.log(convs);
// console.log("invite data use effect= ", tmpInvite.data);
setPartyInvite(tmpInvite.data);
setUser(tmpUser.data);
setConversation(convs.data);
setUsers(tmpUsers.data);
// console.log(`connection....`);
socket.current = io('http://' + process.env.REACT_APP_BASE_URL + ':4001', { transports: ['polling'] });
// console.log(`connection done`);
@ -256,6 +260,10 @@ function Chats(){
const [newGameModalOpen, setNewGameModalOpen] = useState(false);
const [newConversationModalOpen, setNewConversationModalOpen] = useState(false);
const [selectTags, setSelectTag] = useState([{ id: 1, selectedOption: ''}]);
const [users, setUsers] = useState([]);
const openNewGameModal = () => {
setNewGameModalOpen(true);
};
@ -335,6 +343,15 @@ function Chats(){
setShowBlockAlert(false);
};
const handleOptionChange = (selectId, selectedOption) => {
console.log("selected Option=", selectedOption)
setSelectTag((prevTags) =>
prevTags.map((tag) =>
tag.id === selectId ? { ...tag, selectedOption } : tag
)
);
};
//========================================================================================================
//========================================================================================================
// HTML
@ -400,7 +417,24 @@ function Chats(){
</div> */}
<div className="end">
<input className="lookForFriends" type="text" value={friend} onChange={handleFriend} />
{selectTags.map((selectTag) => (
<div key={selectTag.id}>
<select
value={selectTag.selectedOption}
className="lookForFriends"
onChange={(a) => handleOptionChange(selectTag.id, a.target.value)}
>
<option value="">{
selectTag.selectedOption ? selectTag.selectedOption : "Select an option"
}</option>
{users.filter((item) => !selectTags.some((tag) => tag.selectedOption === item.name)).map((item, index) => (
<option key={index} value={item.username}>
{item.username}
</option>
))}
</select>
</div>
))}
<TouchDiv>
<motion.div onClick={handleAddFriend}>
<MdOutlineGroupAdd />

View File

@ -155,6 +155,10 @@ const Modal = ({handleClose}) => {
))}
</select>
)}
{channel.private ? (
<input className="mdp" placeholder="password" type="text" />
):("")}
<div className="div_submit">
<Link to='#' className="submit" onClick={ joinChannel }>Join</Link>

View File

@ -316,3 +316,11 @@ input.in{
border-radius: 12px;
width: 70%;
}
.mdp{
background-color : black;
border-radius: 8px;
color: white;
width: 20%;
}