Files
logisticsAPI/app/Filament/Pages/Journaux.php
Marvin 0ab94fdb91 Update Journaux page to increase default results limit and ensure results are sent as strings
- Changed the default results limit from 10 to 30 in the Journaux page.
- Updated the `searchJournaux` method to cast the results parameter to a string to prevent HTTP 400 errors.
- Modified related tests to reflect the new results format and updated expected data structure in API responses.
- Enhanced documentation for the `jnl_list` endpoint to clarify the requirement for the results parameter to be a string.
2026-02-23 10:34:42 +01:00

74 lines
1.9 KiB
PHP

<?php
namespace App\Filament\Pages;
use App\Exceptions\LogisticsApiException;
use App\Services\LogisticsService;
use App\Support\ApiErrorTranslator;
use Filament\Pages\Page;
use Filament\Support\Icons\Heroicon;
class Journaux extends Page
{
protected static string|\BackedEnum|null $navigationIcon = Heroicon::OutlinedBookOpen;
protected static ?string $navigationLabel = 'Journaux';
protected static ?string $title = 'Journaux';
protected static ?int $navigationSort = 4;
protected string $view = 'filament.pages.journaux';
public string $mode = 'read';
public string $select = '';
public int $results = 30;
public string $type = '';
public array $data = [];
public ?array $metadata = null;
public ?string $errorMessage = null;
public bool $hasSearched = false;
public function searchJournaux(): void
{
$this->errorMessage = null;
if (blank($this->type)) {
$this->errorMessage = 'Le champ type de journal (TYPE) est obligatoire.';
return;
}
$this->hasSearched = true;
try {
$service = app(LogisticsService::class);
$params = array_filter([
'select' => $this->select,
'results' => (string) $this->results,
'TYPE' => $this->type,
]);
$response = $service->jnlList($params);
$this->data = $response['data'] ?? [];
$this->metadata = $response['metadata'] ?? null;
$this->errorMessage = ApiErrorTranslator::translate($response['error'] ?? null);
} catch (LogisticsApiException $e) {
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
$this->data = [];
} catch (\Throwable $e) {
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
$this->data = [];
}
}
}