import { useState } from "react";
import { NAVIGATION_DELAY } from "../constants/app";

export type PageType = "home" | "services" | "about" | "contact";

export function useNavigation() {
  const [currentPage, setCurrentPage] = useState<PageType>("home");
  const [isLoading, setIsLoading] = useState(false);

  const handleNavigate = (page: string, onNavigateAway?: () => void) => {
    setIsLoading(true);
    
    // Simulate navigation delay
    setTimeout(() => {
      setCurrentPage(page as PageType);
      // Reset booking flow when navigating away from home
      if (page !== "home" && onNavigateAway) {
        onNavigateAway();
      }
      setIsLoading(false);
    }, NAVIGATION_DELAY);
  };

  return {
    currentPage,
    isLoading,
    handleNavigate
  };
}