From f1e21f2112825b08e2e049c2813fa2dbf53b94f3 Mon Sep 17 00:00:00 2001 From: romanskijdev Date: Wed, 18 Nov 2026 15:21:18 +0300 Subject: [PATCH] Added notification center to header --- src/components/Layout/Header.tsx | 118 ++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/src/components/Layout/Header.tsx b/src/components/Layout/Header.tsx index 467d563..71b2bf1 100644 --- a/src/components/Layout/Header.tsx +++ b/src/components/Layout/Header.tsx @@ -1,14 +1,89 @@ import { Group, Burger, Text, Avatar, Menu, ActionIcon, Button, Kbd, Breadcrumbs, Box, UnstyledButton, - useMantineColorScheme, useComputedColorScheme, + Popover, Indicator, ThemeIcon, Stack, ScrollArea, } from '@mantine/core' import { spotlight } from '@mantine/spotlight' -import { IconLogout, IconSearch, IconSun, IconMoon, IconUser } from '@tabler/icons-react' +import { + IconLogout, IconSearch, IconBell, IconBriefcase, IconCheck, IconX, type Icon +} from '@tabler/icons-react' import { useLocation } from 'react-router-dom' import { useAuth } from '@/hooks/useAuth' import { findTrail } from './navigation' import { ColorSchemeToggle } from '@/components/ui/ColorSchemeToggle' +// Заглушки для Центра уведомлений +const MOCK_NOTIFICATIONS = [ + { + id: 1, + title: 'Новая задача', + text: 'Вам назначена задача по заявке #1024: «Подготовить договор»', + time: '10 мин назад', + icon: IconBriefcase, + color: 'blue', + unread: true, + }, + { + id: 2, + title: 'Заявка согласована', + text: 'Заявка #980 успешно согласована всеми участниками', + time: '1 час назад', + icon: IconCheck, + color: 'green', + unread: true, + }, + { + id: 3, + title: 'Заявка отклонена', + text: 'Иван Иванов отклонил вашу заявку #975', + time: 'Вчера, 15:30', + icon: IconX, + color: 'red', + unread: false, + }, +] + +function NotificationItem({ + title, text, time, icon: IconCmp, color, unread + }: { + title: string; text: string; time: string; icon: Icon; color: string; unread: boolean +}) { + return ( + ({ + borderBottom: '1px solid var(--mantine-color-default-border)', + width: '100%', + backgroundColor: unread ? 'var(--mantine-color-default-hover)' : 'transparent', + transition: 'background-color 150ms', + '&:hover': { backgroundColor: 'var(--mantine-color-default-hover)' }, + })} + > + + + + + + + {title} + {unread && ( + + )} + + {text} + {time} + + + + ) +} + interface HeaderProps { toggleMobile: () => void toggleDesktop: () => void @@ -22,6 +97,8 @@ export default function Header({ toggleMobile, toggleDesktop, mobileOpened, desk const trail = findTrail(pathname) const role = user?.is_root ? 'Суперадмин' : user?.is_observer ? 'Наблюдатель' : 'Администратор' + const unreadCount = MOCK_NOTIFICATIONS.filter((n) => n.unread).length + return ( @@ -72,6 +149,43 @@ export default function Header({ toggleMobile, toggleDesktop, mobileOpened, desk + {/* Центр уведомлений */} + + + + + + + + + + + Уведомления + {unreadCount > 0 && ( + + )} + + + + {MOCK_NOTIFICATIONS.length > 0 ? ( + + {MOCK_NOTIFICATIONS.map((notif) => ( + + ))} + + ) : ( + Нет новых уведомлений + )} + + + +