{# @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 %}Nouvel utilisateur - {{ isAdmin|default(true) ? 'Admin' : 'Mon entreprise' }}{% 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: 'Nouvel utilisateur' } ] } only %}
{% include '_atoms/icon/icon.html.twig' with { name: 'user-plus', size: 'lg', color: 'success' } only %}

Nouvel utilisateur

Créez un compte pour un nouveau membre

{# ================================================================ 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 -------------------------------------------------------- #}

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

{% if form.company is defined %} {# Admin : peut choisir l'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 sera automatiquement rattaché à l'entreprise sélectionnée et aura accès à ses tokens.

{% elseif managerCompany is defined %} {# Manager : entreprise fixe #}
{% include '_atoms/avatar/avatar.html.twig' with { name: managerCompany.name, size: 'md' } only %}
{{ managerCompany.name }} L'utilisateur sera rattaché à votre 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

{% set roleCount = form.role.children|length %}
{% 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) }} {% do form.role.setRendered() %} {# Taux de commission : visible uniquement pour le rôle Commercial #}
{# -------------------------------------------------------- ACTIONS -------------------------------------------------------- #}
{% include '_atoms/button/button.html.twig' with { label: 'Annuler', variant: 'ghost', size: 'lg', href: path('admin_user_list') } only %} {% include '_atoms/button/button.html.twig' with { label: 'Créer l\'utilisateur', variant: 'primary', size: 'lg', type: 'submit' } only %}
{{ form_end(form) }}
{% endblock %}