export type HostingPlan = { title: string; monthCost: number; tagline: string; minHoursDuration: number; maxHoursDuration: number; stripePriceId: string | null; }; const hostingPlans: HostingPlan[] = [ { title: 'Starter', monthCost: 400, tagline: 'Up to 10 hours of document', minHoursDuration: 0, maxHoursDuration: 10, stripePriceId: process.env.CONTEXT_TIER_ONE_PRICE_ID || null, }, { title: 'Influencer', monthCost: 900, tagline: 'Up to 30 hours of document', minHoursDuration: 11, maxHoursDuration: 30, stripePriceId: process.env.CONTEXT_TIER_TWO_PRICE_ID || null, }, { title: 'Superduper', monthCost: 2900, tagline: 'Up to 100 hours of document', minHoursDuration: 31, maxHoursDuration: 100, stripePriceId: process.env.CONTEXT_TIER_THREE_PRICE_ID || null, }, { title: 'Ultimate', monthCost: 4900, tagline: 'Up to 250 hours of document', minHoursDuration: 101, maxHoursDuration: 250, stripePriceId: process.env.CONTEXT_TIER_FOUR_PRICE_ID || null, }, ]; const hostingPlanFromDuration = (hours: number): HostingPlan | undefined => { const plan = hostingPlans.find((plan) => { return hours >= plan.minHoursDuration && hours <= plan.maxHoursDuration; }); if (plan) return plan; return hostingPlans[hostingPlans.length - 1]; }; const formatPrice = (cents: number): string => { return (cents / 100).toFixed(2); }; const PriceUtil = { hostingPlans, hostingPlanFromDuration, formatPrice, }; export default PriceUtil;