58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import { DateDisplay } from "../display-objects/DateDisplay";
|
|
import type { TeamJoinRequestViewData } from "../view-data/TeamJoinRequestViewData";
|
|
|
|
export class TeamJoinRequestViewModel extends ViewModel {
|
|
private readonly data: TeamJoinRequestViewData;
|
|
|
|
constructor(data: TeamJoinRequestViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get id(): string { return this.data.requestId; }
|
|
get requestId(): string { return this.data.requestId; }
|
|
get driverId(): string { return this.data.driverId; }
|
|
get driverName(): string { return this.data.driverName; }
|
|
get teamId(): string { return this.data.teamId; }
|
|
get requestStatus(): string { return this.data.status; }
|
|
get requestedAt(): string { return this.data.requestedAt; }
|
|
get avatarUrl(): string { return this.data.avatarUrl || ''; }
|
|
get currentUserId(): string { return this.data.currentUserId; }
|
|
get isOwner(): boolean { return this.data.isOwner; }
|
|
|
|
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 DateDisplay.formatDateTime(this.requestedAt);
|
|
}
|
|
|
|
/** 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';
|
|
}
|
|
}
|