From 10c204cd89fa3806ca842f685a58b42df0611e6c Mon Sep 17 00:00:00 2001 From: alejandromumo Date: Thu, 24 Oct 2024 16:41:44 +0100 Subject: [PATCH] refactor: moved RequestResults to invenio-search-ui --- .../components/SearchResultsBox.js | 75 +++++++++++++++++++ .../js/invenio_search_ui/components/index.js | 1 + 2 files changed, 76 insertions(+) create mode 100644 invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/SearchResultsBox.js diff --git a/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/SearchResultsBox.js b/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/SearchResultsBox.js new file mode 100644 index 00000000..e8ffc527 --- /dev/null +++ b/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/SearchResultsBox.js @@ -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_search_ui/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 && ( + + + + + + + + ( + <> + {i18next.t("{{count}} results found", { + count: total, + })} + + )} + /> + + + {sortOptions && ( + ( + <> + + {cmp} + + )} + /> + )} + + + + + + + + + + + + + + ) + ); +}; + +SearchResultsBox.propTypes = { + sortOptions: PropTypes.object.isRequired, + paginationOptions: PropTypes.object.isRequired, + currentResultsState: PropTypes.object.isRequired, +}; diff --git a/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/index.js b/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/index.js index 4e76aead..451a03e7 100644 --- a/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/index.js +++ b/invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/components/index.js @@ -26,3 +26,4 @@ export { ContribBucketAggregationElement, ContribBucketAggregationValuesElement, } from "./common/facets"; +export { SearchResultsBox } from "./SearchResultsBox";