diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-06-29 09:31:37 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-06-29 09:31:37 +0000 |
| commit | e7aee6b9d0c2be22530f7813bf677c0c8bff99e4 (patch) | |
| tree | 2699db4618635115c317fdbcfae3018da7c0c678 /internal/handlers | |
| parent | 509ae15621a3981246e8b2b54804959294938d42 (diff) | |
feat: reschedule tasks from widget bottom sheet
Tapping a doot task shows a date picker. On confirm, POSTs to
/api/widget/reschedule, updates due_date in native_tasks, refreshes
widget. Reschedule button only shows for source="doot" tasks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers')
| -rw-r--r-- | internal/handlers/widget.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/handlers/widget.go b/internal/handlers/widget.go index 360ccc5..ee13dc4 100644 --- a/internal/handlers/widget.go +++ b/internal/handlers/widget.go @@ -101,6 +101,37 @@ type widgetCompleteRequest struct { Source string `json:"source"` } +type widgetRescheduleRequest struct { + ID string `json:"id"` + Source string `json:"source"` + Date string `json:"date"` // YYYY-MM-DD +} + +// HandleWidgetReschedule updates the due date of a native task. +func (h *Handler) HandleWidgetReschedule(w http.ResponseWriter, r *http.Request) { + var req widgetRescheduleRequest + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + http.Error(w, "bad request", http.StatusBadRequest) + return + } + if req.Source != "doot" { + http.Error(w, "only doot tasks can be rescheduled via widget", http.StatusBadRequest) + return + } + parsed, err := time.Parse("2006-01-02", req.Date) + if err != nil { + http.Error(w, "invalid date", http.StatusBadRequest) + return + } + tz := config.GetDisplayTimezone() + dueDate := time.Date(parsed.Year(), parsed.Month(), parsed.Day(), 0, 0, 0, 0, tz) + if err := h.store.RescheduleNativeTask(req.ID, dueDate); err != nil { + http.Error(w, "failed to reschedule", http.StatusInternalServerError) + return + } + w.WriteHeader(http.StatusOK) +} + // HandleWidgetComplete proxies a task completion to the source API or native store. func (h *Handler) HandleWidgetComplete(w http.ResponseWriter, r *http.Request) { var req widgetCompleteRequest |
