/*
 * File: navigationUtils.ts
 * Description: Navigation utilities for Auth module
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

import { AuthNavigationProp } from './navigationTypes';

/**
 * AuthNavigationUtils - Utility functions for Auth module navigation
 * 
 * This module provides helper functions for common navigation patterns
 * within the Auth module, ensuring consistent navigation behavior.
 */

/**
 * Navigate to Login screen
 * @param navigation - Navigation prop from React Navigation
 */
export const navigateToLogin = (navigation: AuthNavigationProp): void => {
  navigation.navigate('Login');
};

/**
 * Navigate to Sign Up screen
 * @param navigation - Navigation prop from React Navigation
 */
export const navigateToSignUp = (navigation: AuthNavigationProp): void => {
  navigation.navigate('SignUp');
};

/**
 * Go back to previous screen
 * @param navigation - Navigation prop from React Navigation
 */
export const goBack = (navigation: AuthNavigationProp): void => {
  if (navigation.canGoBack()) {
    navigation.goBack();
  }
};

/**
 * Reset navigation stack to Login screen
 * @param navigation - Navigation prop from React Navigation
 */
export const resetToLogin = (navigation: AuthNavigationProp): void => {
  navigation.reset({
    index: 0,
    routes: [{ name: 'Login' }],
  });
};

/**
 * Reset navigation stack to Sign Up screen
 * @param navigation - Navigation prop from React Navigation
 */
export const resetToSignUp = (navigation: AuthNavigationProp): void => {
  navigation.reset({
    index: 0,
    routes: [{ name: 'SignUp' }],
  });
};

/**
 * Replace current screen with Login screen
 * @param navigation - Navigation prop from React Navigation
 */
export const replaceWithLogin = (navigation: AuthNavigationProp): void => {
  navigation.replace('Login');
};

/**
 * Replace current screen with Sign Up screen
 * @param navigation - Navigation prop from React Navigation
 */
export const replaceWithSignUp = (navigation: AuthNavigationProp): void => {
  navigation.replace('SignUp');
};

/**
 * Navigate to Sign Up screen and clear back stack
 * @param navigation - Navigation prop from React Navigation
 */
export const navigateToSignUpAndClearStack = (navigation: AuthNavigationProp): void => {
  navigation.reset({
    index: 0,
    routes: [{ name: 'SignUp' }],
  });
};

/**
 * Navigate to Login screen and clear back stack
 * @param navigation - Navigation prop from React Navigation
 */
export const navigateToLoginAndClearStack = (navigation: AuthNavigationProp): void => {
  navigation.reset({
    index: 0,
    routes: [{ name: 'Login' }],
  });
};

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