package handlers import ( "fmt" "net/http" "strconv" "time" "go-crm/internal/db" "go-crm/internal/templates" "github.com/go-chi/chi/v5" ) func (a *App) ListClients(w http.ResponseWriter, r *http.Request) { accountID, ok := a.requireAuth(w, r) if !ok { return } limit, _ := strconv.Atoi(r.URL.Query().Get("limit")) offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) if limit == 0 { limit = 20 } clients, err := db.ListClients(a.DB, accountID, limit, offset) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } buf := templates.BufRender() actions := `` fmt.Fprint(buf, templates.PageHeader("Clients", "Manage your business clients", actions)) // Add form fmt.Fprintf(buf, `
`) if len(clients) == 0 { fmt.Fprint(buf, templates.EmptyState(`