@@ -8,7 +8,7 @@ import { TypeDataset, TypeUseCase } from '@/gql/generated/graphql';
88import { useQuery } from '@tanstack/react-query' ;
99import { Card , Text } from 'opub-ui' ;
1010
11- import { GraphQL } from '@/lib/api' ;
11+ import { GraphQLClient } from '@/lib/api' ;
1212import { formatDate , generateJsonLd } from '@/lib/utils' ;
1313import BreadCrumbs from '@/components/BreadCrumbs' ;
1414import { Icons } from '@/components/icons' ;
@@ -144,11 +144,11 @@ const UseCaseDetailClient = () => {
144144 const {
145145 data : UseCaseDetails ,
146146 isLoading,
147- refetch ,
147+ error ,
148148 } = useQuery < { useCase : TypeUseCase } > (
149149 [ `fetch_UsecaseDetails_${ params . useCaseSlug } ` ] ,
150150 ( ) =>
151- GraphQL (
151+ GraphQLClient (
152152 UseCasedetails ,
153153 { } ,
154154 {
@@ -158,6 +158,13 @@ const UseCaseDetailClient = () => {
158158 {
159159 refetchOnMount : true ,
160160 refetchOnReconnect : true ,
161+ retry : ( failureCount , error : any ) => {
162+ // Don't retry on 401/403 errors
163+ if ( error ?. message ?. includes ( '401' ) || error ?. message ?. includes ( '403' ) ) {
164+ return false ;
165+ }
166+ return failureCount < 3 ;
167+ } ,
161168 }
162169 ) ;
163170 const datasets = UseCaseDetails ?. useCase ?. datasets || [ ] ; // Fallback to an empty array
@@ -195,6 +202,28 @@ const UseCaseDetailClient = () => {
195202 < div className = " flex justify-center p-10" >
196203 < Loading />
197204 </ div >
205+ ) : error ? (
206+ < div className = "container py-10" >
207+ < div className = "flex flex-col items-center justify-center gap-4" >
208+ < Text variant = "headingXl" color = "critical" >
209+ Error Loading Use Case
210+ </ Text >
211+ < Text variant = "bodyLg" >
212+ { ( error as any ) ?. message ?. includes ( '401' ) || ( error as any ) ?. message ?. includes ( '403' )
213+ ? 'You do not have permission to view this use case. Please log in or contact the administrator.'
214+ : 'Failed to load use case details. Please try again later.' }
215+ </ Text >
216+ </ div >
217+ </ div >
218+ ) : ! UseCaseDetails ?. useCase ? (
219+ < div className = "container py-10" >
220+ < div className = "flex flex-col items-center justify-center gap-4" >
221+ < Text variant = "headingXl" > Use Case Not Found</ Text >
222+ < Text variant = "bodyLg" >
223+ The requested use case could not be found.
224+ </ Text >
225+ </ div >
226+ </ div >
198227 ) : (
199228 < >
200229 < BreadCrumbs
0 commit comments