fixed code
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { useState } from "react";
|
||||
import LogoIcon from "./icons/LogoIcon";
|
||||
import {NAV_BOTTOM, NAV_ITEMS} from "../config/feedConstants";
|
||||
import {NavIcons} from "./icons/NavIcons";
|
||||
import GlobeIcon from "./icons/GlobeIcon";
|
||||
import SunIcon from "./icons/SunIcon";
|
||||
import MoonIcon from "./icons/MoonIcon";
|
||||
import { NAV_BOTTOM, NAV_ITEMS } from "../config/feedConstants";
|
||||
import { NavIcons } from "./icons/NavIcons";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { useUnread } from "../context/UnreadContext";
|
||||
import { useLanguageToggle } from "../hooks/useLanguageToggle";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SupportModal from "./SupportModal";
|
||||
|
||||
@@ -21,15 +25,10 @@ export default function Sidebar({
|
||||
const navigate = useNavigate();
|
||||
const { theme, toggle: toggleTheme } = useTheme();
|
||||
const { totalUnread } = useUnread();
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
const { language, toggleLanguage } = useLanguageToggle();
|
||||
const [supportOpen, setSupportOpen] = useState(false);
|
||||
|
||||
const toggleLang = () => {
|
||||
const next = i18n.language === 'ru' ? 'en' : 'ru';
|
||||
i18n.changeLanguage(next);
|
||||
localStorage.setItem('i18nextLng', next);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`f-overlay${open ? " show" : ""}`} onClick={onClose} />
|
||||
@@ -57,16 +56,17 @@ export default function Sidebar({
|
||||
onClose();
|
||||
};
|
||||
return (
|
||||
<div
|
||||
<button
|
||||
type="button"
|
||||
key={itemKey}
|
||||
className={`f-sb-item${activeNav === itemKey ? " active" : ""}`}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<Ic /> {t(labelKey)}
|
||||
{itemKey === "chat" && totalUnread > 0 && (
|
||||
<span className="f-sb-unread-badge">{totalUnread > 99 ? "99+" : totalUnread}</span>
|
||||
<span className="f-sb-unread-badge">{totalUnread > 99 ? "99+" : totalUnread}</span>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
@@ -88,42 +88,31 @@ export default function Sidebar({
|
||||
onClose();
|
||||
};
|
||||
return (
|
||||
<div
|
||||
<button
|
||||
type="button"
|
||||
key={itemKey}
|
||||
className={`f-sb-item${activeNav === itemKey ? " active" : ""}`}
|
||||
onClick={handleBottomClick}
|
||||
>
|
||||
<Ic /> {t(labelKey)}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
<div className="f-sb-item" onClick={() => setSupportOpen(true)}>
|
||||
<button type="button" className="f-sb-item" onClick={() => setSupportOpen(true)}>
|
||||
<NavIcons.help /> {t('nav.support')}
|
||||
</div>
|
||||
</button>
|
||||
<div className="f-sb-divider" />
|
||||
<div className="f-sb-item f-sb-theme-toggle" onClick={toggleTheme}>
|
||||
{theme === "dark" ? (
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx="12" cy="12" r="5"/>
|
||||
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/>
|
||||
</svg>
|
||||
) : (
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
||||
</svg>
|
||||
)}
|
||||
<button type="button" className="f-sb-item f-sb-theme-toggle" onClick={toggleTheme}>
|
||||
{theme === "dark" ? <SunIcon /> : <MoonIcon />}
|
||||
{theme === "dark" ? t('sidebar.lightTheme') : t('sidebar.darkTheme')}
|
||||
</div>
|
||||
<div className="f-sb-item f-sb-lang-toggle" onClick={toggleLang}>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>
|
||||
</svg>
|
||||
{i18n.language === 'ru' ? 'English' : 'Русский'}
|
||||
</div>
|
||||
</button>
|
||||
<button type="button" className="f-sb-item f-sb-lang-toggle" onClick={toggleLanguage}>
|
||||
<GlobeIcon />
|
||||
{language === 'ru' ? 'English' : 'Русский'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{supportOpen && <SupportModal onClose={() => setSupportOpen(false)} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user