{# SAM User Card Component - Card displaying user info with avatar and optional progress Parameters: - user: object (required) - User data with fullname, email, etc. - progress: number - Optional completion percentage (0-100) - showRemoveButton: bool - Show remove/delete button - cohorts: array - Optional list of cohort names - url: string - Link to user detail page - compact: bool - Compact display mode - showEmail: bool - Show email (default: true) - inactiveDays: number - Days of inactivity (shows warning) Usage: {% include 'sam/_components/user_card.html.twig' with { user: {fullname: 'John Doe', email: 'john@example.com'}, progress: 75, url: path('app_sam_users_detail', {id: user.id}) } %} #} {% set userName = user.fullname|default(user.firstname ~ ' ' ~ user.lastname)|default('Utilisateur') %} {% set userInitials = userName|split(' ')|map(w => w|slice(0, 1))|slice(0, 2)|join('')|upper %} {% set userEmail = user.email|default('') %} {% set isCompact = compact|default(false) %} {% set isSuspended = user.suspended|default(false) %} {% set cardClasses = ['sam-user-card'] %} {% if isCompact %} {% set cardClasses = cardClasses|merge(['sam-user-card--compact']) %} {% endif %} {% if url is defined and url %} {% set cardClasses = cardClasses|merge(['sam-user-card--clickable']) %} {% endif %} {% if isSuspended %} {% set cardClasses = cardClasses|merge(['sam-user-card--suspended']) %} {% endif %} {% set tag = url is defined and url ? 'a' : 'div' %} <{{ tag }}{% if url is defined and url %} href="{{ url }}"{% endif %} class="{{ cardClasses|join(' ') }}"> {# Avatar #} {% include 'sam/_components/avatar.html.twig' with { type: 'user', initials: userInitials, size: isCompact ? 'sm' : 'md', suspended: isSuspended } %} {# User info #}
{{ userName }} {% if isSuspended %} {% include 'sam/_components/badge.html.twig' with {text: 'Inactif', type: 'danger', size: 'sm'} %} {% endif %}
{% if showEmail|default(true) and userEmail %}
{{ userEmail }}
{% endif %} {# Cohorts #} {% if cohorts is defined and cohorts|length > 0 %}
{% for cohort in cohorts|slice(0, 2) %} {% include 'sam/_components/entity_tag.html.twig' with {text: cohort, type: 'cohort', size: 'sm', truncate: 15} %} {% endfor %} {% if cohorts|length > 2 %} +{{ cohorts|length - 2 }} {% endif %}
{% endif %} {# Inactivity warning #} {% if inactiveDays is defined and inactiveDays > 0 %}
{% include 'sam/_components/icon.html.twig' with {name: 'clock', size: 12} %} Inactif depuis {{ inactiveDays }} jour{{ inactiveDays > 1 ? 's' : '' }}
{% endif %}
{# Progress #} {% if progress is defined %}
{% include 'sam/_components/progress_ring.html.twig' with { value: progress, size: isCompact ? 36 : 44, strokeWidth: 3 } %}
{% endif %} {# Remove button #} {% if showRemoveButton|default(false) %} {% endif %} {# Arrow for clickable cards #} {% if url is defined and url %}
{% include 'sam/_components/icon.html.twig' with {name: 'chevron-right', size: 16} %}
{% endif %}