change design
This commit is contained in:
@@ -1,14 +1,89 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ProfileAvatar from "./profile/ProfileAvatar";
|
||||
|
||||
export default function RightSidebar() {
|
||||
function FollowButton() {
|
||||
const [following, setFollowing] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<button className="f-right-action-btn" onClick={() => setFollowing(f => !f)}>
|
||||
{following ? t('rightSidebar.following') : t('rightSidebar.subscribe')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function RightSidebar({ ads, profileData, isAuthenticated, onProfileClick, onLoginClick, onNavClick }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const suggestions = [...(ads || [])]
|
||||
.sort((a, b) => (b.likeCount || 0) - (a.likeCount || 0))
|
||||
.slice(0, 4);
|
||||
|
||||
const profileName = isAuthenticated
|
||||
? `${profileData?.firstName || ""} ${profileData?.lastName || ""}`.trim() || profileData?.login
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className="f-right">
|
||||
<div className="f-right-label">{t('rightSidebar.advertisement')}</div>
|
||||
<div className="f-right-empty">
|
||||
<div className="f-right-empty-icon">📢</div>
|
||||
<div className="f-right-empty-text" dangerouslySetInnerHTML={{ __html: t('rightSidebar.emptyText') }} />
|
||||
<button className="f-add-promo-btn">{t('rightSidebar.addAd')}</button>
|
||||
<div className="f-right-profile">
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<ProfileAvatar avatar={profileData?.avatar} name={profileName} />
|
||||
<div className="f-right-profile-info">
|
||||
<div className="f-right-profile-name">{profileName}</div>
|
||||
<div className="f-right-profile-sub">{profileData?.login}</div>
|
||||
</div>
|
||||
<button className="f-right-action-btn" onClick={onProfileClick}>
|
||||
{t('rightSidebar.yourProfile')}
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="f-ig-ring">
|
||||
<div className="f-ig-avatar">👤</div>
|
||||
</div>
|
||||
<div className="f-right-profile-info">
|
||||
<div className="f-right-profile-name">{t('rightSidebar.guest')}</div>
|
||||
<div className="f-right-profile-sub">{t('rightSidebar.guestSub')}</div>
|
||||
</div>
|
||||
<button className="f-right-action-btn" onClick={onLoginClick}>
|
||||
{t('feed.login')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="f-right-header">
|
||||
<span className="f-right-label">{t('rightSidebar.suggestions')}</span>
|
||||
<button className="f-right-link" onClick={() => onNavClick?.("home")}>
|
||||
{t('rightSidebar.all')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{suggestions.length === 0 && (
|
||||
<div className="f-right-suggest-sub">{t('rightSidebar.empty')}</div>
|
||||
)}
|
||||
|
||||
{suggestions.map(ad => (
|
||||
<div className="f-right-suggest" key={ad.id}>
|
||||
<div className="f-ig-ring f-ig-ring-sm">
|
||||
<div className="f-ig-avatar">{ad.emoji || "📋"}</div>
|
||||
</div>
|
||||
<div className="f-right-suggest-info">
|
||||
<div className="f-right-suggest-name">{ad.title}</div>
|
||||
<div className="f-right-suggest-sub">
|
||||
{ad.city || (ad.type === "loss" ? t('postCard.loss') : t('postCard.found'))}
|
||||
</div>
|
||||
</div>
|
||||
<FollowButton />
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div className="f-right-foot">
|
||||
<span>© {new Date().getFullYear()} {t('app.name')}</span>
|
||||
<span>{t('rightSidebar.footRules')}</span>
|
||||
<span>{t('rightSidebar.footPrivacy')}</span>
|
||||
<span>{t('rightSidebar.footSupport')}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user