import { CREDITS_PER_PRODUCT_SCAN, MAX_SCAN_PRODUCTS, } from '../../service/catalog-quality/catalog-quality.constants'; import { formatCredits, generatedFieldsCostCredits, } from '../../lib/credit-costs'; /** * What a new check costs: it samples up to the scan limit from the catalog * and bills every product it scores, so a small catalog pays less. * * @returns {string} The price the button prints, e.g. ``up to 50 credits``. */ export const newCheckCost = (): string => `up to ${formatCredits(MAX_SCAN_PRODUCTS * CREDITS_PER_PRODUCT_SCAN)}`; /** * What re-running a check costs: the same products again, at least one * product's worth, as the agent bills it. * * @param {number} products - Products the check being re-run scored. * @returns {string} The price the button prints, e.g. ``12 credits``. */ export const rerunCost = (products: number): string => formatCredits(Math.max(1, products) * CREDITS_PER_PRODUCT_SCAN); /** * What a bulk improve costs: every field it writes, for every product it * covers. A run over the whole audit skips products gone from the catalog, * so its price is a ceiling; one product's price is exact. * * @param {number} products - Products the run covers. * @param {number} fields - Fields written per product; at least one is billed. * @param {boolean} single - The run is scoped to one product. * @returns {string} The price the button prints. */ export const bulkImproveCost = ( products: number, fields: number, single: boolean ): string => { const credits = generatedFieldsCostCredits(Math.max(1, products), fields); return single ? formatCredits(credits) : `up to ${formatCredits(credits)}`; };