package handler import ( "context" "io" "net/http" "time" "github.com/LazyBachelor/LazyPM/internal/models" "github.com/LazyBachelor/LazyPM/pkg/web/components" "github.com/a-h/templ" ) type ValidationFeedback = models.ValidationFeedback var taskFeedback ValidationFeedback var submitChan chan<- struct{} func SetTaskFeedback(feedback ValidationFeedback) { taskFeedback = feedback } func SetSubmitChan(ch chan<- struct{}) { submitChan = ch } func HandleTaskStatus(w http.ResponseWriter, r *http.Request) { submitChan <- struct{}{} time.Sleep(100 * time.Millisecond) hx := HTMX(r) if hx.IsHxRequest() { hx.WriteString(`
`+feedback.Message+`
`) io.WriteString(w, `You can close the browser and return to the terminal window
`) } for _, check := range feedback.Checks { if !check.Valid { io.WriteString(w, ``+"❌ "+check.Message+`
`) } else { io.WriteString(w, ``+"✅ "+check.Message+`
`) } } return nil }) }