Skip to content

Commit

Permalink
rewrite complex ternary chain with a switch
Browse files Browse the repository at this point in the history
and remove commented console.log
  • Loading branch information
circlecube committed Oct 23, 2024
1 parent 56e9c6f commit 909afe4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/components/WPSolutionsBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export function WPSolutionsBanner() {
return;
}
if ( error ) {
//Uncomment below line, to debug error in API response
//console.log(error.message, "error");
return (
<div className="nfd-flex nfd-p-6 nfd-bg-white nfd-w-full nfd-rounded-lg nfd-text-red-700">
<ExclamationTriangleIcon className="nfd-w-[24px] nfd-h-[24px]" />
Expand All @@ -102,12 +100,20 @@ export function WPSolutionsBanner() {
return <NoExistingPlan availableSolutions={ availableSolutions } />;
}

currentSolution =
purchasedSolution === 'WP_SOLUTION_CREATOR'
? wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_CREATOR
: purchasedSolution === 'WP_SOLUTION_SERVICE'
? wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_SERVICE
: wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_COMMERCE;
switch ( purchasedSolution ) {
case 'WP_SOLUTION_CREATOR':
currentSolution =
wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_CREATOR;
break;
case 'WP_SOLUTION_SERVICE':
currentSolution =
wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_SERVICE;
break;
case 'WP_SOLUTION_COMMERCE':
default:
currentSolution =
wpSolutionsPromotedPluginsList[ 0 ].WP_SOLUTION_COMMERCE;
}
const solutionsCards = Object.values( currentSolution );
return (
hasSolution && (
Expand Down

0 comments on commit 909afe4

Please sign in to comment.