Commit 51f1ce1f authored by Jon Moore's avatar Jon Moore
Browse files

Added comments to key sections of the file

parent a16480bd
Pipeline #39495 passed with stage
in 2 minutes and 46 seconds
...@@ -12,13 +12,18 @@ import BlogCard from './BlogCard'; ...@@ -12,13 +12,18 @@ import BlogCard from './BlogCard';
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);
} }
...@@ -29,6 +34,7 @@ const fetchEntries = async versionStatus => { ...@@ -29,6 +34,7 @@ const fetchEntries = async versionStatus => {
const BlogListing = ({ 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(() => {
...@@ -39,6 +45,7 @@ const BlogListing = ({ className }) => { ...@@ -39,6 +45,7 @@ const BlogListing = ({ 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;
...@@ -46,6 +53,7 @@ const BlogListing = ({ className }) => { ...@@ -46,6 +53,7 @@ const BlogListing = ({ className }) => {
resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`; resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`;
} }
//DELIVERY API PAGING INFO END//
return ( return (
<BlogListingStyled className={className}> <BlogListingStyled className={className}>
...@@ -56,6 +64,7 @@ const BlogListing = ({ className }) => { ...@@ -56,6 +64,7 @@ const BlogListing = ({ className }) => {
/> />
)} )}
{/* DELIVERY API RENDER ENTRIES START */}
{results && {results &&
results.items && results.items &&
results.items.map((entry, idx) => { results.items.map((entry, idx) => {
...@@ -70,6 +79,7 @@ const BlogListing = ({ className }) => { ...@@ -70,6 +79,7 @@ const BlogListing = ({ className }) => {
); );
})} })}
{!results || (results.length < 1 && <p>No results found.</p>)} {!results || (results.length < 1 && <p>No results found.</p>)}
{/* DELIVERY API RENDER ENTRIES END */}
</BlogListingStyled> </BlogListingStyled>
); );
}; };
......
...@@ -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