-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved RequestResults to invenio-search-ui
- Loading branch information
1 parent
23b2578
commit c219da7
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/SearchResultsBox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// This file is part of Invenio | ||
// Copyright (C) 2024 CERN. | ||
// | ||
// Invenio is free software; you can redistribute it and/or modify it | ||
// under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
import { InvenioSearchPagination } from "@js/invenio_search_ui/components"; | ||
import { i18next } from "@translations/invenio_requests/i18next"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { Count, ResultsList, Sort } from "react-searchkit"; | ||
import { Grid, Segment } from "semantic-ui-react"; | ||
|
||
export const SearchResultsBox = ({ | ||
sortOptions, | ||
paginationOptions, | ||
currentResultsState, | ||
}) => { | ||
const { total } = currentResultsState.data; | ||
return ( | ||
total && ( | ||
<Grid> | ||
<Grid.Row> | ||
<Grid.Column width={16}> | ||
<Segment> | ||
<Grid> | ||
<Grid.Row | ||
verticalAlign="middle" | ||
className="small pt-5 pb-5 highlight-background" | ||
> | ||
<Grid.Column width={4}> | ||
<Count | ||
label={() => ( | ||
<> | ||
{i18next.t("{{count}} results found", { | ||
count: total, | ||
})} | ||
</> | ||
)} | ||
/> | ||
</Grid.Column> | ||
<Grid.Column width={12} textAlign="right"> | ||
{sortOptions && ( | ||
<Sort | ||
values={sortOptions} | ||
label={(cmp) => ( | ||
<> | ||
<label className="mr-10">{i18next.t("Sort by")}</label> | ||
{cmp} | ||
</> | ||
)} | ||
/> | ||
)} | ||
</Grid.Column> | ||
</Grid.Row> | ||
<Grid.Row> | ||
<Grid.Column> | ||
<ResultsList /> | ||
</Grid.Column> | ||
</Grid.Row> | ||
</Grid> | ||
</Segment> | ||
</Grid.Column> | ||
</Grid.Row> | ||
<InvenioSearchPagination paginationOptions={paginationOptions} /> | ||
</Grid> | ||
) | ||
); | ||
}; | ||
|
||
SearchResultsBox.propTypes = { | ||
sortOptions: PropTypes.object.isRequired, | ||
paginationOptions: PropTypes.object.isRequired, | ||
currentResultsState: PropTypes.object.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters