Compare commits

..

No commits in common. "6b3886507432c9cf77fb153928e567f80e94960b" and "26a25b0b074e3c9f28ec12ebc7c1678a19c35a89" have entirely different histories.

3 changed files with 33 additions and 87 deletions

View File

@ -41,6 +41,7 @@ public function edit(ClientService $clientService)
$this->authorize('editClient', Auth::user()); $this->authorize('editClient', Auth::user());
$data = $this->clientForm->validate(); $data = $this->clientForm->validate();
if ($this->clientForm->profile_image_path) { if ($this->clientForm->profile_image_path) {
$path = $this->clientForm->profile_image_path->store('client_logos', 'public'); $path = $this->clientForm->profile_image_path->store('client_logos', 'public');
$data['profile_image_path'] = $path; $data['profile_image_path'] = $path;

View File

@ -8,33 +8,16 @@
class ShowClient extends Component class ShowClient extends Component
{ {
public $filters = '';
public $clients;
public function mount()
{
$this->clients = Client::all();
}
#[On('filters-added')]
public function updatedFilters()
{
$this->clients = Client::where('name', 'LIKE', '%' . $this->filters . '%')->get();
}
#[On('client-deleted')] #[On('client-deleted')]
#[On('client-updated')] #[On('client-updated')]
#[On('client-added')] #[On('client-added')]
public function refreshClients()
{
$this->clients = Client::all();
}
public function render() public function render()
{ {
$clients = Client::all();
return view('livewire.admin.show-client', [ return view('livewire.admin.show-client', [
'clients' => $this->clients 'clients' => $clients
]); ]);
} }
} }

View File

@ -1,53 +1,13 @@
<div class="container"> <div class="container grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
<div class="flex justify-center">
<div class="w-full max-w-md mb-6">
<div x-data="{ query: @entangle('filters') }" class="relative rounded-md shadow-sm">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z" clip-rule="evenodd" />
</svg>
</div>
<input
type="text"
wire:model.live.debounce.10ms="filters"
x-model="query"
name="search"
id="search"
class="block w-full outline-none rounded-md bg-white border-0 py-2 pl-10 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
placeholder="Buscar por nome, email..."
@keyup.enter="$dispatch('filters-added')"
>
<div
x-show="query"
style="display: none;"
class="absolute inset-y-0 right-0 flex items-center pr-3">
<button
@click="query = ''; $wire.set('filters', '')"
type="button"
class="text-gray-400 hover:text-gray-600 focus:outline-none">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" />
</svg>
</button>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
@foreach ($clients as $client) @foreach ($clients as $client)
<div class="client-card" wire:transition.scale.origin.top.duration.300ms> <div class="client-card">
<div class="client-card-header"> <div class="client-card-header">
<div class="client-avatar"> <div class="client-avatar">
<img src="{{ asset('storage/' . $client->profile_image_path) }}" x-on:click.prevent="$dispatch('client-detail', { id: '{{ $client->id }}' })" alt="Avatar do Cliente" <img src="{{ asset('storage/' . $client->profile_image_path) }}" alt="Avatar do Cliente"
class="w-32 h-32 rounded-full object-cover cursor-pointer"> class="w-32 h-32 rounded-full object-cover">
</div> </div>
<div x-data="{ open: false }" @click.outside="open = false" class="client-options-menu"> <div x-data="{ open: false }" @click.outside="open = false" class="client-options-menu">
<button @click="open = !open" class="client-options-button cursor-pointer"> <button @click="open = !open" class="client-options-button">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400 hover:text-gray-700" <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400 hover:text-gray-700"
viewBox="0 0 20 20" fill="currentColor"> viewBox="0 0 20 20" fill="currentColor">
<path <path
@ -56,6 +16,9 @@ class="w-32 h-32 rounded-full object-cover cursor-pointer">
</button> </button>
<ul x-show="open" class="client-options-list" x-transition> <ul x-show="open" class="client-options-list" x-transition>
<li><a href="#" class="client-option-item"
x-on:click.prevent="$dispatch('client-detail', { id: '{{ $client->id }}' })">Ver Detalhes</a>
</li>
<li><a href="#" class="client-option-item" <li><a href="#" class="client-option-item"
x-on:click.prevent="$dispatch('update-client', { id: '{{ $client->id }}' })">Editar x-on:click.prevent="$dispatch('update-client', { id: '{{ $client->id }}' })">Editar
Cliente</a></li> Cliente</a></li>
@ -66,10 +29,9 @@ class="w-32 h-32 rounded-full object-cover cursor-pointer">
</div> </div>
</div> </div>
<div class="client-card-name cursor-pointer" x-on:click.prevent="$dispatch('client-detail', { id: '{{ $client->id }}' })"> <div class="client-card-name">
{{ $client->name }} {{ $client->name }}
</div> </div>
</div> </div>
@endforeach @endforeach
</div> </div>
</div>