- Created `quick-replies.blade.php` for managing quick replies. - Added `settings.blade.php` for admin settings management. - Implemented `ticket-show.blade.php` to display ticket details. - Introduced `timeline-card.blade.php` component for displaying timeline information. Enhance quick reply management functionality - Developed `quick-reply-manager.blade.php` for creating and editing quick replies. - Integrated Livewire for dynamic interaction and validation. Implement settings page for AI configuration - Created `settings-page.blade.php` for managing AI settings, including prompts and provider instances. - Added functionality for managing models and embeddings. Add ticket show functionality with real-time updates - Implemented ticket details view with processing status and tool call logs. - Added support for displaying article suggestions and error messages. Create unit tests for AI classifier and domain info tool - Added `AIClassifierServiceTest.php` to validate AI classifier functionality. - Implemented `DomainInfoToolTest.php` for domain parameter validation. - Created `OxxaClientTest.php` to test API interactions and password hashing.
95 lines
2.7 KiB
PHP
95 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Services\AdminQuickReplyService;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class QuickReplyManager extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public string $title = '';
|
|
|
|
public string $content = '';
|
|
|
|
public bool $isActive = true;
|
|
|
|
public array $editRows = [];
|
|
|
|
public function save(AdminQuickReplyService $service): void
|
|
{
|
|
$this->validate([
|
|
'title' => ['required', 'string', 'max:255'],
|
|
'content' => ['required', 'string', 'max:12000'],
|
|
'isActive' => ['boolean'],
|
|
]);
|
|
|
|
$service->create($this->title, $this->content, $this->isActive);
|
|
|
|
$this->reset(['title', 'content']);
|
|
$this->isActive = true;
|
|
session()->flash('success', 'Snelantwoord opgeslagen.');
|
|
$this->resetPage();
|
|
}
|
|
|
|
public function updateQuickReply(int $id, AdminQuickReplyService $service): void
|
|
{
|
|
$this->validate([
|
|
"editRows.{$id}.title" => ['required', 'string', 'max:255'],
|
|
"editRows.{$id}.content" => ['required', 'string', 'max:12000'],
|
|
"editRows.{$id}.is_active" => ['boolean'],
|
|
]);
|
|
|
|
$row = $this->editRows[$id] ?? [];
|
|
$updated = $service->update(
|
|
$id,
|
|
(string) ($row['title'] ?? ''),
|
|
(string) ($row['content'] ?? ''),
|
|
(bool) ($row['is_active'] ?? false)
|
|
);
|
|
|
|
session()->flash('success', $updated
|
|
? "Snelantwoord #{$id} is opgeslagen."
|
|
: "Snelantwoord #{$id} bestaat niet meer.");
|
|
}
|
|
|
|
public function deleteQuickReply(int $id, AdminQuickReplyService $service): void
|
|
{
|
|
$deleted = $service->deleteById($id);
|
|
|
|
session()->flash('success', $deleted
|
|
? "Snelantwoord #{$id} is verwijderd."
|
|
: "Snelantwoord #{$id} bestond niet meer.");
|
|
|
|
unset($this->editRows[$id]);
|
|
$this->resetPage();
|
|
}
|
|
|
|
public function render(AdminQuickReplyService $service)
|
|
{
|
|
$quickReplies = $service->paginate(10);
|
|
$this->hydrateEditRows($quickReplies->items());
|
|
|
|
return view('livewire.admin.quick-reply-manager', [
|
|
'quickReplies' => $quickReplies,
|
|
]);
|
|
}
|
|
|
|
private function hydrateEditRows(array $quickReplies): void
|
|
{
|
|
foreach ($quickReplies as $quickReply) {
|
|
if (array_key_exists($quickReply->id, $this->editRows)) {
|
|
continue;
|
|
}
|
|
|
|
$this->editRows[$quickReply->id] = [
|
|
'title' => $quickReply->title,
|
|
'content' => $quickReply->content,
|
|
'is_active' => $quickReply->is_active,
|
|
];
|
|
}
|
|
}
|
|
}
|