add translate and make refactor

This commit is contained in:
smanylov
2025-12-17 16:41:07 +07:00
parent fd59fb3e5e
commit 9b8cb3b583
13 changed files with 261 additions and 83 deletions
+23 -8
View File
@@ -3,7 +3,9 @@
import { useState, useRef } from 'react';
import { fetchFruits } from '@/app/actions/action';
import { useClickOutside } from '@/app/hooks/useClickOutside';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
import {IconNotification} from '@/app/ui/icons/icons';
export default function NotificationsButton() {
const [isOpen, setIsOpen] = useState(false);
@@ -11,6 +13,7 @@ export default function NotificationsButton() {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const menuRef = useRef<HTMLDivElement | null>(null);
const t = useTranslations('Global');
useClickOutside(menuRef, () => {
setIsOpen(false);
@@ -57,26 +60,38 @@ export default function NotificationsButton() {
) : (
<>
<div className='notification-header'>
<h4>Уведомления</h4>
<span className="notification-count">Нет новых</span>
<h4>
{t('notifications')}
</h4>
<span className="notification-count">
{t('no-new')}
</span>
</div>
{data ? (
<div className="notification-list">
<div className="notification-item">
<div className="notification-icon"></div>
<div className="notification-icon">
<IconNotification/>
</div>
<div className="notification-content">
<div className="notification-title">Токены добавлены</div>
<div className="notification-text">На ваш баланс добавлено 100 токенов. Теперь вы можете защитить ещё больше файлов!</div>
<div className="notification-time">4 дн назад</div>
<div className="notification-title">
{t('tokens-added')}
</div>
<div className="notification-text">{t('added')} 100 {t('tokens')}.</div>
<div className="notification-time">4 {t('days-ago')}</div>
</div>
</div>
{JSON.stringify(data)}
</div>
) : (
<p>Нет данных</p>
<p>
{t('no-data')}
</p>
)}
<div className="notification-footer">
<Link href="/pages/notifications" className="notification-link">Посмотреть все</Link>
<Link href="/pages/notifications" className="notification-link">
{t('view-all')}
</Link>
</div>
</>
)}