package handlers import ( "net/http" "strconv" "time" "go-crm/internal/db" "github.com/go-chi/chi/v5" ) func ListServices(w http.ResponseWriter, r *http.Request) { limit, _ := strconv.Atoi(r.URL.Query().Get("limit")) offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) clientID, _ := strconv.ParseInt(r.URL.Query().Get("client_id"), 10, 64) if limit == 0 { limit = 20 } services, err := db.ListServices(DB, clientID, limit, offset) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } clients, err := db.ListClients(DB, limit, offset) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } var clientOptions string for _, c := range clients { clientOptions += `` } w.Header().Set("Content-Type", "text/html") w.Write([]byte(`
| Name | Price | Duration | Actions |
|---|---|---|---|
| ` + s.Name + ` | ` + strconv.FormatFloat(s.Price, 'f', 2, 64) + ` | ` + s.Duration + ` | View |
Price: ` + strconv.FormatFloat(s.Price, 'f', 2, 64) + `
Description: ` + s.Description + `
Duration: ` + s.Duration + `
Back