diff --git a/apps/journal/app/routes/home.server.ts b/apps/journal/app/routes/home.server.ts index e099e9d..af69e76 100644 --- a/apps/journal/app/routes/home.server.ts +++ b/apps/journal/app/routes/home.server.ts @@ -8,10 +8,12 @@ import { getSessionUser } from "~/lib/auth/session.server"; import { getDb } from "~/lib/db"; import { credentials } from "@trails-cool/db/schema/journal"; import { listActivities, listRecentPublicActivities } from "~/lib/activities.server"; +import type { SportType } from "@trails-cool/db/schema/journal"; export interface HomeActivityCard { id: string; name: string; + sportType: SportType | null; distance: number | null; elevationGain: number | null; duration: number | null; @@ -57,6 +59,7 @@ export async function loadHomeData(request: Request): Promise { activities = rows.slice(0, 20).map((a) => ({ id: a.id, name: a.name, + sportType: a.sportType, distance: a.distance, elevationGain: a.elevationGain, duration: a.duration, @@ -71,6 +74,7 @@ export async function loadHomeData(request: Request): Promise { activities = rows.map((a) => ({ id: a.id, name: a.name, + sportType: a.sportType, distance: a.distance, elevationGain: a.elevationGain, duration: a.duration, diff --git a/apps/journal/app/routes/home.tsx b/apps/journal/app/routes/home.tsx index 2e3f580..cb868ef 100644 --- a/apps/journal/app/routes/home.tsx +++ b/apps/journal/app/routes/home.tsx @@ -4,6 +4,9 @@ import { useTranslation } from "react-i18next"; import type { Route } from "./+types/home"; import { ClientDate } from "~/components/ClientDate"; import { ClientMap } from "~/components/ClientMap"; +import { SportBadge } from "~/components/SportBadge"; +import { StatRow } from "~/components/StatRow"; +import { activityStatItems } from "~/lib/stats"; import { loadHomeData } from "./home.server"; export function meta(_args: Route.MetaArgs) { @@ -146,15 +149,18 @@ export default function Home({ loaderData }: Route.ComponentProps) {
-

{a.name}

-
- {a.distance != null && ( - {(a.distance / 1000).toFixed(1)} km - )} - {a.elevationGain != null && ( - ↑ {Math.round(a.elevationGain)} m - )} +
+

{a.name}

+
+
@@ -266,7 +272,10 @@ export default function Home({ loaderData }: Route.ComponentProps) {
-

{a.name}

+
+

{a.name}

+ +
{a.ownerUsername && ( <> @@ -282,14 +291,14 @@ export default function Home({ loaderData }: Route.ComponentProps) { )}
-
- {a.distance != null && ( - {(a.distance / 1000).toFixed(1)} km + ↑ {Math.round(a.elevationGain)} m - )} -
+ />