import { t } from "@/utils"; import ChatListCard from "./ChatListCard"; import ChatListCardSkeleton from "./ChatListCardSkeleton"; import BlockedUsersMenu from "./BlockedUsersMenu"; import NoChatListFound from "./NoChatListFound"; import InfiniteScroll from "react-infinite-scroll-component"; import CustomLink from "@/components/Common/CustomLink"; const ChatList = ({ chatId, activeTab, buyer, setBuyer, isLargeScreen, seller, setSeller, IsLoading, fetchSellerChatList, fetchBuyerChatList, setSelectedChatDetails }) => { const handleChatTabClick = (chat, isSelling) => { if (isSelling) { setSeller((prev) => ({ ...prev, SellerChatList: prev.SellerChatList.map((item) => item.id === chat.id ? { ...item, unread_chat_count: 0 } : item ), })); } else { setBuyer((prev) => ({ ...prev, BuyerChatList: prev.BuyerChatList.map((item) => item.id === chat.id ? { ...item, unread_chat_count: 0 } : item ), })); } }; return (
{isLargeScreen && (

{t("chat")}

{/* Blocked Users Menu Component */}
)}
{t("selling")} {t("buying")}
{ activeTab === "buying" ? fetchBuyerChatList(buyer.CurrentBuyerPage + 1) : fetchSellerChatList(seller.CurrentSellerPage + 1); }} hasMore={ activeTab === "buying" ? buyer.HasMoreBuyer : seller.HasMoreSeller } loader={Array.from({ length: 3 }, (_, index) => ( ))} scrollableTarget="chatList" > {IsLoading ? Array.from({ length: 8 }, (_, index) => ( )) : (() => { const chatList = activeTab === "selling" ? seller.SellerChatList : buyer.BuyerChatList; return chatList.length > 0 ? ( chatList.map((chat, index) => ( )) ) : (
); })()}
); }; export default ChatList;