view models
This commit is contained in:
@@ -6,11 +6,10 @@ import { CompleteOnboardingOutputDTO } from '../types/generated/CompleteOnboardi
|
||||
*/
|
||||
export class CompleteOnboardingViewModel implements CompleteOnboardingOutputDTO {
|
||||
success: boolean;
|
||||
driverId: string;
|
||||
driverId?: string;
|
||||
|
||||
constructor(dto: CompleteOnboardingOutputDTO & { driverId: string }) {
|
||||
constructor(dto: CompleteOnboardingOutputDTO) {
|
||||
this.success = dto.success;
|
||||
this.driverId = dto.driverId;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether onboarding was successful */
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Record engagement input view model
|
||||
* Represents input data for recording an engagement event
|
||||
*
|
||||
* Note: No matching generated DTO available yet
|
||||
*/
|
||||
export class RecordEngagementInputViewModel {
|
||||
eventType: string;
|
||||
userId?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
|
||||
constructor(data: { eventType: string; userId?: string; metadata?: Record<string, unknown> }) {
|
||||
this.eventType = data.eventType;
|
||||
this.userId = data.userId;
|
||||
this.metadata = data.metadata;
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted event type for display */
|
||||
get displayEventType(): string {
|
||||
return this.eventType.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
||||
}
|
||||
|
||||
/** UI-specific: Has metadata */
|
||||
get hasMetadata(): boolean {
|
||||
return this.metadata !== undefined && Object.keys(this.metadata).length > 0;
|
||||
}
|
||||
|
||||
/** UI-specific: Metadata keys count */
|
||||
get metadataKeysCount(): number {
|
||||
return this.metadata ? Object.keys(this.metadata).length : 0;
|
||||
}
|
||||
}
|
||||
25
apps/website/lib/view-models/RecordPageViewInputViewModel.ts
Normal file
25
apps/website/lib/view-models/RecordPageViewInputViewModel.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Record page view input view model
|
||||
* Represents input data for recording a page view
|
||||
*
|
||||
* Note: No matching generated DTO available yet
|
||||
*/
|
||||
export class RecordPageViewInputViewModel {
|
||||
path: string;
|
||||
userId?: string;
|
||||
|
||||
constructor(data: { path: string; userId?: string }) {
|
||||
this.path = data.path;
|
||||
this.userId = data.userId;
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted path for display */
|
||||
get displayPath(): string {
|
||||
return this.path.startsWith('/') ? this.path : `/${this.path}`;
|
||||
}
|
||||
|
||||
/** UI-specific: Has user context */
|
||||
get hasUserContext(): boolean {
|
||||
return this.userId !== undefined && this.userId !== '';
|
||||
}
|
||||
}
|
||||
48
apps/website/lib/view-models/index.ts
Normal file
48
apps/website/lib/view-models/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* View Models Index
|
||||
*
|
||||
* Central export file for all view models.
|
||||
* View models represent fully prepared UI state and should only be consumed by UI components.
|
||||
*/
|
||||
|
||||
export { AnalyticsDashboardViewModel } from './AnalyticsDashboardViewModel';
|
||||
export { AnalyticsMetricsViewModel } from './AnalyticsMetricsViewModel';
|
||||
export { AvatarViewModel } from './AvatarViewModel';
|
||||
export { CompleteOnboardingViewModel } from './CompleteOnboardingViewModel';
|
||||
export { DeleteMediaViewModel } from './DeleteMediaViewModel';
|
||||
export { DriverLeaderboardItemViewModel } from './DriverLeaderboardItemViewModel';
|
||||
export { DriverLeaderboardViewModel } from './DriverLeaderboardViewModel';
|
||||
export { DriverRegistrationStatusViewModel } from './DriverRegistrationStatusViewModel';
|
||||
export { DriverViewModel } from './DriverViewModel';
|
||||
export { LeagueAdminViewModel } from './LeagueAdminViewModel';
|
||||
export { LeagueJoinRequestViewModel } from './LeagueJoinRequestViewModel';
|
||||
export { LeagueMemberViewModel } from './LeagueMemberViewModel';
|
||||
export { LeagueStandingsViewModel } from './LeagueStandingsViewModel';
|
||||
export { LeagueSummaryViewModel } from './LeagueSummaryViewModel';
|
||||
export { MediaViewModel } from './MediaViewModel';
|
||||
export { MembershipFeeViewModel } from './MembershipFeeViewModel';
|
||||
export { PaymentViewModel } from './PaymentViewModel';
|
||||
export { PrizeViewModel } from './PrizeViewModel';
|
||||
export { ProtestViewModel } from './ProtestViewModel';
|
||||
export { RaceDetailViewModel } from './RaceDetailViewModel';
|
||||
export { RaceListItemViewModel } from './RaceListItemViewModel';
|
||||
export { RaceResultsDetailViewModel } from './RaceResultsDetailViewModel';
|
||||
export { RaceResultViewModel } from './RaceResultViewModel';
|
||||
export { RacesPageViewModel } from './RacesPageViewModel';
|
||||
export { RequestAvatarGenerationViewModel } from './RequestAvatarGenerationViewModel';
|
||||
export { SessionViewModel } from './SessionViewModel';
|
||||
export { SponsorDashboardViewModel } from './SponsorDashboardViewModel';
|
||||
export { SponsorshipDetailViewModel } from './SponsorshipDetailViewModel';
|
||||
export { SponsorshipPricingViewModel } from './SponsorshipPricingViewModel';
|
||||
export { SponsorSponsorshipsViewModel } from './SponsorSponsorshipsViewModel';
|
||||
export { SponsorViewModel } from './SponsorViewModel';
|
||||
export { StandingEntryViewModel } from './StandingEntryViewModel';
|
||||
export { TeamDetailsViewModel } from './TeamDetailsViewModel';
|
||||
export { TeamJoinRequestViewModel } from './TeamJoinRequestViewModel';
|
||||
export { TeamMemberViewModel } from './TeamMemberViewModel';
|
||||
export { TeamSummaryViewModel } from './TeamSummaryViewModel';
|
||||
export { UpdateAvatarViewModel } from './UpdateAvatarViewModel';
|
||||
export { UploadMediaViewModel } from './UploadMediaViewModel';
|
||||
export { UserProfileViewModel } from './UserProfileViewModel';
|
||||
export { WalletTransactionViewModel } from './WalletTransactionViewModel';
|
||||
export { WalletViewModel } from './WalletViewModel';
|
||||
Reference in New Issue
Block a user