Skip to content

Commit

Permalink
Implement backend on registration page
Browse files Browse the repository at this point in the history
  • Loading branch information
TalysonSoares committed Jan 14, 2025
1 parent a4d487c commit 7c4235b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/admin/registration/registration.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
12 changes: 11 additions & 1 deletion src/Controller/Web/Admin/RegistrationAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
19 changes: 19 additions & 0 deletions src/Repository/InscriptionOpportunityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}
25 changes: 25 additions & 0 deletions src/Service/InscriptionOpportunityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions templates/_admin/registration/_partials/tabs/sent.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
<hr>
</div>

{% for inscription in inscriptions %}
<div class="resource-card mt-4">
<div class="resource-card-header">
<div class="resource-icon"></div>
<h4 class="resource-title">{{ 'view.registration.title-card' | trans }}</h4>
<h4 class="resource-title">{{ inscription.opportunity }}</h4>
</div>
<div class="resource-card-body">
<div class="resource-details">
<p><strong>{{ 'phase' | trans }}</strong> {{ 'view.registration.merit' | trans }}</p>
<p><strong>{{ 'type' | trans }}</strong> {{ 'view.registration.data' | trans }}</p>
<p><strong>{{ 'analysis' | trans }}</strong> {{ 'view.registration.hour' | trans }}</p>
<p><strong>{{ 'phase' | trans }}</strong> {{ inscription.phase }}</p>
<p><strong>{{ 'type' | trans }}</strong> {{ inscription.phaseDescription }}</p>
<p><strong>{{ 'analysis' | trans }}</strong> {{ inscription.startDate | date('d/m/Y') }} {{ 'to'|trans }} {{ inscription.endDate | date('d/m/Y') }}</p>
</div>
</div>
<div class="text-end mt-3">
Expand All @@ -38,6 +39,4 @@
</button>
</div>
</div>



{% endfor %}

0 comments on commit 7c4235b

Please sign in to comment.