'use client';

import { useEffect } from 'react';
import { useCart } from '@/lib/cartStore';

export default function ClearCartOnMount() {
  const clear = useCart((s) => s.clear);

  useEffect(() => {
    console.log('🧹 ClearCartOnMount: Clearing cart on success page');
    clear();
    // Also clear the isCheckingOut flag if it was set
    if (typeof window !== 'undefined') {
      sessionStorage.removeItem('isCheckingOut');
    }
  }, []); // Empty dependency array - run once on mount

  return null;
}
