import type { AuthSessionState } from '@/business/auth/types';
import type {
  CampusInfo,
  ModuleId,
  UserRole,
} from '@/shared/types/app';
import type { TopBarSearchResult } from '@/business/top-bar/search';
import type { CurrentUser } from '@/shared/types/auth';

export interface TopBarProps {
  readonly user: CurrentUser | null;
  readonly userRole: UserRole;
  readonly userName: string;
  readonly avatar: string | null;
  readonly campusInfo?: CampusInfo;
  readonly toggleSidebar: () => void;
  readonly setCurrentModule: (moduleId: ModuleId) => void;
}

export interface TopBarNotification {
  readonly id: string;
  readonly text: string;
  readonly time: string;
  readonly unread: boolean;
  /** Optional in-app route to navigate to when the notification is clicked. */
  readonly href?: string;
}

export interface UseTopBarPageOptions extends TopBarProps {
  readonly profile: AuthSessionState['profile'];
  readonly signOut: AuthSessionState['signOut'];
}

export interface TopBarPage {
  readonly userRole: UserRole;
  readonly userName: string;
  readonly avatar: string | null;
  readonly campusInfo?: CampusInfo;
  readonly profileRoleLabel: string;
  readonly roleLabel: string;
  readonly initials: string;
  readonly campusLabel: string;
  readonly showProfileMenu: boolean;
  readonly showNotifications: boolean;
  readonly searchQuery: string;
  readonly searchResults: readonly TopBarSearchResult[];
  readonly signOutError: string | null;
  readonly notifications: readonly TopBarNotification[];
  readonly unreadCount: number;
  readonly toggleSidebar: () => void;
  readonly toggleProfileMenu: () => void;
  readonly closeProfileMenu: () => void;
  readonly toggleNotifications: () => void;
  readonly closeNotifications: () => void;
  readonly setSearchQuery: (value: string) => void;
  readonly selectSearchResult: (result: TopBarSearchResult) => void;
  readonly signOut: () => Promise<void>;
}
