'use client';

import { useRouter } from 'next/navigation';
import ScraperTest from '@/components/ScraperTest';
import { useJobs } from '@/contexts/JobsContext';
import { JobStatus } from '@/components/ScraperTest';

export default function NewScrapePage() {
  const router = useRouter();
  const { addJob, refreshJobs } = useJobs();

  const handleJobsChange = (jobs: JobStatus[]) => {
    // Add new jobs to context
    jobs.forEach(job => addJob(job));
  };

  const handleSelectReviews = (reviews: unknown[], businessName: string, jobId: string) => {
    // Navigate to analytics page for this job
    router.push(`/analytics/${jobId}`);
  };

  return (
    <div className="h-full overflow-y-auto p-6">
      <ScraperTest
        onJobsChange={handleJobsChange}
        onSelectReviews={handleSelectReviews}
      />
    </div>
  );
}
