Skip to content

Commit e0daf0c

Browse files
committed
- filter search results
1 parent f734029 commit e0daf0c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

frontend/pages/SearchPage.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Sensitivity } from 'component/sensitivity';
12
import { Glyphicon, Panel, tableClassStripedHover } from 'f61ui/component/bootstrap';
23
import { Result } from 'f61ui/component/result';
34
import { browseUrl, collectionUrl, searchUrl } from 'generated/frontend_uiroutes';
@@ -42,6 +43,21 @@ export default class SearchPage extends React.Component<SearchPageProps, SearchP
4243
private renderData() {
4344
const [results, loadingOrError] = this.state.results.unwrap();
4445

46+
const resultsFiltered = (results || []).filter((result) => {
47+
if (result.Collection && result.Collection.Sensitivity !== Sensitivity.FamilyFriendly) {
48+
return false;
49+
}
50+
51+
if (
52+
result.Directory &&
53+
result.Directory.Directory.Directory.Sensitivity !== Sensitivity.FamilyFriendly
54+
) {
55+
return false;
56+
}
57+
58+
return true;
59+
});
60+
4561
return (
4662
<div>
4763
<form action={searchUrl({ q: '' })} method="get">
@@ -71,7 +87,7 @@ export default class SearchPage extends React.Component<SearchPageProps, SearchP
7187
</tr>
7288
</thead>
7389
<tbody>
74-
{(results || []).map((result: SearchResult) => {
90+
{resultsFiltered.map((result: SearchResult) => {
7591
const kindIndicator = ((): [string, JSX.Element, JSX.Element] => {
7692
if (result.Collection) {
7793
return [

0 commit comments

Comments
 (0)