85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
import PostOnFeed from "../../pages/PostOnFeed";
|
||
|
||
export default function FeedContent({
|
||
loading,
|
||
cityLoading,
|
||
citySearchActive,
|
||
error,
|
||
filteredAds,
|
||
activeNav,
|
||
searchPrompt,
|
||
liked,
|
||
likeCountAdj,
|
||
onLike,
|
||
onEdit,
|
||
onDelete,
|
||
onMarkFound,
|
||
onImageClick,
|
||
onAuthRequired,
|
||
t,
|
||
}) {
|
||
if (loading || (citySearchActive && cityLoading)) {
|
||
return (
|
||
<div className="f-center">
|
||
<div className="f-spinner-wrap">
|
||
<div className="f-spinner" />
|
||
{t('feed.loading')}
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
if (error) {
|
||
return (
|
||
<div className="f-center">
|
||
<div className="f-center-icon">⚠️</div>
|
||
<div className="f-center-title">{t('feed.loadError')}</div>
|
||
<div className="f-center-sub">{error}</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
if (searchPrompt) {
|
||
return (
|
||
<div className="f-center">
|
||
<div className="f-center-icon">🔍</div>
|
||
<div className="f-center-title">{t('feed.searchPromptTitle')}</div>
|
||
<div className="f-center-sub">{t('feed.searchPromptSub')}</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
if (!filteredAds.length) {
|
||
const emptyMsg = activeNav === "myads"
|
||
? { title: t('feed.emptyMyAdsTitle'), sub: t('feed.emptyMyAdsSub') }
|
||
: activeNav === "favorites"
|
||
? { title: t('feed.emptyFavoritesTitle'), sub: t('feed.emptyFavoritesSub'), icon: "❤️" }
|
||
: citySearchActive
|
||
? { title: t('feed.emptyCityTitle'), sub: t('feed.emptyCitySub') }
|
||
: { title: t('feed.emptyAllTitle'), sub: t('feed.emptyAllSub') };
|
||
|
||
return (
|
||
<div className="f-center">
|
||
<div className="f-center-icon">{emptyMsg.icon || "🔍"}</div>
|
||
<div className="f-center-title">{emptyMsg.title}</div>
|
||
<div className="f-center-sub" dangerouslySetInnerHTML={{ __html: emptyMsg.sub }} />
|
||
</div>
|
||
);
|
||
}
|
||
|
||
return filteredAds.map(ad => (
|
||
<PostOnFeed
|
||
key={ad.id}
|
||
ad={ad}
|
||
liked={liked.has(ad.id)}
|
||
likeCountAdj={likeCountAdj[ad.id] || 0}
|
||
onLike={onLike}
|
||
onEdit={activeNav === "myads" ? onEdit : undefined}
|
||
onDelete={activeNav === "myads" ? onDelete : undefined}
|
||
onMarkFound={activeNav === "myads" ? onMarkFound : undefined}
|
||
isOwner={activeNav === "myads"}
|
||
onImageClick={onImageClick}
|
||
onAuthRequired={onAuthRequired}
|
||
/>
|
||
));
|
||
} |