/**
 * 알림 Context 연동 UI (Provider 하위에서만 사용)
 */
import React from 'react';
import TopMenuBar, { type MenuPage } from './TopMenuBar';
import type { Theme } from '../types';
import type { AuthSession } from '../utils/auth';
import type { TradeAlertPopupLayout, TradeAlertPopupPosition } from '../utils/tradeAlertPopupLayout';
import { useTradeNotification } from '../contexts/TradeNotificationContext';

interface NotifyTopMenuBarProps {
  activePage: MenuPage;
  theme: Theme;
  onPage: (page: MenuPage) => void;
  onTheme: () => void;
  authUser?: AuthSession | null;
  onLoginClick?: () => void;
  onLogout?: () => void;
  menuPermissions?: Record<string, boolean>;
  guestMode?: boolean;
  tradeAlertPopupPosition?: string;
  tradeAlertPopupLayout?: string;
  tradeAlertPopupGridCols?: number;
  onTradeAlertPopupPosition?: (v: TradeAlertPopupPosition) => void;
  onTradeAlertPopupLayout?: (v: TradeAlertPopupLayout) => void;
  onTradeAlertPopupGridCols?: (v: number) => void;
}

export const NotifyTopMenuBar: React.FC<NotifyTopMenuBarProps> = props => {
  const { unreadCount, toastNotifications, dismissAllToasts } = useTradeNotification();
  return (
    <TopMenuBar
      {...props}
      tradeNotifyUnread={unreadCount}
      tradeNotifyToastCount={toastNotifications.length}
      onOpenNotifications={() => props.onPage('notifications')}
      onDismissAllNotifyPopups={dismissAllToasts}
      tradeAlertPopupPosition={props.tradeAlertPopupPosition}
      tradeAlertPopupLayout={props.tradeAlertPopupLayout}
      tradeAlertPopupGridCols={props.tradeAlertPopupGridCols}
      onTradeAlertPopupPosition={props.onTradeAlertPopupPosition}
      onTradeAlertPopupLayout={props.onTradeAlertPopupLayout}
      onTradeAlertPopupGridCols={props.onTradeAlertPopupGridCols}
    />
  );
};

import Toolbar, { type ToolbarProps } from './Toolbar';

export const ChartToolbarNotify: React.FC<ToolbarProps & { onOpenNotifyList: () => void }> = ({
  onOpenNotifyList,
  ...toolbarProps
}) => {
  const { unreadCount } = useTradeNotification();
  return (
    <Toolbar
      {...toolbarProps}
      tradeNotifyUnread={unreadCount}
      onOpenTradeNotifications={onOpenNotifyList}
    />
  );
};
