Uso de NumberInput en Edit BonoPie

This commit is contained in:
Juan Pablo Vial
2025-05-05 15:55:23 -04:00
parent 7e54b72587
commit a8325c3310

View File

@ -33,6 +33,8 @@
</form>
@endsection
@include('layout.body.scripts.number_input')
@push('page_scripts')
<script>
$(document).ready(() => {
@ -40,13 +42,17 @@
fecha.calendar(calendar_date_options)
fecha.calendar('set date', new Date({{$venta->formaPago()->bonoPie->pago->fecha->format('Y, m-1, j')}}))
const numberInput = new NumberInput({input: document.querySelector('input[name="valor"]'), isRational: true})
numberInput.watch()
$('#add_bono').submit(submitEvent => {
submitEvent.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/edit'
const data = new FormData()
data.set('fecha', $('#fecha').calendar('get date').toISOString())
data.set('valor', $('#valor').val())
return APIClient.fetch(url, {method: 'post', body: data}).then(response => {
const method = 'post'
const body = new FormData()
body.set('fecha', $('#fecha').calendar('get date').toISOString())
body.set('valor', numberInput.currentValue)
return APIClient.fetch(url, {method, body}).then(response => {
if (response.ok) {
return response.json()
}