diff --git a/cypress/e2e/admin/registration/registration.cy.js b/cypress/e2e/admin/registration/registration.cy.js index 42621315..12642003 100644 --- a/cypress/e2e/admin/registration/registration.cy.js +++ b/cypress/e2e/admin/registration/registration.cy.js @@ -10,5 +10,9 @@ describe('Página de Minhas Inscrições', () => { cy.get('h1').contains('Minhas Inscrições'); cy.get('input[placeholder="Busque por palavras-chave"]').should('exist'); cy.get('button').contains('Acompanhar').should('exist'); + cy.get(':nth-child(3) > .resource-card-header > .resource-title').contains("Inscrição para o Concurso de Cordelistas - Festival de Literatura Nordestina").should("be.visible"); + cy.get(':nth-child(3) > .resource-card-body > .resource-details > :nth-child(1)').contains("Fase de recurso").should("be.visible"); + cy.get(':nth-child(3) > .resource-card-body > .resource-details > :nth-child(2)').contains("Fase de recurso do Concurso de Cordelistas").should("be.visible"); + cy.get(':nth-child(3) > .resource-card-body > .resource-details > :nth-child(3)').contains("23/07/2024 até 26/07/2024").should("be.visible"); }); }); diff --git a/src/Controller/Web/Admin/RegistrationAdminController.php b/src/Controller/Web/Admin/RegistrationAdminController.php index 7d5b290d..f73e885a 100644 --- a/src/Controller/Web/Admin/RegistrationAdminController.php +++ b/src/Controller/Web/Admin/RegistrationAdminController.php @@ -4,12 +4,22 @@ namespace App\Controller\Web\Admin; +use App\Service\Interface\InscriptionOpportunityServiceInterface; use Symfony\Component\HttpFoundation\Response; class RegistrationAdminController extends AbstractAdminController { + public function __construct( + private readonly InscriptionOpportunityServiceInterface $service, + ) { + } + public function list(): Response { - return $this->render('registration/list.html.twig'); + $inscriptions = $this->service->findUserInscriptionsWithDetails(); + + return $this->render('registration/list.html.twig', [ + 'inscriptions' => $inscriptions, + ]); } } diff --git a/src/Repository/InscriptionOpportunityRepository.php b/src/Repository/InscriptionOpportunityRepository.php index 52e74ccd..f10395b2 100644 --- a/src/Repository/InscriptionOpportunityRepository.php +++ b/src/Repository/InscriptionOpportunityRepository.php @@ -6,6 +6,7 @@ use App\Entity\InscriptionOpportunity; use App\Entity\InscriptionPhase; +use App\Entity\Phase; use App\Repository\Interface\InscriptionOpportunityRepositoryInterface; use Doctrine\Persistence\ManagerRegistry; @@ -78,4 +79,22 @@ public function findOneInscriptionOpportunity(string $inscriptionId, string $opp ->getQuery() ->getOneOrNullResult(); } + + public function findUserInscriptionsWithDetails($agentId) + { + $qb = $this->createQueryBuilder('i'); + + $subQuery = $this->getEntityManager()->createQueryBuilder() + ->select('MAX(p2.startDate)') + ->from(Phase::class, 'p2') + ->where('p2.opportunity = o.id'); + + return $qb->select('i', 'o', 'p') + ->join('i.opportunity', 'o') + ->join(Phase::class, 'p', 'WITH', 'p.opportunity = o.id AND p.startDate = ('.$subQuery->getDQL().')') + ->where('i.agent = :agentId') + ->setParameter('agentId', $agentId) + ->getQuery() + ->getResult(); + } } diff --git a/src/Service/InscriptionOpportunityService.php b/src/Service/InscriptionOpportunityService.php index b2be0e15..27058ef0 100644 --- a/src/Service/InscriptionOpportunityService.php +++ b/src/Service/InscriptionOpportunityService.php @@ -7,6 +7,7 @@ use App\DTO\InscriptionOpportunityDto; use App\Entity\InscriptionOpportunity; use App\Entity\InscriptionPhase; +use App\Entity\Phase; use App\Enum\InscriptionPhaseStatusEnum; use App\Exception\InscriptionOpportunity\AlreadyInscriptionOpportunityException; use App\Exception\InscriptionOpportunity\InscriptionOpportunityResourceNotFoundException; @@ -90,6 +91,30 @@ public function list(Uuid $opportunity, int $limit = 50): array ); } + public function findUserInscriptionsWithDetails(): array + { + $userParams = $this->getUserParams()['agent'][0]; + $agent = $userParams->getId(); + + $inscriptionsWithDetails = $this->repository->findUserInscriptionsWithDetails($agent); + + $faseData = []; + + foreach ($inscriptionsWithDetails as $inscription) { + if ($inscription instanceof Phase) { + $faseData[] = [ + 'opportunity' => $inscription->getOpportunity()->getName(), + 'phase' => $inscription->getName(), + 'phaseDescription' => $inscription->getDescription(), + 'startDate' => $inscription->getStartDate(), + 'endDate' => $inscription->getEndDate(), + ]; + } + } + + return $faseData; + } + public function remove(Uuid $opportunity, Uuid $id): void { $inscriptionOpportunity = $this->repository->findOneBy( diff --git a/src/Service/Interface/InscriptionOpportunityServiceInterface.php b/src/Service/Interface/InscriptionOpportunityServiceInterface.php index 6e19d9e8..72ed5f7f 100644 --- a/src/Service/Interface/InscriptionOpportunityServiceInterface.php +++ b/src/Service/Interface/InscriptionOpportunityServiceInterface.php @@ -15,6 +15,8 @@ public function get(Uuid $opportunity, Uuid $id); public function list(Uuid $opportunity, int $limit = 50): array; + public function findUserInscriptionsWithDetails(): array; + public function remove(Uuid $opportunity, Uuid $id): void; public function update(Uuid $opportunity, Uuid $identifier, array $inscriptionOpportunity): InscriptionOpportunity; diff --git a/templates/_admin/registration/_partials/tabs/sent.html.twig b/templates/_admin/registration/_partials/tabs/sent.html.twig index bbed931d..76e7d254 100644 --- a/templates/_admin/registration/_partials/tabs/sent.html.twig +++ b/templates/_admin/registration/_partials/tabs/sent.html.twig @@ -20,16 +20,17 @@
{{ 'phase' | trans }} {{ 'view.registration.merit' | trans }}
-{{ 'type' | trans }} {{ 'view.registration.data' | trans }}
-{{ 'analysis' | trans }} {{ 'view.registration.hour' | trans }}
+{{ 'phase' | trans }} {{ inscription.phase }}
+{{ 'type' | trans }} {{ inscription.phaseDescription }}
+{{ 'analysis' | trans }} {{ inscription.startDate | date('d/m/Y') }} {{ 'to'|trans }} {{ inscription.endDate | date('d/m/Y') }}