feat: show the travel name above the mailing list

This commit is contained in:
fromme committed 2026-10-14 14:05:42 +02:00
1 parent d305774bee
commit ff722b5cef
5 files changed
+87 -4

No files matched your search

@@ -6,8 +6,10 @@ namespace App\Controller\Admin\TravelMailing;
use App\BpnConnect\Exception\BpnConnectException;
use App\BpnConnect\TravelsClient;
use App\BusProNet\Utility\DateCodeUtility;
use App\Form\Admin\TravelMailingLookupType;
use App\Form\Model\TravelMailingLookupDto;
use App\Service\TravelDataProvider;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -19,6 +21,7 @@ class IndexController extends AbstractController
{
public function __construct(
private readonly TravelsClient $travelsClient,
private readonly TravelDataProvider $travelDataProvider,
) {
}
@@ -32,10 +35,16 @@ class IndexController extends AbstractController
$form->handleRequest($request);
$result = null;
$travelLabel = null;
$failed = false;
if ($form->isSubmitted() && $form->isValid()) {
// The local index matches codes exactly, so "lpjmp-281126" has to become "LPJMP281126"
// before the label lookup; bpn-connect gets the same code to keep both in step.
$travelCode = (new DateCodeUtility())->sanitize((string) $lookup->travelCode);
try {
$result = $this->travelsClient->getMailingRecipients((string) $lookup->travelCode);
$result = $this->travelsClient->getMailingRecipients($travelCode);
$travelLabel = $this->travelDataProvider->mapDateCodeToLabel($travelCode);
} catch (BpnConnectException) {
// The client has already logged the cause; the page only needs to say it failed.
$failed = true;
@@ -45,6 +54,7 @@ class IndexController extends AbstractController
return $this->render('admin/travel_mailing/index.html.twig', [
'form' => $form,
'result' => $result,
'travel_label' => $travelLabel,
'failed' => $failed,
]);
}