Add display_name support for users in backend and frontend

This commit introduces the `display_name` field to the user model. It updates database migrations, API endpoints, and the admin panel to handle this field. Additionally, the `display_name` is now shown in the TopBar and WinnerBadge components, improving user experience.
This commit is contained in:
2026-02-06 12:09:21 +01:00
parent 4a012b7345
commit 3a66c0cf74
7 changed files with 140 additions and 26 deletions

View File

@@ -1,8 +1,26 @@
import React from "react";
import { stylesTokens } from "../styles/theme";
export default function WinnerBadge({ winnerEmail }) {
if (!winnerEmail) return null;
/**
* Props:
* - winner: { display_name?: string, email?: string } | null
* (oder als Fallback:)
* - winnerEmail: string | null
*/
export default function WinnerBadge({ winner, winnerEmail }) {
const name =
(winner?.display_name || "").trim() ||
(winner?.email || "").trim() ||
(winnerEmail || "").trim();
if (!name) return null;
// Optional: wenn display_name vorhanden ist, Email klein anzeigen
const showEmail =
winner &&
(winner?.email || "").trim() &&
(winner?.display_name || "").trim() &&
winner.email.trim().toLowerCase() !== winner.display_name.trim().toLowerCase();
return (
<div
@@ -22,9 +40,18 @@ export default function WinnerBadge({ winnerEmail }) {
>
<div style={{ display: "flex", alignItems: "center", gap: 10 }}>
<div style={{ fontSize: 18 }}>🏆</div>
<div style={{ color: stylesTokens.textMain, fontWeight: 900 }}>
Sieger:
<span style={{ color: stylesTokens.textGold }}>{" "}{winnerEmail}</span>
<div style={{ display: "grid", gap: 2 }}>
<div style={{ color: stylesTokens.textMain, fontWeight: 900 }}>
Sieger:
<span style={{ color: stylesTokens.textGold }}>{" "}{name}</span>
</div>
{showEmail && (
<div style={{ fontSize: 12, opacity: 0.8, color: stylesTokens.textDim }}>
{winner.email}
</div>
)}
</div>
</div>