Skip to content

Commit

Permalink
Type getJetpackProductCallToAction
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieur-z committed Aug 20, 2020
1 parent 64b0ed2 commit be11d84
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
20 changes: 0 additions & 20 deletions client/lib/products-values/get-jetpack-product-call-to-action.js

This file was deleted.

33 changes: 33 additions & 0 deletions client/lib/products-values/get-jetpack-product-call-to-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import { TranslateResult } from 'i18n-calypso';

/**
* Internal dependencies
*/
import { assertValidProduct } from 'lib/products-values/utils/assert-valid-product';
import { formatProduct } from 'lib/products-values/format-product';
import { getJetpackProductsCallToAction } from 'lib/products-values/translations';

/**
* Type dependencies
*/
import type { Product } from 'lib/products-values/products-list';

/**
* Get Jetpack product call-to-action based on the product purchase object.
*
* @param {object} product Product purchase object
* @returns {TranslateResult} Product display name
*/
export function getJetpackProductCallToAction( product: object ): TranslateResult | undefined {
product = formatProduct( product );
assertValidProduct( product );
const jetpackProductsCallToActions = getJetpackProductsCallToAction() as Record<
string,
TranslateResult
>;

return jetpackProductsCallToActions?.[ ( product as Product ).product_slug ];
}

0 comments on commit be11d84

Please sign in to comment.