profile ++

This commit is contained in:
allavenavr 2024-12-05 17:09:07 +01:00
parent 1aa98ce338
commit 4af5d73497
9 changed files with 242 additions and 113 deletions

View File

@ -2,7 +2,11 @@
namespace App\Controller;
use App\Entity\UserApp;
use App\Form\UserAppType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@ -23,6 +27,24 @@ class ProfileController extends AbstractController
'user' => $user,
]);
}
#[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(UserAppType::class, $userApp);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER);
}
return $this->render('profile/edit.html.twig', [
'user_app' => $userApp,
'form' => $form,
]);
}
}

View File

@ -14,7 +14,7 @@ use Symfony\Component\Routing\Attribute\Route;
#[Route('/user')]
final class UserAppController extends AbstractController
{
#[Route(name: 'app_user_app_index', methods: ['GET'])]
#[Route(name: 'app_user_index', methods: ['GET'])]
public function index(UserRepository $userRepository): Response
{
return $this->render('user_app/index.html.twig', [
@ -22,7 +22,7 @@ final class UserAppController extends AbstractController
]);
}
#[Route('/{id}', name: 'app_user_app_show', methods: ['GET'])]
#[Route('/{id}', name: 'app_user_show', methods: ['GET'])]
public function show(UserApp $userApp): Response
{
return $this->render('user_app/show.html.twig', [
@ -30,7 +30,7 @@ final class UserAppController extends AbstractController
]);
}
#[Route('/{id}/edit', name: 'app_user_app_edit', methods: ['GET', 'POST'])]
#[Route('/{id}/edit', name: 'app_user_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(UserAppType::class, $userApp);
@ -39,7 +39,7 @@ final class UserAppController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER);
return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
}
return $this->render('user_app/edit.html.twig', [
@ -48,7 +48,7 @@ final class UserAppController extends AbstractController
]);
}
#[Route('/{id}', name: 'app_user_app_delete', methods: ['POST'])]
#[Route('/{id}', name: 'app_user_delete', methods: ['POST'])]
public function delete(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$userApp->getId(), $request->getPayload()->getString('_token'))) {
@ -56,6 +56,6 @@ final class UserAppController extends AbstractController
$entityManager->flush();
}
return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER);
return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@ -13,7 +13,6 @@ class UserAppType extends AbstractType
{
$builder
->add('nickname')
->add('roles')
->add('password')
->add('firstName')
->add('lastName')

View File

@ -31,10 +31,13 @@
<a class="hover:text-teal-400" href="{{ path('app_index') }}">FAQ</a>
<a class="hover:text-teal-400" href="{{ path('app_index') }}">Messagerie</a>
</nav>
<div>
<div class="flex space-x-4">
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full" href="{{ path('app_profile') }}">
Profil
</a>
<a class="bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-full" href="{{ path('app_logout') }}">
Déconnexion
</a>
</div>
</div>
</header>
@ -68,14 +71,8 @@
<h3 class="text-white text-lg font-bold mb-4">Contactez-nous</h3>
<p>Email: support@hegresphere.com</p>
<p>Téléphone: +33 1 23 45 67 89</p>
<a href="{{ path('app_logout') }}" class="block mt-4 bg-red-500 hover:bg-red-600 text-white text-center py-2 px-4 rounded-full">
Déconnexion
</a>
</div>
</div>
<div class="text-center py-4 border-t border-gray-700">
<p class="text-sm">© 2024 HegreSphere. Tous droits réservés.</p>
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,32 @@
{% extends 'base.html.twig' %}
{% block title %}Modifier l'utilisateur{% endblock %}
{% block body %}
<div class="container mx-auto p-6">
<h1 class="text-4xl font-semibold text-gray-800 mb-6">Modifier l'utilisateur</h1>
<div class="bg-white shadow-md rounded-lg p-6">
{{ form_start(form) }}
<div class="space-y-6">
{{ form_row(form.nickname, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.firstName, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.lastName, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.tel, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.address, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.mail, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.password, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
</div>
<div class="mt-6">
{{ form_widget(form) }}
</div>
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white px-6 py-3 rounded-lg mt-4">
Mettre à jour
</button>
{{ form_end(form) }}
</div>
</div>
{% endblock %}

View File

@ -1,14 +1,45 @@
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-semibold mb-4">Bonjour {{ app.user.firstName }} {{ app.user.lastName }}</h2>
<h2 class="text-xl font-semibold mb-4">Bonjour {{ app.user.nickname }}</h2>
<p class="text-gray-700">Vous êtes à la recherche d'un stage.</p>
<br>
<p class="text-gray-600">Nom : {{ app.user.firstName }}</p>
<p class="text-gray-600">Prénom : {{ app.user.lastName }}</p>
<p class="text-gray-600">Adresse : {{ app.user.address }}</p>
<p class="text-gray-600">Téléphone : {{ app.user.tel }}</p>
<p class="text-gray-600">Email : {{ app.user.mail }}</p>
<h3 class="text-lg font-semibold mt-6">Vos diplômes :</h3>
<ul class="list-disc list-inside text-gray-800">
{% if app.user.degrees|length > 0 %}
{% for deg in app.user.degrees %}
<li>{{ deg.label }}</li>
{% endfor %}
{% else %}
<br>
Aucun pour le moment
{% endif %}
</ul>
<h3 class="text-lg font-semibold mt-6">Vos compétences :</h3>
<ul class="list-disc list-inside text-gray-800">
{% for comp in app.user.skills %}
<li>comp.label</li>
{% endfor %}
{% if app.user.skills|length > 0 %}
{% for comp in app.user.skills %}
<li>{{ comp.label }}</li>
{% endfor %}
{% else %}
<br>
Aucune pour le moment
{% endif %}
</ul>
<div class="flex justify-center mt-6">
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
href="{{ path('app_user_edit',{id: app.user.id}) }}"> Accéder aux favoris
</a>
</div>
<div class="flex justify-end mt-6">
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
href="{{ path('app_profile_edit',{id: app.user.id}) }}"> Modifier
</a>
</div>
</div>

View File

@ -1,13 +1,50 @@
{% extends 'base.html.twig' %}
{% block title %}Edit UserApp{% endblock %}
{% block title %}Modifier l'utilisateur{% endblock %}
{% block body %}
<h1>Edit UserApp</h1>
<div class="container mx-auto p-6">
<h1 class="text-4xl font-semibold text-gray-800 mb-6">Modifier l'utilisateur</h1>
{{ include('user_app/_form.html.twig', {'button_label': 'Update'}) }}
<div class="bg-white shadow-md rounded-lg p-6">
{{ form_start(form) }}
<a href="{{ path('app_user_app_index') }}">back to list</a>
<div class="space-y-6">
{{ form_row(form.nickname, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.firstName, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.lastName, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.tel, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.address, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.mail, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
{{ form_row(form.password, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
</div>
<div class="mt-6">
{{ form_widget(form) }}
</div>
{{ include('user_app/_delete_form.html.twig') }}
{% endblock %}
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white px-6 py-3 rounded-lg mt-4">
Mettre à jour
</button>
{{ form_end(form) }}
</div>
<div class="mt-6 flex justify-between items-center">
<a href="{{ path('app_user_index') }}" class="text-teal-500 hover:text-teal-700 text-lg">
<i class="fas fa-arrow-left"></i> Retour à la liste des utilisateurs
</a>
<div class="flex items-center space-x-4">
<a href="{{ path('app_user_show', {'id': user_app.id}) }}"
class="bg-yellow-500 hover:bg-yellow-600 text-white px-4 py-2 rounded-lg">
Voir l'utilisateur
</a>
<a href="{{ path('app_user_delete', {'id': user_app.id}) }}"
class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg">
Supprimer
</a>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,49 +1,56 @@
{% extends 'base.html.twig' %}
{% block title %}UserApp index{% endblock %}
{% block title %}Liste des utilisateurs{% endblock %}
{% block body %}
<h1>UserApp index</h1>
<div class="container mx-auto p-6">
<h1 class="text-3xl font-bold mb-4">Liste des Utilisateurs</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Nickname</th>
<th>Roles</th>
<th>Password</th>
<th>FirstName</th>
<th>LastName</th>
<th>Tel</th>
<th>Address</th>
<th>Mail</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for user_app in user_apps %}
<tr>
<td>{{ user_app.id }}</td>
<td>{{ user_app.nickname }}</td>
<td>{{ user_app.roles ? user_app.roles|json_encode : '' }}</td>
<td>{{ user_app.password }}</td>
<td>{{ user_app.firstName }}</td>
<td>{{ user_app.lastName }}</td>
<td>{{ user_app.tel }}</td>
<td>{{ user_app.address }}</td>
<td>{{ user_app.mail }}</td>
<td>
<a href="{{ path('app_user_app_show', {'id': user_app.id}) }}">show</a>
<a href="{{ path('app_user_app_edit', {'id': user_app.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="10">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="overflow-x-auto bg-white shadow-lg rounded-lg">
<table class="min-w-full table-auto">
<thead>
<tr class="bg-gray-800 text-white">
<th class="px-4 py-2 text-left">ID</th>
<th class="px-4 py-2 text-left">Nickname</th>
<th class="px-4 py-2 text-left">FirstName</th>
<th class="px-4 py-2 text-left">LastName</th>
<th class="px-4 py-2 text-left">Mail</th>
<th class="px-4 py-2 text-left">Actions</th>
</tr>
</thead>
<tbody>
{% for user_app in user_apps %}
<tr class="border-b">
<td class="px-4 py-2">{{ user_app.id }}</td>
<td class="px-4 py-2">{{ user_app.nickname }}</td>
<td class="px-4 py-2">{{ user_app.firstName }}</td>
<td class="px-4 py-2">{{ user_app.lastName }}</td>
<td class="px-4 py-2">{{ user_app.mail }}</td>
<td class="px-4 py-2">
<a href="{{ path('app_user_show', {'id': user_app.id}) }}" class="text-teal-500 hover:text-teal-700 mr-3">
<i class="fas fa-eye"></i> Voir
</a>
<a href="{{ path('app_user_app_new') }}">Create new</a>
{% endblock %}
<a href="{{ path('app_user_edit', {'id': user_app.id}) }}" class="text-yellow-500 hover:text-yellow-700 mr-3">
<i class="fas fa-edit"></i> Modifier
</a>
<form method="post" action="{{ path('app_user_delete', {'id': user_app.id}) }}" style="display:inline;">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ user_app.id) }}">
<button type="submit" class="text-red-500 hover:text-red-700">
<i class="fas fa-trash-alt"></i> Supprimer
</button>
</form>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center py-4">Aucun utilisateur trouvé</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@ -1,54 +1,58 @@
{% extends 'base.html.twig' %}
{% block title %}UserApp{% endblock %}
{% block title %}Détail de l'utilisateur{% endblock %}
{% block body %}
<h1>UserApp</h1>
<div class="container mx-auto p-6">
<h1 class="text-4xl font-semibold text-gray-800 mb-6">Détail de l'utilisateur</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ user_app.id }}</td>
</tr>
<tr>
<th>Nickname</th>
<td>{{ user_app.nickname }}</td>
</tr>
<tr>
<th>Roles</th>
<td>{{ user_app.roles ? user_app.roles|json_encode : '' }}</td>
</tr>
<tr>
<th>Password</th>
<td>{{ user_app.password }}</td>
</tr>
<tr>
<th>FirstName</th>
<td>{{ user_app.firstName }}</td>
</tr>
<tr>
<th>LastName</th>
<td>{{ user_app.lastName }}</td>
</tr>
<tr>
<th>Tel</th>
<td>{{ user_app.tel }}</td>
</tr>
<tr>
<th>Address</th>
<td>{{ user_app.address }}</td>
</tr>
<tr>
<th>Mail</th>
<td>{{ user_app.mail }}</td>
</tr>
</tbody>
</table>
<div class="bg-white shadow-md rounded-lg p-6">
<table class="min-w-full">
<tbody>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">ID</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.id }}</td>
</tr>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">Nom</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.lastName }}</td>
</tr>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">Prénom</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.firstName }}</td>
</tr>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">Téléphone</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.tel }}</td>
</tr>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">Adresse</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.address }}</td>
</tr>
<tr class="border-b">
<th class="px-6 py-4 text-lg font-medium text-gray-700">E-mail</th>
<td class="px-6 py-4 text-lg text-gray-900">{{ user_app.mail }}</td>
</tr>
</tbody>
</table>
</div>
<a href="{{ path('app_user_app_index') }}">back to list</a>
<div class="mt-6 flex justify-between">
<a href="{{ path('app_user_index') }}" class="text-teal-500 hover:text-teal-700 text-lg">
<i class="fas fa-arrow-left"></i> Retour à la liste des utilisateurs
</a>
<a href="{{ path('app_user_app_edit', {'id': user_app.id}) }}">edit</a>
<div class="flex items-center space-x-4">
<a href="{{ path('app_user_edit', {'id': user_app.id}) }}"
class="text-yellow-500 hover:text-yellow-700 text-lg">
<i class="fas fa-edit"></i> Modifier cet utilisateur
</a>
{{ include('user_app/_delete_form.html.twig') }}
{% endblock %}
<a href="{{ path('app_user_delete', {'id': user_app.id}) }}"
class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg">
<i class="fas fa-trash-alt"></i> Supprimer
</a>
</div>
</div>
</div>
{% endblock %}