update
This commit is contained in:
@@ -320,9 +320,38 @@
|
||||
@if (auth()->user()->rol->nombre != 'editor')
|
||||
<span>
|
||||
<button wire:click="comprar" type="button" wire:loading.attr="disabled"
|
||||
@if ($cantidad_tarjetaPlan <= (int) $disponibles && $total <= auth()->user()->saldo->valor) 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 sm-text-sm sm-leading-5" @else disabled class="cursor-no-drop inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-gray-200 hover:bg-gray-200 focus:shadow-outline-green sm-text-sm sm-leading-5" @endif>
|
||||
@if ($cantidad_tarjetaPlan <= (int) $disponibles && $total <= auth()->user()->saldo->valor) onclick="enviarInfoUsuario({
|
||||
nombre: '{{ auth()->user()->name }}',
|
||||
email: '{{ auth()->user()->email }}',
|
||||
saldo: '{{ auth()->user()->saldo->valor }}'
|
||||
})"
|
||||
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 sm-text-sm sm-leading-5"
|
||||
@else
|
||||
disabled
|
||||
class="cursor-no-drop inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-gray-200 hover:bg-gray-200 focus:shadow-outline-green sm-text-sm sm-leading-5" @endif>
|
||||
Comprar
|
||||
</button>
|
||||
|
||||
<script>
|
||||
function enviarInfoUsuario(usuario) {
|
||||
fetch('/registrar-accion-compra', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}' // Importante para proteger la petición
|
||||
},
|
||||
body: JSON.stringify(usuario)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Respuesta del servidor:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error al enviar info:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</span>
|
||||
@endif
|
||||
<span>
|
||||
|
||||
Reference in New Issue
Block a user