'use client';

import { useState, useEffect } from 'react';

interface LoadingState {
  isLoading: boolean;
  message?: string;
}

interface LoadingContextType {
  loading: LoadingState;
  setLoading: (loading: LoadingState) => void;
}

export const useLoading = () => {
  const [loading, setLoading] = useState<LoadingState>({ isLoading: false });

  const startLoading = (message?: string) => {
    setLoading({ isLoading: true, message });
  };

  const stopLoading = () => {
    setLoading({ isLoading: false });
  };

  return {
    loading,
    setLoading,
    startLoading,
    stopLoading
  };
};