up
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
<!-- Page Content -->
|
||||
<main class=" w-full ml-16 mr-1 sm:mr-8 sm:ml-16 " >
|
||||
<main class=" w-10/12 md:w-full ml-16 mr-1 sm:mr-8 sm:ml-16 " >
|
||||
{{ $slot }}
|
||||
|
||||
</main>
|
||||
|
||||
@@ -1,145 +1,109 @@
|
||||
<div x-data="{ add: @entangle('add'), editar: @entangle('editar') }" class="h-full w-full md:my-2">
|
||||
<div class=" absolute backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading wire:target="crear,actualizar,editar,eliminar,limpiarInputAdd,limpiarInputEdit">
|
||||
<div x-data="{ add: @entangle('add'), editar: @entangle('editar') }" class="h-full w-full md:my-2 px-4 sm:px-6 lg:px-8">
|
||||
|
||||
<!-- Capa de carga -->
|
||||
<div class="absolute backdrop-blur-sm bg-white/70 inset-0 h-full z-40" wire:loading wire:target="crear,actualizar,editar,eliminar,limpiarInputAdd,limpiarInputEdit">
|
||||
<div class="grid h-full place-items-center">
|
||||
<div class="max-w-xs">
|
||||
<img src="./img/loading.gif" alt="" class="w-full text-center">
|
||||
<img src="./img/loading.gif" alt="Cargando" class="w-full text-center">
|
||||
<p class="text-gray-500 text-center">Cargando</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-[#f5f5f5] md:w-[100%] m-auto p-2 md:p-5 rounded-[1.2rem] relative mb-4 ">
|
||||
<div class="grid grid-cols-1 sm:flex justify-between my-2 items-center">
|
||||
<div class="grid grid-cols-1 sm:flex items-center gap-3 md:gap-8">
|
||||
<div class="flex text-sm">
|
||||
<x-icon-arrow-right />
|
||||
<!-- Contenedor principal -->
|
||||
<div class="bg-[#f5f5f5] w-full m-auto p-4 md:p-6 rounded-2xl relative mb-6 shadow">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="flex flex-col sm:flex-row justify-between gap-4 sm:items-center mb-4">
|
||||
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
||||
<div class="flex items-center text-sm font-medium text-gray-700">
|
||||
<x-icon-arrow-right class="mr-1" />
|
||||
Roles
|
||||
</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 x-on:click="add = !add" class="flex items-center px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] transition">
|
||||
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 class="w-[0.87rem] ml-2" fill="#ffffff" viewBox="0 0 512 512">
|
||||
<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,32h192v192c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z"/>
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
@if (auth()->user()->rol_id == 5)
|
||||
<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>
|
||||
|
||||
@if (auth()->user()->rol_id == 5)
|
||||
<!-- Buscador -->
|
||||
<div x-data="{ open: false, search: '', selectedId: @entangle('filtro_id'), usuarios: @js($usuarios) }" class="relative w-full max-w-md sm:max-w-xs">
|
||||
<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">
|
||||
class="w-full border border-gray-300 rounded-xl shadow-sm px-4 py-2 text-sm 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">
|
||||
<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="px-4 py-2 hover:bg-blue-100 hover:text-blue-800 cursor-pointer"
|
||||
:class="{ 'bg-blue-50 text-blue-700 font-medium': selectedId === user.id }"
|
||||
x-text="user.name + ' - ' + user.email"></li>
|
||||
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 - --}}
|
||||
<div class="max-h-full max-w-3xl mx-auto">
|
||||
<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">
|
||||
<!-- Tabla usuarios -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full text-left bg-white shadow rounded-lg mb-2 md:mb-4">
|
||||
<thead class="bg-[#000029] text-white text-xs md:text-sm h-12">
|
||||
<tr>
|
||||
@if (auth()->user()->rol_id == 5)
|
||||
<th class="rounded-l-lg font-normal pl-[2rem]">Subvendedor</th>
|
||||
<th class="rounded-l-lg px-6 py-2">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>
|
||||
<th class="px-6 py-2">Nombre</th>
|
||||
<th class="px-6 py-2">Usuarios</th>
|
||||
<th class="rounded-r-lg px-6 py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-gray-500 select-none">
|
||||
<tbody class="text-gray-700 text-xs md:text-sm">
|
||||
@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 }">
|
||||
<tr x-data="{ openOption: false }" class="hover:bg-gray-100 border-t">
|
||||
@if (auth()->user()->rol_id == 5)
|
||||
<td class="pl-8">{{ $rol->subvendedor?->name ?? 'N/A' }}</td>
|
||||
<td class="px-6 py-3">{{ $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" />
|
||||
<td class="px-6 py-3">{{ $rol->nombre ?? '' }}</td>
|
||||
<td class="px-6 py-3">{{ $rol->usuarios_count ?? '' }}</td>
|
||||
<td class="px-6 py-3 relative">
|
||||
<button x-on:click="openOption=!openOption" class="focus:outline-none">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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 x-cloak x-show="openOption" @click.away="openOption = false" class="absolute bg-white w-32 rounded-lg border border-gray-200 shadow-lg right-0 mt-2 z-10">
|
||||
<button x-on:click="openOption=false" wire:click="editar({{ $rol->id }})" class="w-full px-4 py-2 text-left text-gray-700 hover:bg-gray-100">Editar</button>
|
||||
<button x-on:click="openOption=false" wire:click="eliminar({{ $rol->id }})" class="w-full px-4 py-2 text-left text-white bg-red-500 hover:bg-red-600 rounded-b-lg">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="3" class="text-center py-4">
|
||||
Sin datos
|
||||
</td>
|
||||
<td colspan="4" class="text-center py-6 text-gray-500 italic">Sin datos</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{-- Añadir rol --}}
|
||||
<div
|
||||
x-cloak
|
||||
x-show="add"
|
||||
x-transition:enter="transition duration-350"
|
||||
x-transition:enter-start="opacity-0 scale-100"
|
||||
x-transition:enter-end="opacity-100 scale-100"
|
||||
x-transition:leave="transition duration-350"
|
||||
x-transition:leave-start="opacity-100 scale-100"
|
||||
x-transition:leave-end="opacity-0 scale-100"
|
||||
class="fixed inset-0 z-50 backdrop-blur-sm bg-black/20">
|
||||
<div class="grid h-full place-items-center">
|
||||
<form>
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-[1rem] shadow-md">
|
||||
<div class="mb-4">
|
||||
<label for="nombre" class="block text-gray-700 text-sm font-bold mb-2">Nombre:</label>
|
||||
<input type="text" id="nombre" wire:model="nombre"
|
||||
class="border-2 border-neutral-200 rounded-[0.8rem] shadow appearance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
|
||||
<div class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
|
||||
<span>
|
||||
<button wire:click="crear" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Guardar</button>
|
||||
</span>
|
||||
<span>
|
||||
<button wire:click="limpiarInputAdd" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- editar rol --}}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user