mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:51:14 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
46
src-old/components/notifications/NotificationCenter.tsx
Normal file
46
src-old/components/notifications/NotificationCenter.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
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: { data?: Record<string, unknown> }) => {
|
||||
// Handle navigation based on notification payload
|
||||
const data = notification.data as { url?: string } | undefined;
|
||||
if (data?.url) {
|
||||
navigate(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}
|
||||
subscriber={subscriberId || ''}
|
||||
appearance={appearance}
|
||||
onNotificationClick={handleNotificationClick}
|
||||
/>
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user