41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
/**
|
|
* Activity Item View Model
|
|
*
|
|
* View model for recent activity items.
|
|
*
|
|
* Accepts ActivityItemViewData as input and produces UI-ready data.
|
|
*/
|
|
import { ActivityItemViewData } from "../view-data/ActivityItemViewData";
|
|
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
|
|
export class ActivityItemViewModel extends ViewModel {
|
|
readonly id: string;
|
|
readonly type: string;
|
|
readonly message: string;
|
|
readonly time: string;
|
|
readonly impressions?: number;
|
|
|
|
constructor(viewData: ActivityItemViewData) {
|
|
super();
|
|
this.id = viewData.id;
|
|
this.type = viewData.type;
|
|
this.message = viewData.message;
|
|
this.time = viewData.time;
|
|
this.impressions = viewData.impressions;
|
|
}
|
|
|
|
get typeColor(): string {
|
|
const colors: Record<string, string> = {
|
|
race: 'bg-warning-amber',
|
|
league: 'bg-primary-blue',
|
|
team: 'bg-purple-400',
|
|
driver: 'bg-performance-green',
|
|
platform: 'bg-racing-red',
|
|
};
|
|
return colors[this.type] || 'bg-gray-500';
|
|
}
|
|
|
|
get formattedImpressions(): string | null {
|
|
return this.impressions ? this.impressions.toLocaleString() : null;
|
|
}
|
|
} |