oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/oficina/equipo/internal/equipo/conversation"
5 "amadan.net/oficina/equipo/internal/equipo/planning"
6 "context"
7 "net/http"
8)
9
10func (s *Store) ConversationCards(ctx context.Context, a Actor) ([]Card, error) {
11 return s.coordinatorApplication().ConversationCards(ctx, a)
12}
13func (a *application) conversationHandler() *conversation.Handler {
14 return &conversation.Handler{Live: a.live, App: a.store.coordinatorApplication(), Plans: a.store.PlanApplication, Failure: a.failure,
15 Render: func(w http.ResponseWriter, r *http.Request, v conversation.Page) {
16 data, err := a.page(r, "conversation")
17 if err != nil {
18 a.failure(w, r, err)
19 return
20 }
21 if err := v.PrepareChat(data.Address, data.Specialists, func(id string) (planning.TaskViewData, error) {
22 return a.store.TaskView(r.Context(), Actor{Address: data.Address}, id)
23 }, copyText); err != nil {
24 a.failure(w, r, err)
25 return
26 }
27 data.Conversation, data.Live = v, v.Live
28 name := "conversation"
29 if v.ThreadID != "" {
30 name = "thread"
31 }
32 a.renderLive(w, r, name, data)
33 }, RenderSettings: func(w http.ResponseWriter, r *http.Request, v conversation.CoordinatorPage) {
34 data, err := a.page(r, "coordinator")
35 if err != nil {
36 a.failure(w, r, err)
37 return
38 }
39 data.Coordinator = v
40 a.renderLive(w, r, "coordinator", data)
41 }}
42}
43func (a *application) planHandler() *planning.Handler {
44 return &planning.Handler{App: a.store.PlanApplication, Invalid: ErrInvalid, Forbidden: ErrForbidden, Failure: a.failure, Render: func(w http.ResponseWriter, r *http.Request, v planning.Page) {
45 data, err := a.page(r, "conversation")
46 if err != nil {
47 a.failure(w, r, err)
48 return
49 }
50 data.Plan = v
51 a.renderLive(w, r, "plan", data)
52 }}
53}
54