Skip to content

Commit

Permalink
refactor: update checks for improved readability and UX 😎
Browse files Browse the repository at this point in the history
  • Loading branch information
Valik3201 committed Jan 28, 2024
1 parent ad59b0d commit 8a7f291
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class App extends Component {
currentPage: 1,
isLoading: false,
error: null,
totalHits: 0,
totalHits: null,
};
}

Expand Down Expand Up @@ -91,24 +91,23 @@ class App extends Component {
<Container className="d-flex flex-column justify-content-center mb-5 mx-auto">
{isLoading && <Loader />}
{error && <ErrorAlert errorMessage={error} />}
{images.length > 0 && !error ? (
{images.length > 0 && !error && (
<>
<SearchResultInfo
searchQuery={searchQuery}
totalHits={totalHits}
/>

<ImageGallery images={images} />

{totalHits > images.length && (
<LoadMoreBtn onClick={this.loadMoreImages} />
)}
</>
) : images.length === 0 && searchQuery && !error ? (
)}
{!error && searchQuery && totalHits === 0 && (
<NoResultsAlert searchQuery={searchQuery} />
) : (
!error && <ImagePortalWelcome />
)}

{!searchQuery && <ImagePortalWelcome />}
</Container>
</>
);
Expand Down

0 comments on commit 8a7f291

Please sign in to comment.