feat: add i18n support for Vietnamese and English
This commit is contained in:
@@ -5,15 +5,22 @@ namespace App\Filament\Widgets;
|
||||
use App\Models\Department;
|
||||
use App\Models\Feedback;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class HandlerPerformanceWidget extends ChartWidget
|
||||
{
|
||||
protected ?string $heading = 'Avg Processing Time by Handler';
|
||||
|
||||
protected ?string $description = 'Average time from ticket creation to resolution, broken down by handler.';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
public function getHeading(): string | Htmlable | null
|
||||
{
|
||||
return __('app.widget_avg_time_by_handler');
|
||||
}
|
||||
|
||||
public function getDescription(): string | Htmlable | null
|
||||
{
|
||||
return __('app.widget_avg_time_by_handler_desc');
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
@@ -39,19 +46,18 @@ class HandlerPerformanceWidget extends ChartWidget
|
||||
->with('assignedTo')
|
||||
->get();
|
||||
|
||||
$labels = $handlers->map(fn ($h) => $h->assignedTo?->name ?? 'Unknown')->toArray();
|
||||
$labels = $handlers->map(fn ($h) => $h->assignedTo?->name ?? __('app.widget_unknown'))->toArray();
|
||||
$data = $handlers->map(fn ($h) => round($h->avg_minutes, 1))->toArray();
|
||||
|
||||
// Generate gradient colors based on performance
|
||||
$maxMinutes = max($data) ?: 1;
|
||||
$colors = collect($data)->map(function ($minutes) use ($maxMinutes) {
|
||||
$ratio = $minutes / $maxMinutes;
|
||||
if ($ratio > 0.8) {
|
||||
return 'rgba(220, 38, 38, 0.8)'; // Red for slow
|
||||
return 'rgba(220, 38, 38, 0.8)';
|
||||
} elseif ($ratio > 0.5) {
|
||||
return 'rgba(217, 119, 6, 0.8)'; // Amber for medium
|
||||
return 'rgba(217, 119, 6, 0.8)';
|
||||
}
|
||||
return 'rgba(26, 86, 219, 0.8)'; // Blue for fast
|
||||
return 'rgba(26, 86, 219, 0.8)';
|
||||
})->toArray();
|
||||
|
||||
$borderColors = collect($data)->map(function ($minutes) use ($maxMinutes) {
|
||||
@@ -67,7 +73,7 @@ class HandlerPerformanceWidget extends ChartWidget
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Avg Time (minutes)',
|
||||
'label' => __('app.widget_avg_time_minutes'),
|
||||
'data' => $data,
|
||||
'backgroundColor' => $colors,
|
||||
'borderColor' => $borderColors,
|
||||
|
||||
Reference in New Issue
Block a user