feat(abonnement): message 'changement à la prochaine échéance' sous les cards (#109)

Ajoute la fonction _change_hint et étend le callback _select_plan pour afficher
un hint "changement à la prochaine échéance" quand l'utilisateur sélectionne
un plan différent du plan courant.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-07-05 20:46:54 +02:00
parent 7ae5b75db9
commit e8f74aa529
2 changed files with 62 additions and 2 deletions
+23 -2
View File
@@ -85,18 +85,39 @@ def _selection_state(selected):
)
def _change_hint(selected: str, sub_info: dict | None) -> tuple[str, str]:
sub_info = sub_info or {}
current = sub_info.get("current_plan")
if (
not current
or sub_info.get("status") not in ("active", "trial")
or selected == current
):
return "d-none", ""
echeance = sub_info.get("echeance")
return (
"text-muted mt-2",
f"Le changement d'abonnement sera appliqué à la prochaine échéance : {echeance}.",
)
@callback(
Output("inf-plan-hidden", "value"),
Output("plan-card-simple", "className"),
Output("plan-card-soutien", "className"),
Output("inf-plan-invite", "className"),
Output("inf-change-hint", "className"),
Output("inf-change-hint", "children"),
Input("plan-card-simple", "n_clicks"),
Input("plan-card-soutien", "n_clicks"),
State("inf-sub-info", "data"),
prevent_initial_call=True,
)
def _select_plan(_n_simple, _n_soutien):
def _select_plan(_n_simple, _n_soutien, sub_info):
selected = "simple" if ctx.triggered_id == "plan-card-simple" else "soutien"
return _selection_state(selected)
value, cls_simple, cls_soutien, cls_invite = _selection_state(selected)
hint_cls, hint_txt = _change_hint(selected, sub_info)
return value, cls_simple, cls_soutien, cls_invite, hint_cls, hint_txt
def _legal_note():