'use client';

import { useEffect, useState } from 'react';
import TestUrlsClient, { UrlCategory } from './TestUrlsClient';
import { getTestUrlsData } from './actions';
import { GenericPageSkeleton } from '@/components/ui/skeleton';

export default function TestUrlsPage() {
  const [urlData, setUrlData] = useState<UrlCategory[]>([]);
  const [lastUpdated, setLastUpdated] = useState('N/A');
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    getTestUrlsData()
      .then(result => {
        setUrlData(result.categories);
        setLastUpdated(result.lastUpdated);
      })
      .finally(() => setIsLoading(false));
  }, []);

  if (isLoading) return <GenericPageSkeleton />;

  return <TestUrlsClient initialData={urlData} lastUpdated={lastUpdated} />;
}