Fix UserStats typing in users page counters
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m58s

This commit is contained in:
2026-03-04 17:04:09 +01:00
parent 367eea6ee8
commit f2c1b195b3

View File

@@ -1,6 +1,6 @@
import { auth } from '@/lib/auth'; import { auth } from '@/lib/auth';
import { redirect } from 'next/navigation'; import { redirect } from 'next/navigation';
import { getAllUsersWithStats } from '@/services/auth'; import { getAllUsersWithStats, type UserStats } from '@/services/auth';
import { getGravatarUrl } from '@/lib/gravatar'; import { getGravatarUrl } from '@/lib/gravatar';
import { PageHeader } from '@/components/ui'; import { PageHeader } from '@/components/ui';
@@ -11,7 +11,7 @@ const OWNED_WORKSHOP_COUNT_KEYS = [
'weeklyCheckInSessions', 'weeklyCheckInSessions',
'weatherSessions', 'weatherSessions',
'gifMoodSessions', 'gifMoodSessions',
] as const; ] as const satisfies readonly (keyof UserStats)[];
const SHARED_WORKSHOP_COUNT_KEYS = [ const SHARED_WORKSHOP_COUNT_KEYS = [
'sharedSessions', 'sharedSessions',
@@ -20,12 +20,9 @@ const SHARED_WORKSHOP_COUNT_KEYS = [
'sharedWeeklyCheckInSessions', 'sharedWeeklyCheckInSessions',
'sharedWeatherSessions', 'sharedWeatherSessions',
'sharedGifMoodSessions', 'sharedGifMoodSessions',
] as const; ] as const satisfies readonly (keyof UserStats)[];
function sumCountKeys( function sumCountKeys(counts: UserStats, keys: readonly (keyof UserStats)[]): number {
counts: Record<string, number>,
keys: readonly string[]
): number {
return keys.reduce((acc, key) => acc + (counts[key] ?? 0), 0); return keys.reduce((acc, key) => acc + (counts[key] ?? 0), 0);
} }