<?php
namespace App\Controller;
use App\Entity\Client;
use App\Services\Time;
use App\Services\CallApiServices;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints\Length;
class UserInterfaceController extends AbstractController
{
private $time;
public function __construct(Time $time)
{
$this->time = $time;
}
/**
* @Route("/user-interface", name="app_user_interface")
*/
public function index(): Response
{
return $this->render('user_interface/index.html.twig', [
'controller_name' => 'UserInterfaceController',
]);
}
/**
* @Route("/userComment", name="app_userComment", methods={"GET"})
*/
public function userComment(CallApiServices $callApiServices): Response
{
$user = $this->getUser();
if ($user instanceof Client) {
$serviceId = $user->getServiceId();
$clientId = $user->getClientId();
}
$clientAvis = $callApiServices->clientAvis($serviceId, $clientId);
return $this->render('user_interface/userComment.html.twig', [
'clientAvis' => $clientAvis,
]);
}
/**
* @Route("/userOperation", name="app_userOperation")
*/
public function userOperation(CallApiServices $callApiServices): Response
{
$user = $this->getUser();
$serviceId = $this->getParameter('app.serviceId');
$accountId = $this->getParameter('app.accountId');
if ($user instanceof Client) {
$clientId = $user->getClientId();
}
$clientOperations = $callApiServices->clientOperations($serviceId, $clientId);
$clientTransactions = $callApiServices->clientTransactions($serviceId, $clientId);
return $this->render('user_interface/userOperation.html.twig', [
'clientOperations' => $clientOperations,
'clientTransactions' => $clientTransactions,
]);
}
/**
* @Route("/userConsulting", name="app_userConsulting")
*/
public function userConsulting(CallApiServices $callApiServices): Response
{
$user = $this->getUser();
$serviceId = $this->getParameter('app.serviceId');
$accountId = $this->getParameter('app.accountId');
if ($user instanceof Client) {
$clientId = $user->getClientId();
}
$clientConsultations = $callApiServices->clientConsultations($serviceId, $clientId);
$timeConverti = [];
foreach ($clientConsultations as $consulte) {
$timeAConvertir = $consulte['dureeConsultation'];
$timeConverti[] = $this->time->ConvertisseurTime($timeAConvertir);
}
return $this->render('user_interface/userConsulting.html.twig', [
'clientConsultations' => $clientConsultations,
'time' => $timeConverti
]);
}
}