Update ChatNotifications.tsx
This commit is contained in:
@@ -29,12 +29,10 @@ export default function ChatNotifications() {
|
||||
useEffect(() => {
|
||||
const fetchUnreadCounts = async () => {
|
||||
try {
|
||||
// Get auth token from cookies
|
||||
const authToken = getCookie("Authorization");
|
||||
|
||||
if (!authToken) return;
|
||||
|
||||
// Set up axios with the auth token
|
||||
const authAxios = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_URL,
|
||||
headers: {
|
||||
@@ -42,15 +40,15 @@ export default function ChatNotifications() {
|
||||
}
|
||||
});
|
||||
|
||||
// Get vendor ID from profile
|
||||
const vendorResponse = await authAxios.get('/auth/me');
|
||||
|
||||
console.log(vendorResponse.data.vendor._id);
|
||||
|
||||
const vendorId = vendorResponse.data.vendor._id;
|
||||
|
||||
const response = await authAxios.get(`/chats/vendor/${vendorId}/unread`);
|
||||
setUnreadCounts(response.data);
|
||||
|
||||
// If there are unread messages, fetch chat metadata
|
||||
if (response.data.totalUnread > 0) {
|
||||
const chatIds = Object.keys(response.data.chatCounts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user