FIX exit on focus from some inputs
All checks were successful
Deploy React / build-and-deploy (push) Successful in 16s

This commit is contained in:
2026-03-05 09:45:27 +01:00
parent 6ca3120c9e
commit 552b2a8561
6 changed files with 73 additions and 32 deletions

View File

@@ -399,8 +399,8 @@ async function addHotelUser(user_id,hotel_ids) {
//if (!accessTokenSingle || !clientId) return; //if (!accessTokenSingle || !clientId) return;
const ws = new WebSocket( const ws = new WebSocket(
//`ws://localhost:7080/auth/ws/${accessTokenSingle}` `ws://localhost:7080/auth/ws/${accessTokenSingle}`
`wss://79.137.75.155/hotel-demo/api/auth/ws/${accessTokenSingle}` //`wss://79.137.75.155/hotel-demo/api/auth/ws/${accessTokenSingle}`
); );
wsRef.current = ws; wsRef.current = ws;

View File

@@ -142,6 +142,10 @@ export default function Login({ onLogin }) {
<button onClick={LoginTest1} >login test 1</button> <button onClick={LoginTest1} >login test 1</button>
<button onClick={LoginTest2} >login test 2</button> <button onClick={LoginTest2} >login test 2</button>
</div> </div>
<div>
<p>Connectez-vous en utilisant
"test1"/"test2" comme username et password</p>
</div>
</div> </div>
</div> </div>
</> </>

View File

@@ -1,3 +1,4 @@
.chatWidget { .chatWidget {
margin :5px; margin :5px;
display: flex; display: flex;
@@ -12,7 +13,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 0.5rem; gap: 0.5rem;
padding: 0.75rem; padding: 8px;
overflow-y: auto; overflow-y: auto;
height: 20%; height: 20%;
} }
@@ -61,6 +62,7 @@ width: 70%;
/* Messages */ /* Messages */
.msg { .msg {
margin: 5px;
max-width: 70%; max-width: 70%;
padding: 0.5rem 0.75rem; padding: 0.5rem 0.75rem;
border-radius: 10px; border-radius: 10px;
@@ -79,11 +81,18 @@ width: 70%;
} }
.createConvBox { .createConvBox {
margin: 5px;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
} }
.createConvBox > * { .createConvBox > * {
margin: 5px;
} }
.convUtils button {
margin: 3px;
}

View File

@@ -28,6 +28,14 @@ export default function ChatWidget({convlist}) {
console.log("client id in chat widget"); console.log("client id in chat widget");
function hideCreateConv(){
setShowCreateConv(false);
};
function hideAddUser(){
showAddUsers(false)
};
return ( return (
<div className="chatWidget"> <div className="chatWidget">
<div className="convlist"> <div className="convlist">
@@ -45,7 +53,7 @@ return (
disabled={!activeConvId} disabled={!activeConvId}
onClick={() => setShowAddUsers(v => !v)} onClick={() => setShowAddUsers(v => !v)}
> >
Add users Update users
</button> </button>
<button <button
hidden={showCreateConv} hidden={showCreateConv}
@@ -64,12 +72,14 @@ return (
fetchConvUsers={fetchConvUsers} fetchConvUsers={fetchConvUsers}
onValidate={addUserToConv} onValidate={addUserToConv}
onClose={() => setShowAddUsers(false)} onClose={() => setShowAddUsers(false)}
/> />
)} )}
{showCreateConv && ( {showCreateConv && (
<CreateConvMenu <CreateConvMenu
onSend={createConversation} onSend={createConversation}
exit={hideCreateConv}
/> />
)} )}
@@ -205,7 +215,7 @@ function AddUsersMenu({ convId, usersById, fetchConvUsers, onValidate, onClose }
return ( return (
<div className="addUsersMenu"> <div className="addUsersMenu">
<h3>Add users</h3> <h3>update users</h3>
<ul> <ul>
{Object.entries(usersById).map(([id, name]) => ( {Object.entries(usersById).map(([id, name]) => (
@@ -228,24 +238,32 @@ function AddUsersMenu({ convId, usersById, fetchConvUsers, onValidate, onClose }
); );
} }
function CreateConvMenu({onSend}) { function CreateConvMenu({onSend, exit}) {
const [nameText, setNameText] = useState(""); const [nameText, setNameText] = useState("");
const handleSend = () =>{ const handleSend = () =>{
if (!nameText.trim()) return; if (!nameText.trim()) return;
onSend(nameText); onSend(nameText);
setNameText(""); setNameText("");
setTimeout(() => {
window.location.reload();
}, 1000);
}; };
return ( return (
<div className="createConvBox"> <div className="createConvBox">
<input <input
value= {nameText} value= {nameText}
autoFocus
onChange= {element => setNameText(element.target.value)} onChange= {element => setNameText(element.target.value)}
onKeyDown={e => e.key === "Enter" && handleSend() } onKeyDown={e => e.key === "Enter" && handleSend() }
placeholder="Ma Conversation" placeholder="Ma Conversation"
onBlur={exit}
/> />
<button onClick= {handleSend}>Send</button> <button onClick= {handleSend}>Send</button>
</div> </div>

View File

@@ -49,6 +49,10 @@ function ItemCard({id, name, amount}) {
setEditing(false); setEditing(false);
} }
function closeInput(){
setEdtiting(false);
}
return ( return (
<div className="itemcard"> <div className="itemcard">
<h3>{name}</h3> <h3>{name}</h3>
@@ -65,6 +69,7 @@ function ItemCard({id, name, amount}) {
autoFocus autoFocus
onChange={e => setItemAmount(e.target.value)} onChange={e => setItemAmount(e.target.value)}
onKeyDown={e => e.key == "Enter" && submit(id, itemAmount)} onKeyDown={e => e.key == "Enter" && submit(id, itemAmount)}
onBlur={closeInput}
/> />
</div> </div>
)} )}

View File

@@ -34,6 +34,10 @@ function RoomCard({ number, status ,id}) {
setEdtiting(false); setEdtiting(false);
} }
function closeInput(){
setEdtiting(false);
}
return ( return (
<div className="card"> <div className="card">
<h3>Room {number}</h3> <h3>Room {number}</h3>
@@ -51,6 +55,7 @@ function RoomCard({ number, status ,id}) {
autoFocus autoFocus
onChange={e => SetValue(e.target.value)} onChange={e => SetValue(e.target.value)}
onKeyDown={e => e.key === "Enter" && submit()} onKeyDown={e => e.key === "Enter" && submit()}
onBlur={closeInput}
/> />
</div> </div>
)} )}