Commit 4a140705 authored by Jon Moore's avatar Jon Moore
Browse files

Update EventsListing.js

parent 492fb50f
Pipeline #39498 passed with stage
in 3 minutes and 23 seconds
...@@ -13,13 +13,18 @@ import EventCard from './EventCard'; ...@@ -13,13 +13,18 @@ import EventCard from './EventCard';
const fetchEntries = async versionStatus => { const fetchEntries = async versionStatus => {
const triggerSearch = async versionStatus => { const triggerSearch = async versionStatus => {
try { try {
//DELIVERY API QUERY START//
let query = new Query( let query = new Query(
Op.equalTo('sys.contentTypeId', 'blogPost'), Op.equalTo('sys.contentTypeId', 'blogPost'),
Op.equalTo('sys.versionStatus', versionStatus) Op.equalTo('sys.versionStatus', versionStatus)
); );
query.pageSize = 3; query.pageSize = 3;
query.fields = ['title', 'summary', 'image', 'sys']; query.fields = ['title', 'summary', 'image', 'sys'];
//DELIVERY API QUERY END//
//DELIVERY API SEARCH START//
return await cachedSearch.search(query, 1); return await cachedSearch.search(query, 1);
//DELIVERY API SEARCH END//
} catch (error) { } catch (error) {
throw new Error(error); throw new Error(error);
} }
...@@ -28,8 +33,9 @@ const fetchEntries = async versionStatus => { ...@@ -28,8 +33,9 @@ const fetchEntries = async versionStatus => {
return entries; return entries;
}; };
const EventListing = ({ className }) => { const BlogListing = ({ className }) => {
const [results, setResults] = useState(); const [results, setResults] = useState();
//GET VERSION STATUS
const versionStatus = useSelector(selectVersionStatus); const versionStatus = useSelector(selectVersionStatus);
//const versionStatus = 'latest'; //const versionStatus = 'latest';
useEffect(() => { useEffect(() => {
...@@ -40,6 +46,7 @@ const EventListing = ({ className }) => { ...@@ -40,6 +46,7 @@ const EventListing = ({ className }) => {
let resultsInfo = null; let resultsInfo = null;
//DELIVERY API PAGING INFO START//
if (results && results.totalCount > 0) { if (results && results.totalCount > 0) {
const start = results.pageIndex * results.pageSize + 1; const start = results.pageIndex * results.pageSize + 1;
let end = results.pageSize; let end = results.pageSize;
...@@ -47,6 +54,7 @@ const EventListing = ({ className }) => { ...@@ -47,6 +54,7 @@ const EventListing = ({ className }) => {
resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`; resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`;
} }
//DELIVERY API PAGING INFO END//
return ( return (
<EventsListingStyled className={className}> <EventsListingStyled className={className}>
...@@ -57,6 +65,7 @@ const EventListing = ({ className }) => { ...@@ -57,6 +65,7 @@ const EventListing = ({ className }) => {
/> />
)} )}
{/* DELIVERY API RENDER ENTRIES START */}
{results && results.items && ( {results && results.items && (
<ul> <ul>
{results.items.map((entry, idx) => { {results.items.map((entry, idx) => {
...@@ -65,12 +74,13 @@ const EventListing = ({ className }) => { ...@@ -65,12 +74,13 @@ const EventListing = ({ className }) => {
</ul> </ul>
)} )}
{!results || (results.length < 1 && <p>No results found.</p>)} {!results || (results.length < 1 && <p>No results found.</p>)}
{/* DELIVERY API RENDER ENTRIES END */}
</EventsListingStyled> </EventsListingStyled>
); );
}; };
EventListing.propTypes = { BlogListing.propTypes = {
className: PropTypes.string, className: PropTypes.string,
}; };
export default EventListing; export default BlogListing;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment