Add interactive citizen page with sidebar, display settings, and adaptive CSS
Major rework of the citizen-facing page: - Chart + sidebar layout (auth/vote/countdown in right sidebar) - DisplaySettings component (font size, chart density, color palettes) - Adaptive CSS with clamp() throughout, responsive breakpoints at 480/768/1024 - Baseline charts zoomed on first tier for small consumption detail - Marginal price chart with dual Y-axes (foyers left, €/m³ right) - Key metrics banner (5 columns: recettes, palier, prix palier, prix médian, mon prix) - Client-side p0/impacts computation, draggable median price bar - Household dots toggle, vote overlay curves - Auth returns volume_m3, vote captures submitted_at - Cleaned header nav (removed Accueil/Super Admin for public visitors) - Terminology: foyer for bills, électeur for votes - 600m³ added to impact reference volumes - Realistic seed votes (50 votes, 3 profiles) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -103,29 +103,47 @@ async def current_curve(slug: str, db: AsyncSession = Depends(get_db)):
|
||||
)
|
||||
votes = result.scalars().all()
|
||||
|
||||
# Published curve from admin (if any)
|
||||
published = None
|
||||
if params.published_vinf is not None:
|
||||
published = {
|
||||
"vinf": params.published_vinf,
|
||||
"a": params.published_a,
|
||||
"b": params.published_b,
|
||||
"c": params.published_c,
|
||||
"d": params.published_d,
|
||||
"e": params.published_e,
|
||||
"p0": params.published_p0,
|
||||
}
|
||||
|
||||
if not votes:
|
||||
# Return default Bézier curve (a=b=c=d=e=0.5, vinf=vmax/2)
|
||||
default_vinf = params.vmax / 2
|
||||
# Use published curve if available, otherwise default
|
||||
if published:
|
||||
dv, da, db_, dc, dd, de = published["vinf"], published["a"], published["b"], published["c"], published["d"], published["e"]
|
||||
else:
|
||||
dv, da, db_, dc, dd, de = 400, 0.5, 0.5, 0.5, 0.5, 0.5
|
||||
|
||||
default_tariff = compute_tariff(
|
||||
households,
|
||||
recettes=params.recettes, abop=params.abop, abos=params.abos,
|
||||
vinf=default_vinf, vmax=params.vmax, pmax=params.pmax,
|
||||
a=0.5, b=0.5, c=0.5, d=0.5, e=0.5,
|
||||
vinf=dv, vmax=params.vmax, pmax=params.pmax,
|
||||
a=da, b=db_, c=dc, d=dd, e=de,
|
||||
)
|
||||
_, default_impacts = compute_impacts(
|
||||
households,
|
||||
recettes=params.recettes, abop=params.abop, abos=params.abos,
|
||||
vinf=default_vinf, vmax=params.vmax, pmax=params.pmax,
|
||||
a=0.5, b=0.5, c=0.5, d=0.5, e=0.5,
|
||||
vinf=dv, vmax=params.vmax, pmax=params.pmax,
|
||||
a=da, b=db_, c=dc, d=dd, e=de,
|
||||
)
|
||||
|
||||
return {
|
||||
"has_votes": False,
|
||||
"vote_count": 0,
|
||||
"params": tariff_params,
|
||||
"published": published,
|
||||
"median": {
|
||||
"vinf": default_vinf, "a": 0.5, "b": 0.5,
|
||||
"c": 0.5, "d": 0.5, "e": 0.5,
|
||||
"vinf": dv, "a": da, "b": db_,
|
||||
"c": dc, "d": dd, "e": de,
|
||||
},
|
||||
"p0": default_tariff.p0,
|
||||
"curve_volumes": default_tariff.curve_volumes,
|
||||
@@ -166,6 +184,7 @@ async def current_curve(slug: str, db: AsyncSession = Depends(get_db)):
|
||||
"has_votes": True,
|
||||
"vote_count": len(votes),
|
||||
"params": tariff_params,
|
||||
"published": published,
|
||||
"median": {
|
||||
"vinf": median.vinf,
|
||||
"a": median.a,
|
||||
|
||||
Reference in New Issue
Block a user