diff --git a/src/components/AuthModal.jsx b/src/components/AuthModal.jsx index 39288a8..cecb76f 100644 --- a/src/components/AuthModal.jsx +++ b/src/components/AuthModal.jsx @@ -98,10 +98,10 @@ function LoginFormInline({ saveAuth, onClose, onSwitch }) { -

+

{t('auth.noAccount')}{" "} @@ -216,10 +216,10 @@ function RegisterFormInline({ saveAuth, onClose, onSwitch }) { -

+

{t('auth.hasAccount')}{" "}

diff --git a/src/components/RightSidebar.jsx b/src/components/RightSidebar.jsx index 8a2edb7..0717496 100644 --- a/src/components/RightSidebar.jsx +++ b/src/components/RightSidebar.jsx @@ -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 ( + + ); +} + +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 (
-
{t('rightSidebar.advertisement')}
-
-
📢
-
- +
+ {isAuthenticated ? ( + <> + +
+
{profileName}
+
{profileData?.login}
+
+ + + ) : ( + <> +
+
👤
+
+
+
{t('rightSidebar.guest')}
+
{t('rightSidebar.guestSub')}
+
+ + + )} +
+ +
+ {t('rightSidebar.suggestions')} + +
+ + {suggestions.length === 0 && ( +
{t('rightSidebar.empty')}
+ )} + + {suggestions.map(ad => ( +
+
+
{ad.emoji || "📋"}
+
+
+
{ad.title}
+
+ {ad.city || (ad.type === "loss" ? t('postCard.loss') : t('postCard.found'))} +
+
+ +
+ ))} + +
+ © {new Date().getFullYear()} {t('app.name')} + {t('rightSidebar.footRules')} + {t('rightSidebar.footPrivacy')} + {t('rightSidebar.footSupport')}
); diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx index a205615..2c234ce 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.jsx @@ -11,6 +11,7 @@ import { useUnread } from "../context/UnreadContext"; import { useLanguageToggle } from "../hooks/useLanguageToggle"; import { useTranslation } from 'react-i18next'; import SupportModal from "./SupportModal"; +import ProfileAvatar from "./profile/ProfileAvatar"; export default function Sidebar({ open, @@ -21,6 +22,9 @@ export default function Sidebar({ onLoginClick, onRulesClick, onReviewsClick, + onCreatePost, + onProfileClick, + profileData, }) { const navigate = useNavigate(); const { theme, toggle: toggleTheme } = useTheme(); @@ -28,6 +32,35 @@ export default function Sidebar({ const { t } = useTranslation(); const { language, toggleLanguage } = useLanguageToggle(); const [supportOpen, setSupportOpen] = useState(false); + const HelpIcon = NavIcons.help; + + const handleNavItem = (itemKey) => { + if (!isAuthenticated && itemKey === "myads") { + onLoginClick(); + return; + } + if (itemKey === "chat") { + if (!isAuthenticated) { + onLoginClick(); + } else { + navigate("/chats"); + } + return; + } + if (itemKey === "create") { + onCreatePost?.(); + return; + } + onNavClick(itemKey); + }; + + const handleProfileClick = () => { + if (!isAuthenticated) { + onLoginClick(); + } else { + onProfileClick?.(); + } + }; return ( <> @@ -40,27 +73,15 @@ export default function Sidebar({