import { useEffect, useState } from 'react';
import { usePointsMallPageLogic } from './PointsMallPageLogic';
import PointsMallPageWeb from './components/PointsMallPageWeb';
import PointsMallPageH5 from './components/PointsMallPageH5';

const isMobileDevice = () => {
  if (typeof window === 'undefined') return false;
  return window.innerWidth < 768;
};

export default function PointsMallPage() {
  const logic = usePointsMallPageLogic();
  const [isMobile, setIsMobile] = useState(isMobileDevice());

  useEffect(() => {
    const handleResize = () => {
      setIsMobile(isMobileDevice());
    };
    window.addEventListener('resize', handleResize);
    return () => window.removeEventListener('resize', handleResize);
  }, []);

  return isMobile ? <PointsMallPageH5 logic={logic} /> : <PointsMallPageWeb logic={logic} />;
}
