Skip to content

Commit

Permalink
fixed sorting issue with listing core members on the about page
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinvanschoren committed Nov 1, 2023
1 parent a7be24b commit 8a06748
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/src/components/search/CoreFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CoreFilter = ({ addFilter, removeFilter, setSort }) => {
// Clear previous filters for user_id field
removeFilter("user_id.keyword");
addFilter("user_id.keyword", core_ids, "any");
setSort("user_id.last_name");
setSort([{ field: "last_name.keyword", direction: "asc" }]); // Has to be an array or it won't work
});

return <div></div>;
Expand Down
18 changes: 6 additions & 12 deletions app/src/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,10 @@ const coreConfig = {
image: { raw: {} },
date: { raw: {} },
},
disjunctiveFacets: [
"user_id.keyword",
"last_name.keyword",
"first_name.keyword",
],
// Both are needed to filter on user_id
disjunctiveFacets: ["user_id.keyword"],
facets: {
"user_id.keyword": { type: "value", size: 30, sort: "count" },
"last_name.keyword": { type: "value", size: 30, sort: "count" },
"first_name.keyword": { type: "value", size: 30, sort: "count" },
},
},
};
Expand All @@ -381,7 +376,9 @@ function About() {
if (process.env.NODE_ENV === "development") {
i18n.reloadResources();
}

// We're rendering the list of core members using Search UI.
// This requires a SearchProvider, but we don't want to show search options.
// The CoreFilter component applies the needed search options on loading.
return (
<Wrapper>
<Helmet title={t("about.helmet")} />
Expand Down Expand Up @@ -426,10 +423,7 @@ function About() {
</Typography>
<Typography sx={{ pb: 5 }}>{t("about.core_text")}</Typography>
<Grid container>
<SearchProvider
config={coreConfig}
onSearch={(state) => console.log(state)}
>
<SearchProvider config={coreConfig}>
<CoreFilter />
<ResultsWrapper>
<Results
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function handler(req, res) {
}

//This runs server-side, so the output appears in the terminal
console.log("OnSearch", indexName, requestState, queryConfig);
//console.log("OnSearch", indexName, requestState, queryConfig);
const response = await connectorsCache[indexName].onSearch(
requestState,
queryConfig,
Expand Down
4 changes: 2 additions & 2 deletions app/src/services/SearchAPIConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SearchAPIConnector {
queryConfig,
}),
};
console.log(request.body);
//console.log(request.body);
const response = await fetch("/api/search", request);
return response.json();
}
Expand All @@ -41,7 +41,7 @@ class SearchAPIConnector {
queryConfig,
}),
};
console.log(request.body);
//console.log(request.body);
const response = await fetch("/api/autocomplete", request);
return response.json();
}
Expand Down

0 comments on commit 8a06748

Please sign in to comment.