Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Add tile descriptions (#1717)

Luke Vella21694767f105
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index bc8581c5c..5b4f92ece 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -340,5 +340,7 @@
"homeActionsTitle": "Actions",
"dismissFeedback": "Don't show again",
"tooManyAttempts": "Too many attempts, please try again later.",
- "unknownError": "Something went wrong"
+ "unknownError": "Something went wrong",
+ "livePollCount": "{count} live",
+ "upcomingEventCount": "{count} upcoming"
}
diff --git a/apps/web/src/app/[locale]/(space)/page.tsx b/apps/web/src/app/[locale]/(space)/page.tsx
index ea27bb786..3bf8d028c 100644
--- a/apps/web/src/app/[locale]/(space)/page.tsx
+++ b/apps/web/src/app/[locale]/(space)/page.tsx
@@ -1,7 +1,6 @@
-import { Tile, TileGrid, TileTitle } from "@rallly/ui/tile";
+import { Tile, TileDescription, TileGrid, TileTitle } from "@rallly/ui/tile";
import Link from "next/link";
-import type { Params } from "@/app/[locale]/types";
import {
BillingPageIcon,
CreatePageIcon,
@@ -20,12 +19,47 @@ import {
} from "@/app/components/page-layout";
import { Trans } from "@/components/trans";
import { IfCloudHosted } from "@/contexts/environment";
+import { getUser } from "@/data/get-user";
import { getTranslation } from "@/i18n/server";
+import { prisma } from "@rallly/database";
import { FeedbackAlert } from "./feedback-alert";
-export default async function Page(props: { params: Promise<Params> }) {
- const params = await props.params;
- await getTranslation(params.locale);
+async function loadData() {
+ const user = await getUser();
+
+ if (!user) {
+ return {
+ livePollCount: 0,
+ upcomingEventCount: 0,
+ };
+ }
+
+ const now = new Date();
+ const [livePollCount, upcomingEventCount] = await Promise.all([
+ prisma.poll.count({
+ where: {
+ userId: user.id,
+ status: "live",
+ },
+ }),
+ prisma.event.count({
+ where: {
+ userId: user.id,
+ start: {
+ gte: now,
+ },
+ },
+ }),
+ ]);
+
+ return {
+ livePollCount,
+ upcomingEventCount,
+ };
+}
+
+export default async function Page() {
+ const { livePollCount, upcomingEventCount } = await loadData();
return (
<PageContainer>
@@ -71,6 +105,13 @@ export default async function Page(props: { params: Promise<Params> }) {
<TileTitle>
<Trans i18nKey="polls" defaults="Polls" />
</TileTitle>
+ <TileDescription>
+ <Trans
+ i18nKey="livePollCount"
+ defaults="{count} live"
+ values={{ count: livePollCount }}
+ />
+ </TileDescription>
</Link>
</Tile>
@@ -80,6 +121,13 @@ export default async function Page(props: { params: Promise<Params> }) {
<TileTitle>
<Trans i18nKey="events" defaults="Events" />
</TileTitle>
+ <TileDescription>
+ <Trans
+ i18nKey="upcomingEventCount"
+ defaults="{count} upcoming"
+ values={{ count: upcomingEventCount }}
+ />
+ </TileDescription>
</Link>
</Tile>
</TileGrid>
diff --git a/packages/ui/src/tile.tsx b/packages/ui/src/tile.tsx
index e29336025..3429b8dd8 100644
--- a/packages/ui/src/tile.tsx
+++ b/packages/ui/src/tile.tsx
@@ -18,7 +18,7 @@ const Tile = React.forwardRef<
<Comp
ref={ref}
className={cn(
- "text-card-foreground bg-background flex flex-col justify-end rounded-xl border p-3 shadow-sm transition-shadow hover:bg-gray-50 active:shadow-none",
+ "text-card-foreground relative bg-background flex flex-col justify-end rounded-xl border p-3 shadow-sm transition-shadow hover:bg-gray-50 active:shadow-none",
className,
)}
{...props}
@@ -55,7 +55,10 @@ const TileDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<p
ref={ref}
- className={cn("text-muted-foreground text-center text-sm", className)}
+ className={cn(
+ "text-muted-foreground pointer-events-none absolute right-3 top-3 text-sm",
+ className,
+ )}
{...props}
/>
));