This commit is contained in:
NotII
2025-03-03 21:30:36 +00:00
parent 3282051671
commit c70828ddcf
4 changed files with 53 additions and 26 deletions

View File

@@ -40,11 +40,16 @@ export default function ChatNotifications() {
}
});
// Get vendor info from profile endpoint - removing /api prefix
const vendorResponse = await authAxios.get('/auth/me');
console.log(vendorResponse.data.vendor._id);
const vendorId = vendorResponse.data.vendor._id;
// Access correct property - the vendor ID is in vendor._id
const vendorId = vendorResponse.data.vendor?._id;
if (!vendorId) {
console.error("Vendor ID not found in profile response:", vendorResponse.data);
return;
}
const response = await authAxios.get(`/chats/vendor/${vendorId}/unread`);
setUnreadCounts(response.data);
@@ -56,11 +61,11 @@ export default function ChatNotifications() {
// Create a simplified metadata object with just needed info
const metadata: Record<string, { buyerId: string }> = {};
// Fetch each chat to get buyer IDs
// Fetch each chat to get buyer IDs - removing /api prefix
await Promise.all(
chatIds.map(async (chatId) => {
try {
const chatResponse = await authAxios.get(`/api/chats/${chatId}`);
const chatResponse = await authAxios.get(`/chats/${chatId}`);
metadata[chatId] = {
buyerId: chatResponse.data.buyerId,
};