import 'package:flutter_modular/flutter_modular.dart';

import 'route_paths.dart';

/// Typed navigation extension for the Client application.
///
/// This extension provides type-safe navigation methods for all routes
/// in the Client app. All client navigation should use these methods
/// instead of hardcoding route strings.
///
/// Usage:
/// ```dart
/// import 'package:flutter_modular/flutter_modular.dart';
/// import 'package:krow_core/routing.dart';
///
/// // In your widget or bloc
/// Modular.to.toClientSignIn();
/// Modular.to.toClientHome();
/// Modular.to.toOrderDetails('order123');
/// ```
///
/// See also:
///  * [ClientPaths] for route path constants
///  * [StaffNavigator] for Staff app navigation
extension ClientNavigator on IModularNavigator {
  // ==========================================================================
  // AUTHENTICATION FLOWS
  // ==========================================================================

  /// Navigate to the root authentication screen.
  /// 
  /// This effectively logs out the user by navigating to root.
  /// Used when signing out or session expires.
  void toClientRoot() {
    navigate(ClientPaths.root);
  }

  /// Navigates to the client sign-in page.
  ///
  /// This page allows existing clients to log in using email/password
  /// or social authentication providers.
  void toClientSignIn() {
    pushNamed(ClientPaths.signIn);
  }

  /// Navigates to the client sign-up page.
  ///
  /// This page allows new clients to create an account and provides
  /// the initial registration form.
  void toClientSignUp() {
    pushNamed(ClientPaths.signUp);
  }

  /// Navigates to the client home dashboard.
  ///
  /// This is typically called after successful authentication or when
  /// returning to the main application from a deep feature.
  ///
  /// Uses pushNamed to avoid trailing slash issues with navigate().
  void toClientHome() {
    navigate(ClientPaths.home);
  }

  /// Navigates to the client main shell.
  ///
  /// This is the container with bottom navigation. Usually you'd navigate
  /// to a specific tab instead (like [toClientHome]).
  void toClientMain() {
    navigate(ClientPaths.main);
  }

  // ==========================================================================
  // MAIN NAVIGATION TABS
  // ==========================================================================

  /// Navigates to the Coverage tab.
  ///
  /// Displays workforce coverage analytics and metrics.
  void toClientCoverage() {
    navigate(ClientPaths.coverage);
  }

  /// Navigates to the Billing tab.
  ///
  /// Access billing history, invoices, and payment methods.
  void toClientBilling() {
    navigate(ClientPaths.billing);
  }

  /// Navigates to the Orders tab.
  ///
  /// View and manage all shift orders with filtering and sorting.
  void toClientOrders() {
    navigate(ClientPaths.orders);
  }

  /// Navigates to the Reports tab.
  ///
  /// Generate and view workforce reports and analytics.
  void toClientReports() {
    navigate(ClientPaths.reports);
  }

  // ==========================================================================
  // SETTINGS
  // ==========================================================================

  /// Pushes the client settings page.
  ///
  /// Manage account settings, notifications, and app preferences.
  void toClientSettings() {
    pushNamed(ClientPaths.settings);
  }

  // ==========================================================================
  // HUBS MANAGEMENT
  // ==========================================================================

  /// Pushes the client hubs management page.
  ///
  /// View and manage physical locations/hubs where staff are deployed.
  Future<void> toClientHubs() async {
    await pushNamed(ClientPaths.hubs);
  }

  // ==========================================================================
  // ORDER CREATION
  // ==========================================================================

  /// Pushes the order creation flow entry page.
  ///
  /// This is the starting point for all order creation flows.
  void toCreateOrder() {
    pushNamed(ClientPaths.createOrder);
  }

  /// Pushes the rapid order creation flow.
  ///
  /// Quick shift creation with simplified inputs for urgent needs.
  void toCreateOrderRapid() {
    pushNamed(ClientPaths.createOrderRapid);
  }

  /// Pushes the one-time order creation flow.
  ///
  /// Create a shift that occurs once at a specific date and time.
  void toCreateOrderOneTime() {
    pushNamed(ClientPaths.createOrderOneTime);
  }

  /// Pushes the recurring order creation flow.
  ///
  /// Create shifts that repeat on a defined schedule (daily, weekly, etc.).
  void toCreateOrderRecurring() {
    pushNamed(ClientPaths.createOrderRecurring);
  }

  /// Pushes the permanent order creation flow.
  ///
  /// Create a long-term or permanent staffing position.
  void toCreateOrderPermanent() {
    pushNamed(ClientPaths.createOrderPermanent);
  }
}
