/** * TasksSummaryWidget — shows open tasks count (Task 5.25). */ import React from 'react'; import { useTranslation } from 'react-i18next'; import type { WidgetComponentProps } from '@/components/dashboard/MiniAppHost'; import { useTasks } from '@/api/tasks'; import { CheckSquare, AlertCircle, Clock } from 'lucide-react'; export function TasksSummaryWidget({ settings }: WidgetComponentProps) { const { t } = useTranslation(); const { data, isLoading, isError } = useTasks(1, 100); if (isLoading) { return
; } if (isError) { return

{t('dashboard.widgetError')}

; } const tasks = data?.items ?? []; const openTasks = tasks.filter((task) => task.status !== 'done'); const overdueTasks = tasks.filter((task) => { if (!task.due_date || task.status === 'done') return false; return new Date(task.due_date) < new Date(); }); const highPriority = openTasks.filter((task) => task.priority === 'high' || task.priority === 'urgent'); return (
{openTasks.length} {t('dashboard.openTasks')}
{overdueTasks.length > 0 && (
{overdueTasks.length} {t('dashboard.overdueTasks')}
)} {highPriority.length > 0 && (
{highPriority.length} {t('dashboard.highPriorityTasks')}
)} {openTasks.length === 0 && (

{t('dashboard.noOpenTasks')}

)}
); }