Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useEffect, useState } from 'react';
import { useEffect, useState, useCallback } from 'react';
import { useRouter } from 'next/navigation';
import {
StatsGrid,
QuickActions,
Expand Down Expand Up @@ -30,6 +31,12 @@ export default function Home() {
const [studyAheadCount, setStudyAheadCount] = useState(0);
const [newDeckName, setNewDeckName] = useState('');
const [loading, setLoading] = useState(true);
const router = useRouter();

const handleLogout = useCallback(async () => {
await fetch('/api/auth/logout', { method: 'POST' });
router.push('/login');
}, [router]);

useEffect(() => {
fetchDecks();
Expand Down Expand Up @@ -79,7 +86,15 @@ export default function Home() {
return (
<div className="min-h-screen bg-background">
<div className="max-w-4xl mx-auto p-4 sm:p-8">
<h1 className="text-3xl font-bold text-text mb-2">Spanish Flashcards</h1>
<div className="flex items-center justify-between mb-2">
<h1 className="text-3xl font-bold text-text">Spanish Flashcards</h1>
<button
onClick={handleLogout}
className="px-3 py-1.5 text-sm text-text-secondary hover:text-text border border-border rounded-lg hover:bg-surface transition"
>
Log out
</button>
</div>
<p className="text-text-secondary mb-8">Learn Spanish with spaced repetition</p>

<StatsGrid
Expand Down