Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The way of the prince #82

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading