import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const ScrollToTop = () => {
	const { pathname } = useLocation();

	useEffect(() => {
		const timeoutId = setTimeout(() => {
			console.log('ScrollToTop useEffect triggered for pathname:', pathname);
			window.scrollTo({ top: 0, behavior: 'auto' });
		}, 150); // 150ms delay

		// Cleanup in case component unmounts before timeout
		return () => clearTimeout(timeoutId);
	}, [pathname]);

	return null;
};

export default ScrollToTop;
