Skip to content

Commit

Permalink
WCMS-16979: More graceful error handling (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
brdunfield authored Oct 4, 2023
1 parent a33f5b5 commit 224980a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@civicactions/cmsds-open-data-components",
"version": "2.1.2",
"version": "2.1.3",
"description": "Components for the open data catalog frontend using CMS Design System",
"main": "dist/main.js",
"source": "src/index.ts",
Expand Down
12 changes: 7 additions & 5 deletions src/templates/DatasetSearch/DatasetSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ const DatasetSearch = ({
axios.get(`${rootUrl}/search/?${qs.stringify(params, {arrayFormat: 'comma',encode: false, skipEmptyString: true })}`)
);

if (data && totalItems != data.data.total) setTotalItems(data.data.total);
if ((data && data.data.total) && totalItems != data.data.total) setTotalItems(data.data.total);

const { theme, keyword } = separateFacets(data ? data.data.facets : []);
const { theme, keyword } = (data && data.data.facets) ? separateFacets(data ? data.data.facets : []) : {theme: null, keyword: null};

return (
<section className="ds-l-container">
Expand Down Expand Up @@ -203,15 +203,17 @@ const DatasetSearch = ({
</div>
<ol className="dc-dataset-search-list ds-u-padding--0">
{noResults && <Alert variation="error" heading="No results found." />}
{data && Object.keys(data.data.results).map((key) => {
{data && data.data.results ? Object.keys(data.data.results).map((key) => {
return data.data.results[key];
}).map((item) => (
<li className="ds-u-padding--0" key={item.identifier}>
<DatasetSearchListItem item={item} updateFacets={updateSelectedFacets} />
</li>
))}
)): (
<Alert variation="error" heading="Could not connect to the API." />
)}
</ol>
{data && data.data.total != 0 && (
{(data && data.data.total) && data.data.total !== 0 && (
<Pagination
id="test-default"
currentPage={Number(page)}
Expand Down

0 comments on commit 224980a

Please sign in to comment.