Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
💬 Show a fixed "Save up to 40%" on the pricing page (#3597)
Luke Vella912de6776ed2
diff --git a/apps/landing/public/locales/en/pricing.json b/apps/landing/public/locales/en/pricing.jsonindex 0a0ba3c85..3c3f4a738 100644--- a/apps/landing/public/locales/en/pricing.json+++ b/apps/landing/public/locales/en/pricing.json@@ -74,5 +74,5 @@"whenPollInactiveAnswer": "Polls become inactive when all date options are more than 30 days in the past and there has been no activity for 30 days. Activity includes new votes, comments, or changes to the poll. Inactive polls are automatically deleted if you do not have a paid subscription.","whyUpgrade": "Why should I upgrade?","whyUpgradeAnswer2": "Upgrading to a paid plan makes sense if you use Rallly often or use it for work. The current subscription rate is a special early adopter rate and will increase in the future. By upgrading now, you will get early access to new, high-quality scheduling tools as they are released and lock in your subscription rate so you won't be affected by future price increases.",- "yearlySavePercent": "Save {percent}%"+ "yearlySaveUpTo": "Save up to {percent}%"}diff --git a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx b/apps/landing/src/app/[locale]/(main)/pricing/page.tsxindex ffd7f2cce..ab7b1c81f 100644--- a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/pricing/page.tsx@@ -1,7 +1,6 @@"use cache";-import type { PriceAmounts } from "@rallly/billing";-import { PLAN_NAMES, yearlySavingsPercent } from "@rallly/billing";+import { PLAN_NAMES } from "@rallly/billing";import { buttonVariants } from "@rallly/ui";import { Badge } from "@rallly/ui/badge";import {@@ -83,7 +82,6 @@ import {PricingControls,PricingControlsDivider,PricingProvider,- YearlySavingsBadge,} from "./pricing-controls";const faqLinkClassName =@@ -103,21 +101,6 @@ export default async function Page(props: {getMonthlyVoterCount(),getPricing(),]);- const savingsLabels = Object.fromEntries(- Object.entries(prices).map(- ([currency, amounts]: [string, PriceAmounts]) => [- currency,- <Trans- key={currency}- t={t}- ns="pricing"- i18nKey="yearlySavePercent"- defaults="Save {percent}%"- values={{ percent: yearlySavingsPercent(amounts) }}- />,- ],- ),- );const included = t("included", {ns: "pricing",defaultValue: "Included",@@ -184,7 +167,13 @@ export default async function Page(props: {variant="pill"className="bg-lime-300 font-semibold text-lime-900">- <YearlySavingsBadge labels={savingsLabels} />+ <Trans+ t={t}+ ns="pricing"+ i18nKey="yearlySaveUpTo"+ defaults="Save up to {percent}%"+ values={{ percent: 40 }}+ /></Badge>}/>diff --git a/apps/landing/src/app/[locale]/(main)/pricing/pricing-controls.tsx b/apps/landing/src/app/[locale]/(main)/pricing/pricing-controls.tsxindex 2a44cff77..1309a81fd 100644--- a/apps/landing/src/app/[locale]/(main)/pricing/pricing-controls.tsx+++ b/apps/landing/src/app/[locale]/(main)/pricing/pricing-controls.tsx@@ -183,15 +183,6 @@ export function PricingControlsDivider() {);}-export function YearlySavingsBadge({- labels,-}: {- labels: Record<string, React.ReactNode>;-}) {- const { currency } = usePricing();- return labels[currency] ?? null;-}-export function PlanPrice() {const { interval, currency, prices, locale } = usePricing();const amounts = prices[currency];diff --git a/packages/billing/src/pricing.test.ts b/packages/billing/src/pricing.test.tsindex c3bb20054..6e4203c3a 100644--- a/packages/billing/src/pricing.test.ts+++ b/packages/billing/src/pricing.test.ts@@ -1,21 +1,5 @@import { describe, expect, it } from "vitest";-import {- formatMinorUnitAmount,- getCountryCurrency,- yearlySavingsPercent,-} from "./pricing";--describe("yearlySavingsPercent", () => {- it("rounds the saving of yearly against twelve months to a whole percent", () => {- expect(yearlySavingsPercent({ monthly: 700, yearly: 5600 })).toBe(33);- expect(yearlySavingsPercent({ monthly: 560, yearly: 4500 })).toBe(33);- expect(yearlySavingsPercent({ monthly: 1000, yearly: 8400 })).toBe(30);- });-- it("is zero when yearly costs the same as twelve months", () => {- expect(yearlySavingsPercent({ monthly: 100, yearly: 1200 })).toBe(0);- });-});+import { formatMinorUnitAmount, getCountryCurrency } from "./pricing";describe("getCountryCurrency", () => {const available = ["usd", "eur", "gbp"];diff --git a/packages/billing/src/pricing.ts b/packages/billing/src/pricing.tsindex f85de06fb..ef9c1f3a1 100644--- a/packages/billing/src/pricing.ts+++ b/packages/billing/src/pricing.ts@@ -14,16 +14,6 @@ export const pricingData = {},};-export function yearlySavingsPercent({- monthly,- yearly,-}: {- monthly: number;- yearly: number;-}) {- return Math.round((1 - yearly / (monthly * 12)) * 100);-}-export const displayedCurrencies = ["usd", "eur", "gbp"] as const;// Set by the landing proxy from the request country and rewritten when the