complete story 15.3
This commit is contained in:
@@ -12,6 +12,9 @@ new class extends Component {
|
||||
public string $typeFilter = '';
|
||||
public int $perPage = 10;
|
||||
|
||||
public ?int $deletingClientId = null;
|
||||
public bool $showDeleteModal = false;
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
@@ -34,6 +37,34 @@ new class extends Component {
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function confirmDelete(int $id): void
|
||||
{
|
||||
$this->deletingClientId = $id;
|
||||
$this->showDeleteModal = true;
|
||||
}
|
||||
|
||||
public function cancelDelete(): void
|
||||
{
|
||||
$this->deletingClientId = null;
|
||||
$this->showDeleteModal = false;
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
if ($this->deletingClientId) {
|
||||
PotentialClient::find($this->deletingClientId)?->delete();
|
||||
session()->flash('success', __('potential-clients.deleted_success'));
|
||||
}
|
||||
|
||||
$this->deletingClientId = null;
|
||||
$this->showDeleteModal = false;
|
||||
}
|
||||
|
||||
public function getDeletingClientProperty(): ?PotentialClient
|
||||
{
|
||||
return $this->deletingClientId ? PotentialClient::find($this->deletingClientId) : null;
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
return [
|
||||
@@ -58,7 +89,7 @@ new class extends Component {
|
||||
<flux:text class="mt-1 text-zinc-500">{{ __('potential-clients.subtitle') }}</flux:text>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<flux:button variant="primary" href="#" icon="plus" class="w-full sm:w-auto justify-center">
|
||||
<flux:button variant="primary" :href="route('admin.potential-clients.create')" wire:navigate icon="plus" class="w-full sm:w-auto justify-center">
|
||||
{{ __('potential-clients.add_potential_client') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
@@ -160,16 +191,26 @@ new class extends Component {
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="eye"
|
||||
href="#"
|
||||
:href="route('admin.potential-clients.show', $potentialClient)"
|
||||
wire:navigate
|
||||
:title="__('potential-clients.view')"
|
||||
/>
|
||||
<flux:button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="pencil"
|
||||
href="#"
|
||||
:href="route('admin.potential-clients.edit', $potentialClient)"
|
||||
wire:navigate
|
||||
:title="__('potential-clients.edit')"
|
||||
/>
|
||||
<flux:button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="trash"
|
||||
wire:click="confirmDelete({{ $potentialClient->id }})"
|
||||
:title="__('potential-clients.delete')"
|
||||
class="text-red-600 hover:text-red-700"
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -190,7 +231,7 @@ new class extends Component {
|
||||
{{ __('potential-clients.clear_filters') }}
|
||||
</flux:button>
|
||||
@else
|
||||
<flux:button variant="primary" href="#" class="mt-4">
|
||||
<flux:button variant="primary" :href="route('admin.potential-clients.create')" wire:navigate class="mt-4">
|
||||
{{ __('potential-clients.add_potential_client') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
@@ -208,4 +249,26 @@ new class extends Component {
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Delete Confirmation Modal --}}
|
||||
<flux:modal wire:model="showDeleteModal" class="min-w-[22rem]">
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('potential-clients.delete_confirm_title') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('potential-clients.delete_confirm_message') }}</flux:text>
|
||||
@if ($this->deletingClient)
|
||||
<flux:text class="mt-2 font-medium">{{ $this->deletingClient->name ?? __('potential-clients.not_provided') }}</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<flux:spacer />
|
||||
<flux:button variant="ghost" wire:click="cancelDelete">
|
||||
{{ __('potential-clients.cancel') }}
|
||||
</flux:button>
|
||||
<flux:button variant="danger" wire:click="delete">
|
||||
{{ __('potential-clients.delete') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user