do to formatters
This commit is contained in:
52
apps/website/lib/formatters/UserStatusFormatter.ts
Normal file
52
apps/website/lib/formatters/UserStatusFormatter.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user