/**
 * User roles - Frontend version
 * Content should match backend enum exactly
 * However, we cannot use a basic enum here as we're using erasableSyntaxOnly.
 */
export const UserRole = {
    USER: "user",
    ADMIN: "admin",
} as const;

// Create a type from the values
export type UserRole = typeof UserRole[keyof typeof UserRole];

/**
 * Helper functions for UserRole in frontend
 */
export const UserRoleHelper = {
    /**
     * Get display name for role (German)
     */
    getDisplayName(role: UserRole): string {
        const displayNames: Record<UserRole, string> = {
            [UserRole.USER]: "Benutzer",
            [UserRole.ADMIN]: "Administrator",
        };
        return displayNames[role];
    },

    /**
     * Get all roles with display names for dropdowns
     */
    getRoleOptions(): Array<{ value: UserRole; label: string }> {
        return Object.values(UserRole).map((role) => ({
            value: role,
            label: this.getDisplayName(role),
        }));
    },

    /**
     * Check if a string is a valid role
     */
    isValidRole(value: string): value is UserRole {
        return Object.values(UserRole).includes(value as UserRole);
    },

    /**
     * Get all role values
     */
    getAllRoles(): UserRole[] {
        return Object.values(UserRole);
    },
};