This commit is contained in:
slawk0
2024-11-01 19:24:00 +01:00
parent 27d7456998
commit 34d3f1c75b

View File

@@ -8,6 +8,7 @@ import ContactsList from '../components/chat/ContactsList.tsx';
import { initializeSocket, sendContact } from '../socket/socket.tsx';
import Cookies from 'js-cookie';
import { setStatus } from '../api/contactsApi.tsx';
import { axiosClient } from '../App.tsx';
type ChatMessages = {
sender: string;
@@ -50,10 +51,19 @@ function Chat() {
c.usernamecontact === newContact ? { ...c, read: true } : c,
),
);
setStatus(newContact, true);
axiosClient
.put(
`api/chat/contacts/${newContact}`,
{ status: true },
{ withCredentials: true },
)
.then((res) => {
console.log(res.data.message);
})
.catch((e) => console.log(e.response.data.message));
console.log('Contact submitted:', newContact);
}
}
function updateStatus(contactObj: ContactObjProps, read: boolean) {
setContactsList((prevContacts) =>