feat: add i18n support for Vietnamese and English
This commit is contained in:
@@ -27,7 +27,7 @@ class InteractionsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'interactions';
|
||||
|
||||
protected static ?string $title = 'Interaction History';
|
||||
protected static ?string $title = 'feedback.interaction_history';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -35,9 +35,9 @@ class InteractionsRelationManager extends RelationManager
|
||||
->components([
|
||||
Select::make('type')
|
||||
->options([
|
||||
'note' => 'Note',
|
||||
'status_change' => 'Status Change',
|
||||
'assignment' => 'Assignment / Forward',
|
||||
'note' => __('feedback.interaction_type_note'),
|
||||
'status_change' => __('feedback.interaction_type_status_change'),
|
||||
'assignment' => __('feedback.interaction_type_assignment'),
|
||||
])
|
||||
->default('note')
|
||||
->required()
|
||||
@@ -52,28 +52,28 @@ class InteractionsRelationManager extends RelationManager
|
||||
->columnSpanFull(),
|
||||
|
||||
Select::make('new_status')
|
||||
->label('New Status')
|
||||
->label(__('app.new_status'))
|
||||
->options(fn (): array => auth()->user()->hasPermissionTo('close-ticket')
|
||||
? ['pending' => 'Pending', 'processing' => 'Processing', 'resolved' => 'Resolved', 'closed' => 'Closed']
|
||||
: ['pending' => 'Pending', 'processing' => 'Processing', 'resolved' => 'Resolved'],
|
||||
? ['pending' => __('app.status_pending'), 'processing' => __('app.status_processing'), 'resolved' => __('app.status_resolved'), 'closed' => __('app.status_closed')]
|
||||
: ['pending' => __('app.status_pending'), 'processing' => __('app.status_processing'), 'resolved' => __('app.status_resolved')],
|
||||
)
|
||||
->visible(fn ($get): bool => $get('type') === 'status_change'),
|
||||
|
||||
Select::make('new_assignee')
|
||||
->label('Assign To')
|
||||
->label(__('app.assign_to'))
|
||||
->options(User::pluck('name', 'id')->toArray())
|
||||
->searchable()
|
||||
->visible(fn ($get): bool => $get('type') === 'assignment'),
|
||||
|
||||
Select::make('department_id')
|
||||
->label('Target Department')
|
||||
->label(__('app.target_department'))
|
||||
->options(Department::pluck('name', 'id')->toArray())
|
||||
->searchable()
|
||||
->nullable()
|
||||
->visible(fn ($get): bool => $get('type') === 'assignment'),
|
||||
|
||||
FileUpload::make('attachments')
|
||||
->label('Attachments')
|
||||
->label(__('app.attachments'))
|
||||
->multiple()
|
||||
->disk('local')
|
||||
->directory('feedback-attachments')
|
||||
@@ -90,13 +90,13 @@ class InteractionsRelationManager extends RelationManager
|
||||
->dateTime('d/m/Y H:i')
|
||||
->sortable(),
|
||||
TextColumn::make('user.name')
|
||||
->label('By'),
|
||||
->label(__('app.by')),
|
||||
TextColumn::make('type')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => match ($state) {
|
||||
'note' => 'Note',
|
||||
'status_change' => 'Status Change',
|
||||
'assignment' => 'Assignment',
|
||||
'note' => __('feedback.interaction_type_note'),
|
||||
'status_change' => __('feedback.interaction_type_status_change'),
|
||||
'assignment' => __('feedback.interaction_type_assignment'),
|
||||
default => $state,
|
||||
})
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
@@ -110,7 +110,7 @@ class InteractionsRelationManager extends RelationManager
|
||||
->limit(80)
|
||||
->wrap(),
|
||||
TextColumn::make('changes')
|
||||
->label('Details')
|
||||
->label(__('app.details'))
|
||||
->formatStateUsing(function (?array $state): string {
|
||||
if (! $state) return '';
|
||||
$lines = [];
|
||||
@@ -123,7 +123,7 @@ class InteractionsRelationManager extends RelationManager
|
||||
})
|
||||
->html(),
|
||||
TextColumn::make('attachments_count')
|
||||
->label('Files')
|
||||
->label(__('app.files'))
|
||||
->counts('attachments')
|
||||
->badge()
|
||||
->color(fn (int $state): string => $state > 0 ? 'primary' : 'gray'),
|
||||
@@ -131,9 +131,9 @@ class InteractionsRelationManager extends RelationManager
|
||||
->defaultSort('created_at', 'desc')
|
||||
->recordActions([
|
||||
Action::make('viewAttachments')
|
||||
->label('View Attachments')
|
||||
->label(__('feedback.view_attachments'))
|
||||
->icon('heroicon-o-paper-clip')
|
||||
->modalHeading('Attachments')
|
||||
->modalHeading(__('app.attachments'))
|
||||
->modalContent(function (FeedbackInteraction $record): \Illuminate\Contracts\View\View {
|
||||
$fileService = App::make(FileService::class);
|
||||
$attachments = $record->attachments;
|
||||
@@ -155,7 +155,7 @@ class InteractionsRelationManager extends RelationManager
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->label('Add Interaction')
|
||||
->label(__('feedback.add_interaction'))
|
||||
->icon('heroicon-o-plus')
|
||||
->mutateFormDataUsing(function (array $data, $livewire): array {
|
||||
$data['user_id'] = auth()->id();
|
||||
@@ -177,8 +177,8 @@ class InteractionsRelationManager extends RelationManager
|
||||
|
||||
if ($data['type'] === 'assignment' && isset($data['new_assignee'])) {
|
||||
$feedback = $livewire->getOwnerRecord();
|
||||
$oldAssignee = $feedback->assignedTo?->name ?? 'Unassigned';
|
||||
$newAssignee = User::find($data['new_assignee'])?->name ?? 'Unknown';
|
||||
$oldAssignee = $feedback->assignedTo?->name ?? __('app.unassigned');
|
||||
$newAssignee = User::find($data['new_assignee'])?->name ?? __('app.widget_unknown');
|
||||
$data['changes'] = [
|
||||
'assignment' => ['old' => $oldAssignee, 'new' => $newAssignee],
|
||||
];
|
||||
@@ -221,13 +221,13 @@ class InteractionsRelationManager extends RelationManager
|
||||
|
||||
if ($record->type === 'assignment') {
|
||||
Notification::make()
|
||||
->title('Feedback assigned successfully')
|
||||
->title(__('feedback.assigned_successfully'))
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
if ($record->type === 'status_change') {
|
||||
Notification::make()
|
||||
->title('Status updated successfully')
|
||||
->title(__('feedback.status_updated'))
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user