From 19b209fca41f866783153d4ce6d9637bab3700b9 Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Thu, 13 Dec 2018 09:06:26 -0800 Subject: [PATCH] Add util to packages to fix build. (https://github.com/woocommerce/woocommerce-admin/pull/1079) --- .../src/search/autocompleters/taxes.js | 3 +-- .../src/search/autocompleters/utils.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/packages/components/src/search/autocompleters/taxes.js b/plugins/woocommerce-admin/packages/components/src/search/autocompleters/taxes.js index 531588426c4..1fa004555a3 100644 --- a/plugins/woocommerce-admin/packages/components/src/search/autocompleters/taxes.js +++ b/plugins/woocommerce-admin/packages/components/src/search/autocompleters/taxes.js @@ -12,8 +12,7 @@ import { stringifyQuery } from '@woocommerce/navigation'; /** * Internal dependencies */ -import { computeSuggestionMatch } from './utils'; -import { getTaxCode } from 'analytics/report/taxes/utils'; +import { computeSuggestionMatch, getTaxCode } from './utils'; /** * A tax completer. diff --git a/plugins/woocommerce-admin/packages/components/src/search/autocompleters/utils.js b/plugins/woocommerce-admin/packages/components/src/search/autocompleters/utils.js index 23d9becb214..b99fd9380a4 100644 --- a/plugins/woocommerce-admin/packages/components/src/search/autocompleters/utils.js +++ b/plugins/woocommerce-admin/packages/components/src/search/autocompleters/utils.js @@ -1,4 +1,9 @@ /** @format */ +/** + * External dependencies + */ +import { __ } from '@wordpress/i18n'; + /** * Parse a string suggestion, split apart by where the first matching query is. * Used to display matched partial in bold. @@ -19,3 +24,15 @@ export function computeSuggestionMatch( suggestion, query ) { suggestionAfterMatch: suggestion.substring( indexOfMatch + query.length ), }; } + +export function getTaxCode( tax ) { + return [ tax.country, tax.state, tax.name || __( 'TAX', 'wc-admin' ), tax.priority ] + .map( item => + item + .toString() + .toUpperCase() + .trim() + ) + .filter( Boolean ) + .join( '-' ); +}