Implement house points system: Add houseJoinPoints, houseLeavePoints, and houseCreatePoints to SitePreferences model and update related services. Enhance house management features to award and deduct points for house creation, membership removal, and leaving a house. Update environment configuration for PostgreSQL and adjust UI components to reflect new functionalities.
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,13 @@ import { prisma } from "../database";
|
||||
import { normalizeBackgroundUrl } from "@/lib/avatars";
|
||||
import type { SitePreferences } from "@/prisma/generated/prisma/client";
|
||||
|
||||
// Type étendu pour les préférences avec les nouveaux champs de points des maisons
|
||||
type SitePreferencesWithHousePoints = SitePreferences & {
|
||||
houseJoinPoints?: number;
|
||||
houseLeavePoints?: number;
|
||||
houseCreatePoints?: number;
|
||||
};
|
||||
|
||||
export interface UpdateSitePreferencesInput {
|
||||
homeBackground?: string | null;
|
||||
eventsBackground?: string | null;
|
||||
@@ -9,6 +16,9 @@ export interface UpdateSitePreferencesInput {
|
||||
challengesBackground?: string | null;
|
||||
eventRegistrationPoints?: number;
|
||||
eventFeedbackPoints?: number;
|
||||
houseJoinPoints?: number;
|
||||
houseLeavePoints?: number;
|
||||
houseCreatePoints?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +52,19 @@ export class SitePreferencesService {
|
||||
challengesBackground: null,
|
||||
eventRegistrationPoints: 100,
|
||||
eventFeedbackPoints: 100,
|
||||
houseJoinPoints: 100,
|
||||
houseLeavePoints: 100,
|
||||
houseCreatePoints: 100,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// S'assurer que les valeurs par défaut sont présentes même si les colonnes n'existent pas encore
|
||||
const prefs = sitePreferences as SitePreferencesWithHousePoints;
|
||||
if (prefs.houseJoinPoints == null) prefs.houseJoinPoints = 100;
|
||||
if (prefs.houseLeavePoints == null) prefs.houseLeavePoints = 100;
|
||||
if (prefs.houseCreatePoints == null) prefs.houseCreatePoints = 100;
|
||||
|
||||
return sitePreferences;
|
||||
}
|
||||
|
||||
@@ -82,6 +101,16 @@ export class SitePreferencesService {
|
||||
data.eventFeedbackPoints !== undefined
|
||||
? data.eventFeedbackPoints
|
||||
: undefined,
|
||||
houseJoinPoints:
|
||||
data.houseJoinPoints !== undefined ? data.houseJoinPoints : undefined,
|
||||
houseLeavePoints:
|
||||
data.houseLeavePoints !== undefined
|
||||
? data.houseLeavePoints
|
||||
: undefined,
|
||||
houseCreatePoints:
|
||||
data.houseCreatePoints !== undefined
|
||||
? data.houseCreatePoints
|
||||
: undefined,
|
||||
},
|
||||
create: {
|
||||
id: "global",
|
||||
@@ -99,6 +128,9 @@ export class SitePreferencesService {
|
||||
: (data.challengesBackground ?? null),
|
||||
eventRegistrationPoints: data.eventRegistrationPoints ?? 100,
|
||||
eventFeedbackPoints: data.eventFeedbackPoints ?? 100,
|
||||
houseJoinPoints: data.houseJoinPoints ?? 100,
|
||||
houseLeavePoints: data.houseLeavePoints ?? 100,
|
||||
houseCreatePoints: data.houseCreatePoints ?? 100,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user