UNPKG

@automattic/calypso-products

Version:

This module contains information about the various products sold within calypso, such as product slugs, plan intervals, etc.

20 lines (17 loc) 662 B
import { TERM_ANNUALLY } from './constants'; import { PRODUCTS_LIST } from './products-list'; import type { ProductSlug } from './types'; /** * Return the yearly variant of a product * @param {ProductSlug} productSlug Slug of the product to get the yearly variant from * @returns {string} Slug of the yearly variant */ export function getProductYearlyVariant( productSlug: ProductSlug ): string | undefined { const product = PRODUCTS_LIST[ productSlug ]; if ( product ) { return Object.values( PRODUCTS_LIST ) .filter( ( { type } ) => type === product.type ) .find( ( { term } ) => TERM_ANNUALLY === term )?.product_slug; } return undefined; }