Add profile and house background preferences to SitePreferences: Extend SitePreferences model and related services to include profileBackground and houseBackground fields. Update API and UI components to support new background settings, enhancing user customization options.

This commit is contained in:
Julien Froidefond
2025-12-22 08:54:51 +01:00
parent 14c767cfc0
commit 9bcafe54d3
18 changed files with 295 additions and 10 deletions

View File

@@ -14,6 +14,8 @@ export interface UpdateSitePreferencesInput {
eventsBackground?: string | null;
leaderboardBackground?: string | null;
challengesBackground?: string | null;
profileBackground?: string | null;
houseBackground?: string | null;
eventRegistrationPoints?: number;
eventFeedbackPoints?: number;
houseJoinPoints?: number;
@@ -50,6 +52,8 @@ export class SitePreferencesService {
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
profileBackground: null,
houseBackground: null,
eventRegistrationPoints: 100,
eventFeedbackPoints: 100,
houseJoinPoints: 100,
@@ -93,6 +97,14 @@ export class SitePreferencesService {
data.challengesBackground === ""
? null
: (data.challengesBackground ?? undefined),
profileBackground:
data.profileBackground === ""
? null
: (data.profileBackground ?? undefined),
houseBackground:
data.houseBackground === ""
? null
: (data.houseBackground ?? undefined),
eventRegistrationPoints:
data.eventRegistrationPoints !== undefined
? data.eventRegistrationPoints
@@ -126,6 +138,12 @@ export class SitePreferencesService {
data.challengesBackground === ""
? null
: (data.challengesBackground ?? null),
profileBackground:
data.profileBackground === ""
? null
: (data.profileBackground ?? null),
houseBackground:
data.houseBackground === "" ? null : (data.houseBackground ?? null),
eventRegistrationPoints: data.eventRegistrationPoints ?? 100,
eventFeedbackPoints: data.eventFeedbackPoints ?? 100,
houseJoinPoints: data.houseJoinPoints ?? 100,
@@ -139,7 +157,13 @@ export class SitePreferencesService {
* Récupère l'image de fond pour une page donnée
*/
async getBackgroundImage(
page: "home" | "events" | "leaderboard" | "challenges",
page:
| "home"
| "events"
| "leaderboard"
| "challenges"
| "profile"
| "houses",
defaultImage: string
): Promise<string> {
try {
@@ -151,7 +175,9 @@ export class SitePreferencesService {
return defaultImage;
}
const imageKey = `${page}Background` as keyof typeof sitePreferences;
// Mapping spécial pour "houses" -> "house" (car la colonne est houseBackground)
const dbPage = page === "houses" ? "house" : page;
const imageKey = `${dbPage}Background` as keyof typeof sitePreferences;
const customImage = sitePreferences[imageKey];
const imageUrl = (customImage as string | null) || defaultImage;