{# @tailwind-safelist bg-primary/10 bg-cohorts/10 bg-warning/10 bg-error/10 bg-success/10 bg-info/10 bg-pink/10 #} {% extends 'base.html.twig' %} {% block title %}Modifier {{ user.fullName }} - {{ isAdmin|default(true) ? 'Admin' : 'Gestion' }}{% endblock %} {% block body %}
{# ================================================================ HEADER ================================================================ #}
{% include '_molecules/breadcrumb/breadcrumb.html.twig' with { items: [ { label: 'Dashboard', href: path('app_dashboard') }, { label: 'Utilisateurs', href: path('admin_user_list') }, { label: user.fullName, href: path('admin_user_show', {uuid: user.uuid}) }, { label: 'Modifier' } ] } only %}
{% include '_atoms/icon/icon.html.twig' with { name: 'edit', size: 'lg', color: 'warning' } only %}

Modifier l'utilisateur

{{ user.fullName }} ({{ user.email }})

{# ================================================================ FORMULAIRE ================================================================ #} {{ form_start(form, {'attr': {'class': 'space-y-8'}}) }} {# -------------------------------------------------------- INFORMATIONS PERSONNELLES -------------------------------------------------------- #}

{% include '_atoms/icon/icon.html.twig' with { name: 'user', size: 'sm', color: 'primary' } only %} Informations personnelles

{# Email #}
{{ form_label(form.email, null, {'label_attr': {'class': 'block text-sm font-medium text-gray-700'}}) }} {{ form_widget(form.email, {'attr': { 'class': 'w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors', 'placeholder': 'exemple@domaine.com' }}) }} {{ form_errors(form.email) }}
{# Prénom / Nom #}
{{ form_label(form.firstName, null, {'label_attr': {'class': 'block text-sm font-medium text-gray-700'}}) }} {{ form_widget(form.firstName, {'attr': { 'class': 'w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors', 'placeholder': 'Prénom' }}) }} {{ form_errors(form.firstName) }}
{{ form_label(form.lastName, null, {'label_attr': {'class': 'block text-sm font-medium text-gray-700'}}) }} {{ form_widget(form.lastName, {'attr': { 'class': 'w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors', 'placeholder': 'Nom de famille' }}) }} {{ form_errors(form.lastName) }}
{# -------------------------------------------------------- ENTREPRISE (admin uniquement) -------------------------------------------------------- #} {% if form.company is defined %}

{% include '_atoms/icon/icon.html.twig' with { name: 'buildings', size: 'sm', color: 'primary' } only %} Entreprise

{{ form_widget(form.company, {'attr': { 'class': 'w-full px-4 py-2.5 border border-gray-200 rounded-lg bg-white focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors' }}) }} {{ form_errors(form.company) }}

L'utilisateur aura accès aux tokens de cette entreprise.

{% endif %} {# -------------------------------------------------------- RÔLE -------------------------------------------------------- #} {% set roleStyles = { 'ROLE_USER': { label: 'Utilisateur', desc: 'Accès standard aux outils', icon: 'user', iconColor: 'primary', borderColor: '#0C81E4', bgColor: 'rgba(12, 129, 228, 0.05)', iconBg: 'rgba(12, 129, 228, 0.1)' }, 'ROLE_COMPANY_MANAGER': { label: 'Gestionnaire', desc: 'Gère les utilisateurs de son entreprise', icon: 'buildings', iconColor: 'info', borderColor: '#3B82F6', bgColor: 'rgba(59, 130, 246, 0.05)', iconBg: 'rgba(59, 130, 246, 0.1)' }, 'ROLE_COMMERCIAL': { label: 'Commercial', desc: 'Apporteur d\'affaires rémunéré à la commission', icon: 'wallet', iconColor: 'warning', borderColor: '#F59E0B', bgColor: 'rgba(245, 158, 11, 0.05)', iconBg: 'rgba(245, 158, 11, 0.1)' }, 'ROLE_ADMIN': { label: 'Administrateur', desc: 'Accès complet à la plateforme', icon: 'settings', iconColor: 'error', borderColor: '#EF4444', bgColor: 'rgba(239, 68, 68, 0.05)', iconBg: 'rgba(239, 68, 68, 0.1)' } } %}

{% include '_atoms/icon/icon.html.twig' with { name: 'shield', size: 'sm', color: 'primary' } only %} Rôle

{% if isSelfEdit|default(false) %}
{% include '_atoms/icon/icon.html.twig' with { name: 'info', size: 'sm', color: 'warning' } only %}

Vous ne pouvez pas modifier votre propre rôle.

{% endif %}
{% for child in form.role %} {% set roleValue = child.vars.value %} {% set style = roleStyles[roleValue]|default(roleStyles['ROLE_USER']) %} {% set isChecked = child.vars.checked|default(false) %}
{% include '_atoms/icon/icon.html.twig' with { name: style.icon, size: 'lg', color: style.iconColor } only %}
{{ style.label }} {{ style.desc }}
{% endfor %}
{{ form_errors(form.role) }} {# Marquer le champ comme rendu pour éviter le doublon via form_end #} {% do form.role.setRendered() %} {# Taux de commission : visible uniquement pour le rôle Commercial. Sans effet si l'utilisateur a déjà un profil Commercial (le taux existant n'est pas modifié par cet écran). #}
{# -------------------------------------------------------- ACTIONS -------------------------------------------------------- #}
{% include '_atoms/button/button.html.twig' with { label: 'Annuler', variant: 'ghost', size: 'lg', href: path('admin_user_show', {uuid: user.uuid}) } only %} {% include '_atoms/button/button.html.twig' with { label: 'Enregistrer', variant: 'primary', size: 'lg', type: 'submit' } only %}
{{ form_end(form) }}
{% endblock %}