/*
 * File: navigationTypes.ts
 * Description: TypeScript type definitions for navigation parameters and routes
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

import { NavigatorScreenParams } from '@react-navigation/native';
import { ERDashboard, Patient, Alert as AlertType } from '../shared/types';

// ============================================================================
// ROOT NAVIGATION TYPES
// ============================================================================

/**
 * RootStackParamList
 * 
 * Purpose: Defines the main navigation stack parameters for the entire app
 * 
 * Routes:
 * - Auth: Authentication stack navigator
 * - Main: Main app with bottom tab navigation
 */
export type RootStackParamList = {
  Auth: undefined;  // Auth stack navigator handles its own screens
  ResetPassword: undefined;  // Reset password screen for onboarding
  Main: NavigatorScreenParams<MainTabParamList>;  // Main app with tab navigation
};

// ============================================================================
// MAIN TAB NAVIGATION TYPES
// ============================================================================

/**
 * MainTabParamList
 * 
 * Purpose: Defines the bottom tab navigation parameters
 * 
 * Tabs:
 * - Dashboard: ER dashboard with patient overview
 * - Patients: Patient list and management
 * - AIPredictions: AI-powered medical case predictions and analysis
 * - Settings: User preferences and app configuration
 */
export type MainTabParamList = {
  Dashboard: DashboardScreenParams;     // Dashboard with initial data
  Patients: PatientsScreenParams;      // Patient list screen
  AIPredictions: AIPredictionScreenParams; // AI predictions screen
  Settings: SettingsScreenParams;      // Settings screen
};

// ============================================================================
// SCREEN PARAMETER TYPES
// ============================================================================

/**
 * DashboardScreenParams
 * 
 * Purpose: Parameters passed to the dashboard screen
 * 
 * Parameters:
 * - dashboard: ER dashboard data including statistics and shift info
 * - patients: Array of patient data for display
 * - alerts: Array of critical alerts and notifications
 */
export interface DashboardScreenParams {
  dashboard: ERDashboard;
  patients: Patient[];
  alerts: AlertType[];
}

/**
 * PatientsScreenParams
 * 
 * Purpose: Parameters for the patients screen
 * 
 * Parameters:
 * - filter: Optional filter to apply to patient list
 * - searchQuery: Optional search term for patient search
 */
export interface PatientsScreenParams {
  filter?: 'all' | 'critical' | 'active' | 'pending';
  searchQuery?: string;
}

/**
 * AIPredictionScreenParams
 * 
 * Purpose: Parameters for the AI predictions screen
 * 
 * Parameters:
 * - filter: Optional filter for prediction types
 * - urgency: Optional urgency level filter
 * - searchQuery: Optional search term for predictions
 */
export interface AIPredictionScreenParams {
  filter?: 'all' | 'critical' | 'urgent' | 'pending' | 'reviewed';
  urgency?: 'emergency' | 'urgent' | 'moderate' | 'low' | 'routine';
  searchQuery?: string;
}

/**
 * ReportsScreenParams
 * 
 * Purpose: Parameters for the reports screen
 * 
 * Parameters:
 * - patientId: Optional patient ID to filter reports
 * - dateRange: Optional date range for report filtering
 */
export interface ReportsScreenParams {
  patientId?: string;
  dateRange?: {
    start: Date;
    end: Date;
  };
}

/**
 * SettingsScreenParams
 * 
 * Purpose: Parameters for the settings screen
 * 
 * Parameters:
 * - section: Optional section to navigate to within settings
 */
export interface SettingsScreenParams {
  section?: 'profile' | 'notifications' | 'security' | 'about';
}

// ============================================================================
// NAVIGATION PROPS TYPES
// ============================================================================

/**
 * NavigationProps
 * 
 * Purpose: Common navigation props used across components
 * 
 * Properties:
 * - navigation: Navigation object for screen navigation
 * - route: Current route information and parameters
 */
export interface NavigationProps<T extends keyof RootStackParamList> {
  navigation: any; // Will be properly typed when navigation is set up
  route: {
    params: RootStackParamList[T];
  };
}

/**
 * TabNavigationProps
 * 
 * Purpose: Navigation props for tab screens
 * 
 * Properties:
 * - navigation: Tab navigation object
 * - route: Current tab route information
 */
export interface TabNavigationProps<T extends keyof MainTabParamList> {
  navigation: any; // Will be properly typed when navigation is set up
  route: {
    params: MainTabParamList[T];
  };
}

// ============================================================================
// NAVIGATION UTILITY TYPES
// ============================================================================

/**
 * NavigationRef
 * 
 * Purpose: Reference to the navigation object for programmatic navigation
 * 
 * Usage:
 * - Used for navigation from outside React components
 * - Enables navigation from services, utilities, or event handlers
 */
export type NavigationRef = {
  navigate: (name: keyof RootStackParamList, params?: any) => void;
  goBack: () => void;
  reset: (state: any) => void;
};

/*
 * End of File: navigationTypes.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 