Update show-roles.blade.php

This commit is contained in:
lizandrogd
2025-07-07 14:48:38 -05:00
parent 52eb78c188
commit 5f18f42ee4
+62 -31
View File
@@ -17,25 +17,50 @@
</div>
@if (auth()->user()->subvendedor)
<a x-on:click="add = !add" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-3 md:mb-0">
Añadir rol
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" class="w-[0.87rem] ml-2">
<path d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z" fill="#ffffff" />
</svg>
</a>
<a x-on:click="add = !add" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-3 md:mb-0">
Añadir rol
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" class="w-[0.87rem] ml-2">
<path d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z" fill="#ffffff" />
</svg>
</a>
@endif
</div>
@if (auth()->user()->rol_id == 5)
<div>
<select wire:model="filtro_id" name="filtro_user" id="filtro_user" class="w-[8rem] border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none ring-0 focus:ring-0 focus:border-neutral-300 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Filtrar todos</option>
@foreach ($usuarios as $user)
<option value="{{ $user->id }}">{{ $user->name ?? '' }} - {{ $user->email ?? '' }}</option>
@endforeach
</select>
</div>
<div
x-data="{ open: false, search: '', selectedId: @entangle('filtro_id'), usuarios: @js($usuarios) }"
class="relative w-full max-w-xl ml-auto">
<label class="block text-sm font-medium text-gray-700 mb-1">Buscar subvendedor</label>
<input
type="text"
placeholder="Escribe nombre o correo..."
x-model="search"
@input="open = true"
@click.away="open = false"
class="w-full border border-gray-300 rounded-xl shadow-sm px-4 py-2 text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-blue-400 transition">
<ul
x-show="open && search.length > 0"
x-transition
class="absolute z-50 mt-2 w-full bg-white border border-gray-300 rounded-xl shadow-lg max-h-60 overflow-y-auto text-sm">
<template
x-for="user in usuarios.filter(u => (u.name + ' ' + u.email).toLowerCase().includes(search.toLowerCase()))"
:key="user.id">
<li
@click="selectedId = user.id; search = user.name + ' - ' + user.email; open = false"
class="px-4 py-2 hover:bg-blue-100 hover:text-blue-800 cursor-pointer transition"
:class="{ 'bg-blue-50 text-blue-700 font-medium': selectedId === user.id }"
x-text="user.name + ' - ' + user.email"></li>
</template>
<li x-show="usuarios.filter(u => (u.name + ' ' + u.email).toLowerCase().includes(search.toLowerCase())).length === 0" class="px-4 py-2 text-gray-500 italic">
No se encontraron resultados.
</li>
</ul>
</div>
@endif
</div>
{{-- -Tabla usuarios - --}}
@@ -43,6 +68,9 @@
<table class="w-full sm-w-[20rem] text-center mt-4 border-separate border-spacing-y-2 bg-white shadow-md rounded-lg mb-2">
<thead class="font-normal bg-[#000029] text-white h-9">
<tr class="text-left">
@if (auth()->user()->rol_id == 5)
<th class="rounded-l-lg font-normal pl-[2rem]">Subvendedor</th>
@endif
<th class="rounded-l-lg font-normal pl-[2rem]">Nombre</th>
<th class="font-normal pl-[2rem]">Usuarios</th>
<th class="rounded-r-lg font-normal"></th>
@@ -50,21 +78,24 @@
</thead>
<tbody class="text-gray-500 select-none">
@forelse ($roles as $rol)
<tr class="border-gray-200 text-left w-full pl-4 hover:bg-gray-200 hover:ring-gray-500" x-data="{ openOption: false }">
<td class="pl-8">{{ $rol->nombre ?? '' }}</td>
<td class="pl-8">{{ $rol->usuarios_count ?? '' }}</td>
<td class="pl-2">
<button x-on:click="openOption=!openOption">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</button>
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg">
<button x-on:click="openOption=false" wire:click="editar({{ $rol->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $rol->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
</div>
</td>
</tr>
<tr class="border-gray-200 text-left w-full pl-4 hover:bg-gray-200 hover:ring-gray-500" x-data="{ openOption: false }">
@if (auth()->user()->rol_id == 5)
<td class="pl-8">{{ $rol->subvendedor?->name ?? 'N/A' }}</td>
@endif
<td class="pl-8">{{ $rol->nombre ?? '' }}</td>
<td class="pl-8">{{ $rol->usuarios_count ?? '' }}</td>
<td class="pl-2">
<button x-on:click="openOption=!openOption">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</button>
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg">
<button x-on:click="openOption=false" wire:click="editar({{ $rol->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $rol->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="text-center py-4">
@@ -122,4 +153,4 @@
</div>
</div>
</div>
</div>
</div>