Skip to content

Commit

Permalink
simplify button creation for marketplace items
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed Jun 20, 2022
1 parent 420eff4 commit 75c165e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions components/marketplace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { default as MarketplaceList } from '../marketplaceList/';
const Marketplace = ({methods, constants, Components, ...props}) => {
const [ isLoading, setIsLoading ] = methods.useState( true );
const [ isError, setIsError ] = methods.useState( false );
const [ marketplaceCategories, setMarketplaceCategories ] = methods.useState( ['All'] );
const [ marketplaceCategories, setMarketplaceCategories ] = methods.useState( [] );
const [ marketplaceItems, setMarketplaceItems ] = methods.useState( [] );
const [ initialTab, setInitialTab ] = methods.useState( 'all' );

Expand Down Expand Up @@ -120,7 +120,6 @@ import { default as MarketplaceList } from '../marketplaceList/';
tabs={ marketplaceCategories }
>
{ ( tab ) => <MarketplaceList
key={tab.name}
marketplaceItems={marketplaceItems}
category={tab.name}
Components={Components}
Expand Down
19 changes: 13 additions & 6 deletions components/marketplaceItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,20 @@
/>
}
<Components.CardFooter>
{ item.primaryCallToAction && item.primaryUrl &&
<Components.Button
{ item.primaryCallToAction && item.clickToBuyId &&
<Components.Button
variant="primary"
target={ item.clickToBuyId ? undefined : '_blank' }
href={ item.clickToBuyId ? undefined : item.primaryUrl }
data-action={ item.clickToBuyId ? 'load-nfd-ctb' : undefined }
data-ctb-id={ item.clickToBuyId ? item.clickToBuyId : undefined }
data-action="load-nfd-ctb"
data-ctb-id={ item.clickToBuyId }
>
{ item.primaryCallToAction }
</Components.Button>
}
{ item.primaryCallToAction && item.primaryUrl && !item.clickToBuyId &&
<Components.Button
variant="primary"
target="_blank"
href={ item.primaryUrl }
>
{ item.primaryCallToAction }
</Components.Button>
Expand Down

0 comments on commit 75c165e

Please sign in to comment.