feat(v1.5): complete phases 40-43 workflow cleanup

This commit is contained in:
2026-03-25 22:46:51 +01:00
parent b8dda81e7b
commit 3610571949
37 changed files with 1557 additions and 259 deletions

View File

@@ -14,10 +14,19 @@ use Throwable;
final class AutomationController
{
private const ALLOWED_EVENTS = ['receipt.created'];
private const ALLOWED_CONDITION_TYPES = ['integration'];
private const ALLOWED_EVENTS = ['receipt.created', 'shipment.status_changed'];
private const ALLOWED_CONDITION_TYPES = ['integration', 'shipment_status'];
private const ALLOWED_ACTION_TYPES = ['send_email'];
private const ALLOWED_RECIPIENTS = ['client', 'client_and_company', 'company'];
private const SHIPMENT_STATUS_OPTIONS = [
'registered' => ['label' => 'Przesylka zarejestrowana', 'statuses' => ['created', 'confirmed']],
'ready_for_pickup' => ['label' => 'Przesylka do odbioru', 'statuses' => ['ready_for_pickup']],
'dropped_at_point' => ['label' => 'Przesylka nadana w punkcie', 'statuses' => ['confirmed', 'in_transit']],
'picked_up' => ['label' => 'Przesylka odebrana', 'statuses' => ['delivered']],
'cancelled' => ['label' => 'Przesylka anulowana', 'statuses' => ['cancelled']],
'unclaimed' => ['label' => 'Przesylka nieodebrana', 'statuses' => ['problem']],
'picked_up_return' => ['label' => 'Przesylka odebrana (zwrot)', 'statuses' => ['returned']],
];
public function __construct(
private readonly Template $template,
@@ -185,6 +194,7 @@ final class AutomationController
'conditionTypes' => self::ALLOWED_CONDITION_TYPES,
'actionTypes' => self::ALLOWED_ACTION_TYPES,
'recipientOptions' => self::ALLOWED_RECIPIENTS,
'shipmentStatusOptions' => self::SHIPMENT_STATUS_OPTIONS,
'errorMessage' => Flash::get('settings.automation.error', ''),
], 'layouts/app');
@@ -289,6 +299,21 @@ final class AutomationController
return count($integrationIds) > 0 ? ['integration_ids' => $integrationIds] : null;
}
if ($type === 'shipment_status') {
$keys = $condition['shipment_status_keys'] ?? [];
if (!is_array($keys)) {
$keys = [];
}
$allowedKeys = array_keys(self::SHIPMENT_STATUS_OPTIONS);
$statusKeys = array_values(array_filter(
array_map(static fn (mixed $key): string => trim((string) $key), $keys),
static fn (string $key): bool => $key !== '' && in_array($key, $allowedKeys, true)
));
return count($statusKeys) > 0 ? ['status_keys' => array_values(array_unique($statusKeys))] : null;
}
return null;
}