import type { TeamJoinRequestDTO } from '@/lib/types/generated/TeamJoinRequestDTO'; export class TeamJoinRequestViewModel { 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'; } }