feat: add i18n support for Vietnamese and English
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled

This commit is contained in:
2026-05-04 10:40:39 +00:00
parent 3a8db5cae6
commit 8c6b71cb8a
64 changed files with 4652 additions and 254 deletions

View File

@@ -35,29 +35,29 @@ class AvgProcessingTimeWidget extends BaseWidget
$avgDisplay = $avgMinutes ? round($avgMinutes) . ' min' : 'N/A';
$avgDescription = $avgMinutes
? 'Avg time from creation to resolution'
: 'No resolved tickets yet';
? __('app.widget_avg_time_desc')
: __('app.widget_no_resolved_tickets');
return [
Stat::make('Resolved Tickets', (string) $totalResolved)
->description('Total resolved/closed tickets')
Stat::make(__('app.widget_resolved_tickets'), (string) $totalResolved)
->description(__('app.widget_total_resolved_closed'))
->descriptionIcon('heroicon-m-check-circle')
->color('success')
->chart([7, 3, 4, 5, 6, 8, $totalResolved]),
Stat::make('Avg Processing Time', $avgDisplay)
Stat::make(__('app.widget_avg_processing_time'), $avgDisplay)
->description($avgDescription)
->descriptionIcon('heroicon-m-clock')
->color('info'),
Stat::make('Pending Tickets', (string) $totalPending)
->description('Still in progress')
Stat::make(__('app.widget_pending_tickets'), (string) $totalPending)
->description(__('app.widget_still_in_progress'))
->descriptionIcon('heroicon-m-arrow-path')
->color('warning')
->chart([3, 5, 4, 6, 5, 4, $totalPending]),
Stat::make('Escalated', (string) $escalatedCount)
->description('Tickets marked as escalated')
Stat::make(__('app.widget_escalated'), (string) $escalatedCount)
->description(__('app.widget_escalated_desc'))
->descriptionIcon('heroicon-m-exclamation-triangle')
->color('danger'),
];

View File

@@ -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,

View File

@@ -35,37 +35,37 @@ class ResolvedTicketsWidget extends BaseWidget
->color('primary'),
TextColumn::make('title')
->label('Ticket')
->label(__('app.widget_ticket'))
->searchable()
->weight('semibold')
->url(fn (Feedback $record): string => FeedbackResource::getUrl('edit', ['record' => $record]))
->color('primary'),
TextColumn::make('customer.name')
->label('Customer')
->label(__('app.widget_customer'))
->searchable(),
TextColumn::make('customerProduct.product.name')
->label('Product')
->placeholder('General'),
->label(__('app.product'))
->placeholder(__('app.general')),
TextColumn::make('assignedTo.name')
->label('Handler'),
->label(__('app.widget_handler')),
TextColumn::make('currentDepartment.name')
->label('Department')
->label(__('app.department'))
->badge()
->color('info'),
TextColumn::make('updated_at')
->label('Resolved')
->label(__('app.widget_resolved'))
->since()
->sortable()
->color('secondary'),
])
->defaultSort('updated_at', 'desc')
->heading('Tickets Awaiting Closure')
->description('Tickets that have been resolved and are pending manager review for closure.')
->heading(__('app.widget_tickets_awaiting_closure'))
->description(__('app.widget_tickets_awaiting_desc'))
->paginated([5]);
}