Skip to content

Commit

Permalink
refactor: moved RequestResults to invenio-search-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo committed Oct 25, 2024
1 parent 23b2578 commit 10c204c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
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_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 && (
<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,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export {
ContribBucketAggregationElement,
ContribBucketAggregationValuesElement,
} from "./common/facets";
export { SearchResultsBox } from "./SearchResultsBox";

0 comments on commit 10c204c

Please sign in to comment.