dealroom/internal/handler/subscription.go

27 lines
714 B
Go

package handler
import (
"net/http"
"dealroom/templates"
)
func (h *Handler) handleSubscription(w http.ResponseWriter, r *http.Request) {
profile := getProfile(r.Context())
var roomsUsed, usersUsed int
h.db.QueryRow("SELECT COUNT(*) FROM deals WHERE organization_id = ? AND is_archived = 0", profile.OrganizationID).Scan(&roomsUsed)
h.db.QueryRow("SELECT COUNT(*) FROM profiles WHERE organization_id = ?", profile.OrganizationID).Scan(&usersUsed)
stats := &templates.SubscriptionStats{
RoomsUsed: roomsUsed,
RoomsLimit: 15,
UsersUsed: usersUsed,
UsersLimit: 25,
StorageUsed: "23GB",
StorageLimit: "100GB",
}
templates.SubscriptionPage(profile, stats).Render(r.Context(), w)
}