'use client'; import React, { Suspense } from 'react'; import { useParams } from 'next/navigation'; import { ItemsList } from '@/components/ItemsList'; // Loading component for better UX function LoadingSpinner() { return (
Loading items...
); } // Error boundary component function ErrorFallback({ error, resetError }: { error: Error; resetError: () => void }) { return (

Something went wrong

{error.message || 'An unexpected error occurred while loading the items.'}

); } // Simple error boundary implementation class ErrorBoundary extends React.Component< { children: React.ReactNode; fallback: (error: Error, resetError: () => void) => React.ReactNode }, { hasError: boolean; error?: Error } > { constructor(props: { children: React.ReactNode; fallback: (error: Error, resetError: () => void) => React.ReactNode }) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error) { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error('Error caught by boundary:', error, errorInfo); } render() { if (this.state.hasError && this.state.error) { return this.props.fallback(this.state.error, () => { this.setState({ hasError: false, error: undefined }); }); } return this.props.children; } } export default function UrlPage() { const params = useParams(); const encodedUrlParam = params.encodedUrl || ''; // Handle both string and string[] cases const encodedUrl = Array.isArray(encodedUrlParam) ? encodedUrlParam[0] : encodedUrlParam; const decodedUrl = decodeURIComponent(encodedUrl); return (
{/* Header */}

CompareWare

Item Comparison Tool
{/* Main content */}

{`Items Comparison for "${decodedUrl}"`}

{/* Items list with error boundary and suspense */} }> }>
{/* Footer */}
); }