# Phase 3 Step 4: Todoist Write Operations ## Goal Implement write operations for Todoist (Create Task, Complete Task) and update the UI to support them. ## Requirements ### Backend 1. **Models**: * Add `Project` struct to `internal/models/types.go`. * Add `Projects []Project` to `DashboardData`. 2. **API (`internal/api/todoist.go`)**: * Refactor `GetProjects` to return `[]models.Project`. * Implement `CreateTask(content, projectID string)`. * Implement `CompleteTask(taskID string)`. * Refactor `baseURL` to be a struct field for testability. 3. **Handlers (`internal/handlers/handlers.go`)**: * Update `aggregateData` to fetch projects and populate `DashboardData`. * Implement `HandleCreateTask`: * Parse form (`content`, `project_id`). * Call `CreateTask`. * Return updated task list partial. * Implement `HandleCompleteTask`: * Call `CompleteTask`. * Return empty string (to remove from DOM). ### Frontend 1. **Template (`web/templates/partials/todoist-tasks.html`)**: * Add "Quick Add" form at the top. * Input: Task content. * Select: Project (populated from `.Projects`). * Update Task Items: * Add Checkbox. * `hx-post="/tasks/complete"`. * `hx-target="closest .todoist-task-item"`. * `hx-swap="outerHTML"`. ## Verification * Unit tests for API client. * Manual verification of UI flows.