correctifs mineurs
This commit is contained in:
parent
3d3a94a35c
commit
5c303bf412
@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Employee;
|
||||
use App\Form\AnnouncementType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
@ -76,17 +77,13 @@ final class AnnouncementController extends AbstractController
|
||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request,): Response
|
||||
{
|
||||
/*$user = $this->getUser();
|
||||
$user = $this->getUser();
|
||||
|
||||
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||
$company = $user->getCompany();
|
||||
|
||||
if (!$company)
|
||||
{
|
||||
echo "Compétez votre profile avant de créer une annonce";
|
||||
$this->redirectToRoute('app_user_edit',['id' => $user->getId(),]);
|
||||
}
|
||||
}*/
|
||||
if (!$user instanceof Employee) {
|
||||
$this->addFlash('error', "Vous n'etes pas autorisé à faire cette action.");
|
||||
return $this->redirectToRoute('app_index');
|
||||
}
|
||||
$company = $user->getCompany();
|
||||
|
||||
$announcement = new Announcement();
|
||||
$form = $this->createForm(AnnouncementType::class, $announcement);
|
||||
@ -95,6 +92,7 @@ final class AnnouncementController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$announcement->setCreationDate(new \DateTime());
|
||||
$announcement->setStatus('notVerified');
|
||||
$announcement->setCompany($company);
|
||||
$this->entityManager->persist($announcement);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@ -104,6 +102,7 @@ final class AnnouncementController extends AbstractController
|
||||
return $this->render('announcement/new.html.twig', [
|
||||
'announcement' => $announcement,
|
||||
'form' => $form,
|
||||
'company' => $company,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,10 @@ class InternFavoriteController extends AbstractController
|
||||
public function addFavorite(Announcement $announcement,): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
if (!$user instanceof Intern) {
|
||||
throw new AccessDeniedHttpException('Seuls les stagiaires peuvent ajouter aux favoris.');
|
||||
}
|
||||
|
||||
// Vérifier si l'intern a déjà ce favori
|
||||
$existingFavorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
'announcement' => $announcement,
|
||||
'intern' => $user,
|
||||
|
@ -4,7 +4,6 @@ namespace App\Form;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Company;
|
||||
use App\Entity\Status;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
@ -18,10 +17,6 @@ class AnnouncementType extends AbstractType
|
||||
$builder
|
||||
->add('title')
|
||||
->add('description')
|
||||
->add('company', EntityType::class, [
|
||||
'class' => Company::class,
|
||||
'choice_label' => 'name',
|
||||
])
|
||||
->add('date', TextType::class, [
|
||||
'label' => 'Date de stage',
|
||||
'required' => true,
|
||||
|
@ -43,15 +43,17 @@
|
||||
<span class="text-green-500 font-semibold">Validée</span>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-xl">
|
||||
{% if announcement.id in favorites %}
|
||||
⭐
|
||||
{% else %}
|
||||
☆
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-xl">
|
||||
{% if announcement.id in favorites %}
|
||||
⭐
|
||||
{% else %}
|
||||
☆
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% block body %}
|
||||
<div class="container mx-auto p-6">
|
||||
<h1 class="text-3xl font-bold mb-4">Créer une Annonce</h1>
|
||||
<h1 class="text-3xl font-bold mb-4">Créer une Annonce pour {{ company.name }}</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
<div class="mb-4">
|
||||
@ -19,10 +19,6 @@
|
||||
{{ form_label(form.date) }}
|
||||
{{ form_widget(form.date, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ form_label(form.company) }}
|
||||
{{ form_widget(form.company, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||
</div>
|
||||
<button type="submit" class="bg-teal-500 text-white px-4 py-2 rounded">
|
||||
Créer l'annonce
|
||||
</button>
|
||||
|
@ -59,6 +59,16 @@
|
||||
<i class="fas fa-paper-plane"></i> Candidater à cette offre
|
||||
</button>
|
||||
</form>
|
||||
<!-- Vérifier si c'est un favori -->
|
||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
{% if isFavorite %}
|
||||
⭐ Retirer des favoris
|
||||
{% else %}
|
||||
☆ Ajouter aux favoris
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
@ -78,18 +88,7 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
<!-- Vérifier si c'est un favori -->
|
||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
{% if isFavorite %}
|
||||
⭐ Retirer des favoris
|
||||
{% else %}
|
||||
☆ Ajouter aux favoris
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Bouton de retour à la liste -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user