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';
const fetchEntries = async versionStatus => {
const triggerSearch = async versionStatus => {
try {
//DELIVERY API QUERY START//
let query = new Query(
Op.equalTo('sys.contentTypeId', 'blogPost'),
Op.equalTo('sys.versionStatus', versionStatus)
);
query.pageSize = 3;
query.fields = ['title', 'summary', 'image', 'sys'];
//DELIVERY API QUERY END//
//DELIVERY API SEARCH START//
return await cachedSearch.search(query, 1);
//DELIVERY API SEARCH END//
} catch (error) {
throw new Error(error);
}
......@@ -28,8 +33,9 @@ const fetchEntries = async versionStatus => {
return entries;
};
const EventListing = ({ className }) => {
const BlogListing = ({ className }) => {
const [results, setResults] = useState();
//GET VERSION STATUS
const versionStatus = useSelector(selectVersionStatus);
//const versionStatus = 'latest';
useEffect(() => {
......@@ -40,6 +46,7 @@ const EventListing = ({ className }) => {
let resultsInfo = null;
//DELIVERY API PAGING INFO START//
if (results && results.totalCount > 0) {
const start = results.pageIndex * results.pageSize + 1;
let end = results.pageSize;
......@@ -47,6 +54,7 @@ const EventListing = ({ className }) => {
resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`;
}
//DELIVERY API PAGING INFO END//
return (
<EventsListingStyled className={className}>
......@@ -57,6 +65,7 @@ const EventListing = ({ className }) => {
/>
)}
{/* DELIVERY API RENDER ENTRIES START */}
{results && results.items && (
<ul>
{results.items.map((entry, idx) => {
......@@ -65,12 +74,13 @@ const EventListing = ({ className }) => {
</ul>
)}
{!results || (results.length < 1 && <p>No results found.</p>)}
{/* DELIVERY API RENDER ENTRIES END */}
</EventsListingStyled>
);
};
EventListing.propTypes = {
BlogListing.propTypes = {
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