Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♻️ Make Stats presentational and move count fetching into pages (#2991)
Luke Vella8c059296e97c
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsxindex 17a7ac2f5..cacae6d9d 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx@@ -5,6 +5,7 @@ import { cacheLife } from "next/cache";import Image from "next/image";import Link from "next/link";import { Trans } from "react-i18next/TransWithoutContext";+import { AnimatedStat } from "@/components/home/animated-number";import { Cta } from "@/components/home/cta";import { Faq, FaqItem } from "@/components/home/faq";import { Hero, HeroAnnouncement } from "@/components/home/hero";@@ -20,6 +21,7 @@ import {SectionTitle,} from "@/components/section";import { getTranslation } from "@/i18n/server";+import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";export default async function Page(props: {params: Promise<{ locale: string }>;@@ -27,6 +29,10 @@ export default async function Page(props: {cacheLife("days");const { locale } = await props.params;const { t } = await getTranslation(locale, ["home"]);+ const [pollCount, voterCount] = await Promise.all([+ getMonthlyPollCount(),+ getMonthlyVoterCount(),+ ]);return (<div className="divide-y"><Section>@@ -60,7 +66,18 @@ export default async function Page(props: {><HeroDemo locale={locale} /></Hero>- <Stats locale={locale} className="mt-4 sm:mt-16" />+ <Stats className="mt-8 sm:mt-24">+ <Trans+ t={t}+ ns="home"+ i18nKey="statsLast30Days"+ defaults="<b>{voterCount, plural, one {# person} other {# people}}</b> voted on <b>{pollCount, plural, one {# poll} other {# polls}}</b> in the last 30 days"+ values={{ voterCount, pollCount }}+ components={{+ b: <AnimatedStat locale={locale} />,+ }}+ />+ </Stats></Section><Section><Testimonialdiff --git a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsxindex c7950b077..c445febe7 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx@@ -5,6 +5,7 @@ import { cacheLife } from "next/cache";import Image from "next/image";import Link from "next/link";import { Trans } from "react-i18next/TransWithoutContext";+import { AnimatedStat } from "@/components/home/animated-number";import { Cta } from "@/components/home/cta";import { Faq, FaqItem } from "@/components/home/faq";import { Hero, HeroAnnouncement } from "@/components/home/hero";@@ -20,6 +21,7 @@ import {SectionTitle,} from "@/components/section";import { getTranslation } from "@/i18n/server";+import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";export default async function Page(props: {params: Promise<{ locale: string }>;@@ -27,6 +29,10 @@ export default async function Page(props: {cacheLife("days");const { locale } = await props.params;const { t } = await getTranslation(locale, ["home"]);+ const [pollCount, voterCount] = await Promise.all([+ getMonthlyPollCount(),+ getMonthlyVoterCount(),+ ]);return (<div className="divide-y"><Section>@@ -60,7 +66,18 @@ export default async function Page(props: {><HeroDemo locale={locale} /></Hero>- <Stats locale={locale} className="mt-4 sm:mt-16" />+ <Stats className="mt-8 sm:mt-24">+ <Trans+ t={t}+ ns="home"+ i18nKey="statsLast30Days"+ defaults="<b>{voterCount, plural, one {# person} other {# people}}</b> voted on <b>{pollCount, plural, one {# poll} other {# polls}}</b> in the last 30 days"+ values={{ voterCount, pollCount }}+ components={{+ b: <AnimatedStat locale={locale} />,+ }}+ />+ </Stats></Section><Section><Testimonialdiff --git a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsxindex de4efebcb..e7133f00e 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx@@ -5,6 +5,7 @@ import { cacheLife } from "next/cache";import Image from "next/image";import Link from "next/link";import { Trans } from "react-i18next/TransWithoutContext";+import { AnimatedStat } from "@/components/home/animated-number";import { Cta } from "@/components/home/cta";import { Faq, FaqItem } from "@/components/home/faq";import { Hero, HeroAnnouncement } from "@/components/home/hero";@@ -20,6 +21,7 @@ import {SectionTitle,} from "@/components/section";import { getTranslation } from "@/i18n/server";+import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";export default async function Page(props: {params: Promise<{ locale: string }>;@@ -27,6 +29,10 @@ export default async function Page(props: {cacheLife("days");const { locale } = await props.params;const { t } = await getTranslation(locale, ["home"]);+ const [pollCount, voterCount] = await Promise.all([+ getMonthlyPollCount(),+ getMonthlyVoterCount(),+ ]);return (<div className="divide-y"><Section>@@ -60,7 +66,18 @@ export default async function Page(props: {><HeroDemo locale={locale} /></Hero>- <Stats locale={locale} className="mt-4 sm:mt-16" />+ <Stats className="mt-8 sm:mt-24">+ <Trans+ t={t}+ ns="home"+ i18nKey="statsLast30Days"+ defaults="<b>{voterCount, plural, one {# person} other {# people}}</b> voted on <b>{pollCount, plural, one {# poll} other {# polls}}</b> in the last 30 days"+ values={{ voterCount, pollCount }}+ components={{+ b: <AnimatedStat locale={locale} />,+ }}+ />+ </Stats></Section><Section><Testimonialdiff --git a/apps/landing/src/app/[locale]/(main)/page.tsx b/apps/landing/src/app/[locale]/(main)/page.tsxindex 939004ddd..72a9067b0 100644--- a/apps/landing/src/app/[locale]/(main)/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/page.tsx@@ -5,6 +5,7 @@ import { cacheLife } from "next/cache";import Image from "next/image";import Link from "next/link";import { Trans } from "react-i18next/TransWithoutContext";+import { AnimatedStat } from "@/components/home/animated-number";import { Cta } from "@/components/home/cta";import { Faq, FaqItem } from "@/components/home/faq";import { Hero, HeroAnnouncement } from "@/components/home/hero";@@ -20,6 +21,7 @@ import {SectionTitle,} from "@/components/section";import { getTranslation } from "@/i18n/server";+import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";export default async function Page(props: {params: Promise<{ locale: string }>;@@ -27,6 +29,10 @@ export default async function Page(props: {cacheLife("days");const { locale } = await props.params;const { t } = await getTranslation(locale, ["home", "common"]);+ const [pollCount, voterCount] = await Promise.all([+ getMonthlyPollCount(),+ getMonthlyVoterCount(),+ ]);return (<div className="divide-y"><Section>@@ -63,7 +69,18 @@ export default async function Page(props: {><HeroDemo locale={locale} /></Hero>- <Stats locale={locale} className="mt-4 sm:mt-16" />+ <Stats className="mt-8 sm:mt-24">+ <Trans+ t={t}+ ns="home"+ i18nKey="statsLast30Days"+ defaults="<b>{voterCount, plural, one {# person} other {# people}}</b> voted on <b>{pollCount, plural, one {# poll} other {# polls}}</b> in the last 30 days"+ values={{ voterCount, pollCount }}+ components={{+ b: <AnimatedStat locale={locale} />,+ }}+ />+ </Stats></Section><Section><Testimonialdiff --git a/apps/landing/src/components/home/stats.tsx b/apps/landing/src/components/home/stats.tsxindex 2e7d19de7..3d40c2874 100644--- a/apps/landing/src/components/home/stats.tsx+++ b/apps/landing/src/components/home/stats.tsx@@ -1,22 +1,13 @@import { cn } from "@rallly/ui";-import { Trans } from "react-i18next/TransWithoutContext";-import { AnimatedStat } from "@/components/home/animated-number";-import { getTranslation } from "@/i18n/server";-import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";+import type * as React from "react";-export async function Stats({- locale,+export function Stats({className,+ children,}: {- locale: string;className?: string;+ children: React.ReactNode;}) {- const [pollCount, voterCount] = await Promise.all([- getMonthlyPollCount(),- getMonthlyVoterCount(),- ]);- const { t } = await getTranslation(locale, ["home"]);-return (<pclassName={cn(@@ -24,16 +15,7 @@ export async function Stats({className,)}>- <Trans- t={t}- ns="home"- i18nKey="statsLast30Days"- defaults="<b>{voterCount, plural, one {# person} other {# people}}</b> voted on <b>{pollCount, plural, one {# poll} other {# polls}}</b> in the last 30 days"- values={{ voterCount, pollCount }}- components={{- b: <AnimatedStat locale={locale} />,- }}- />+ {children}</p>);}