Skip to content

Commit

Permalink
Merge pull request #82 from cmd-AJ/the-way-of-the-prince
Browse files Browse the repository at this point in the history
The way of the prince
  • Loading branch information
Jose-Prince authored Nov 14, 2024
2 parents 3d916bc + b5463dc commit d8b7f5e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Scrum/Working/src/components/Chat/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ const Sidebar = () => {
? "active"
: ""
}`}
onClick={() => handlePersonClick(person.dpi)}
onClick={() => {handlePersonClick(person.dpi)
localStorage.setItem('firstInteraction', 'false')
setFirstInteraction(localStorage.getItem('firstInteraction'))
}
}
>
<img className="imagen" src={person.img} alt="" />
<div className="text-container">
Expand Down Expand Up @@ -330,7 +334,7 @@ const Sidebar = () => {
<span className="name">Selecciona un chat</span>
)}
</div>
{isDetailsOpen ? (
{isDetailsOpen || firstInteraction === "true" ? (
<Details
onClose={() => setIsDetailsOpen(false)}
setFirstInteraction={setFirstInteraction}
Expand Down
23 changes: 23 additions & 0 deletions Scrum/Working/src/controller/ChatController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,26 @@ export async function setHiringState(chatID: string, state: boolean) {
throw error;
}
}

export async function getMessageID(chatID: string, time: string) {
const url = `https://${import.meta.env.VITE_API_HOSTI}/api/messageID/?chatID=${chatID}&time=${time}`;

try {
const response = await fetch(url, {
method: 'GET',
headers: {
'api-key': import.meta.env.VITE_API_KEY,
'Content-Type': 'application/json',
}
});

if (!response.ok) {
throw new Error('Failed to get message ID for the given chatID and time');
}

return await response.json();
} catch (error) {
console.error('Error fetching message ID:', error);
throw error;
}
}
19 changes: 19 additions & 0 deletions Scrum/Working/src/controller/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,4 +751,23 @@ export async function setHiringState(idChat, state) {
}
}

export async function getMessageID(chatID, time) {
try {
const query = {
text: `select id_mensaje from mensaje
where id_chat = $1
and to_char("time", 'HH24:MI') = $2`,
values: [chatID, time]
}

const result = await client.query(query);

return result.rows[0]

} catch (error) {
console.error('Error while setting the working state:', error)
throw error
}
}


18 changes: 17 additions & 1 deletion Scrum/Working/src/controller/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8b7f5e

Please sign in to comment.