'use client';

import { useEffect } from 'react';
import { useRouter, useSearchParams } from 'next/navigation';

export default function AddStoryRedirectPage() {
  const router = useRouter();
  const searchParams = useSearchParams();

  useEffect(() => {
    // Redirect to the new /import route while preserving query parameters
    const mode = searchParams.get('mode');
    const authorId = searchParams.get('authorId');
    const from = searchParams.get('from');
    
    let redirectUrl = '/import';
    const queryParams = new URLSearchParams();
    
    if (mode) queryParams.set('mode', mode);
    if (authorId) queryParams.set('authorId', authorId);
    if (from) queryParams.set('from', from);
    
    const queryString = queryParams.toString();
    if (queryString) {
      redirectUrl += '?' + queryString;
    }
    
    router.replace(redirectUrl);
  }, [router, searchParams]);

  return (
    <div className="min-h-screen flex items-center justify-center">
      <div className="text-center">
        <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
        <p className="text-gray-600">Redirecting...</p>
      </div>
    </div>
  );
}