fix(dashboard): correct prices

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-03-24 11:22:20 +01:00
parent 7ab869ff45
commit 490d12b24d
2 changed files with 21 additions and 3 deletions

View File

@@ -129,7 +129,7 @@ export default function Billing({ organization }: Props) {
style: 'currency', style: 'currency',
currency: price.priceCurrency, currency: price.priceCurrency,
minimumFractionDigits: 0, minimumFractionDigits: 0,
maximumFractionDigits: 0, maximumFractionDigits: 1,
}).format(price.priceAmount / 100)} }).format(price.priceAmount / 100)}
{' / '} {' / '}
{recurringInterval === 'year' ? 'year' : 'month'} {recurringInterval === 'year' ? 'year' : 'month'}

View File

@@ -69,6 +69,7 @@ async function main() {
const isDry = process.argv.includes('--dry'); const isDry = process.argv.includes('--dry');
const products = await getProducts(); const products = await getProducts();
const createProducts = [];
for (const price of PRICING) { for (const price of PRICING) {
if (price.price === 0) { if (price.price === 0) {
const exists = products.find( const exists = products.find(
@@ -126,12 +127,14 @@ async function main() {
const monthlyProductExists = products.find( const monthlyProductExists = products.find(
(p) => (p) =>
p.metadata?.eventsLimit === price.events && p.metadata?.eventsLimit === price.events &&
p.recurringInterval === 'month', p.recurringInterval === 'month' &&
p.name === productCreate.name,
); );
const yearlyProductExists = products.find( const yearlyProductExists = products.find(
(p) => (p) =>
p.metadata?.eventsLimit === price.events && p.metadata?.eventsLimit === price.events &&
p.recurringInterval === 'year', p.recurringInterval === 'year' &&
p.name === `${productCreate.name} (yearly)`,
); );
if (monthlyProductExists) { if (monthlyProductExists) {
@@ -148,6 +151,7 @@ async function main() {
console.log(' - Prices:', monthlyProduct.prices); console.log(' - Prices:', monthlyProduct.prices);
console.log(' - Recurring Interval:', monthlyProduct.recurringInterval); console.log(' - Recurring Interval:', monthlyProduct.recurringInterval);
console.log(' - Events Limit:', monthlyProduct.metadata?.eventsLimit); console.log(' - Events Limit:', monthlyProduct.metadata?.eventsLimit);
createProducts.push(monthlyProduct);
} }
if (yearlyProductExists) { if (yearlyProductExists) {
@@ -165,6 +169,7 @@ async function main() {
) { ) {
productCreate.prices[0]!.priceAmount = price.price * 100 * 10; productCreate.prices[0]!.priceAmount = price.price * 100 * 10;
} }
// console.log('CREATE YEARLY', productCreate);
const yearlyProduct = await polar.products.create(productCreate); const yearlyProduct = await polar.products.create(productCreate);
console.log('Yearly product created:'); console.log('Yearly product created:');
console.log(' - ID:', yearlyProduct.id); console.log(' - ID:', yearlyProduct.id);
@@ -172,10 +177,23 @@ async function main() {
console.log(' - Prices:', yearlyProduct.prices); console.log(' - Prices:', yearlyProduct.prices);
console.log(' - Recurring Interval:', yearlyProduct.recurringInterval); console.log(' - Recurring Interval:', yearlyProduct.recurringInterval);
console.log(' - Events Limit:', yearlyProduct.metadata?.eventsLimit); console.log(' - Events Limit:', yearlyProduct.metadata?.eventsLimit);
createProducts.push(yearlyProduct);
} }
} }
console.log('---'); console.log('---');
} }
if (createProducts.length > 0) {
console.log('Create below products:');
for (const product of createProducts) {
console.log('Product created:');
console.log(' - ID:', product.id);
console.log(' - Name:', product.name);
console.log(' - Prices:', product.prices);
console.log(' - Recurring Interval:', product.recurringInterval);
console.log(' - Events Limit:', product.metadata?.eventsLimit);
}
}
} }
main(); main();