"""Tasks plugin — manage free tasks/activities linked to contacts."""

from __future__ import annotations

from app.plugins.base import BasePlugin
from app.plugins.manifest import (
    PluginManifest,
    PluginRouteDef,
    FrontendMenuItem,
    FrontendPageRoute,
    CronJobContribution,
)


class TasksPlugin(BasePlugin):
    """Tasks plugin for managing activities (calls, notes, visits) linked to contacts."""

    manifest = PluginManifest(
        name="tasks",
        version="1.0.0",
        display_name="Tasks",
        description="Manage free tasks/activities with status, priority, due dates, and contact links.",
        dependencies=["permissions"],
        routes=[
            PluginRouteDef(
                path="/api/v1/tasks",
                module="app.plugins.builtins.tasks.routes",
                router_attr="router",
            ),
        ],
        events=[],
        migrations=["0001_initial.sql"],
        permissions=[
            "tasks:read",
            "tasks:write",
            "tasks:delete",
        ],
        is_core=True,
        menu_items=[
            FrontendMenuItem(
                label_key="nav.tasks",
                label="Tasks",
                path="/tasks",
                icon="CheckSquare",
                order=30,
            ),
        ],
        page_routes=[
            FrontendPageRoute(
                path="/tasks",
                component="@/pages/Tasks",
                protected=True,
                order=30,
            ),
        ],
        cron_jobs=[
            CronJobContribution(
                name="tasks_due_reminder",
                cron_expression="0 8 * * *",
                job_type="custom",
                target_name="tasks_due_reminder",
                plugin_name="tasks",
            ),
        ],
    )
