diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 2cd6369..4b63a4f 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -309,6 +309,10 @@ export const api = { return ensureArray(res); }, + async getThought(thoughtId: string): Promise { + return request(`/api/v1/thoughts/${encodeURIComponent(thoughtId)}`); + }, + async triageAction( thoughtId: string, action: 'keep' | 'discard' | 'restore', diff --git a/internal/api/server.go b/internal/api/server.go index 56b6561..637948e 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -88,6 +88,7 @@ func (s *Server) Router() http.Handler { // Instant Capture & Thoughts r.Post("/api/v1/inbox", s.handleCaptureInbox) r.Get("/api/v1/thoughts", s.handleGetThoughts) + r.Get("/api/v1/thoughts/{id}", s.handleGetThought) r.Patch("/api/v1/thoughts/{id}", s.handleUpdateThought) r.Delete("/api/v1/thoughts/{id}", s.handleDeleteThought) r.Delete("/api/v1/thoughts/discarded/purge", s.handlePurgeDiscarded) @@ -702,6 +703,17 @@ func (s *Server) handleGetThoughts(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, thoughts) } +func (s *Server) handleGetThought(w http.ResponseWriter, r *http.Request) { + userID := auth.GetUserID(r.Context()) + thoughtID := chi.URLParam(r, "id") + thought, err := s.store.GetThoughtByID(userID, thoughtID) + if err != nil || thought == nil { + writeError(w, http.StatusNotFound, "Aufgabe nicht gefunden") + return + } + writeJSON(w, http.StatusOK, thought) +} + func (s *Server) handleGetTriageDeck(w http.ResponseWriter, r *http.Request) { userID := auth.GetUserID(r.Context()) thoughts, err := s.store.GetThoughts(userID, "inbox", 100)