diff --git a/prisma/dev.db b/prisma/dev.db index e69de29..e374783 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/src/app/[encodedUrl]/page.tsx b/src/app/[encodedUrl]/page.tsx new file mode 100644 index 0000000..66a14d3 --- /dev/null +++ b/src/app/[encodedUrl]/page.tsx @@ -0,0 +1,132 @@ +'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 */} + +
+ ); +}