@@ -20,14 +20,15 @@ interface ChromosomeInterface {
2020}
2121
2222function JBrowseContent ( ) {
23- const [ accession , setAccession ] = useState < string > ( '' )
23+ const [ accession , setAccession ] = useState < string | null > ( null )
2424 const [ annotationId , setAnnotationId ] = useState < string > ( '' )
2525 const [ assembly , setAssembly ] = useState < AssemblyRecord | null > ( null )
2626 const [ annotations , setAnnotations ] = useState < AnnotationRecord [ ] > ( [ ] )
2727 const [ selectedAnnotationId , setSelectedAnnotationId ] = useState < string | undefined > ( )
2828 const [ selectedChromosome , setSelectedChromosome ] = useState < ChromosomeInterface | null > ( null )
2929 const [ isDetailsExpanded , setIsDetailsExpanded ] = useState ( true )
3030 const [ isLoading , setIsLoading ] = useState ( true )
31+ const [ isInitialized , setIsInitialized ] = useState ( false )
3132
3233 // Read URL parameters on client side
3334 useEffect ( ( ) => {
@@ -36,11 +37,12 @@ function JBrowseContent() {
3637 const accessionParam = urlParams . get ( 'accession' )
3738 const annotationIdParam = urlParams . get ( 'annotationId' )
3839
39- if ( accessionParam ) setAccession ( accessionParam )
40+ setAccession ( accessionParam )
4041 if ( annotationIdParam ) {
4142 setAnnotationId ( annotationIdParam )
4243 setSelectedAnnotationId ( annotationIdParam )
4344 }
45+ setIsInitialized ( true )
4446 }
4547 } , [ ] )
4648
@@ -67,18 +69,28 @@ function JBrowseContent() {
6769 fetchData ( )
6870 } , [ accession ] )
6971
72+ // Show loading while initializing
73+ if ( ! isInitialized ) {
74+ return (
75+ < div className = "min-h-screen flex items-center justify-center" >
76+ < div className = "animate-spin rounded-full h-12 w-12 border-b-2 border-primary" > </ div >
77+ </ div >
78+ )
79+ }
80+
81+ // Show error only after initialization and if no accession
7082 if ( ! accession ) {
7183 return (
7284 < div className = "min-h-screen flex items-center justify-center" >
7385 < div className = "text-center" >
7486 < h1 className = "text-2xl font-bold text-red-600 mb-4" > Invalid Accession</ h1 >
7587 < p className = "text-gray-600 mb-4" > No assembly accession provided in URL parameters.</ p >
76- < a
77- href = "/"
78- className = "inline-flex items-center px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90"
79- >
80- ← Back to Home
81- </ a >
88+ < Link href = "/" >
89+ < Button variant = "default" className = "gap-2" >
90+ < ArrowLeft className = "h-4 w-4" />
91+ Back to Home
92+ </ Button >
93+ </ Link >
8294 </ div >
8395 </ div >
8496 )
0 commit comments