// src/pages/DashboardPage.tsx import { useState } from 'react' import { useAuth } from '../context/AuthContext' import { useTodos } from '../hooks/useTodos' import Navbar from '../components/Navbar' import TodoForm from '../components/todos/TodoForm' import TodoList from '../components/todos/TodoList' type FilterType = 'all' | 'pending' | 'completed' const DashboardPage = () => { const { user } = useAuth() const { todos, isLoading, createTodo, toggleTodo, deleteTodo, updateTodo } = useTodos() const [filter, setFilter] = useState('all') const filteredTodos = todos.filter(todo => { if (filter === 'completed') return todo.completed if (filter === 'pending') return !todo.completed return true }) const filters: { label: string; value: FilterType; count: number }[] = [ { label: 'All', value: 'all', count: todos.length }, { label: 'Pending', value: 'pending', count: todos.filter(t => !t.completed).length }, { label: 'Completed', value: 'completed', count: todos.filter(t => t.completed).length }, ] return (

Good day, {user?.name}!

You have {todos.filter(t => !t.completed).length} pending todos

{filters.map(f => ( ))}
) } export default DashboardPage