Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(dashboard): correct prices

Carl-Gerhard Lindesvärd490d12b24d2e
diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/organization/billing.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/organization/billing.tsx
index 2aa9e34b1..ad24846c0 100644
--- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/organization/billing.tsx
+++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/organization/billing.tsx
@@ -129,7 +129,7 @@ export default function Billing({ organization }: Props) {
style: 'currency',
currency: price.priceCurrency,
minimumFractionDigits: 0,
- maximumFractionDigits: 0,
+ maximumFractionDigits: 1,
}).format(price.priceAmount / 100)}
{' / '}
{recurringInterval === 'year' ? 'year' : 'month'}
diff --git a/packages/payments/scripts/create-products.ts b/packages/payments/scripts/create-products.ts
index 6407cf26b..d49feb9b1 100644
--- a/packages/payments/scripts/create-products.ts
+++ b/packages/payments/scripts/create-products.ts
@@ -69,6 +69,7 @@ async function main() {
const isDry = process.argv.includes('--dry');
const products = await getProducts();
+ const createProducts = [];
for (const price of PRICING) {
if (price.price === 0) {
const exists = products.find(
@@ -126,12 +127,14 @@ async function main() {
const monthlyProductExists = products.find(
(p) =>
p.metadata?.eventsLimit === price.events &&
- p.recurringInterval === 'month',
+ p.recurringInterval === 'month' &&
+ p.name === productCreate.name,
);
const yearlyProductExists = products.find(
(p) =>
p.metadata?.eventsLimit === price.events &&
- p.recurringInterval === 'year',
+ p.recurringInterval === 'year' &&
+ p.name === `${productCreate.name} (yearly)`,
);
if (monthlyProductExists) {
@@ -148,6 +151,7 @@ async function main() {
console.log(' - Prices:', monthlyProduct.prices);
console.log(' - Recurring Interval:', monthlyProduct.recurringInterval);
console.log(' - Events Limit:', monthlyProduct.metadata?.eventsLimit);
+ createProducts.push(monthlyProduct);
}
if (yearlyProductExists) {
@@ -165,6 +169,7 @@ async function main() {
) {
productCreate.prices[0]!.priceAmount = price.price * 100 * 10;
}
+ // console.log('CREATE YEARLY', productCreate);
const yearlyProduct = await polar.products.create(productCreate);
console.log('Yearly product created:');
console.log(' - ID:', yearlyProduct.id);
@@ -172,10 +177,23 @@ async function main() {
console.log(' - Prices:', yearlyProduct.prices);
console.log(' - Recurring Interval:', yearlyProduct.recurringInterval);
console.log(' - Events Limit:', yearlyProduct.metadata?.eventsLimit);
+ createProducts.push(yearlyProduct);
}
}
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();