File size: 845 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import { getCurrentPlan } from 'calypso/state/sites/plans/selectors';
/**
* Returns a site's current plan purchase ID or null if the site doesn't exist or the purchase ID
* is unknown.
*
* The ID returned by this selector is retrieved from the site plan. It is intended to provide a
* means of retrieving full purchase information based on a site and its plan information.
* Caution! It _does not_ retrieve the ID from a purchase.
* @param {Object} state Global state tree
* @param {number} siteId Site ID
* @returns {?number} Purchase ID if known
*/
export default function getCurrentPlanPurchaseId( state, siteId ) {
const result = getCurrentPlan( state, siteId )?.id ?? null;
// getCurrentPlan uses an "assembler" which may have NaN in the `id`.
if ( Number.isNaN( result ) ) {
return null;
}
return result;
}
|