password
This commit is contained in:
parent
cd4e414d16
commit
612d0084c0
@ -57,6 +57,45 @@ const Modal = ({handleClose}: ModalProps) => {
|
|||||||
getConv();
|
getConv();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [askPass, setAskPass] = useState(false);
|
||||||
|
const [PassWord, setPassWord] = useState('');
|
||||||
|
useEffect(()=> {
|
||||||
|
|
||||||
|
const getConv = async ()=>{
|
||||||
|
console.log("chan changed")
|
||||||
|
console.log("chan = ", channel);
|
||||||
|
try{
|
||||||
|
|
||||||
|
const tmpConv = await api.post("/convId", {convId: channel});
|
||||||
|
if (tmpConv.data.password)
|
||||||
|
setAskPass(true);
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
// if (channel.password)
|
||||||
|
// console.log("password true")
|
||||||
|
// else
|
||||||
|
// console.log("password false")
|
||||||
|
}
|
||||||
|
getConv();
|
||||||
|
}, [channel]);
|
||||||
|
|
||||||
|
const handlePassword = async (e: { key: string; }) => {
|
||||||
|
if (e.key !== "Enter")
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
const ret = await api.post("/verifyPassword", {convId: channel, password: PassWord})
|
||||||
|
if (ret)
|
||||||
|
console.log("ici ret password", ret);
|
||||||
|
|
||||||
|
// window.location.reload();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
handleClose();
|
||||||
|
}
|
||||||
|
|
||||||
const handleOptionChange = (selectId: number, selectedOption: string) => {
|
const handleOptionChange = (selectId: number, selectedOption: string) => {
|
||||||
console.log("selected Option=", selectedOption)
|
console.log("selected Option=", selectedOption)
|
||||||
setSelectTag((prevTags) =>
|
setSelectTag((prevTags) =>
|
||||||
@ -75,6 +114,8 @@ const Modal = ({handleClose}: ModalProps) => {
|
|||||||
const joinChannel = async () => {
|
const joinChannel = async () => {
|
||||||
try {
|
try {
|
||||||
console.log("channel= ", channel)
|
console.log("channel= ", channel)
|
||||||
|
console.log("ici test channel= ", channel)
|
||||||
|
|
||||||
await api.post("/join", {convId: channel})
|
await api.post("/join", {convId: channel})
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -157,13 +198,18 @@ const Modal = ({handleClose}: ModalProps) => {
|
|||||||
{conv.name}
|
{conv.name}
|
||||||
</option>
|
</option>
|
||||||
)
|
)
|
||||||
|
// {conv.password ? (console.log("here is test")):("")}
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
)}
|
)}
|
||||||
{/* {channel.private ? (
|
{/* {console.log("here is channel == ",channel.password)} */}
|
||||||
<input className="mdp" placeholder="passdddddword" type="text" />
|
|
||||||
):("")} */}
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
{askPass ? (
|
||||||
|
<input className="mdp" placeholder="password" type="password" onChange={(e) => setPassWord(e.target.value)} onKeyDown={handlePassword}/>
|
||||||
|
):("") }
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="div_submit">
|
<div className="div_submit">
|
||||||
<Link to='#' className="submit" onClick={ joinChannel }>Join</Link>
|
<Link to='#' className="submit" onClick={ joinChannel }>Join</Link>
|
||||||
|
|||||||
@ -384,7 +384,8 @@ input.in_howLong{
|
|||||||
background-color : black;
|
background-color : black;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
color: white;
|
color: white;
|
||||||
width: 20%;
|
width: 60%;
|
||||||
|
height: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.case{
|
.case{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user