Files
thrilltrack-explorer/src/components/notifications/NotificationCenter.tsx
2025-10-01 12:49:14 +00:00

46 lines
1.3 KiB
TypeScript

import { lazy, Suspense } from 'react';
import { useNovuNotifications } from '@/hooks/useNovuNotifications';
import { useNovuTheme } from '@/hooks/useNovuTheme';
import { useNavigate } from 'react-router-dom';
import { Bell } from 'lucide-react';
import { Button } from '@/components/ui/button';
// Lazy load Novu Inbox to prevent React instance conflicts
const Inbox = lazy(() =>
import('@novu/react').then(module => ({ default: module.Inbox }))
);
export function NotificationCenter() {
const { applicationIdentifier, subscriberId, isEnabled } = useNovuNotifications();
const appearance = useNovuTheme();
const navigate = useNavigate();
if (!isEnabled) {
return null;
}
const handleNotificationClick = (notification: any) => {
// Handle navigation based on notification payload
if (notification.data?.url) {
navigate(notification.data.url);
}
};
return (
<Suspense
fallback={
<Button variant="ghost" size="icon" className="h-9 w-9" disabled>
<Bell className="h-5 w-5" />
</Button>
}
>
<Inbox
applicationIdentifier={applicationIdentifier}
subscriberId={subscriberId}
appearance={appearance}
onNotificationClick={handleNotificationClick}
/>
</Suspense>
);
}