56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Inventory;
|
|
|
|
use App\Models\InventorySyncRun;
|
|
|
|
class InventorySyncStatusBadge
|
|
{
|
|
/**
|
|
* @return array{label: string, color: string, icon: string}
|
|
*/
|
|
public static function for(?string $status): array
|
|
{
|
|
$status = (string) ($status ?? '');
|
|
|
|
$label = match ($status) {
|
|
InventorySyncRun::STATUS_SUCCESS => 'Success',
|
|
InventorySyncRun::STATUS_PARTIAL => 'Partial',
|
|
InventorySyncRun::STATUS_FAILED => 'Failed',
|
|
InventorySyncRun::STATUS_RUNNING => 'Running',
|
|
InventorySyncRun::STATUS_PENDING => 'Pending',
|
|
InventorySyncRun::STATUS_SKIPPED => 'Skipped',
|
|
'queued' => 'Queued',
|
|
default => '—',
|
|
};
|
|
|
|
$color = match ($status) {
|
|
InventorySyncRun::STATUS_SUCCESS => 'success',
|
|
InventorySyncRun::STATUS_PARTIAL => 'warning',
|
|
InventorySyncRun::STATUS_FAILED => 'danger',
|
|
InventorySyncRun::STATUS_RUNNING => 'info',
|
|
InventorySyncRun::STATUS_PENDING, 'queued' => 'gray',
|
|
InventorySyncRun::STATUS_SKIPPED => 'gray',
|
|
default => 'gray',
|
|
};
|
|
|
|
$icon = match ($status) {
|
|
InventorySyncRun::STATUS_SUCCESS => 'heroicon-m-check-circle',
|
|
InventorySyncRun::STATUS_PARTIAL => 'heroicon-m-exclamation-triangle',
|
|
InventorySyncRun::STATUS_FAILED => 'heroicon-m-x-circle',
|
|
InventorySyncRun::STATUS_RUNNING => 'heroicon-m-arrow-path',
|
|
InventorySyncRun::STATUS_PENDING, 'queued' => 'heroicon-m-clock',
|
|
InventorySyncRun::STATUS_SKIPPED => 'heroicon-m-minus-circle',
|
|
default => 'heroicon-m-clock',
|
|
};
|
|
|
|
return [
|
|
'label' => $label,
|
|
'color' => $color,
|
|
'icon' => $icon,
|
|
];
|
|
}
|
|
}
|