package ui

import (
	"net/http"
)

func PageHandler(w http.ResponseWriter, r *http.Request) {
	access := getConvergeAccess(r)

	switch r.URL.Path {
	case "":
		fallthrough
	case "/":
		fallthrough
	case "index.html":
		AboutTab().Render(r.Context(), w)
		// TODO use contexts later.
	case "usage.html":
		UsageTab(access).Render(r.Context(), w)
	case "downloads.html":
		DownloadsTab().Render(r.Context(), w)
	case "sessions.html":
		SessionsTab(nil, nil, access.Location).Render(r.Context(), w)
	default:
		http.NotFound(w, r)
	}
}