package httpserver

import "update_server/internal/db"

type PageData struct {
	Title       string
	Eyebrow     string
	Heading     string
	Description string
	BaseURL     string
	CSRFToken   string
	CurrentUser *db.User
	Flash       *FlashMessage
}

type FlashMessage struct {
	Kind    string
	Message string
}

type PageLink struct {
	Label       string
	Href        string
	Description string
}

type HomePageData struct {
	PageData
	Links []PageLink
}

type DashboardMetric struct {
	Label       string
	Value       string
	Description string
}

type DashboardPageData struct {
	PageData
	Links   []PageLink
	Metrics []DashboardMetric
}

type LoginFormData struct {
	Action    string
	Email     string
	Next      string
	Error     string
	SetupHint string
}

type LoginPageData struct {
	PageData
	Login LoginFormData
}

type ProjectsPageData struct {
	PageData
	Projects []db.ProjectListItem
}

type ProjectFormData struct {
	Action      string
	SubmitLabel string
	Name        string
	Slug        string
	Description string
	Error       string
}

type ReleaseUploadData struct {
	Action       string
	Version      string
	Build        string
	ReleaseNotes string
	Error        string
	MaxUploadMB  int64
}

type ProjectFormPageData struct {
	PageData
	Form ProjectFormData
}

type ProjectDetailPageData struct {
	PageData
	Project         db.Project
	Form            ProjectFormData
	Tags            []db.Tag
	AvailableTags   []db.Tag
	Releases        []db.ReleaseListItem
	LatestRelease   *db.Release
	AttachTagAction string
	ArchiveAction   string
	ArchiveState    string
	ArchiveLabel    string
	Upload          ReleaseUploadData
}

type TagsPageData struct {
	PageData
	Tags []db.TagListItem
}

type TagFormData struct {
	Action       string
	SubmitLabel  string
	Name         string
	Slug         string
	Description  string
	Error        string
	DeleteAction string
	CanDelete    bool
}

type TagFormPageData struct {
	PageData
	Form     TagFormData
	Tag      *db.Tag
	Projects []db.Project
}

type APIKeyProjectChoice struct {
	Project  db.Project
	Selected bool
}

type APIKeyTagChoice struct {
	Tag      db.Tag
	Selected bool
}

type APIKeysPageData struct {
	PageData
	APIKeys []db.APIKeyListItem
}

type APIKeyFormData struct {
	Action             string
	SubmitLabel        string
	Name               string
	Description        string
	ScopeMode          db.ScopeMode
	ExpiresAt          string
	CanDownload        bool
	CanUpload          bool
	CanDelete          bool
	CanManageProjects  bool
	SelectedProjectIDs []int64
	SelectedTagIDs     []int64
	Error              string
	RevealKey          string
}

type APIKeyPageData struct {
	PageData
	APIKey             *db.APIKey
	Form               APIKeyFormData
	ProjectChoices     []APIKeyProjectChoice
	TagChoices         []APIKeyTagChoice
	AccessibleProjects []db.Project
	ToggleAction       string
	ToggleState        string
	ToggleLabel        string
}
