22
33import ResultCard from "@/components/result-card" ;
44import SearchBar from "@/components/search-bar" ;
5- import { getJson } from "@/utils/api" ;
5+ import { ApiError , getJson } from "@/utils/api" ;
66import { getProjectShortUrl } from "@/utils/shortUrl" ;
7- import { Button , Flex , Heading , Text } from "@radix-ui/themes" ;
7+ import { Button , Flex , Heading , Link , Text } from "@radix-ui/themes" ;
88import { useQuery } from "@tanstack/react-query" ;
9+ import NextLink from "next/link" ;
910import { useRouter } from "next/navigation" ;
1011import { useEffect , useState } from "react" ;
1112
@@ -35,14 +36,18 @@ export default function SubmissionStudiesBody({
3536 const [ showAll , setShowAll ] = useState ( false ) ;
3637 const acc = accession . toUpperCase ( ) ;
3738
38- const { data, isLoading, isError, error } = useQuery ( {
39+ const { data, isLoading, isError, error, refetch } = useQuery ( {
3940 queryKey : [ "submission-studies" , acc ] ,
4041 queryFn : ( ) => getJson < SubmissionResponse > ( `/submission/${ acc } ` ) ,
4142 enabled : isSubmission ( acc ) ,
4243 retry : false ,
4344 staleTime : Infinity ,
4445 } ) ;
4546
47+ // The API 404s when nothing is filed under the submission; anything else is a
48+ // failure on our side and shouldn't read as "not found".
49+ const noStudies = error instanceof ApiError && error . status === 404 ;
50+
4651 const studies = data ?. studies ?? [ ] ;
4752 const visible = showAll ? studies : studies . slice ( 0 , INITIAL_ROWS ) ;
4853 const soleStudy = studies . length === 1 ? studies [ 0 ] . accession : null ;
@@ -66,10 +71,18 @@ export default function SubmissionStudiesBody({
6671 px = { { initial : "4" , md : "3" } }
6772 direction = "column"
6873 >
69- < Heading size = "6" > Studies for submission { acc } </ Heading >
74+ { /* Suppressed for a non-submission accession: the message below is its
75+ own heading, and "Studies for submission FOO" above "FOO isn't a
76+ submission accession" just contradicts itself. */ }
77+ { isSubmission ( acc ) && (
78+ < Heading size = "6" > Studies for submission { acc } </ Heading >
79+ ) }
7080
7181 { isLoading && < Text color = "gray" > Searching…</ Text > }
72- { isError && (
82+
83+ { /* Not a submission accession at all, so the query never ran — without
84+ this the page is just a heading over blank space. */ }
85+ { ! isSubmission ( acc ) && (
7386 < Flex
7487 align = "center"
7588 justify = "center"
@@ -78,18 +91,74 @@ export default function SubmissionStudiesBody({
7891 gap = "3"
7992 >
8093 < Text size = { { initial : "5" , md : "6" } } weight = "bold" >
81- No studies found for submission { acc }
94+ { acc } isn’t a submission accession
8295 </ Text >
8396 < Text
8497 size = "2"
8598 align = "center"
8699 style = { { color : "var(--gray-11)" , maxWidth : "32rem" } }
87100 >
88- { String ( error ) }
101+ Submission accessions look like SRA123456, ERA123456 or DRA123456.
102+ For a study, sample or run, paste it into the search bar above.
89103 </ Text >
90104 </ Flex >
91105 ) }
92106
107+ { isError && (
108+ < Flex
109+ align = "center"
110+ justify = "center"
111+ direction = "column"
112+ height = "20rem"
113+ gap = "3"
114+ >
115+ { noStudies ? (
116+ < >
117+ < Text size = { { initial : "5" , md : "6" } } weight = "bold" >
118+ No studies found for submission { acc }
119+ </ Text >
120+ < Text
121+ size = "2"
122+ align = "center"
123+ style = { { color : "var(--gray-11)" , maxWidth : "32rem" } }
124+ >
125+ No SRP/ERP/DRP study in seqout is filed under this submission.
126+ The accession may belong to an archive we don’t mirror,
127+ or its studies may not be public yet.
128+ </ Text >
129+ < Button variant = "soft" asChild >
130+ < NextLink href = "/" > Search by title or keywords</ NextLink >
131+ </ Button >
132+ < Text size = "2" style = { { color : "var(--gray-11)" } } >
133+ Prefer plain English?{ " " }
134+ < Link asChild underline = "always" >
135+ < NextLink href = "/mcp" > Use seqout with an LLM</ NextLink >
136+ </ Link > { " " }
137+ to describe the data you’re after in your own words.
138+ </ Text >
139+ </ >
140+ ) : (
141+ < >
142+ < Text size = { { initial : "5" , md : "6" } } weight = "bold" >
143+ Couldn’t load submission { acc }
144+ </ Text >
145+ < Text
146+ size = "2"
147+ align = "center"
148+ style = { { color : "var(--gray-11)" , maxWidth : "32rem" } }
149+ >
150+ The request failed before we could look this submission up, so
151+ we don’t know whether it has studies. This one is on us,
152+ not your accession.
153+ </ Text >
154+ < Button variant = "soft" onClick = { ( ) => refetch ( ) } >
155+ Try again
156+ </ Button >
157+ </ >
158+ ) }
159+ </ Flex >
160+ ) }
161+
93162 { data && studies . length > 1 && (
94163 < Text color = "gray" weight = "light" >
95164 { studies . length . toLocaleString ( ) } studies
0 commit comments