update
This commit is contained in:
@@ -9,6 +9,7 @@ import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import axios from "axios";
|
||||
import { toast } from "sonner";
|
||||
import { getCookie } from "@/lib/client-utils";
|
||||
|
||||
interface Chat {
|
||||
_id: string;
|
||||
@@ -36,12 +37,12 @@ export default function ChatList() {
|
||||
useEffect(() => {
|
||||
const fetchVendorData = async () => {
|
||||
try {
|
||||
// Get vendor info from session storage or context
|
||||
const vendorId = sessionStorage.getItem("vendorId");
|
||||
// Get vendor info from cookies
|
||||
const vendorId = getCookie("vendorId");
|
||||
|
||||
if (!vendorId) {
|
||||
toast.error("You need to be logged in to view chats");
|
||||
router.push("/login");
|
||||
router.push("/auth/login");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ export default function ChatList() {
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const vendorId = sessionStorage.getItem("vendorId");
|
||||
const vendorId = getCookie("vendorId");
|
||||
|
||||
// Fetch chats
|
||||
const chatsResponse = await axios.get(`/api/chats/vendor/${vendorId}`);
|
||||
|
||||
Reference in New Issue
Block a user