diff --git a/assets/styles/app.css b/assets/styles/app.css index e28b4f4..b50894d 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -1,4 +1,5 @@ @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,600;1,400;1,600&display=swap'); +@import "button.css"; @tailwind base; @tailwind components; diff --git a/assets/styles/button.css b/assets/styles/button.css new file mode 100644 index 0000000..6b01645 --- /dev/null +++ b/assets/styles/button.css @@ -0,0 +1,91 @@ +.btnPrimary { + @apply bg-[#2a8d57] text-white font-bold py-2 px-4 border-b-4 rounded transition-all duration-300 ease-in-out; + + /* Bordure */ + border-color: #1e7a43; + + /* Survol */ + &:hover { + @apply bg-[#1e7a43] border-[#155d2e]; + } + + /* Clique (État actif) */ + &:active { + @apply bg-[#1b6b38] border-[#155d2e]; + } + + /* Focus (État focus) */ + &:focus { + outline: none; + box-shadow: 0 0 0 4px rgba(42, 141, 87, 0.5); + } +} + +.btnSecondary { + @apply bg-[#2f4858] text-white font-bold py-2 px-4 border-b-4 rounded transition-all duration-300 ease-in-out; + + /* Bordure */ + border-color: #1e3c46; + + /* Survol */ + &:hover { + @apply bg-[#1e3c46] border-[#16323a]; + } + + /* Clique (État actif) */ + &:active { + @apply bg-[#193d49] border-[#16323a]; + } + + /* Focus (État focus) */ + &:focus { + outline: none; + box-shadow: 0 0 0 4px rgba(47, 72, 88, 0.5); + } +} + +.btnThird { + @apply bg-[#c0ab4d] text-white font-bold py-2 px-4 border-b-4 rounded transition-all duration-300 ease-in-out; + + /* Bordure */ + border-color: #b0a139; + + /* Survol */ + &:hover { + @apply bg-[#b0a139] border-[#9a8b2b]; + } + + /* Clique (État actif) */ + &:active { + @apply bg-[#9a8b2b] border-[#6f6a1c]; + } + + /* Focus (État focus) */ + &:focus { + outline: none; + box-shadow: 0 0 0 4px rgba(192, 171, 77, 0.5); + } +} + +.btnAnnule { + @apply bg-[#d54f45] text-white font-bold py-2 px-4 border-b-4 rounded transition-all duration-300 ease-in-out; + + /* Bordure */ + border-color: #a73a2d; + + /* Survol */ + &:hover { + @apply bg-[#a73a2d] border-[#8b2d1e]; + } + + /* Clique (État actif) */ + &:active { + @apply bg-[#90271e] border-[#8b2d1e]; + } + + /* Focus (État focus) */ + &:focus { + outline: none; + box-shadow: 0 0 0 4px rgba(213, 79, 69, 0.5); + } +} \ No newline at end of file diff --git a/config/services.yaml b/config/services.yaml index fbcedf0..7683a5c 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -28,5 +28,12 @@ services: arguments: $targetDirectory: '../public/upload/image/profile/' + App\EventListener\UserProfileListener: + arguments: + - '@security.token_storage' + - '@twig' + tags: + - { name: 'kernel.event_subscriber' } + # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 8c3264b..7ff317d 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -48,12 +48,9 @@ class AdminController extends AbstractController #[Route('/admin/user', name: 'app_adminUser')] public function adminUser(TokenStorageInterface $tokenStorage): Response { - $token = $tokenStorage->getToken(); - $userConnect = $token?->getUser(); $participants = $this->participantRepository->findAll(); $sites = $this->siteRepository->findAll(); return $this->render('admin/user.html.twig', [ - 'profile' => $userConnect, 'participants' => $participants, 'sites' => $sites, 'controller_name' => 'AdminController', diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 7b18f42..f14d1d3 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -19,8 +19,6 @@ class MainController extends AbstractController { // Récupérer les 5 dernières sorties $latestSorties = $sortieRepository->findBy([], ['dateHeureDebut' => 'DESC'], 5); - $token = $tokenStorage->getToken(); - $userConnect = $token?->getUser(); $dateLimit = new \DateTime(); $dateLimit->modify('-30 days'); // Date limite = il y a 30 jours @@ -35,7 +33,6 @@ class MainController extends AbstractController return $this->render('main/home.html.twig', [ 'lastSorties' => $latestSorties, - 'profile' => $userConnect, 'pastEvents' => $pastEvents, ]); } diff --git a/src/Controller/SortieController.php b/src/Controller/SortieController.php index 60d9507..ae0b7fd 100644 --- a/src/Controller/SortieController.php +++ b/src/Controller/SortieController.php @@ -25,13 +25,9 @@ class SortieController extends AbstractController { #[Route('/sortie/liste', name: 'list', methods: ['GET'])] public function index( - TokenStorageInterface $tokenStorage, SortieRepository $sortieRepository, Request $request ): Response { - $token = $tokenStorage->getToken(); - $userConnect = $token?->getUser(); - // Récupérer les paramètres de filtre $search = $request->query->get('search', ''); $siteId = $request->query->get('site', ''); @@ -46,7 +42,6 @@ class SortieController extends AbstractController $sorties = $sortieRepository->findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $userConnect); return $this->render('sortie/list.html.twig', [ - 'profile' => $userConnect, 'sorties' => $sorties, 'sites' => $sortieRepository->findAllSites(), ]); @@ -62,7 +57,6 @@ class SortieController extends AbstractController ParticipantRepository $participantRepository, EtatRepository $etatRepository ): Response { - // Vérifier si l'utilisateur est connecté $userConnect = $tokenStorage->getToken()?->getUser(); if (!$userConnect) { $this->addFlash('error', 'Vous devez être connecté pour créer une sortie.'); @@ -114,7 +108,6 @@ class SortieController extends AbstractController } return $this->render('sortie/create.html.twig', [ - 'profile' => $userConnect, 'form' => $form->createView(), 'sortie' => $sortie, ]); @@ -124,7 +117,6 @@ class SortieController extends AbstractController public function view( string $id, EntityManagerInterface $entityManager, - TokenStorageInterface $tokenStorage ): Response { $sortie = $entityManager->getRepository(Sortie::class)->find($id); if (!$sortie) { @@ -146,7 +138,6 @@ class SortieController extends AbstractController return $this->render('sortie/view.html.twig', [ 'sortie' => $sortie, - 'profile' => $tokenStorage->getToken()?->getUser(), ]); } diff --git a/src/EventListener/UserProfileListener.php b/src/EventListener/UserProfileListener.php new file mode 100644 index 0000000..e97ccbd --- /dev/null +++ b/src/EventListener/UserProfileListener.php @@ -0,0 +1,42 @@ +tokenStorage = $tokenStorage; + $this->twig = $twig; + } + + public function onKernelRequest(RequestEvent $event) + { + $token = $this->tokenStorage->getToken(); + + // Vérifie si l'utilisateur est connecté + if ($token && $token->getUser()) { + $profile = $token->getUser(); // Récupère l'utilisateur connecté + $event->getRequest()->attributes->set('profile', $profile); + + // Ajoute 'profile' à toutes les vues Twig + $this->twig->addGlobal('profile', $profile); + } + } + + public static function getSubscribedEvents() + { + return [ + KernelEvents::REQUEST => 'onKernelRequest', + ]; + } +} diff --git a/templates/admin/site.html.twig b/templates/admin/site.html.twig index 67f0fbd..9193dee 100644 --- a/templates/admin/site.html.twig +++ b/templates/admin/site.html.twig @@ -14,7 +14,7 @@
-
diff --git a/templates/admin/user.html.twig b/templates/admin/user.html.twig index 072ebaf..166cc61 100644 --- a/templates/admin/user.html.twig +++ b/templates/admin/user.html.twig @@ -14,7 +14,7 @@
@@ -24,10 +24,10 @@
-
@@ -177,7 +177,7 @@

* Champ obligatoire

- +
@@ -205,7 +205,7 @@
diff --git a/templates/auth/login.html.twig b/templates/auth/login.html.twig index 6a07e30..50de79a 100644 --- a/templates/auth/login.html.twig +++ b/templates/auth/login.html.twig @@ -1,4 +1,5 @@ {% extends 'main/base.html.twig' %} + {% block head %} @@ -16,22 +17,24 @@
+
Mot de passe oublié ?
+ - + + +
- + - +
@@ -49,8 +52,8 @@
- - + +
@@ -68,6 +71,5 @@ document.getElementById('resetModal').classList.add('hidden'); }); - {% endblock %} diff --git a/templates/auth/register.html.twig b/templates/auth/register.html.twig index f2825ba..7b24eb3 100644 --- a/templates/auth/register.html.twig +++ b/templates/auth/register.html.twig @@ -24,7 +24,7 @@ {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.pseudo) }} {{ form_row(registrationForm.plainPassword) }} - + {{ form_end(registrationForm) }} diff --git a/templates/profile/edit.html.twig b/templates/profile/edit.html.twig index 02c9a8f..58dafb0 100644 --- a/templates/profile/edit.html.twig +++ b/templates/profile/edit.html.twig @@ -44,7 +44,7 @@ {{ form_row(formProfile.deleteImage) }} image de profile {% endif %} - + {{ form_end(formProfile) }} diff --git a/templates/profile/view.html.twig b/templates/profile/view.html.twig index d50d305..bf09808 100644 --- a/templates/profile/view.html.twig +++ b/templates/profile/view.html.twig @@ -26,7 +26,7 @@
- diff --git a/templates/sortie/create.html.twig b/templates/sortie/create.html.twig index 4d15cb6..57c35f9 100644 --- a/templates/sortie/create.html.twig +++ b/templates/sortie/create.html.twig @@ -110,9 +110,6 @@
{% endif %} -
@@ -121,10 +118,7 @@
{{ form_widget(form.lieu, { 'attr': { 'class': 'block w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500', 'id': 'lieu-select' } }) }} -
@@ -154,10 +148,10 @@
- - + Annuler
diff --git a/templates/sortie/edit.html.twig b/templates/sortie/edit.html.twig index 5711d57..b64d9d0 100644 --- a/templates/sortie/edit.html.twig +++ b/templates/sortie/edit.html.twig @@ -71,10 +71,10 @@
- + ❌ Annuler -
diff --git a/templates/sortie/list.html.twig b/templates/sortie/list.html.twig index 3701b6d..a5c0ff4 100644 --- a/templates/sortie/list.html.twig +++ b/templates/sortie/list.html.twig @@ -97,7 +97,7 @@
-
diff --git a/templates/sortie/view.html.twig b/templates/sortie/view.html.twig index a353001..82202ea 100644 --- a/templates/sortie/view.html.twig +++ b/templates/sortie/view.html.twig @@ -79,7 +79,7 @@ {% if app.user and sortie.etat.libelle == 'Ouverte' and not sortie.participants.contains(app.user) and date(sortie.dateLimiteInscription) > date() %}
-
@@ -88,7 +88,7 @@

✅ Vous êtes déjà inscrit à cette sortie.

{% if sortie.etat.libelle == 'Ouverte' %}
-
@@ -102,9 +102,13 @@ + + ✏️ Modifier la sortie + {% endif %} {% if sortie.etat.libelle == 'Créée' %}