11'use client'
2- import React from 'react'
32import { VoloCmsKitContentsPageDto } from '@/client'
43import { PageView } from '@/components/page/PageView'
4+ import { Alert , AlertDescription } from '@/components/ui/alert'
55import { Button } from '@/components/ui/button'
66import { Card , CardContent , CardDescription , CardHeader , CardTitle } from '@/components/ui/card'
7- import { Alert , AlertDescription } from '@/components/ui/alert'
87import Error from '@/components/ui/Error'
98import Loader from '@/components/ui/Loader'
109import { usePageBySlug } from '@/lib/hooks/usePages'
1110import { AlertTriangle , Home , RefreshCw , Search } from 'lucide-react'
1211import Link from 'next/link'
1312import { useParams , useRouter } from 'next/navigation'
14- import { useEffect , useState } from 'react'
13+ import React , { useEffect , useState } from 'react'
1514
1615export default function PageViewPage ( ) {
1716 const params = useParams ( )
1817 const router = useRouter ( )
1918 const slug = params . slug as string
2019 const [ retryCount , setRetryCount ] = useState ( 0 )
2120
22- const {
23- data : page ,
24- isLoading,
25- isError,
26- error,
27- refetch
28- } = usePageBySlug ( slug )
21+ const { data : page , isLoading, isError, error, refetch } = usePageBySlug ( slug )
2922
3023 // Handle retry logic
3124 const handleRetry = ( ) => {
32- setRetryCount ( prev => prev + 1 )
25+ setRetryCount ( ( prev ) => prev + 1 )
3326 refetch ( )
3427 }
3528
@@ -52,12 +45,17 @@ export default function PageViewPage() {
5245
5346 // Handle different types of errors gracefully
5447 if ( isError ) {
55- const errorMessage = error && typeof error === 'object' && 'message' in error
56- ? String ( error . message )
57- : 'An unexpected error occurred'
58-
48+ const errorMessage =
49+ error && typeof error === 'object' && 'message' in error
50+ ? String ( error . message )
51+ : 'An unexpected error occurred'
52+
5953 // Network or server errors
60- if ( errorMessage . includes ( 'fetch' ) || errorMessage . includes ( 'network' ) || errorMessage . includes ( 'timeout' ) ) {
54+ if (
55+ errorMessage . includes ( 'fetch' ) ||
56+ errorMessage . includes ( 'network' ) ||
57+ errorMessage . includes ( 'timeout' )
58+ ) {
6159 return (
6260 < div className = "min-h-screen bg-background flex items-center justify-center p-4" >
6361 < Card className = "w-full max-w-md" >
@@ -67,17 +65,16 @@ export default function PageViewPage() {
6765 </ div >
6866 < CardTitle > Connection Error</ CardTitle >
6967 < CardDescription >
70- We' re having trouble connecting to our servers. This might be a temporary issue.
68+ We' re having trouble connecting to our servers. This might be a temporary issue.
7169 </ CardDescription >
7270 </ CardHeader >
7371 < CardContent className = "space-y-4" >
7472 < Alert >
7573 < AlertTriangle className = "h-4 w-4" />
7674 < AlertDescription >
77- { retryCount > 0
75+ { retryCount > 0
7876 ? `Attempt ${ retryCount + 1 } failed. Please try again.`
79- : 'Please check your internet connection and try again.'
80- }
77+ : 'Please check your internet connection and try again.' }
8178 </ AlertDescription >
8279 </ Alert >
8380 < div className = "flex gap-2" >
@@ -107,12 +104,14 @@ export default function PageViewPage() {
107104 </ div >
108105 < CardTitle > Page Not Found</ CardTitle >
109106 < CardDescription >
110- The page you' re looking for doesn' t exist or may have been moved.
107+ The page you' re looking for doesn' t exist or may have been moved.
111108 </ CardDescription >
112109 </ CardHeader >
113110 < CardContent className = "space-y-4" >
114111 < div className = "text-sm text-muted-foreground" >
115- < p > Slug: < code className = "bg-muted px-1 rounded" > { slug } </ code > </ p >
112+ < p >
113+ Slug: < code className = "bg-muted px-1 rounded" > { slug } </ code >
114+ </ p >
116115 </ div >
117116 < div className = "flex gap-2" >
118117 < Button asChild className = "flex-1" >
@@ -147,9 +146,7 @@ export default function PageViewPage() {
147146 < CardContent className = "space-y-4" >
148147 < Alert >
149148 < AlertTriangle className = "h-4 w-4" />
150- < AlertDescription >
151- { errorMessage }
152- </ AlertDescription >
149+ < AlertDescription > { errorMessage } </ AlertDescription >
153150 </ Alert >
154151 < div className = "flex gap-2" >
155152 < Button onClick = { handleRetry } className = "flex-1" >
@@ -220,9 +217,10 @@ class ErrorBoundary extends React.Component<
220217 }
221218
222219 static getDerivedStateFromError ( error : unknown ) {
223- const errorObj = error && typeof error === 'object' && 'message' in error
224- ? error as Error
225- : { message : String ( error ) , name : 'Error' } as Error
220+ const errorObj =
221+ error && typeof error === 'object' && 'message' in error
222+ ? ( error as Error )
223+ : ( { message : String ( error ) , name : 'Error' } as Error )
226224 return { hasError : true , error : errorObj }
227225 }
228226
@@ -237,4 +235,4 @@ class ErrorBoundary extends React.Component<
237235
238236 return this . props . children
239237 }
240- }
238+ }
0 commit comments