This repository has been archived on 2024-05-20. You can view files and clone it, but cannot push or open issues or pull requests.

87 lines
3.1 KiB
PHP

<?php
use App\Models\Quote;
use App\Models\RequestedQuote;
use App\Providers\RouteServiceProvider;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Layout;
use Livewire\Attributes\On;
use Livewire\Attributes\Rule;
use Livewire\Volt\Component;
new #[Layout('layouts.guest')] class extends Component
{
public Collection $quotes;
public function mount(): void
{
$this->getRequestedQuotes();
}
public function approve(RequestedQuote $quote): void
{
$this->authorize('approve', $quote);
$quote->approve();
$this->dispatch('quote-approved');
}
public function reject(RequestedQuote $quote): void
{
$this->authorize('reject', $quote);
$quote->reject();
$this->dispatch('quote-rejected');
}
#[On('quote-approved')]
#[On('quote-rejected')]
#[On('quote-requested')]
public function getRequestedQuotes(): void
{
$this->quotes = RequestedQuote::all()->whereNull('deleted_at')->sortDesc();
}
}; ?>
<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">
Requested Quotes
</th>
@if(!empty(auth()->user()) && auth()->user()->is_admin)
<th scope="col"></th>
@endif
</tr>
</thead>
<tbody>
@foreach ($quotes as $quote)
<tr>
<td class="relative py-4 pl-4 pr-3 text-sm sm:pl-6 border-t text-nexi-black dark:text-gray-200">
{{ $quote->quote }}
</td>
@if(!empty(auth()->user()) && auth()->user()->is_admin)
<td class="relative w-8 pl-4 pr-3 text-sm sm:pl-6 border-t">
<div class="flex flex-row space-x-2">
<form wire:submit="approve({{ $quote }})">
<x-primary-button wire:loading.attr="disabled" wire:loading.class="opacity-50" class="bg-nexi-green w-24">{{ __('Approve') }}</x-primary-button>
</form>
<form wire:submit="reject({{ $quote }})">
<x-primary-button wire:loading.attr="disabled" wire:loading.class="opacity-50" class="bg-nexi-red w-24">{{ __('Reject') }}</x-primary-button>
</form>
</div>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>