Skip to content

Commit

Permalink
Moving SearchResultsMessage logic into RecordList and deleting co…
Browse files Browse the repository at this point in the history
…mponent.
  • Loading branch information
erinesullivan committed Dec 12, 2024
1 parent 1a44b31 commit 62e2da4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 45 deletions.
35 changes: 29 additions & 6 deletions src/modules/records/components/RecordList/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Anchor } from '../../../reusable';
import { Anchor, Icon } from '../../../reusable';
import { GoToList } from '../../../lists';
import ILLRequestMessage from '../ILLRequestMessage';
import KeywordSwitch from '../KeywordSwitch';
import React from 'react';
import Record from '../Record';
import { SearchResultsMessage } from '../../../search';
import Sorts from '../Sorts';
import { Specialists } from '../../../specialists';
import { useSelector } from 'react-redux';
Expand All @@ -16,10 +15,10 @@ const RecordList = () => {
const { loading, records } = useSelector((state) => {
return state.records;
});
const list = useSelector((state) => {
return state.lists[activeDatastore];
const { [activeDatastore]: list } = useSelector((state) => {
return state.lists;
});
const { data, query } = useSelector((state) => {
const { data, parserMessage, query } = useSelector((state) => {
return state.search;
});

Expand Down Expand Up @@ -49,7 +48,31 @@ const RecordList = () => {
{message()}
</h2>
{!noResults && <Sorts {...{ activeDatastore }} />}
{!loadingRecords && <SearchResultsMessage />}
{!loadingRecords && (
parserMessage
? (
<section>
<p className='margin__none' aria-live='polite'>
Showing results for: <span className='strong'>{parserMessage.actual}</span>
</p>
<p className='font-small margin__none'>
You searched for: <span className='strong'>{parserMessage.original}</span>
</p>
<span className='flex parser-message font-small intent__warning'>
<div><Icon icon='warning' size={15} /></div>
<p
className='details-message'
dangerouslySetInnerHTML={{ __html: parserMessage.details }}
/>
</span>
</section>
)
: (
<p className='margin__none' aria-live='polite'>
Showing results for: <span className='strong'>{query}</span>
</p>
)
)}
</div>
{noResults && !loadingRecords
? (
Expand Down
37 changes: 0 additions & 37 deletions src/modules/search/components/SearchResultsMessage/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/modules/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import {
import { getSearchStateFromURL, stringifySearch } from './utilities';
import SearchBox from './components/SearchBox';
import searchReducer from './reducer';
import SearchResultsMessage from './components/SearchResultsMessage';

export {
clearSearch,
getSearchStateFromURL,
resetSort,
searchReducer,
SearchBox,
SearchResultsMessage,
searching,
setPage,
setSearchData,
Expand Down

0 comments on commit 62e2da4

Please sign in to comment.