Skip to content

Commit

Permalink
Merge pull request #44 from newfold-labs/feature/category-subnav-helper
Browse files Browse the repository at this point in the history
Feature/category subnav helper
  • Loading branch information
circlecube authored Nov 7, 2023
2 parents e696819 + 4cc1e3f commit 3f836e2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/marketplace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ const defaults = {
title={getSectionTitle()}
subTitle={constants.text.subTitle}
/>
<Components.SectionContent className={methods.classnames('newfold-marketplace-wrapper')}>
<Components.SectionContent className={methods.classnames(
'newfold-marketplace-wrapper',
`newfold-marketplace-${marketplaceCategories[activeCategoryIndex]}`
)}>
{ isLoading &&
renderSkeleton()
}
Expand Down
28 changes: 28 additions & 0 deletions components/marketplaceSubnav/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';
import apiFetch from '@wordpress/api-fetch';

/**
* Marketplace Subnav Helper Method
*
* @returns array of routes
*/
export const getMarketplaceSubnavRoutes = () => {
return apiFetch( {
url: NewfoldRuntime.createApiUrl( '/newfold-marketplace/v1/marketplace' )
}).then( ( response ) => {
let marketplaceSubnav = [];
if ( response.hasOwnProperty('categories') ) {
let marketPlaceCategories = response.categories.data;
marketPlaceCategories.forEach( (cat) => {
// format categories for subnav routes
marketplaceSubnav.push(
{
name: '/marketplace/' + cat.name,
title: cat.title
}
);
});
}
return marketplaceSubnav;
});
};

0 comments on commit 3f836e2

Please sign in to comment.