Move UI controls to bottom and require authentication for stats

- Moved stats button, auth buttons, and debug info to bottom of main page
- Added authentication requirement for /stats route
- Show login prompt for unauthenticated users accessing stats
- Include AuthModal for sign in/sign up from stats page

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
George Powell
2026-02-05 17:57:29 -05:00
parent 96024d5048
commit b1591229ba
3 changed files with 79 additions and 69 deletions

View File

@@ -4,13 +4,20 @@ import { eq, desc } from 'drizzle-orm';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ url, locals }) => {
const userId = url.searchParams.get('userId');
const anonymousId = url.searchParams.get('anonymousId');
// Check if user is authenticated
if (!locals.user) {
return {
stats: null,
error: null,
user: null,
session: null,
requiresAuth: true
};
}
// Prioritize userId (authenticated user) over anonymousId
const targetId = userId || anonymousId;
const userId = locals.user.id;
if (!targetId) {
if (!userId) {
return {
stats: null,
error: 'No user ID provided',
@@ -24,7 +31,7 @@ export const load: PageServerLoad = async ({ url, locals }) => {
const completions = await db
.select()
.from(dailyCompletions)
.where(eq(dailyCompletions.anonymousId, targetId))
.where(eq(dailyCompletions.anonymousId, userId))
.orderBy(desc(dailyCompletions.date));
if (completions.length === 0) {