FIX: Remove login for API

This commit is contained in:
2023-11-25 00:55:31 -03:00
parent 3cadaca746
commit ec7d8e69ab
34 changed files with 140 additions and 71 deletions

View File

@ -269,7 +269,7 @@
return {
provincias: () => {
const uri = '{{$urls->api}}/region/' + this.data.region + '/provincias'
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -286,7 +286,7 @@
},
comunas: provincia_id => {
const uri = '{{$urls->api}}/provincia/' + provincia_id + '/comunas'
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -581,7 +581,7 @@
return {
propietario: rut => {
const uri = '{{$urls->api}}/ventas/propietario/' + rut.split('-')[0]
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -664,7 +664,7 @@
return {
unidades: () => {
const uri = '{{$urls->api}}/proyecto/' + this.data.id + '/unidades'
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}

View File

@ -201,7 +201,7 @@
this.draw().loading()
return fetch('{{$urls->api}}/proyectos').then(response => {
return fetchAPI('{{$urls->api}}/proyectos').then(response => {
if (response.ok) {
return response.json()
}
@ -223,7 +223,7 @@
})
},
cierres: proyecto_id => {
return fetch('{{$urls->api}}/ventas/cierres',
return fetchAPI('{{$urls->api}}/ventas/cierres',
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
if (response.ok) {
return response.json()

View File

@ -105,7 +105,7 @@
const cuota_id = button.data('cuota')
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
fetch('{{$urls->api}}/ventas/cuota/abonar', {
return fetchAPI('{{$urls->api}}/ventas/cuota/abonar', {
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
}).then(response => {
if (response.ok) {
@ -125,7 +125,7 @@
const cuota_id = button.data('cuota')
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
fetch('{{$urls->api}}/ventas/cuota/devolver', {
return fetchAPI('{{$urls->api}}/ventas/cuota/devolver', {
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
}).then(response => {
if (response.ok) {

View File

@ -105,7 +105,7 @@
const cuota_id = button.data('cuota')
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
fetch('{{$urls->api}}/ventas/cuota/depositar', {
return fetchAPI('{{$urls->api}}/ventas/cuota/depositar', {
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
}).then(response => {
if (response.ok) {

View File

@ -68,7 +68,7 @@
return
}
const uri = '{{$urls->api}}/venta/{{$venta->id}}'
return fetch(uri,
return fetchAPI(uri,
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
).then(response => {
if (response.ok) {

View File

@ -53,7 +53,7 @@
method: 'post',
body: data
}
return this.sent.uf[date.toISOString()] = fetch(url, options).then(response => {
return this.sent.uf[date.toISOString()] = fetchAPI(url, options).then(response => {
if (response.ok) {
return response.json()
}
@ -75,7 +75,7 @@
method: 'post',
body: data
}
return this.sent.ipc[dateKey] = fetch(url, options).then(response => {
return this.sent.ipc[dateKey] = fetchAPI(url, options).then(response => {
if (response.ok) {
return response.json()
}
@ -127,7 +127,7 @@
return {
unidades: () => {
const url = '{{$urls->api}}/venta/' + this.id + '/unidades'
return fetch(url).then(response => {
return fetchAPI(url).then(response => {
if (response.ok) {
return response.json()
}
@ -233,7 +233,7 @@
return {
ventas: () => {
const url = '{{$urls->api}}/ventas/facturacion/proyecto/' + this.selected
return fetch(url).then(response => {
return fetchAPI(url).then(response => {
if (response.ok) {
return response.json()
}

View File

@ -103,7 +103,7 @@
ventas: proyecto_id => {
this.data.venta_ids = []
this.data.ventas = []
return fetch('{{$urls->api}}/ventas',
return fetchAPI('{{$urls->api}}/ventas',
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}
).then(response => {
this.loading.precios = false
@ -130,7 +130,7 @@
})
},
venta: venta_id => {
return fetch('{{$urls->api}}/venta/' + venta_id).then(response => {
return fetchAPI('{{$urls->api}}/venta/' + venta_id).then(response => {
if (response.ok) {
return response.json()
}

View File

@ -34,7 +34,7 @@
return {
pagos: () => {
const uri = '{{$urls->api}}/ventas/pagos/pendientes'
fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -138,7 +138,7 @@
return {
pendientes: () => {
const uri = '{{$urls->api}}/ventas/pagos/abonar'
fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -218,7 +218,7 @@
return {
devueltos: () => {
const uri = '{{$urls->api}}/ventas/pagos/rebotes'
fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}

View File

@ -339,7 +339,7 @@
$(this.ids.buttons.add).hide()
return fetch('{{$urls->api}}/proyectos').then(response => {
return fetchAPI('{{$urls->api}}/proyectos').then(response => {
if (response.ok) {
return response.json()
}
@ -357,7 +357,7 @@
},
precios: proyecto_id => {
this.data.precios = []
return fetch('{{$urls->api}}/ventas/precios',
return fetchAPI('{{$urls->api}}/ventas/precios',
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}
).then(response => {
$('.item.proyecto').css('cursor', 'default')
@ -639,7 +639,7 @@
fecha: $(this.ids.fields.calendar).calendar('get date'),
valor: $(this.ids.fields.valor).val()
}
return fetch('{{$urls->api}}/precios/update',
return fetchAPI('{{$urls->api}}/precios/update',
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
).then(response => {
if (response.ok) {

View File

@ -79,7 +79,7 @@ Editar Propietario
const original_id = $("[name='comuna']").val()
const uri = '{{$urls->api}}/direcciones/comunas/find'
const data = {direccion}
return fetch(uri,
return fetchAPI(uri,
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
).then(response => {
if (response.ok) {
@ -101,7 +101,7 @@ Editar Propietario
const parent = $('#comunas')
parent.hide()
const uri = '{{$urls->api}}/direcciones/region/' + region_id + '/comunas'
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}
@ -195,7 +195,7 @@ Editar Propietario
redirect()
return
}
return fetch(uri,
return fetchAPI(uri,
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
).then(response => {
if (response.ok) {

View File

@ -48,7 +48,7 @@
return {
comentarios: () => {
const uri = '{{$urls->api}}/venta/{{$venta->id}}/comentarios'
return fetch(uri).then(response => {
return fetchAPI(uri).then(response => {
if (response.ok) {
return response.json()
}

View File

@ -176,7 +176,7 @@
modal.find('.ui.button').click(event => {
modal.modal('hide')
const date = modal.find('#fecha').val()
return fetch(uri,
return fetchAPI(uri,
{method: 'put', body: JSON.stringify({fecha: date}), headers: {'Content-Type': 'application/json'}}
).then(response => {
anchor.css('pointer-events', '')
@ -206,7 +206,7 @@
modal.modal('show')
modal.find('.ui.button').click(event => {
const date = modal.find('#fecha').val()
return fetch(uri,
return fetchAPI(uri,
{method: 'put', body: JSON.stringify({fecha: date}), headers: {'Content-Type': 'application/json'}}
).then(response => {
anchor.css('pointer-events', '')