♻️ Move country logic into PricingTitleBadge

This commit is contained in:
Philipp Stracker 2024-12-12 17:54:38 +01:00
parent b89164e1ea
commit 5bd3e5f976
No known key found for this signature in database
9 changed files with 27 additions and 146 deletions

View file

@ -1,10 +1,12 @@
import { __, sprintf } from '@wordpress/i18n';
import { countryPriceInfo } from '../../utils/countryPriceInfo';
import TitleBadge, { TITLE_BADGE_INFO } from './TitleBadge';
import { CommonHooks } from '../../data';
const PricingTitleBadge = ( { item, country, currency } ) => {
const infos = countryPriceInfo[ country ];
const PricingTitleBadge = ( { item } ) => {
const { storeCountry } = CommonHooks.useWooSettings();
const infos = countryPriceInfo[ storeCountry ];
if ( ! infos || ! infos[ item ] ) {
return null;
@ -20,7 +22,7 @@ const PricingTitleBadge = ( { item, country, currency } ) => {
),
percentage,
fixedFee,
currency
infos.currencySymbol
);
return <TitleBadge type={ TITLE_BADGE_INFO } text={ label } />;