feature: onboarding emails
* wip * wip * wip * fix coderabbit comments * remove template
This commit is contained in:
committed by
GitHub
parent
67301d928c
commit
e645c094b2
@@ -1,5 +1,11 @@
|
||||
export type { ProductPrice } from '@polar-sh/sdk/models/components/productprice.js';
|
||||
|
||||
function formatEventsCount(events: number) {
|
||||
return new Intl.NumberFormat('en-gb', {
|
||||
notation: 'compact',
|
||||
}).format(events);
|
||||
}
|
||||
|
||||
export type IPrice = {
|
||||
price: number;
|
||||
events: number;
|
||||
@@ -39,3 +45,29 @@ export const FREE_PRODUCT_IDS = [
|
||||
'a18b4bee-d3db-4404-be6f-fba2f042d9ed', // Prod
|
||||
'036efa2a-b3b4-4c75-b24a-9cac6bb8893b', // Sandbox
|
||||
];
|
||||
|
||||
export function getRecommendedPlan<T>(
|
||||
monthlyEvents: number | undefined | null,
|
||||
cb: (
|
||||
options: {
|
||||
formattedEvents: string;
|
||||
formattedPrice: string;
|
||||
} & IPrice,
|
||||
) => T,
|
||||
): T | undefined {
|
||||
if (!monthlyEvents) {
|
||||
return undefined;
|
||||
}
|
||||
const price = PRICING.find((price) => price.events >= monthlyEvents);
|
||||
if (!price) {
|
||||
return undefined;
|
||||
}
|
||||
return cb({
|
||||
...price,
|
||||
formattedEvents: formatEventsCount(price.events),
|
||||
formattedPrice: Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
}).format(price.price),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user