Skip to content

Commit d41d7d1

Browse files
committed
improved page state detection
1 parent 95ff2bd commit d41d7d1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

client/src/SearchPage.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const SearchPage = () => {
7070
setError('');
7171
setResults([]);
7272
setSearchCompleted(false);
73-
console.log('searchQuery:', searchQuery);
73+
//console.log('searchQuery:', searchQuery);
7474
try {
7575
const response = await fetch('./data-api/rest/findSamples', {
7676
method: 'POST',
@@ -126,9 +126,12 @@ const SearchPage = () => {
126126
}
127127

128128
let pageStatus = "first_load";
129+
if (results.length === 0 && loading == true) pageStatus = "searching";
129130
if (results.length === 0 && !loading && searchCompleted) pageStatus = "no_results";
130131
if (results.length > 0) pageStatus = "results_found";
131-
//console.log('Page Status:', pageStatus);
132+
if (error) pageStatus = "error";
133+
134+
console.log('Page Status:', pageStatus);
132135
//console.log('Search Completed:', searchCompleted);
133136

134137
return (
@@ -191,19 +194,19 @@ const SearchPage = () => {
191194
</Button>
192195
</div>
193196

194-
{loading && (
197+
{(pageStatus == "searching") && (
195198
<div style={{ textAlign: 'center', margin: '20px 0' }}>
196199
<Spinner label="Searching..." />
197200
</div>
198201
)}
199202

200-
{error && (
203+
{(pageStatus == "error") && (
201204
<Text block style={{ textAlign: 'center', color: 'red', marginBottom: '20px' }}>
202205
{error}
203206
</Text>
204207
)}
205208

206-
{(pageStatus === "first_load") &&
209+
{(pageStatus === "first_load") &&
207210
(
208211
<Text block style={{ textAlign: 'center' }}>
209212
Start searching to get results!

0 commit comments

Comments
 (0)