import { useNavigate } from 'react-router-dom';
import { useCallback } from 'react';

/**
 * Hook for navigating within the warehouse module
 */
export function useWarehouseNavigation() {
  const navigate = useNavigate();

  // Articles
  const goToArticles = useCallback(() => {
    navigate('/warehouse/articles');
  }, [navigate]);

  const goToArticle = useCallback((id: number) => {
    navigate(`/warehouse/articles/${id}`);
  }, [navigate]);

  const goToNewArticle = useCallback(() => {
    navigate('/warehouse/articles/new');
  }, [navigate]);

  const goToEditArticle = useCallback((id: number) => {
    navigate(`/warehouse/articles/${id}/edit`);
  }, [navigate]);

  // Warehouses
  const goToWarehouses = useCallback(() => {
    navigate('/warehouse/locations');
  }, [navigate]);

  const goToWarehouse = useCallback((id: number) => {
    navigate(`/warehouse/locations/${id}`);
  }, [navigate]);

  const goToNewWarehouse = useCallback(() => {
    navigate('/warehouse/locations/new');
  }, [navigate]);

  // Categories
  const goToCategories = useCallback(() => {
    navigate('/warehouse/categories');
  }, [navigate]);

  // Movements
  const goToMovements = useCallback(() => {
    navigate('/warehouse/movements');
  }, [navigate]);

  const goToMovement = useCallback((id: number) => {
    navigate(`/warehouse/movements/${id}`);
  }, [navigate]);

  const goToNewInbound = useCallback(() => {
    navigate('/warehouse/movements/inbound/new');
  }, [navigate]);

  const goToNewOutbound = useCallback(() => {
    navigate('/warehouse/movements/outbound/new');
  }, [navigate]);

  const goToNewTransfer = useCallback(() => {
    navigate('/warehouse/movements/transfer/new');
  }, [navigate]);

  const goToNewAdjustment = useCallback(() => {
    navigate('/warehouse/movements/adjustment/new');
  }, [navigate]);

  // Batches
  const goToBatches = useCallback(() => {
    navigate('/warehouse/batches');
  }, [navigate]);

  const goToBatch = useCallback((id: number) => {
    navigate(`/warehouse/batches/${id}`);
  }, [navigate]);

  const goToNewBatch = useCallback(() => {
    navigate('/warehouse/batches/new');
  }, [navigate]);

  // Serials
  const goToSerials = useCallback(() => {
    navigate('/warehouse/serials');
  }, [navigate]);

  const goToSerial = useCallback((id: number) => {
    navigate(`/warehouse/serials/${id}`);
  }, [navigate]);

  const goToNewSerial = useCallback(() => {
    navigate('/warehouse/serials/new');
  }, [navigate]);

  // Stock
  const goToStockLevels = useCallback(() => {
    navigate('/warehouse/stock');
  }, [navigate]);

  const goToValuation = useCallback(() => {
    navigate('/warehouse/valuation');
  }, [navigate]);

  // Inventory
  const goToInventories = useCallback(() => {
    navigate('/warehouse/inventory');
  }, [navigate]);

  const goToInventory = useCallback((id: number) => {
    navigate(`/warehouse/inventory/${id}`);
  }, [navigate]);

  const goToNewInventory = useCallback(() => {
    navigate('/warehouse/inventory/new');
  }, [navigate]);

  // Dashboard
  const goToDashboard = useCallback(() => {
    navigate('/warehouse');
  }, [navigate]);

  return {
    // Articles
    goToArticles,
    goToArticle,
    goToNewArticle,
    goToEditArticle,
    // Warehouses
    goToWarehouses,
    goToWarehouse,
    goToNewWarehouse,
    // Categories
    goToCategories,
    // Movements
    goToMovements,
    goToMovement,
    goToNewInbound,
    goToNewOutbound,
    goToNewTransfer,
    goToNewAdjustment,
    // Batches
    goToBatches,
    goToBatch,
    goToNewBatch,
    // Serials
    goToSerials,
    goToSerial,
    goToNewSerial,
    // Stock
    goToStockLevels,
    goToValuation,
    // Inventory
    goToInventories,
    goToInventory,
    goToNewInventory,
    // Dashboard
    goToDashboard,
  };
}
