feat: admin view listing a travel's mailing recipients from bpn-connect
This commit is contained in:
1 parent
63ffe0b0b4
commit
e796dd01ee
10 files changed
+347
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin\TravelMailing;
|
||||
|
||||
use App\BpnConnect\Exception\BpnConnectException;
|
||||
use App\BpnConnect\TravelsClient;
|
||||
use App\Form\Admin\TravelMailingLookupType;
|
||||
use App\Form\Model\TravelMailingLookupDto;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
#[IsGranted('ROLE_CUSTOMER_EXPERT')]
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TravelsClient $travelsClient,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/travel-mailing', name: 'app_admin_travelmailing')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$lookup = new TravelMailingLookupDto();
|
||||
$form = $this->createForm(TravelMailingLookupType::class, $lookup, [
|
||||
'action' => $this->generateUrl('app_admin_travelmailing'),
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$result = null;
|
||||
$failed = false;
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
try {
|
||||
$result = $this->travelsClient->getMailingRecipients((string) $lookup->travelCode);
|
||||
} catch (BpnConnectException) {
|
||||
// The client has already logged the cause; the page only needs to say it failed.
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('admin/travel_mailing/index.html.twig', [
|
||||
'form' => $form,
|
||||
'result' => $result,
|
||||
'failed' => $failed,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user