implementado defectos
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
@@ -34,6 +34,7 @@
|
||||
mesesAumento:0,
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -49,29 +50,38 @@
|
||||
const respPropiedad = fetch($urlG+"/api/contrato/propietario?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respgarantes = fetch($urlG+"/api/contratos/garantes?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respCanons = fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||
const respoDefect = fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c, d] = await Promise.all([respPropiedad, respgarantes, respCanons, respoDefect]);
|
||||
|
||||
const datosPropiedad = await p.json();
|
||||
const datosGarantes = await g.json();
|
||||
const datosCanons = await c.json();
|
||||
const datosDefect = await d.json();
|
||||
|
||||
prop = datosPropiedad;
|
||||
garantes = datosGarantes;
|
||||
canons = datosCanons;
|
||||
defectos = datosDefect;
|
||||
} catch {
|
||||
modaldata = "Fallo hacer las request";
|
||||
}
|
||||
@@ -233,6 +243,44 @@
|
||||
function abrirModalNotif() {
|
||||
shownotif = true;
|
||||
}
|
||||
|
||||
|
||||
async function marcarDefectoPago(defecto: DefectoDto) {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/defecto/marcarpago?iddefecto="+defecto.id, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
let dr = await r.json();
|
||||
modaldata = dr.message;
|
||||
if (r.ok) {
|
||||
refreshDefectos();
|
||||
}
|
||||
|
||||
}catch {
|
||||
modaldata = "No se pudo marcar como pago";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDefectos() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let rr =await r.json();
|
||||
defectos = rr;
|
||||
} catch {
|
||||
modaldata ="No se pudo pedir la lista de Defectos";
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -405,6 +453,64 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="ht">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#ct"
|
||||
aria-expanded="false"
|
||||
aria-controls="ct"
|
||||
>
|
||||
Defectos
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="ct"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción</th>
|
||||
<th>Costo</th>
|
||||
<th>Estado</th>
|
||||
<th>Paga Inquilino</th>
|
||||
<th>Divisa</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if defectos.length == 0}
|
||||
<tr>
|
||||
<td colspan="6">No hay defectos que mostrar</td>
|
||||
</tr>
|
||||
{:else}
|
||||
{#each defectos as defecto}
|
||||
<tr>
|
||||
<td>{defecto.descripcion}</td>
|
||||
<td>{defecto.costo}</td>
|
||||
<td>{defecto.estado}</td>
|
||||
<td>{defecto.pagainquilino}</td>
|
||||
<td>{defecto.divisa}</td>
|
||||
<td>
|
||||
{#if defecto.estado !== "Pagado"}
|
||||
<button class="btn btn-secondary" onclick={()=>marcarDefectoPago(defecto)}>Marcar Pago</button>
|
||||
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user