Files
gridpilot.gg/apps/website/lib/view-models/TeamJoinRequestViewModel.ts
Marc Mintel d97f50ed72
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 6m4s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-23 11:59:49 +01:00

67 lines
1.8 KiB
TypeScript

import type { TeamJoinRequestDTO } from '@/lib/types/generated/TeamJoinRequestDTO';
import { ViewModel } from "../contracts/view-models/ViewModel";
export class TeamJoinRequestViewModel extends ViewModel {
requestId: string;
driverId: string;
driverName: string;
teamId: string;
requestStatus: string;
requestedAt: string;
avatarUrl: string;
private readonly currentUserId: string;
private readonly isOwner: boolean;
constructor(dto: TeamJoinRequestDTO, currentUserId: string, isOwner: boolean) {
this.requestId = dto.requestId;
this.driverId = dto.driverId;
this.driverName = dto.driverName;
this.teamId = dto.teamId;
this.requestStatus = dto.status;
this.requestedAt = dto.requestedAt;
this.avatarUrl = dto.avatarUrl || '';
this.currentUserId = currentUserId;
this.isOwner = isOwner;
}
get id(): string {
return this.requestId;
}
get status(): string {
if (this.requestStatus === 'pending') return 'Pending';
if (this.requestStatus === 'approved') return 'Approved';
if (this.requestStatus === 'rejected') return 'Rejected';
return this.requestStatus;
}
/** UI-specific: Whether current user can approve */
get canApprove(): boolean {
return this.isOwner;
}
/** UI-specific: Formatted requested date */
get formattedRequestedAt(): string {
return new Date(this.requestedAt).toLocaleString();
}
/** UI-specific: Status color */
get statusColor(): string {
if (this.requestStatus === 'approved') return 'green';
if (this.requestStatus === 'rejected') return 'red';
return 'yellow';
}
/** UI-specific: Approve button text */
get approveButtonText(): string {
return 'Approve';
}
/** UI-specific: Reject button text */
get rejectButtonText(): string {
return 'Reject';
}
}