diff --git a/Scrum/Working/src/components/Chat/Sidebar.tsx b/Scrum/Working/src/components/Chat/Sidebar.tsx
index 01f7abb..930d0a1 100644
--- a/Scrum/Working/src/components/Chat/Sidebar.tsx
+++ b/Scrum/Working/src/components/Chat/Sidebar.tsx
@@ -296,7 +296,11 @@ const Sidebar = () => {
? "active"
: ""
}`}
- onClick={() => handlePersonClick(person.dpi)}
+ onClick={() => {handlePersonClick(person.dpi)
+ localStorage.setItem('firstInteraction', 'false')
+ setFirstInteraction(localStorage.getItem('firstInteraction'))
+ }
+ }
>
@@ -330,7 +334,7 @@ const Sidebar = () => {
Selecciona un chat
)}
- {isDetailsOpen ? (
+ {isDetailsOpen || firstInteraction === "true" ? (
setIsDetailsOpen(false)}
setFirstInteraction={setFirstInteraction}
diff --git a/Scrum/Working/src/controller/ChatController.tsx b/Scrum/Working/src/controller/ChatController.tsx
index f0c4999..c5af5ee 100644
--- a/Scrum/Working/src/controller/ChatController.tsx
+++ b/Scrum/Working/src/controller/ChatController.tsx
@@ -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;
+ }
+}
diff --git a/Scrum/Working/src/controller/db.js b/Scrum/Working/src/controller/db.js
index 5989b7b..31fcda6 100644
--- a/Scrum/Working/src/controller/db.js
+++ b/Scrum/Working/src/controller/db.js
@@ -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
+ }
+}
+
diff --git a/Scrum/Working/src/controller/main.js b/Scrum/Working/src/controller/main.js
index 5ce9f57..6ddacae 100644
--- a/Scrum/Working/src/controller/main.js
+++ b/Scrum/Working/src/controller/main.js
@@ -2,7 +2,7 @@
import express from 'express'
import cors from 'cors'
import { apiKeyAuth, adminapiKeyAuth } from './auth.js'
-import { insertJobToCompleted, deleteHiringFromAvailable, insertSurveyToCompletedJob, insertCommentWithId, getCommentsWithThreadID, getThreadPosts, createThreadPost, createNewChat, getUsers, getLoginUser, insertUser, gettrabajo, getUserbyDPI, setsettings, getContactsByUserDPI, getChatBetweenUsers, updatetrab, gettrabajoant, insertartrabant, insertartipotrabajo, gettrabajoSABTE, getTrabajoSABTEemple, insertChatMessage, getChatID, insertHiring, getCurrentHirings, getpasscode, updataepasscode_phone, getmail, getphone, changepass, getreport_nofecha, getreport_withfecha, getcontrataciones_por_mes, setWorkingState ,getreviewone, setnewtrabajoperfil, removenew_trabajo, chworkdescription, gettrabajos, setHiringState } from './db.js'
+import { insertJobToCompleted, deleteHiringFromAvailable, insertSurveyToCompletedJob, insertCommentWithId, getCommentsWithThreadID, getThreadPosts, createThreadPost, createNewChat, getUsers, getLoginUser, insertUser, gettrabajo, getUserbyDPI, setsettings, getContactsByUserDPI, getChatBetweenUsers, updatetrab, gettrabajoant, insertartrabant, insertartipotrabajo, gettrabajoSABTE, getTrabajoSABTEemple, insertChatMessage, getChatID, insertHiring, getCurrentHirings, getpasscode, updataepasscode_phone, getmail, getphone, changepass, getreport_nofecha, getreport_withfecha, getcontrataciones_por_mes, setWorkingState ,getreviewone, setnewtrabajoperfil, removenew_trabajo, chworkdescription, gettrabajos, setHiringState, getMessageID } from './db.js'
import { deleteRelationUserTojob, addRelationUserToJob, getJobsOfWorkerWithDPI,getWorkers, getTrustedUsersByDpi, creatNeoUser, updateNeoUser, addUserAsTrustedPerson, getAllTrabajos, insertNewJob, getWorkersByFlexibleName } from './neo.js'
import { Admin_Exist, extendban, getbanusers, getbanusersprev, getreports, unban } from './administration.js';
import { send_email_forfg, send_fg_password } from './fg_function.js'
@@ -1016,6 +1016,22 @@ app.put('/api/setHiringState/', async (req, res) => {
}
});
+app.get('/api/messageID/', async (req, res) => {
+ const { chatID, time } = req.query;
+
+ if (!chatID || !time) {
+ return res.status(400).json({ error: 'Missing attributes in query' });
+ }
+
+ try {
+ const result = await getMessageID(chatID, time);
+
+ return res.status(200).json(result);
+ } catch (error) {
+ console.error('Error fetching message ID:', error);
+ return res.status(500).json({ error: 'Internal Server Error' });
+ }
+});
app.put('/api/changedescription/', apiKeyAuth ,async (req, res) => {