53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
/**
|
|
* UserStatusDisplay
|
|
*
|
|
* Deterministic mapping of user status codes to display labels and variants.
|
|
*/
|
|
|
|
export class UserStatusFormatter {
|
|
/**
|
|
* Maps user status to display label.
|
|
*/
|
|
static statusLabel(status: string): string {
|
|
const map: Record<string, string> = {
|
|
active: 'Active',
|
|
suspended: 'Suspended',
|
|
deleted: 'Deleted',
|
|
};
|
|
return map[status] || status;
|
|
}
|
|
|
|
/**
|
|
* Maps user status to badge variant.
|
|
*/
|
|
static statusVariant(status: string): string {
|
|
const map: Record<string, string> = {
|
|
active: 'performance-green',
|
|
suspended: 'yellow-500',
|
|
deleted: 'racing-red',
|
|
};
|
|
return map[status] || 'gray-500';
|
|
}
|
|
|
|
/**
|
|
* Determines if a user can be suspended.
|
|
*/
|
|
static canSuspend(status: string): boolean {
|
|
return status === 'active';
|
|
}
|
|
|
|
/**
|
|
* Determines if a user can be activated.
|
|
*/
|
|
static canActivate(status: string): boolean {
|
|
return status === 'suspended';
|
|
}
|
|
|
|
/**
|
|
* Determines if a user can be deleted.
|
|
*/
|
|
static canDelete(status: string): boolean {
|
|
return status !== 'deleted';
|
|
}
|
|
}
|