package web

import "gitea.dooplex.hu/admin/felhom-controller/internal/stacks"

// MetaBadge is a catalog-metadata badge: a short pill on an app card or app page that says
// something about the APP ITSELF rather than about its running state. State badges (Fut, Leállítva,
// …) come from stateLabel/stateColor and are a different axis — an app can be "Fut" and
// "Nem karbantartott" at the same time, which is exactly the case this exists for.
//
// Deliberately generic: the lifecycle badge is the first user, and R-56's difficulty labels
// (kezdő / haladó / technikás) are meant to be a second `*MetaBadge`-returning funcmap entry plus a
// call to the same `meta_badge` partial — no new markup, no new CSS.
type MetaBadge struct {
	Label string // the pill text (Hungarian)
	Class string // a tag-* variant from style.css: tag-warn, tag-neutral, …
	Title string // hover/assistive explanation; a badge that only says a word is a riddle
}

// lifecycleBadge returns the badge for an app's catalog lifecycle, or nil when there is nothing to
// say (the available case, which is almost every app — a badge on everything is a badge on nothing).
//
// `hidden` deliberately renders NOTHING on a deployed app: the customer is running it, it works, and
// "we stopped offering this to new customers" is not their problem. Only `abandoned` is a fact they
// need, because it changes what they can expect from the software over time.
func lifecycleBadge(m stacks.Metadata) *MetaBadge {
	if m.EffectiveLifecycle() != stacks.LifecycleAbandoned {
		return nil
	}
	return &MetaBadge{
		Label: "Nem karbantartott",
		Class: "tag-warn",
		Title: "Az alkalmazás fejlesztője felhagyott a fejlesztéssel. " +
			"A telepített verzió továbbra is használható, de frissítések és biztonsági javítások már nem érkeznek hozzá.",
	}
}
