uwu
This commit is contained in:
@@ -54,9 +54,17 @@ export default function ChatList() {
|
||||
}
|
||||
});
|
||||
|
||||
// First, get vendor info using the /api/auth/me endpoint
|
||||
// First, get vendor info using the /auth/me endpoint
|
||||
const vendorResponse = await authAxios.get('/auth/me');
|
||||
const vendorId = vendorResponse.data._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);
|
||||
toast.error("Could not retrieve vendor information");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch vendor's stores using storefront endpoint
|
||||
const storesResponse = await authAxios.get(`/storefront`);
|
||||
@@ -99,11 +107,19 @@ export default function ChatList() {
|
||||
});
|
||||
|
||||
// Get vendor ID from profile
|
||||
const vendorResponse = await authAxios.get('/api/auth/me');
|
||||
const vendorId = vendorResponse.data._id;
|
||||
const vendorResponse = await authAxios.get('/auth/me');
|
||||
|
||||
// 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);
|
||||
toast.error("Could not retrieve vendor information");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch chats
|
||||
const chatsResponse = await authAxios.get(`/api/chats/vendor/${vendorId}`);
|
||||
const chatsResponse = await authAxios.get(`/chats/vendor/${vendorId}`);
|
||||
|
||||
// Filter chats by selected store
|
||||
const filteredChats = chatsResponse.data.filter(
|
||||
@@ -113,7 +129,7 @@ export default function ChatList() {
|
||||
setChats(filteredChats);
|
||||
|
||||
// Fetch unread counts
|
||||
const unreadResponse = await authAxios.get(`/api/chats/vendor/${vendorId}/unread`);
|
||||
const unreadResponse = await authAxios.get(`/chats/vendor/${vendorId}/unread`);
|
||||
setUnreadCounts(unreadResponse.data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching chats:", error);
|
||||
|
||||
Reference in New Issue
Block a user