142 lines
6.5 KiB
PHP
142 lines
6.5 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">
|
|
<x-button
|
|
x-data=""
|
|
x-on:click.prevent="$dispatch('open-modal', 'confirm-quote-approve-{{ $quote->id }}')"
|
|
wire:loading.attr="disabled"
|
|
wire:loading.class="opacity-50"
|
|
class="bg-nexi-green w-24"
|
|
>{{ __('Approve') }}</x-button>
|
|
|
|
<x-modal name="confirm-quote-approve-{{ $quote->id }}" :show="$errors->isNotEmpty()" focusable>
|
|
<form wire:submit="approve({{ $quote }})" class="p-6">
|
|
<h2 class="text-lg font-medium text-nexi-black dark:text-gray-100">
|
|
{{ __('Are you sure you want to approve the quote?') }}
|
|
</h2>
|
|
|
|
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
|
|
"{{ $quote->quote }}"
|
|
</p>
|
|
|
|
<div class="mt-6 flex justify-end">
|
|
<x-secondary-button x-on:click="$dispatch('close')">
|
|
{{ __('Cancel') }}
|
|
</x-secondary-button>
|
|
<x-button
|
|
wire:loading.attr="disabled"
|
|
wire:loading.class="opacity-50"
|
|
class="bg-nexi-green w-24 ml-3"
|
|
>{{ __('Approve') }}</x-button>
|
|
</div>
|
|
</form>
|
|
</x-modal>
|
|
|
|
<x-button
|
|
x-data=""
|
|
x-on:click.prevent="$dispatch('open-modal', 'confirm-quote-reject-{{ $quote->id }}')"
|
|
wire:loading.attr="disabled"
|
|
wire:loading.class="opacity-50"
|
|
class="bg-nexi-red w-24"
|
|
>{{ __('Reject') }}</x-button>
|
|
|
|
<x-modal name="confirm-quote-reject-{{ $quote->id }}" :show="$errors->isNotEmpty()" focusable>
|
|
<form wire:submit="reject({{ $quote }})" class="p-6">
|
|
<h2 class="text-lg font-medium text-nexi-black dark:text-gray-100">
|
|
{{ __('Are you sure you want to reject the quote?') }}
|
|
</h2>
|
|
|
|
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
|
|
"{{ $quote->quote }}"
|
|
</p>
|
|
|
|
<div class="mt-6 flex justify-end">
|
|
<x-secondary-button x-on:click="$dispatch('close')">
|
|
{{ __('Cancel') }}
|
|
</x-secondary-button>
|
|
<x-button
|
|
wire:loading.attr="disabled"
|
|
wire:loading.class="opacity-50"
|
|
class="bg-nexi-red w-24 ml-3"
|
|
>{{ __('Reject') }}</x-button>
|
|
</div>
|
|
</form>
|
|
</x-modal>
|
|
</div>
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|