feat: basic log page

This commit is contained in:
llama committed 2023-10-10 23:48:05 +11:00
1 parent faaed8fa1b
commit e3bb7cb69f
12 files changed
+131 -16

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
<x-app-layout>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="p-6 text-nexi-black dark:text-gray-100">
<livewire:pages.admin.logs/>
</div>
</div>
</div>
</x-app-layout>
+1 -6
View File
@@ -38,12 +38,7 @@
<x-sidebar-nav :href="route('admin.send')" route="send">Send Quote</x-sidebar-nav>
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('a-2')" route="a-2">Second Page</x-sidebar-nav>--}}
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('a-3')" route="a-3">Third Page</x-sidebar-nav>--}}
<x-sidebar-nav :href="route('admin.logs')" route="admin.log">Logs</x-sidebar-nav>
</li>
</ul>
</li>
@@ -0,0 +1,67 @@
<?php
use App\Models\Log;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('layouts.app')] class extends Component
{
public Collection $logs;
public function mount(): void
{
$this->getLogs();
}
public function getLogs(): void
{
// TODO: look into pagination for this.
$this->logs = Log::with(['user', 'quote', 'requestedQuote'])->get()->sortByDesc('created_at');
}
}; ?>
<div class="px-4 sm:px-6 lg:px-8">
<div class="-mx-4 mt-10 ring-1 ring-gray-300 sm:mx-0 sm:rounded-lg bg-nexi-primary dark:bg-zinc-800 transition-colors duration-300">
<table class="min-w-full divide-y divide-gray-300">
<thead>
<tr>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-nexi-black dark:text-gray-200 sm:pl-6">
User
</th>
<th scope="col"
class="px-3 py-3.5 text-left text-sm font-semibold text-nexi-black dark:text-gray-200">
Logs
</th>
<th scope="col"
class="px-3 py-3.5 text-left text-sm font-semibold text-nexi-black dark:text-gray-200">
Type
</th>
</tr>
</thead>
<tbody>
@foreach ($logs as $log)
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-nexi-black dark:text-gray-200 sm:pl-0">
{{ $log?->user->fullName() ?? 'N/A' }}
</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-nexi-black dark:text-gray-200">
{{ $log->content }}
</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-nexi-black dark:text-gray-200">
@if (!empty($log->quote_id))
Quote - {{ $log->quote_id }}
@elseif (!empty($log->requested_quote_id))
Requsted Quote - ID: {{ $log->requested_quote_id }}
@else
N/A
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@@ -20,7 +20,7 @@ new #[Layout('layouts.app')] class extends Component
Log::create([
'user_id' => auth()?->user()?->id,
'content' => "Quote sent. {$validated['quote']}"
'content' => "Quote sent. {$validated['quote']}",
]);
$this->quote = '';
@@ -42,7 +42,7 @@ new #[Layout('layouts.guest')] class extends Component
Log::create([
'user_id' => auth()?->user()?->id,
'content' => "Quote sent. {$quote}"
'content' => "Quote sent. {$quote}",
]);
$this->redirect(
@@ -61,7 +61,7 @@ new #[Layout('layouts.guest')] class extends Component
Log::create([
'user_id' => auth()?->user()?->id,
'content' => "Quote sent. {$quote}"
'content' => "Quote sent. {$quote}",
]);
$this->redirectRoute('login', navigate: true);
@@ -31,7 +31,7 @@ new class extends Component
Log::create([
'user_id' => auth()?->user()?->id,
'content' => "Quote sent. {$quote}"
'content' => "Quote sent. {$quote}",
]);
$this->reset('current_password', 'password', 'password_confirmation');