This commit is contained in:
2025-12-12 14:23:40 +01:00
parent 6a88fe93ab
commit 2cd3bfbb47
58 changed files with 2866 additions and 260 deletions

View File

@@ -38,7 +38,7 @@ export class Achievement implements IEntity<string> {
readonly description: string;
readonly category: AchievementCategory;
readonly rarity: AchievementRarity;
readonly iconUrl?: string;
readonly iconUrl: string;
readonly points: number;
readonly requirements: AchievementRequirement[];
readonly isSecret: boolean;
@@ -50,7 +50,7 @@ export class Achievement implements IEntity<string> {
this.description = props.description;
this.category = props.category;
this.rarity = props.rarity;
this.iconUrl = props.iconUrl;
this.iconUrl = props.iconUrl ?? '';
this.points = props.points;
this.requirements = props.requirements;
this.isSecret = props.isSecret;

View File

@@ -16,7 +16,7 @@ export interface SponsorAccountProps {
passwordHash: string;
companyName: string;
isActive: boolean;
createdAt: Date;
createdAt?: Date;
lastLoginAt?: Date;
}
@@ -37,7 +37,7 @@ export class SponsorAccount {
this.passwordHash = props.passwordHash;
this.companyName = props.companyName;
this.isActive = props.isActive;
this.createdAt = props.createdAt;
this.createdAt = props.createdAt ?? new Date();
this.lastLoginAt = props.lastLoginAt;
}
@@ -128,7 +128,7 @@ export class SponsorAccount {
companyName: this.companyName,
isActive: false,
createdAt: this.createdAt,
lastLoginAt: this.lastLoginAt,
...(this.lastLoginAt ? { lastLoginAt: this.lastLoginAt } : {}),
});
}
@@ -145,7 +145,7 @@ export class SponsorAccount {
companyName: this.companyName,
isActive: this.isActive,
createdAt: this.createdAt,
lastLoginAt: this.lastLoginAt,
...(this.lastLoginAt ? { lastLoginAt: this.lastLoginAt } : {}),
});
}
}

View File

@@ -14,10 +14,10 @@ export interface UserProps {
export class User {
private readonly id: UserId;
private displayName: string;
private email?: string;
private iracingCustomerId?: string;
private primaryDriverId?: string;
private avatarUrl?: string;
private email: string | undefined;
private iracingCustomerId: string | undefined;
private primaryDriverId: string | undefined;
private avatarUrl: string | undefined;
private constructor(props: UserProps) {
if (!props.displayName || !props.displayName.trim()) {

View File

@@ -20,7 +20,7 @@ export class UserAchievement implements IEntity<string> {
readonly userId: string;
readonly achievementId: string;
readonly earnedAt: Date;
readonly notifiedAt?: Date;
readonly notifiedAt: Date | undefined;
readonly progress: number;
private constructor(props: UserAchievementProps) {
@@ -53,8 +53,12 @@ export class UserAchievement implements IEntity<string> {
*/
markNotified(): UserAchievement {
return new UserAchievement({
...this,
id: this.id,
userId: this.userId,
achievementId: this.achievementId,
earnedAt: this.earnedAt,
notifiedAt: new Date(),
progress: this.progress,
});
}
@@ -64,7 +68,11 @@ export class UserAchievement implements IEntity<string> {
updateProgress(progress: number): UserAchievement {
const clampedProgress = Math.max(0, Math.min(100, progress));
return new UserAchievement({
...this,
id: this.id,
userId: this.userId,
achievementId: this.achievementId,
earnedAt: this.earnedAt,
...(this.notifiedAt ? { notifiedAt: this.notifiedAt } : {}),
progress: clampedProgress,
});
}