//! Status reducer organized by functionality.
//!
//! This module contains all status-related reducer logic, split into focused
//! sub-modules for better organization and maintainability.
//!
//! **Module Organization:**
//! - `navigation.rs` - Navigation actions (up, down, page up/down, top, bottom)
//! - `selection.rs` - Selection actions (next/prev staged, next/prev conflict)
//! - `status_updates.rs` - Status data updates (entries, summary, errors)
//! - `reset.rs` - Reset confirmation actions
//! - `staging.rs` - Staging/unstaging actions
//! - `other.rs` - All other status-related actions

mod navigation;
mod selection;
mod status_updates;
mod reset;
mod staging;
mod other;

use crate::app::{actions::Action, state::AppState};

/// Main reducer function that delegates to specialized handlers.
pub fn reduce(mut state: AppState, action: &Action) -> Option<AppState> {
    // Try each specialized handler in order
    if navigation::handle_navigation(&mut state, action) {
        return Some(state);
    }
    if selection::handle_selection(&mut state, action) {
        return Some(state);
    }
    if status_updates::handle_status_updates(&mut state, action) {
        return Some(state);
    }
    if reset::handle_reset(&mut state, action) {
        return Some(state);
    }
    if staging::handle_staging(&mut state, action) {
        return Some(state);
    }
    
    // Delegate to other handler for remaining actions
    other::handle_other(&mut state, action)
}

