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

@@ -17,7 +17,7 @@ export interface LiveryTemplateProps {
baseImageUrl: string;
adminDecals: LiveryDecal[];
createdAt: Date;
updatedAt?: Date;
updatedAt: Date | undefined;
}
export class LiveryTemplate implements IEntity<string> {
@@ -28,7 +28,7 @@ export class LiveryTemplate implements IEntity<string> {
readonly baseImageUrl: string;
readonly adminDecals: LiveryDecal[];
readonly createdAt: Date;
readonly updatedAt?: Date;
readonly updatedAt: Date | undefined;
private constructor(props: LiveryTemplateProps) {
this.id = props.id;
@@ -37,7 +37,7 @@ export class LiveryTemplate implements IEntity<string> {
this.carId = props.carId;
this.baseImageUrl = props.baseImageUrl;
this.adminDecals = props.adminDecals;
this.createdAt = props.createdAt;
this.createdAt = props.createdAt ?? new Date();
this.updatedAt = props.updatedAt;
}
@@ -113,9 +113,9 @@ export class LiveryTemplate implements IEntity<string> {
*/
updateDecal(decalId: string, updatedDecal: LiveryDecal): LiveryTemplate {
const index = this.adminDecals.findIndex(d => d.id === decalId);
if (index === -1) {
throw new RacingDomainError('Decal not found in template');
throw new RacingDomainValidationError('Decal not found in template');
}
const updatedDecals = [...this.adminDecals];