refactor(overview): derive payment badge colour from shared status variant

This commit is contained in:
Simon 2026-07-10 16:27:16 +02:00
parent 0acd12360f
commit e967cb59e9
3 changed files with 25 additions and 17 deletions

View file

@ -158,13 +158,12 @@ defmodule MvWeb.MemberLive.Index.PaymentAging do
def suspended_to_params(_), do: %{}
@doc """
Badge descriptor for an unpaid-cycle count. A count of 0 reads "Alle bezahlt"
(success/green); a positive count reads "N offen" (error/red). Reuses the
established cycle-status color and hero-icon codes so the overview badge reads
consistently with the member show page.
Badge descriptor for an unpaid-cycle count. A count of 0 reads "All paid"
(success/green); a positive count reads "N open" (error/red). The color class
is derived from the shared `MembershipFeeHelpers.status_variant/1` mapping, so
the overview badge reads consistently with the member show page.
"""
@spec badge(non_neg_integer()) :: %{
variant: atom(),
color_class: String.t(),
icon: String.t(),
label: String.t(),
@ -172,8 +171,7 @@ defmodule MvWeb.MemberLive.Index.PaymentAging do
}
def badge(0) do
%{
variant: :success,
color_class: cycle_color_class(:paid),
color_class: status_badge_class(:paid),
icon: MembershipFeeHelpers.status_icon(:paid),
label: gettext("All paid"),
count: 0
@ -182,14 +180,23 @@ defmodule MvWeb.MemberLive.Index.PaymentAging do
def badge(count) when is_integer(count) and count > 0 do
%{
variant: MembershipFeeHelpers.status_variant(:unpaid),
color_class: cycle_color_class(:unpaid),
color_class: status_badge_class(:unpaid),
icon: MembershipFeeHelpers.status_icon(:unpaid),
label: gettext("%{count} open", count: count),
count: count
}
end
@doc """
DaisyUI badge color class for a cycle status, derived from the single shared
`MembershipFeeHelpers.status_variant/1` mapping so the overview badges, the
tooltip badges and the member show page all stay in lock-step. daisyUI emits
all `badge-*` component colors, so the interpolated class is always bundled.
"""
@spec status_badge_class(:paid | :unpaid | :suspended) :: String.t()
def status_badge_class(status),
do: "badge-#{MembershipFeeHelpers.status_variant(status)}"
@doc """
Compact short code for a payment period (§1.28), or nil when the period is not
compactly codeable (the header then falls back to a plain "filtered" badge).