import { useState, useCallback } from 'react';
import type { Service } from '@/types/service';

/**
 * Hook personnalisé pour gérer l'état des modales de services
 * Remplace la logique dans App.tsx et simplifie la gestion d'état
 */
export const useServiceModal = () => {
  const [selectedService, setSelectedService] = useState<Service | null>(null);

  const openServiceModal = useCallback((service: Service) => {
    setSelectedService(service);
  }, []);

  const closeServiceModal = useCallback(() => {
    setSelectedService(null);
  }, []);

  const isModalOpen = selectedService !== null;

  return {
    selectedService,
    openServiceModal,
    closeServiceModal,
    isModalOpen,
  };
};
